Skip to content

feat(golden): netns pairs for congestion, loss, socket options and states - #330

Merged
randomizedcoder merged 18 commits into
mainfrom
feat/golden-workload-sockets
Nov 25, 2026
Merged

randomizedcoder merged 18 commits into
mainfrom
feat/golden-workload-sockets

Conversation

@randomizedcoder

@randomizedcoder randomizedcoder commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

The golden fixture had only idle ESTABLISHED loopback sockets with cubic, so a real host populates many columns the fixture never exercises: per-algorithm info structs, loss counters, TOS/class_id/sockopt, non-ESTABLISHED states, and real MTUs. This widens the capture workload so coverage.json can require them. Includes #327 (coverage gate) and #329 (tool knobs), merged in; merge those first. The new commits start at "test(golden): coverage for the wider workload (red)". Done test-first.

Workload (golden-workload.sh): four named netns pairs joined by veth

  • golden-cc (MTU 1500): one idle connection per algorithm in tcp_available_congestion_control, IPv4 and IPv6, after loading every tcp_* module. 17 on 7.3.1. The list goes into the manifest as cong_available, so a new kernel's new algorithm is required without editing anything
  • dctcp clients dial a dctcp listener on a second address: a SYN that dctcp marks ECT gets ECN back only from a listener whose algorithm needs ECN (tcp_ecn_create_request, net/ipv4/tcp_input.c); otherwise dctcp_init falls back to dctcp-reno (net/ipv4/tcp_dctcp.c)
  • golden-bulk (MTU 1500, netem delay 5 ms, loss 2 %, reorder 1 %): a 4 MiB echo each for cubic, bbr, dctcp and vegas, done before xtcp2 starts, so the counters are settled
  • golden-opts (MTU 1450): TOS 0x08/0xb8 (traffic class on IPv6), priority 6, freebind/transparent/bind-no-port, receive buffers of 64 KiB, 1 MiB and 16 MiB, one SO_BINDTODEVICE client
  • golden-states (MTU 1300): a FIN_WAIT2/CLOSE_WAIT pair; after poll 1 the capture adds exactly 3 TIME_WAIT and 2 SYN_SENT sockets (to 192.0.2.1, blackholed; a blackhole rather than unreachable, since an ICMP error aborts SYN_SENT)
  • Offloads (TSO/GSO/GRO) are off on the netem pair: with them netem drops whole 64 KiB super-packets, and a client could lose none of its own segments (seen once in a later capture: 3 of 4 bulk clients retransmitted). Verified in the next PR's captures, which run this workload
  • Root sets any algorithm or option in a named netns without container capabilities, and no host TCP opens before poll 2
  • The planned tools/golden-cc Go helper was dropped: listing modules and reading one sysctl is a few lines of shell

Checks

  • ROW lines (golden-capture.sh), all four categories: every_cc, cc_info, opts_seen (positive); loss_seen, no_loss_idle (negative); state_counts (boundary); mtu_paths (corner). Any FAIL fails the capture
  • coverage.json requires the bbr/vegas/dctcp info, total_retrans, bytes_retrans, rcv_ooopack, class_id, states 2/5/6/8, shutdown 1/2, tos 8/184, tclass 184, pmtu 1300/1450/1500, snd_mss 1248/1398/1448, and inet_diag_cong ⊇ @manifest.cong_available
  • Changed after the red commit:
    • bbr_info_bw_hi → bbr_info_bw_lo: hi is the top 32 bits of the bandwidth in bytes/s (bbr_get_info, net/ipv4/tcp_bbr.c), nonzero only above about 34 Gbit/s, which a VM can't reach reliably
    • enrich_socket_interface_name moves to the next PR: only the locality enricher fills it (pkg/xtcp/enrich.go)

Determinism

  • Two captures: xtcp2-golden diff first showed differences only on the bulk rows (dsack_dups, reord_seen, rwnd_limited, probes, retrans, dctcp_alpha, tcp_info_reordering), because netem drops and reorders at random
  • Diff now skips, in rows of Options.LossyNetns (default golden-bulk-a/b), only the twelve columns strict diffs of five captures (two from this PR, three from feat(golden): uplink2, NIC speed, locality and ASN in the capture VM #331) showed varying: goldenrec.lossyColumns = dsack_dups, reord_seen, rwnd_limited, probes, delivery_rate_app_limited, inet_diag_msg_retrans, dctcp_info_alpha, tcp_info_reordering, and the RTO group (total_rto, total_rto_recoveries, total_rto_time, rehash: they move only when a tail loss ends in a retransmission timeout, net/ipv4/tcp_timer.c; one capture in five had one, in two bulk rows). Every other column of those rows (total_retrans, bytes_received, ca_state, ...) and every other row compare as before; a missing row is still reported. Rather than reclassing these columns everywhere, which would hide changes on the idle rows
  • After that, every pair of captures diffs clean (exit 0), including feat(golden): uplink2, NIC speed, locality and ASN in the capture VM #331's fixture against a capture taken after these fixes; the fixture is the first one
  • TestDiff gains lossy_counters_ignored, lossy_presence_kept, lossy_retrans_kept, lossy_strict_kept, lossy_elsewhere, lossy_disabled, lossy_custom, lossy_row_missing; TestLossyColumns pins the list (and that each name is a column); the RTO rows went red first too

Red (coverage commit, against the old fixture)

coverage: bbr_info_bw_hi never populated
coverage: bbr_info_min_rtt never populated
coverage: bbr_info_pacing_gain never populated
coverage: dctcp_info_enabled never populated
coverage: enrich_socket_interface_name never populated
coverage: inet_diag_class_id never populated
coverage: inet_diag_msg_state=2 missing
coverage: inet_diag_msg_state=5 missing
coverage: inet_diag_msg_state=6 missing
coverage: inet_diag_msg_state=8 missing
coverage: inet_diag_shutdown=1 missing
coverage: inet_diag_shutdown=2 missing
coverage: inet_diag_tclass=184 missing
coverage: inet_diag_tos=184 missing
coverage: inet_diag_tos=8 missing
coverage: manifest has no cong_available
coverage: tcp_info_bytes_retrans never populated
coverage: tcp_info_pmtu=1300 missing
coverage: tcp_info_pmtu=1450 missing
coverage: tcp_info_pmtu=1500 missing
coverage: tcp_info_rcv_ooopack never populated
coverage: tcp_info_snd_mss=1248 missing
coverage: tcp_info_snd_mss=1398 missing
coverage: tcp_info_snd_mss=1448 missing
coverage: tcp_info_total_retrans never populated
coverage: vegas_info_enabled never populated
coverage: vegas_info_rtt never populated
exit status 1

LossyNetns (tests commit):

pkg/goldenrec/diff_test.go:125:12: unknown field LossyNetns in struct literal of type Options

Review fixes (each red first)

  • The lossy rows first skipped every Presence column, so zeroed receive bytes in all eight bulk rows passed both diff and coverage. Narrowed to the measured list above. Red:
--- FAIL: TestDiff/lossy_presence_kept: [negative] a netem pair's receive bytes going to zero is still a difference: 0 differences, expected 1
--- FAIL: TestDiff/lossy_retrans_kept: [negative] a netem pair that stops retransmitting is still a difference: 0 differences, expected 1
pkg/goldenrec/diff_test.go:205:17: undefined: lossyColumns
  • Bulk readiness: before a bulk socket's first byte, ss prints no bytes_received; the grep matched nothing, exited 1, and pipefail (writeShellApplication) aborted the workload. bulk_done counts with awk, which prints 0. Red: bash -c 'set -euo pipefail; n=$(printf "cubic rtt:1/1\n" | grep -oE "bytes_received:[0-9]+" | awk … | wc -l); echo reached' exits 1 without reached. The awk was checked on positive, negative (no bytes yet, no sockets), boundary (4 MiB − 1, exactly 4 MiB) and corner (bytes_acked) inputs
  • Also carries feat(tools): socket options, bulk and close modes for tcp_client/tcp_server #329's -close and procnet fixes

Green

All 17 ROW lines PASS in both captures; xtcp2-golden check passes coverage; go test ./... and the nix checks (gofmt, go-vet, nix-fmt, lint-baseline, golangci ×3, redteam-lint, golden-records, test-fuzz-all) pass.

🤖 Generated with Claude Code

randomizedcoder and others added 10 commits November 24, 2026 15:00
Every congestion algorithm the kernel offers (@manifest.cong_available),
their info structs, loss counters, TOS/tclass/class_id, shutdown, the
non-ESTABLISHED states, three path MTUs, SO_BINDTODEVICE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ates

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- dctcp clients dial a dctcp listener: an ECT SYN gets ECN back only
  from a listener whose algorithm needs ECN (tcp_ecn_create_request),
  else dctcp_init falls back to dctcp-reno
- q strips whitespace, so the ROW strings use commas
- coverage requires bbr_info_bw_lo: bw_hi is nonzero only above about
  34 Gbit/s (bbr_get_info)
- enrich_socket_interface_name waits for the locality enricher
- README and CHANGELOG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
netem drops and reorders at random, so two captures disagree on which
of a bulk transfer's counters are nonzero (dsack_dups, reord_seen,
rwnd_limited, probes) and on tcp_info_reordering. Diff skips Presence
columns and the loss-history Strict columns in Options.LossyNetns
(default golden-bulk-a/b); the rest of those rows, and every other
row, compare as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
158 rows: 17 algorithms x 2 families, bulk over netem, socket options,
TIME_WAIT/SYN_SENT/FIN_WAIT2/CLOSE_WAIT, three MTUs. Two captures diff
clean; coverage.json passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With TSO/GSO netem drops whole 64 KiB super-packets, so a 4 MiB
transfer is about a hundred packets and a client could lose none of its
own (loss_seen saw 3 of 4). Per-segment loss makes it near certain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
randomizedcoder and others added 8 commits November 24, 2026 19:23
Review: skipping every Presence column in the netem rows let a bulk
transfer's receive bytes go to zero unnoticed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The netem rows skipped every Presence column, so a bulk transfer whose
receive bytes went to zero diffed clean. lossyColumns lists the eight
columns a strict diff of four captures showed varying; ca_state never
did and is compared again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before a bulk socket receives its first byte, ss prints no
bytes_received; the grep matched nothing, exited 1, and pipefail
aborted the workload. bulk_done counts with awk, which prints 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fifth capture had one RTO in two bulk rows (total_rto, its recoveries
and time, and rehash), which four captures had not shown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@randomizedcoder
randomizedcoder merged commit 04c1d58 into main Nov 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant