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/66_netx.ling
# ───────────────────────────── LINGNET: the network, in detail ───────────────
# Data: netx.snap from sampler_hw.ps1 -Kind netx. "Device" means a network adapter on this PC: every view can be
# narrowed to one (Up / Down, or click a chip in the bar) or show all of them together.
# Windows keeps counters per adapter and per IP version, and a connection table that names the local address,
# so those are the things split by device. It does not count traffic for other machines on your network;
# the neighbours (ARP / NDP table) show who is there, not how much they send.
# pack NX: [good, ads, ms, addrs, gws, dnss, neigh, proto, conns, ks, dns, probes, t, vecs]
bind NX_AD = 1
bind NX_M = 2
bind NX_ADDR = 3
bind NX_GW = 4
bind NX_DNS = 5
bind NX_NB = 6
bind NX_PR = 7
bind NX_CN = 8
bind NX_K = 9
bind NX_DC = 10
bind NX_PQ = 11
bind NX_T = 12
bind NX_VEC = 13
# history strips: 7 for all devices, 7 for each of up to six, 7 for the protocols, 3 for DNS
bind HN_ALL = 0
bind HN_DEV = 7
bind HN_PROTO = 49
bind HN_DNS = 56
bind HN_COUNT = 59
bind FLEET_HUE = [3, 4, 1, 6, 0, 2, 5, 3]
bind NET_VIEWS = ["DEVICES", "FLOW", "PACKETS", "PROTOCOLS", "DNS", "ADDRESSES"]
bind LANE_NAME = ["BYTES IN", "BYTES OUT", "PACKETS IN", "PACKETS OUT", "MULTICAST IN", "MULTICAST OUT", "ERRORS"]
bind PROTO_NAME = ["IPV4", "IPV6", "TCP V4", "TCP V6", "UDP V4", "UDP V6", "ICMP"]
bind DNS_NAME = ["A", "AAAA", "CNAME", "PTR", "SRV", "OTHER", "NEGATIVE"]
fn pos_of(ifx, idx) {
bind i = 0
while i < len(ifx) {
if ifx[i] == idx { return i }
bind i = i + 1
}
return 0 - 1
}
fn parse_netx(text) {
bind rows = snap_rows(text)
bind ads = []
bind ifx = []
bind vecs = []
bind ms = []
bind addrs = []
bind gws = []
bind dnss = []
bind neigh = []
bind proto = zeros(12)
bind conns = []
bind k4 = zeros(7)
bind k6 = zeros(7)
bind dns = zeros(8)
bind probes = []
bind i = 0
while i < len(rows) {
bind r = rows[i]
if r[0] == "a" {
bind ads = list_push(ads, [str_upper(sf(r, 2)), str_upper(sf(r, 3)), nf(r, 5)])
bind ifx = list_push(ifx, nf(r, 1))
bind vecs = list_push(vecs, [nf(r, 6), nf(r, 7), nf(r, 8), nf(r, 9), nf(r, 10), nf(r, 11), nf(r, 12)])
}
bind i = i + 1
}
bind i = 0
while i < len(rows) {
bind r = rows[i]
bind tag = r[0]
bind ps = pos_of(ifx, nf(r, 1))
if tag == "m" {
if ps >= 0 { bind ms = list_push(ms, [ps, nf(r, 2), nf(r, 3), nf(r, 4), nf(r, 5)]) }
}
if tag == "p" {
if ps >= 0 { bind addrs = list_push(addrs, [ps, nf(r, 2), sf(r, 3), nf(r, 4), sf(r, 5), sf(r, 6)]) }
}
if tag == "g" {
if ps >= 0 { bind gws = list_push(gws, [ps, nf(r, 2), sf(r, 3)]) }
}
if tag == "s" {
if ps >= 0 { bind dnss = list_push(dnss, [ps, nf(r, 2), sf(r, 3)]) }
}
if tag == "n" {
if ps >= 0 { bind neigh = list_push(neigh, [ps, nf(r, 2), nf(r, 3), nf(r, 4)]) }
}
if tag == "r" { bind proto = pad_to(nums(r, 1), 12) }
if tag == "c" { bind conns = list_push(conns, [nf(r, 1), pos_of(ifx, nf(r, 2)), nf(r, 3), nf(r, 4), nf(r, 5), str_upper(sf(r, 6))]) }
if tag == "k" {
if nf(r, 1) == 4 { bind k4 = pad_to(nums(r, 2), 7) } else { bind k6 = pad_to(nums(r, 2), 7) }
}
if tag == "d" { bind dns = pad_to(nums(r, 1), 8) }
if tag == "q" { bind probes = list_push(probes, [nf(r, 1), sf(r, 2), nf(r, 3), nf(r, 4), nf(r, 5)]) }
bind i = i + 1
}
bind good = 0
if len(ads) > 0 { bind good = 1 }
return [good, ads, ms, addrs, gws, dnss, neigh, proto, conns, [k4, k6], dns, probes, snap_time(rows), vecs]
}
fn sim_netx(t) {
bind b1 = pow(abs(sin(t * 0.21)), 5.0)
bind b2 = pow(abs(sin(t * 0.33 + 1.0)), 6.0)
bind ads = [["SIM WI-FI 7 ADAPTER", "WI-FI", 1000000000.0], ["SIM GIGABIT ETHERNET", "ETHERNET", 1000000000.0], ["SIM VPN TUNNEL", "VPN", 100000000.0]]
bind vecs = [[40000.0 + 90000.0 * (1.0 + sin(t * 0.5)) + 40000000.0 * b1, 8000.0 + 6000000.0 * b2, 300.0 + 3000.0 * b1, 120.0 + 2000.0 * b2, 4.0, 2.0, 0.0],
[200000.0 * (1.0 + sin(t * 0.3)), 50000.0 * (1.0 + sin(t * 0.4)), 160.0 * (1.0 + sin(t * 0.3)), 60.0 * (1.0 + sin(t * 0.4)), 1.0, 1.0, 0.0],
[9000.0 * (1.0 + sin(t * 0.7)), 4000.0 * (1.0 + sin(t * 0.6)), 20.0, 10.0, 0.0, 0.0, 1.5 * (1.0 + sin(t * 0.2))]]
bind ms = [[0, 4, 1, 1500, 35], [0, 6, 1, 1500, 35], [1, 4, 0, 1500, 25], [1, 6, 1, 1500, 25], [2, 4, 0, 1400, 50], [2, 6, 1, 1400, 50]]
bind addrs = [[0, 4, "192.168.1.20", 24, "PRIVATE", "Dhcp"], [0, 6, "2001:db8:1::20", 64, "GLOBAL", "RouterAdvertisement"],
[0, 6, "fd12:3456:789a::20", 64, "ULA", "RouterAdvertisement"], [0, 6, "fe80::9f9b:b525:5f56:ada1", 64, "LINKLOCAL", "WellKnown"],
[1, 4, "10.0.0.5", 24, "PRIVATE", "Manual"], [1, 6, "fe80::dd9f:2a3a:24fb:369e", 64, "LINKLOCAL", "WellKnown"],
[2, 4, "100.64.0.2", 32, "CGNAT", "Manual"], [2, 6, "fd7a:115c:a1e0::2", 128, "ULA", "Manual"]]
bind gws = [[0, 4, "192.168.1.1"], [0, 6, "fe80::1"], [1, 4, "10.0.0.1"]]
bind dnss = [[0, 4, "1.1.1.1"], [0, 4, "9.9.9.9"], [0, 6, "2606:4700:4700::1111"], [1, 4, "10.0.0.1"]]
bind neigh = []
bind i = 0
while i < 14 {
bind vv = 4
if i % 3 == 1 { bind vv = 6 }
bind neigh = list_push(neigh, [i % 3, vv, fract(i * 0.618 + 0.2), i % 3])
bind i = i + 1
}
bind ports = [443, 443, 443, 80, 53, 22, 8333, 25565, 443, 993, 443, 3389, 8080, 51820]
bind conns = []
bind i = 0
while i < 40 {
bind vv = 4
if i % 4 == 0 { bind vv = 6 }
bind conns = list_push(conns, [vv, i % 3, 0, fract(i * 0.618 + 0.1), ports[i % 14], str_upper(SIM_NAMES[(i * 7) % 20])])
bind i = i + 1
}
bind proto = [450.0 + 300.0 * b1, 30.0 + 40.0 * b2, 140.0 + 90.0 * b1, 12.0 + 20.0 * b2, 3.0 + 40.0 * b2, 8.0 + 15.0 * b1, 2.0 + 6.0 * b2, 5.0, 87.0, 12.0, 3.0, 1.0]
bind probes = [[4, "1.1.1.1", 12.0 + 4.0 * b2, 1, 1], [4, "9.9.9.9", 50.0, 1, 1], [6, "2606:4700:4700::1111", 18.0, 1, 1], [4, "1.1.1.1", 15.0, 1, 28]]
return [1, ads, ms, addrs, gws, dnss, neigh, proto, conns, [[87.0, 108.0, 13.0, 6.0, 0.0, 0.0, 600.0], [12.0, 29.0, 0.0, 0.0, 0.0, 0.0, 2.0]], [103.0, 22.0, 6.0, 12.0, 0.0, 0.0, 11.0, 154.0], probes, 0.0, vecs]
}
# ───────────────────────────── small helpers ─────────────────────────────────
fn inr(mx, my, r) {
if mx >= r[0] {
if mx <= r[0] + r[2] {
if my >= r[1] {
if my <= r[1] + r[3] { return 1 }
}
}
}
return 0
}
fn dev_name(nx, i) {
if i < 0 { return "ALL DEVICES" }
return str_slice(nx[NX_AD][i][1], 0, 18)
}
# the seven counters of one device, or the sum of all of them
fn sel_vec(nx, sel) {
bind vecs = nx[NX_VEC]
if sel >= 0 {
if sel < len(vecs) { return vecs[sel] }
}
bind s = zeros(7)
bind i = 0
while i < len(vecs) {
bind j = 0
while j < 7 {
bind s = list_set(s, j, s[j] + vecs[i][j])
bind j = j + 1
}
bind i = i + 1
}
return s
}
# connections of one device (or all), as [ver, pos, state, hash, port, proc]
fn sel_conns(nx, sel) {
bind cn = nx[NX_CN]
if sel < 0 { return cn }
bind out = []
bind i = 0
while i < len(cn) {
if cn[i][1] == sel { bind out = list_push(out, cn[i]) }
bind i = i + 1
}
return out
}
fn scope_hue(sc) {
if sc == "GLOBAL" { return 3 }
if sc == "PUBLIC" { return 3 }
if sc == "PRIVATE" { return 4 }
if sc == "ULA" { return 5 }
if sc == "LINKLOCAL" { return 1 }
if sc == "CGNAT" { return 6 }
if sc == "LOOPBACK" { return 0 }
return 2
}
fn origin_name(o) {
if o == "Dhcp" { return "DHCP" }
if o == "RouterAdvertisement" { return "RA" }
if o == "Manual" { return "STATIC" }
if o == "WellKnown" { return "AUTO" }
return str_upper(o)
}
fn fmt_speed(bps) { return fmt_bytes(bps) + "BIT" }
fn gw_of(nx, pos, vv) {
bind g = nx[NX_GW]
bind i = 0
while i < len(g) {
if g[i][0] == pos {
if g[i][1] == vv { return g[i][2] }
}
bind i = i + 1
}
return "NONE"
}
fn count_conns(nx, pos, vv) {
bind cn = nx[NX_CN]
bind c = 0
bind i = 0
while i < len(cn) {
if cn[i][1] == pos {
if cn[i][0] == vv { bind c = c + 1 }
}
bind i = i + 1
}
return c
}
fn count_neigh(nx, pos, vv) {
bind nb = nx[NX_NB]
bind c = 0
bind i = 0
while i < len(nb) {
if nb[i][0] == pos {
if nb[i][1] == vv { bind c = c + 1 }
}
bind i = i + 1
}
return c
}
# the first address of a device in a family, shortened: "ADDRESS/PREFIX SCOPE"
fn first_addr(nx, pos, vv) {
bind a = nx[NX_ADDR]
bind best = "NONE"
bind i = 0
while i < len(a) {
if a[i][0] == pos {
if a[i][1] == vv {
if best == "NONE" { bind best = str_slice(a[i][2], 0, 26) + "/" + num_str(a[i][3]) + " " + a[i][4] }
if a[i][4] == "GLOBAL" { bind best = str_slice(a[i][2], 0, 26) + "/" + num_str(a[i][3]) + " " + a[i][4] }
}
}
bind i = i + 1
}
return best
}
# busiest processes among a list of connections: [names, counts], at most m
fn top_procs(cn, m) {
bind names = []
bind counts = []
bind i = 0
while i < len(cn) {
bind nm = cn[i][5]
bind found = 0 - 1
bind j = 0
while j < len(names) {
if names[j] == nm { bind found = j }
bind j = j + 1
}
if found >= 0 {
bind counts = list_set(counts, found, counts[found] + 1)
} else {
bind names = list_push(names, nm)
bind counts = list_push(counts, 1)
}
bind i = i + 1
}
bind on = []
bind oc = []
bind k = 0
while k < m {
bind bi = 0 - 1
bind bv = 0
bind j = 0
while j < len(names) {
if counts[j] > bv {
bind bv = counts[j]
bind bi = j
}
bind j = j + 1
}
if bi >= 0 {
bind on = list_push(on, names[bi])
bind oc = list_push(oc, bv)
bind counts = list_set(counts, bi, 0)
}
bind k = k + 1
}
return [on, oc]
}
fn hn_new() {
bind hs = []
bind i = 0
while i < HN_COUNT {
bind hs = list_push(hs, zeros(HS_N))
bind i = i + 1
}
return hs
}
# the seven lane values of a counter vector, each 0..1
fn lane_fracs(v) {
return [lg(v[0], 9.0), lg(v[1], 9.0), lg(v[2], 6.0), lg(v[3], 6.0), lg(v[4], 5.0), lg(v[5], 5.0), lg(v[6], 2.0)]
}
fn hn_sample(hs, nx) {
bind lf = lane_fracs(sel_vec(nx, 0 - 1))
bind i = 0
while i < 7 {
bind hs = hs_push(hs, HN_ALL + i, lf[i])
bind i = i + 1
}
bind d = 0
while d < min(len(nx[NX_VEC]), 6) {
bind lf = lane_fracs(nx[NX_VEC][d])
bind i = 0
while i < 7 {
bind hs = hs_push(hs, HN_DEV + d * 7 + i, lf[i])
bind i = i + 1
}
bind d = d + 1
}
bind p = nx[NX_PR]
bind pf = [lg(p[0], 4.5), lg(p[1], 4.5), lg(p[2], 4.5), lg(p[3], 4.5), lg(p[4], 4.0), lg(p[5], 4.0), lg(p[6] + p[7], 3.0)]
bind i = 0
while i < 7 {
bind hs = hs_push(hs, HN_PROTO + i, pf[i])
bind i = i + 1
}
bind pq = nx[NX_PQ]
bind a4 = 0.0
bind a6 = 0.0
bind i = 0
while i < len(pq) {
if pq[i][3] > 0.5 {
if pq[i][4] == 1 {
if a4 <= 0.0 { bind a4 = pq[i][2] / 300.0 }
} else {
if a6 <= 0.0 { bind a6 = pq[i][2] / 300.0 }
}
}
bind i = i + 1
}
bind hs = hs_push(hs, HN_DNS, a4)
bind hs = hs_push(hs, HN_DNS + 1, a6)
bind hs = hs_push(hs, HN_DNS + 2, lg(nx[NX_DC][7], 3.0))
return hs
}
# ───────────────────────────── view 1: DEVICES ───────────────────────────────
fn dev_rect(i, n, W, H) {
bind cols = n
if n > 2 { bind cols = 3 }
if n == 4 { bind cols = 2 }
bind rows = ceil(n / cols)
bind gap = 14.0
bind cw = (W - 36.0 - (cols - 1) * gap) / cols
bind ch = (H - 82.0 - (rows - 1) * gap) / rows
return [18.0 + (i % cols) * (cw + gap), 70.0 + floor(i / cols) * (ch + gap), cw, ch]
}
fn dev_hit(mx, my, W, H, n) {
bind i = 0
while i < n {
if inr(mx, my, dev_rect(i, n, W, H)) == 1 { return i }
bind i = i + 1
}
return 0 - 1
}
fn view_net_devices(Z) {
bind W = Z[Z_W]
bind H = Z[Z_H]
bind hs = Z[Z_HS]
bind sat = Z[Z_SAT]
bind D = Z[Z_D]
bind nx = D[0]
bind sel = D[1]
bind hst = D[D_HS]
bind n = min(len(nx[NX_AD]), 6)
bind hov = dev_hit(Z[Z_MX], Z[Z_MY], W, H, n)
bind rows = ceil(n / max(min(n, 3), 1))
if n == 4 { bind rows = 2 }
bind g = 0
while g < n {
bind ad = nx[NX_AD][g]
bind v = nx[NX_VEC][g]
bind r = dev_rect(g, n, W, H)
bind x = r[0]
bind y = r[1]
bind cw = r[2]
bind ch = r[3]
bind k = FLEET_HUE[g % 8]
bind on = 0
if g == sel { bind on = 1 }
bind lit = 30.0 + 40.0 * on
if g == hov { bind lit = lit + 14.0 }
col(k, sat * 0.7, lit, hs)
brect(x, y, 1.0, 0.0, 0.0, cw, ch)
if on == 1 {
bind a = 14.0
col(k, sat, 84.0, hs)
bline(x, y, 1.0, 0.0, a, 0.0, 0.0)
bline(x, y, 1.0, 0.0, 0.0, a, 0.0)
bline(x, y, 1.0, cw - a, 0.0, cw, 0.0)
bline(x, y, 1.0, cw, 0.0, cw, a)
bline(x, y, 1.0, cw, ch - a, cw, ch)
bline(x, y, 1.0, cw, ch, cw - a, ch)
bline(x, y, 1.0, a, ch, 0.0, ch)
bline(x, y, 1.0, 0.0, ch, 0.0, ch - a)
}
tile(num_str(g), x + 10.0, y + 10.0, 38.0, 54.0 + 28.0 * on, k, sat, hs, 0.5 + on)
bind tw = (cw - 70.0) / 0.74
col(k, sat, 80.0 + 10.0 * on, hs)
daemon_text(str_slice(ad[1], 0, 20), x + 58.0, y + 24.0, min(15.0, (cw - 70.0) / (0.74 * 14.0)))
ink(50.0)
daemon_text(str_slice(ad[0], 0, 30), x + 58.0, y + 44.0, min(10.0, (cw - 70.0) / (0.74 * 26.0)))
# traffic in and out
bind lw = cw - 24.0
col(4, sat, 82.0, hs)
daemon_text("IN " + fmt_bytes(v[0]) + "/S", x + 12.0, y + 84.0, 15.0)
hbar(x + 12.0, y + 106.0, lw, lg(v[0], 9.0), 4, sat, 58.0, hs)
col(1, sat, 82.0, hs)
daemon_text("OUT " + fmt_bytes(v[1]) + "/S", x + 12.0, y + 126.0, 15.0)
hbar(x + 12.0, y + 148.0, lw, lg(v[1], 9.0), 1, sat, 58.0, hs)
bind pe = lg(v[6], 2.0)
bind lines = ["LINK " + fmt_speed(ad[2]) + " PKTS " + fmt_rate(v[2]) + " IN " + fmt_rate(v[3]) + " OUT",
"MULTICAST " + fmt_rate(v[4]) + " IN " + fmt_rate(v[5]) + " OUT ERR " + fmt_rate(v[6]),
"V4 " + first_addr(nx, g, 4), "V6 " + first_addr(nx, g, 6),
"GW " + gw_of(nx, g, 4) + " V6 GW " + str_slice(gw_of(nx, g, 6), 0, 12),
"TCP " + num_str(count_conns(nx, g, 4)) + " V4 " + num_str(count_conns(nx, g, 6)) + " V6 NEIGHBOURS " + num_str(count_neigh(nx, g, 4)) + "+" + num_str(count_neigh(nx, g, 6))]
bind lh = min(12.0, lw / (0.74 * 38.0))
bind q = 0
while q < len(lines) {
ink(66.0 - 3.0 * q)
if q == 1 {
if pe > 0.05 { col(0, sat, 80.0, hs) }
}
daemon_text(lines[q], x + 12.0, y + 184.0 + q * 24.0, lh)
bind q = q + 1
}
if rows == 1 {
ink(46.0)
daemon_text("BYTES IN, LAST 50 S", x + 12.0, y + ch - 66.0, 10.0)
spark(x + 12.0, y + ch - 56.0, lw, 44.0, hst[HN_DEV + g * 7], 100, k, sat, 64.0, hs)
}
bind g = g + 1
}
}
# ───────────────────────────── view 2: FLOW ──────────────────────────────────
# the connections of the chosen device, in sectors by remote port; circle = IPv4, diamond = IPv6
fn nx_node_xy(nd, i, cx, cy, R) {
return node_xy([nd[3], nd[4]], i, cx, cy, R)
}
fn view_net_flow2(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.31, H * 0.5 - 16.0)
bind t = Z[Z_T]
bind hs = Z[Z_HS]
bind sat = Z[Z_SAT]
bind en = Z[Z_ENERGY]
bind D = Z[Z_D]
bind nx = D[0]
bind sel = D[1]
bind nodes = sel_conns(nx, sel)
bind v = sel_vec(nx, sel)
bind sec = TAU / 7.0
bind counts = [0, 0, 0, 0, 0, 0, 0]
bind n4 = 0
bind n6 = 0
bind i = 0
while i < len(nodes) {
bind c = port_class(nodes[i][4])
bind counts = list_set(counts, c, counts[c] + 1)
if nodes[i][0] == 6 { bind n6 = n6 + 1 } else { bind n4 = n4 + 1 }
bind i = i + 1
}
bind c = 0
while c < 7 {
bind a0 = c * sec + 0.02
bind a1 = (c + 1) * sec - 0.02
col(c, sat * 0.8, 36.0 + 24.0 * en[c], hs)
arc(cx, cy, R, a0, a1)
arc(cx, cy, R * 0.915, a0, a1)
col(c, sat * 0.6, 16.0, hs)
pline(cx, cy, R * 0.17, c * sec, R * 0.915, c * sec)
col(c, sat, 66.0, 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
}
bind i = 0
while i < len(nodes) {
bind nd = nodes[i]
bind xy = nx_node_xy(nd, i, cx, cy, R)
bind k = port_class(nd[4])
col(k, sat * 0.7, 14.0, hs)
pline(cx, cy, R * 0.17, xy[2], xy[3], xy[2])
col(k, sat, 56.0, hs)
if nd[0] == 6 {
square(xy[0], xy[1], 4.5, 0.7854)
draw_circle(xy[0], xy[1], 1.5)
} else {
draw_circle(xy[0], xy[1], 5.0)
draw_circle(xy[0], xy[1], 2.0)
}
bind i = i + 1
}
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 s1 = "IN " + fmt_bytes(v[0])
bind s2 = "OUT " + fmt_bytes(v[1])
col(0, sat, 80.0, hs)
bind h1 = fit_h(s1, hr * 1.5, hr * 0.3)
daemon_text(s1, cx - text_w(s1, h1) / 2.0, cy - hr * 0.2, h1)
col(1, sat, 80.0, hs)
bind h2 = fit_h(s2, hr * 1.5, hr * 0.3)
daemon_text(s2, cx - text_w(s2, h2) / 2.0, cy + hr * 0.22, h2)
# pulses ride the spokes: in = circle travelling to the hub, out = 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[4])
bind xy = nx_node_xy(nd, ni, cx, cy, R)
bind q = p
if ev[j] == 0 { bind q = 1.0 - p }
bind x = mix(px(cx, hr, xy[2]), xy[0], q)
bind y = mix(py(cy, hr, xy[2]), 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, 6.0) } else { square(x, y, 5.0, p * 4.0) }
}
bind j = j + 6
}
# left: who and how many
bind lx = 18.0
bind ly = 112.0
tile("D", lx, ly - 54.0, 44.0, 66.0, 6, sat, hs, 0.6)
col(6, sat, 82.0, hs)
daemon_text(dev_name(nx, sel), lx + 54.0, ly - 30.0, 13.0)
bind lines = ["CONNECTIONS " + num_str(len(nodes)), "IPV4 " + num_str(n4) + " IPV6 " + num_str(n6), "IN " + fmt_bytes(v[0]) + "/S", "OUT " + fmt_bytes(v[1]) + "/S",
"PKTS " + fmt_rate(v[2]) + " IN " + fmt_rate(v[3]) + " OUT"]
bind q = 0
while q < len(lines) {
ink(70.0 - 4.0 * q)
daemon_text(lines[q], lx, ly + 16.0 + q * 24.0, 13.0)
bind q = q + 1
}
ink(52.0)
daemon_text("CIRCLE IPV4", lx, ly + 160.0, 11.0)
daemon_text("DIAMOND IPV6", lx, ly + 180.0, 11.0)
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, 112.0, 13.0)
bind tp = top_procs(nodes, 9)
bind top = 1.0
if len(tp[1]) > 0 { bind top = max(tp[1][0], 1.0) }
bind i = 0
while i < len(tp[0]) {
bind yy = 144.0 + i * 44.0
bind k = name_hue(tp[0][i])
col(k, sat, 72.0, hs)
daemon_text(str_slice(tp[0][i], 0, 14) + " " + num_str(tp[1][i]), rx0, yy, 12.0)
hbar(rx0, yy + 16.0, pw, tp[1][i] / top, k, sat, 56.0, hs)
bind i = i + 1
}
}
# ───────────────────────────── view 3: PACKETS ───────────────────────────────
fn view_net_packets(Z) {
bind D = Z[Z_D]
bind nx = D[0]
bind sel = D[1]
bind v = sel_vec(nx, sel)
bind base = HN_ALL
if sel >= 0 { bind base = HN_DEV + sel * 7 }
bind vals = [fmt_bytes(v[0]) + "/S", fmt_bytes(v[1]) + "/S", fmt_rate(v[2]) + "/S", fmt_rate(v[3]) + "/S", fmt_rate(v[4]) + "/S", fmt_rate(v[5]) + "/S", fmt_rate(v[6]) + "/S"]
bind ids = [base, base + 1, base + 2, base + 3, base + 4, base + 5, base + 6]
scope(Z, LANE_NAME, "RTIOMNE", ids, vals)
}
# ───────────────────────────── view 4: PROTOCOLS ─────────────────────────────
fn proto_panel(Z, x, y, w, vv, label, kc, est, pk) {
bind sat = Z[Z_SAT]
bind hs = Z[Z_HS]
bind k = 4
if vv == 6 { bind k = 5 }
tile(num_str(vv), x, y, 44.0, 66.0, k, sat, hs, 0.6)
col(k, sat, 84.0, hs)
daemon_text(label, x + 56.0, y + 16.0, 16.0)
ink(56.0)
daemon_text(fmt_rate(pk) + " PACKETS/S", x + 56.0, y + 38.0, 11.0)
bind lines = ["ESTABLISHED " + fmt_rate(kc[0]), "LISTENING " + fmt_rate(kc[1]), "TIME WAIT " + fmt_rate(kc[2]), "CLOSE WAIT " + fmt_rate(kc[3]), "SYN SENT " + fmt_rate(kc[4]), "OTHER " + fmt_rate(kc[5]), "LOOPBACK " + fmt_rate(kc[6])]
bind q = 0
while q < len(lines) {
ink(68.0 - 3.0 * q)
daemon_text(lines[q], x, y + 90.0 + q * 24.0, 13.0)
hbar(x, y + 100.0 + q * 24.0, w, lg(kc[q], 3.0), k, sat, 52.0, hs)
bind q = q + 1
}
}
fn view_net_protocols(Z) {
bind W = Z[Z_W]
bind H = Z[Z_H]
bind D = Z[Z_D]
bind nx = D[0]
bind p = nx[NX_PR]
bind ks = nx[NX_K]
bind total = p[0] + p[1]
bind v6pct = 0.0
if total > 0.0 { bind v6pct = p[1] / total * 100.0 }
bind labels = []
bind pv = [p[0], p[1], p[2], p[3], p[4], p[5], p[6] + p[7]]
bind q = 0
while q < 7 {
bind labels = list_push(labels, PROTO_NAME[q] + " " + fmt_rate(pv[q]) + " PER S ")
bind q = q + 1
}
bind R = min(W * 0.3, H * 0.5 - 16.0)
ring_stack_at(Z, W / 2.0, H / 2.0, R, 7, IDM, labels, Z[Z_FRAC], pct(v6pct) + "%", "OF IP IS V6", 5)
bind pw = min(W * 0.2, 250.0)
proto_panel(Z, 18.0, 90.0, pw, 4, "IPV4", ks[0], p[8], p[0])
proto_panel(Z, W - 18.0 - pw, 90.0, pw, 6, "IPV6", ks[1], p[9], p[1])
ink(46.0)
daemon_text("ALL DEVICES, COUNTED PER PROTOCOL BY WINDOWS", 18.0, H - 24.0, 11.0)
}
# ───────────────────────────── view 5: DNS ───────────────────────────────────
fn probe_for(nx, server, qtype) {
bind pq = nx[NX_PQ]
bind i = 0
while i < len(pq) {
if pq[i][1] == server {
if pq[i][4] == qtype { return pq[i] }
}
bind i = i + 1
}
return []
}
fn view_net_dns(Z) {
bind W = Z[Z_W]
bind H = Z[Z_H]
bind hs = Z[Z_HS]
bind sat = Z[Z_SAT]
bind D = Z[Z_D]
bind nx = D[0]
bind sel = D[1]
bind hst = D[D_HS]
bind dc = nx[NX_DC]
bind labels = []
bind q = 0
while q < 7 {
bind labels = list_push(labels, DNS_NAME[q] + " " + fmt_rate(dc[q]) + " ")
bind q = q + 1
}
bind R = min(W * 0.3, H * 0.5 - 16.0)
ring_stack_at(Z, W / 2.0, H / 2.0, R, 7, IDM, labels, Z[Z_FRAC], fmt_rate(dc[7]), "IN CACHE", 6)
# left: the servers this device uses, asked directly
bind lx = 18.0
bind lw = min(W * 0.24, 300.0)
col(6, sat, 80.0, hs)
daemon_text("DNS SERVERS", lx, 92.0, 14.0)
ink(52.0)
daemon_text(dev_name(nx, sel), lx, 112.0, 10.0)
bind dn = nx[NX_DNS]
bind row = 0
bind i = 0
while i < len(dn) {
if sel < 0 || dn[i][0] == sel {
if row < 5 {
bind sv = dn[i][2]
bind pr = probe_for(nx, sv, 1)
bind vv = dn[i][1]
bind k = 4
if vv == 6 { bind k = 5 }
bind yy = 150.0 + row * 54.0
col(k, sat, 78.0, hs)
daemon_text("V" + num_str(vv) + " " + str_slice(sv, 0, 24), lx, yy, min(12.0, lw / (0.74 * 28.0)))
bind msg = "NOT PROBED"
bind frac = 0.0
if len(pr) > 0 {
if pr[3] > 0.5 {
bind msg = num_str(round(pr[2])) + " MS"
bind frac = clamp(pr[2] / 200.0, 0.0, 1.0)
} else {
bind msg = "NO ANSWER"
}
}
if msg == "NO ANSWER" { col(0, sat, 80.0, hs) } else { ink(62.0) }
daemon_text(msg, lx, yy + 18.0, 11.0)
hbar(lx, yy + 38.0, lw, frac, k, sat, 56.0, hs)
bind row = row + 1
}
}
bind i = i + 1
}
if row == 0 {
ink(52.0)
daemon_text("NO DNS SERVERS", lx, 150.0, 12.0)
}
# right: what the answers look like
bind rx0 = W - 18.0 - min(W * 0.24, 300.0)
bind pq = nx[NX_PQ]
bind ok6 = 0
bind aaaa = 0.0 - 1.0
bind i = 0
while i < len(pq) {
if pq[i][4] == 28 {
if pq[i][3] > 0.5 { bind aaaa = pq[i][2] }
}
if pq[i][0] == 6 {
if pq[i][3] > 0.5 { bind ok6 = ok6 + 1 }
}
bind i = i + 1
}
bind v6s = 0
bind i = 0
while i < len(dn) {
if dn[i][1] == 6 { bind v6s = v6s + 1 }
bind i = i + 1
}
bind aq = "AAAA ANSWERED " + num_str(round(aaaa)) + " MS"
if aaaa < 0.0 { bind aq = "AAAA NOT ANSWERED" }
bind real = dc[0] + dc[1] + dc[2] + dc[3] + dc[4] + dc[5]
bind v6share = 0.0
if dc[0] + dc[1] > 0.0 { bind v6share = dc[1] / (dc[0] + dc[1]) * 100.0 }
bind facts = ["CACHE " + num_str(dc[7]) + " ENTRIES", "ANSWERS " + num_str(real) + " NEGATIVE " + num_str(dc[6]), "AAAA OF ADDRESSES " + pct(v6share) + "%", "V6 SERVERS " + num_str(v6s) + " ANSWERING " + num_str(ok6), aq]
col(6, sat, 80.0, hs)
daemon_text("RESOLVER", rx0, 92.0, 14.0)
bind q = 0
while q < len(facts) {
ink(68.0 - 3.0 * q)
daemon_text(facts[q], rx0, 126.0 + q * 24.0, 12.0)
bind q = q + 1
}
ink(46.0)
daemon_text("FIRST SERVER LATENCY, LAST 50 S", rx0, 276.0, 10.0)
spark(rx0, 286.0, min(W * 0.24, 300.0), 60.0, hst[HN_DNS], 100, 4, sat, 64.0, hs)
ink(46.0)
daemon_text("PROBES GO STRAIGHT TO EACH SERVER FOR DNS.MSFTNCSI.COM; NAMES IN YOUR CACHE ARE COUNTED, NEVER SHOWN", 18.0, H - 24.0, 10.0)
}
# ───────────────────────────── view 6: ADDRESSES ─────────────────────────────
fn view_net_addresses(Z) {
bind W = Z[Z_W]
bind H = Z[Z_H]
bind t = Z[Z_T]
bind hs = Z[Z_HS]
bind sat = Z[Z_SAT]
bind D = Z[Z_D]
bind nx = D[0]
bind sel = D[1]
bind ad = nx[NX_ADDR]
bind lx = 18.0
bind lw = W * 0.55
bind y = 92.0
bind d = 0
while d < len(nx[NX_AD]) {
if sel < 0 || d == sel {
bind k = FLEET_HUE[d % 8]
col(k, sat, 82.0, hs)
daemon_text(str_slice(nx[NX_AD][d][1], 0, 24) + " " + fmt_speed(nx[NX_AD][d][2]), lx, y, 13.0)
bind y = y + 22.0
bind i = 0
while i < len(ad) {
if ad[i][0] == d {
bind sc = scope_hue(ad[i][4])
ink(66.0)
daemon_text("V" + num_str(ad[i][1]) + " " + str_slice(ad[i][2], 0, 30) + "/" + num_str(ad[i][3]), lx + 12.0, y, min(12.0, lw / (0.74 * 44.0)))
col(sc, sat, 80.0, hs)
daemon_text(ad[i][4], lx + lw * 0.62, y, 11.0)
ink(50.0)
daemon_text(origin_name(ad[i][5]), lx + lw * 0.62 + 100.0, y, 10.0)
bind y = y + 20.0
}
bind i = i + 1
}
bind ms = nx[NX_M]
bind mtu = 0
bind dhcp4 = 0
bind dhcp6 = 0
bind i = 0
while i < len(ms) {
if ms[i][0] == d {
bind mtu = ms[i][3]
if ms[i][1] == 4 { bind dhcp4 = ms[i][2] } else { bind dhcp6 = ms[i][2] }
}
bind i = i + 1
}
ink(56.0)
daemon_text("GW " + gw_of(nx, d, 4) + " V6 GW " + str_slice(gw_of(nx, d, 6), 0, 22), lx + 12.0, y, 11.0)
bind y = y + 18.0
bind dn = ""
bind i = 0
while i < len(nx[NX_DNS]) {
if nx[NX_DNS][i][0] == d { bind dn = dn + str_slice(nx[NX_DNS][i][2], 0, 18) + " " }
bind i = i + 1
}
if str_len(dn) == 0 { bind dn = "NONE" }
daemon_text("DNS " + str_slice(dn, 0, 64), lx + 12.0, y, 11.0)
bind y = y + 18.0
daemon_text("MTU " + num_str(mtu) + " DHCP V4 " + yes_no(dhcp4) + " V6 " + yes_no(dhcp6), lx + 12.0, y, 11.0)
bind y = y + 32.0
}
bind d = d + 1
}
# right: the neighbours (ARP and NDP tables): outer ring IPv4, inner ring IPv6
bind cx = W - 18.0 - min(W * 0.2, H * 0.4)
bind cy = H * 0.5
bind R = min(W * 0.2, H * 0.4) - 6.0
col(4, sat * 0.8, 40.0, hs)
draw_circle(cx, cy, R)
col(5, sat * 0.8, 40.0, hs)
draw_circle(cx, cy, R * 0.62)
ink(20.0)
draw_circle(cx, cy, R * 0.25)
bind nb = nx[NX_NB]
bind c4 = 0
bind c6 = 0
bind i = 0
while i < len(nb) {
bind nd = nb[i]
if sel < 0 || nd[0] == sel {
bind a = nd[2] * TAU + Z[Z_ROT] * 0.04
bind rr = R
bind k = 4
if nd[1] == 6 {
bind rr = R * 0.62
bind k = 5
bind c6 = c6 + 1
} else {
bind c4 = c4 + 1
}
bind sk = 3
if nd[3] == 1 { bind sk = 1 }
if nd[3] == 2 { bind sk = 0 }
bind x = px(cx, rr, a)
bind yy = py(cy, rr, a)
col(sk, sat, 66.0, hs)
draw_circle(x, yy, 6.0)
col(k, sat, 78.0, hs)
draw_circle(x, yy, 2.5)
}
bind i = i + 1
}
bind big = num_str(c4 + c6)
col(6, sat, 82.0, hs)
bind bh = fit_h(big, R * 0.4, R * 0.2)
daemon_text(big, cx - text_w(big, bh) / 2.0, cy - 4.0, bh)
ink(56.0)
daemon_text("NEIGHBOURS", cx - text_w("NEIGHBOURS", 10.0) / 2.0, cy + R * 0.14, 10.0)
ink(56.0)
daemon_text("OUTER V4 " + num_str(c4) + " INNER V6 " + num_str(c6), cx - R, cy + R + 22.0, 11.0)
col(3, sat, 70.0, hs)
daemon_text("GREEN REACHABLE", cx - R, cy + R + 42.0, 10.0)
col(1, sat, 70.0, hs)
daemon_text("ORANGE STALE", cx - R + 150.0, cy + R + 42.0, 10.0)
col(0, sat, 70.0, hs)
daemon_text("RED NO ANSWER", cx - R + 270.0, cy + R + 42.0, 10.0)
}
fn yes_no(x) {
if x > 0 { return "ON" }
return "OFF"
}