LingSys
↓ 0 downloadsYour machine's memory, GPU, motherboard and network, drawn and played in the Ling design system: LingSys, a small build for USB liquid-cooler displays, LingNet for IPv4/IPv6, DNS and packets, and a LingOS edition. 64-bit and 32-bit Windows builds included.
Keywords system-monitor, visualization, network, ipv6, gpu, lcd, lingos, ling
lingfu install LingSysCode / Files (48)
src/64_net.ling
# ───────────────────────────── NETWORK section ───────────────────────────────
# Channels (rings, lanes, pulse categories): RX, TX, PKT IN, PKT OUT, TCP, UDP, RETRANS.
# Data: net.snap from sampler_hw.ps1 (interface counters, TCP/UDP counters, netstat, one probe of your gateway).
# Remote addresses are never drawn as text: a connection is a dot whose place comes from a hash of the
# address and whose sector is its remote port (HTTPS, HTTP, DNS, REMOTE, MAIL, HIGH, OTHER).
# an arc of a circle, a0 to a1 (radians, clockwise from up)
fn arc(cx, cy, r, a0, a1) {
bind n = floor(abs(a1 - a0) * r / 6.0) + 1
bind i = 0
while i < n {
pline(cx, cy, r, mix(a0, a1, i / n), r, mix(a0, a1, (i + 1) / n))
bind i = i + 1
}
}
# Chesilin text laid along an arc, centred on angle ac, radius rm
fn arc_text(str, cx, cy, rm, ac, h) {
bind m = str_len(str)
bind da = h * 1.25 / rm
bind q = 0
while q < m {
bind ch = str_slice(str, q, 1)
if ch != " " { chesilin_glyph(ch, cx, cy, rm, ac + (q - (m - 1) / 2.0) * da, h * 1.05, h) }
bind q = q + 1
}
}
fn adapter_name(np) {
bind ads = np[NP_AD]
if len(ads) == 0 { return "NO ADAPTER" }
bind ad = ads[0]
bind s = str_upper(ad[0])
bind s = str_replace(s, "INTEL[R] ", "")
bind s = str_replace(s, "INTEL(R) ", "")
return s
}
fn node_xy(nd, i, cx, cy, R) {
bind c = port_class(nd[1])
bind sec = TAU / 7.0
bind a = c * sec + sec * (0.1 + 0.8 * fract(nd[0] * 3.7 + 0.31)) + (fract(i * 0.37) - 0.5) * 0.015
bind r = R * (0.4 + 0.47 * fract(nd[0] * 17.3 + nd[1] * 0.0137))
return [px(cx, r, a), py(cy, r, a), a, r]
}
# ---- view 1: FLOW, a constellation of live connections
fn view_net_flow(Z) {
bind W = Z[Z_W]
bind H = Z[Z_H]
bind cx = W / 2.0
bind cy = H / 2.0
bind R = min(W * 0.34, H * 0.5 - 20.0)
bind t = Z[Z_T]
bind hs = Z[Z_HS]
bind sat = Z[Z_SAT]
bind en = Z[Z_ENERGY]
bind np = Z[Z_D][D_NET]
bind nv = np[NP_NV]
bind nodes = np[NP_NODE]
bind sec = TAU / 7.0
bind spin = Z[Z_ROT] * 0.02
# sectors: rim arc, divider, name and count
bind counts = [0, 0, 0, 0, 0, 0, 0]
bind i = 0
while i < len(nodes) {
bind c = port_class(nodes[i][1])
bind counts = list_set(counts, c, counts[c] + 1)
bind i = i + 1
}
bind c = 0
while c < 7 {
bind e = en[c]
bind a0 = c * sec + 0.02
bind a1 = (c + 1) * sec - 0.02
col(c, sat * 0.8, 36.0 + 24.0 * e, hs)
arc(cx, cy, R, a0, a1)
arc(cx, cy, R * 0.915, a0, a1)
col(c, sat * 0.6, 16.0 + 10.0 * e, hs)
pline(cx, cy, R * 0.17, c * sec, R * 0.915, c * sec)
col(c, sat, 66.0 + 24.0 * e, hs)
arc_text(PORT_NAME[c] + " " + num_str(counts[c]), cx, cy, R * 0.955, (c + 0.5) * sec, R * 0.05)
bind c = c + 1
}
# spokes and dots
bind pos = []
bind i = 0
while i < len(nodes) {
bind nd = nodes[i]
bind xy = node_xy(nd, i, cx, cy, R)
bind pos = list_push(pos, xy[0])
bind pos = list_push(pos, xy[1])
bind k = port_class(nd[1])
col(k, sat * 0.7, 14.0 + 8.0 * en[k], hs)
pline(cx, cy, R * 0.17, xy[2], xy[3], xy[2])
col(k, sat, 52.0 + 24.0 * en[k], hs)
if nd[2] == 0 {
draw_circle(xy[0], xy[1], 5.0)
draw_circle(xy[0], xy[1], 2.0)
} else {
square(xy[0], xy[1], 4.0, t * 0.8 + i)
}
bind i = i + 1
}
# hub: this machine, rates in and out
bind hr = R * 0.17
col(2, sat, 70.0, hs)
draw_circle(cx, cy, hr)
square(cx, cy, hr * 0.7, Z[Z_ROT] * 0.5)
square(cx, cy, hr * 0.7, Z[Z_ROT] * 0.5 + 0.7854)
bind a1s = "IN " + fmt_bytes(nv[NV_RX])
bind a2s = "OUT " + fmt_bytes(nv[NV_TX])
bind hh = fit_h(a1s, hr * 1.5, hr * 0.3)
col(0, sat, 80.0, hs)
daemon_text(a1s, cx - text_w(a1s, hh) / 2.0, cy - hr * 0.2, hh)
bind hh2 = fit_h(a2s, hr * 1.5, hr * 0.3)
col(1, sat, 80.0, hs)
daemon_text(a2s, cx - text_w(a2s, hh2) / 2.0, cy + hr * 0.22, hh2)
# pulses: rx = circle travelling in, tx = square travelling out
bind ev = Z[Z_EV]
bind j = 0
while j < len(ev) {
bind ni = ev[j + 5]
if ni < len(nodes) {
bind p = (t - ev[j + 2]) / 1.8
bind nd = nodes[ni]
bind k = port_class(nd[1])
bind xy = node_xy(nd, ni, cx, cy, R)
bind q = p
if ev[j] == 0 { bind q = 1.0 - p }
bind hx = px(cx, hr, xy[2])
bind hy = py(cy, hr, xy[2])
bind x = mix(hx, xy[0], q)
bind y = mix(hy, xy[1], q)
col(k, sat, (1.0 - p * 0.6) * (60.0 + 38.0 * ev[j + 4]), hs)
if ev[j] == 0 {
draw_circle(x, y, 7.0)
draw_circle(x, y, 3.0)
} else {
square(x, y, 6.0, p * 4.0)
}
}
bind j = j + 6
}
# left: the link
bind lx = 18.0
bind ly = H * 0.18
bind lh = 13.0
bind rtt = nv[NV_RTT]
bind rs = "---"
if rtt > 0.0 { bind rs = num_str(round(rtt)) + "MS" }
bind adn = str_slice(adapter_name(np), 0, 26)
bind bw = nv[NV_BW]
bind lines = [adn, "LINK " + fmt_bytes(bw) + "BIT", "IN " + fmt_bytes(nv[NV_RX]) + "/S", "OUT " + fmt_bytes(nv[NV_TX]) + "/S",
"PKTS " + fmt_rate(nv[NV_PRX]) + " IN " + fmt_rate(nv[NV_PTX]) + " OUT", "GATEWAY " + rs, "RETRANS " + fmt_rate(nv[NV_RETX]) + "/S",
"TCP EST " + fmt_rate(nv[NV_EST]), "LISTEN " + fmt_rate(nv[NV_LISTEN]) + " WAIT " + fmt_rate(nv[NV_TW]),
"CLOSE " + fmt_rate(nv[NV_CW]) + " LOOP " + fmt_rate(nv[NV_LOOP])]
tile("N", lx, ly - 54.0, 44.0, 66.0, 6, sat, hs, 0.6)
bind i = 0
while i < len(lines) {
col(6, sat, 78.0 - 4.0 * i, hs)
if i > 1 { ink(64.0 - 2.0 * i) }
daemon_text(lines[i], lx, ly + 8.0 + i * 24.0, lh)
bind i = i + 1
}
# right: who holds the connections
bind rx0 = W - 18.0 - min(W * 0.22, 280.0)
bind pw = min(W * 0.22, 280.0)
col(6, sat, 70.0, hs)
daemon_text("BUSIEST PROCESSES", rx0, H * 0.1, 13.0)
bind pr = np[NP_PROC]
bind top = 1.0
if len(pr) > 0 { bind top = max(pr[0][1], 1.0) }
bind i = 0
while i < min(len(pr), 9) {
bind pe = pr[i]
bind yy = H * 0.1 + 32.0 + i * 44.0
bind k = name_hue(pe[0])
col(k, sat, 72.0, hs)
daemon_text(str_slice(pe[0], 0, 14) + " " + num_str(pe[1]), rx0, yy, 12.0)
hbar(rx0, yy + 16.0, pw, pe[1] / top, k, sat, 56.0, hs)
bind i = i + 1
}
}
# ---- view 2: LINKS, seven rings, one per channel
fn view_net_links(Z) {
bind np = Z[Z_D][D_NET]
bind nv = np[NP_NV]
bind labels = ["RX " + fmt_bytes(nv[NV_RX]) + " PER S ", "TX " + fmt_bytes(nv[NV_TX]) + " PER S ", "PACKETS IN " + fmt_rate(nv[NV_PRX]) + " ",
"PACKETS OUT " + fmt_rate(nv[NV_PTX]) + " ", "TCP " + fmt_rate(nv[NV_EST]) + " LINKS ", "UDP " + fmt_rate(nv[NV_UDP]) + " PER S ",
"RETRANSMITS " + fmt_rate(nv[NV_RETX]) + " "]
bind rtt = nv[NV_RTT]
bind big = "---"
if rtt > 0.0 { bind big = num_str(round(rtt)) + "MS" }
ring_stack(Z, 7, IDM, labels, Z[Z_FRAC], big, str_slice(adapter_name(np), 0, 22), 6)
}
# ---- view 3: TRACES, the last minute of seven vital signs
fn view_net_traces(Z) {
bind nv = Z[Z_D][D_NET][NP_NV]
bind titles = ["RECEIVE", "TRANSMIT", "PACKETS IN", "PACKETS OUT", "TCP LINKS", "UDP", "GATEWAY"]
bind rtt = nv[NV_RTT]
bind rs = "---"
if rtt > 0.0 { bind rs = num_str(round(rtt)) + "MS" }
bind vals = [fmt_bytes(nv[NV_RX]) + "/S", fmt_bytes(nv[NV_TX]) + "/S", fmt_rate(nv[NV_PRX]) + "/S", fmt_rate(nv[NV_PTX]) + "/S",
fmt_rate(nv[NV_EST]), fmt_rate(nv[NV_UDP]) + "/S", rs]
bind ids = [HS_NET, HS_NET + 1, HS_NET + 2, HS_NET + 3, HS_NET + 4, HS_NET + 5, HS_NET + 6]
scope(Z, titles, "RTIOCUG", ids, vals)
}