Make link state real, and re-converge when a cable is pulled #1058
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1058
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/link-state-renewal"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Linkhas carriedstate: 'up' | 'down' | 'blocked'since the physical layer was built, andnothing in the engine ever read it.
Link.isUp()existed, was exported, was serialised — and had nocaller:
So a cable marked
downstill carried every frame, still counted as a bridge port, and was stillwalked by the DHCP segment search. The field was decoration, and the failure it hid was total: a
lab could show a cut link passing traffic.
What a state change now does — four things, all of them what real gear does
reason: 'link down'and the link id, so the timeline says where it died rather than going quiet.
topology finds the other way. This is the whole reason STP exists, and it cannot be demonstrated
if the tree ignores link state.
the entries is how a real network black-holes after a failure: traffic is unicast into the port
that used to lead somewhere.
Re-convergence, end to end
A redundant triangle of three switches, host to host:
With no second path it stays broken, and healing one link brings it back. With the change at 10 s:
reason: 'converging'reason: 'converging'getConvergence().convergedAtMsis 40 000, and the schedule carriesfromMs: 10000plus an entryfor the change itself, so nothing in it claims to be ready before the event that caused it.
Two things the tests caught that I had wrong
The change instant lived in the wrong place. I first kept it on the
Simulator, and a labreloaded from disk reverted to
fromMs: 0— it would have reported the network as converged at 30 sbecause something converged at 30 s, hours before the cable was pulled. It belongs on the topology
(
lastChangeAtMs) and on the link (stateSinceMs), and it is saved.lastChangeAtMs: 0on every file. Writing the field unconditionally brokeexamples-idempotent— four regenerated examples grew a field they had no business carrying. A labbuilt and never disturbed has nothing to say about when it changed, so the field is written only
when it is non-zero. Same for
stateSinceMson a link that never moved.The UI
A down cable is drawn dashed and red and carries
data-link-state, and the cable context menugains Take link down / Bring link up — distinct from Delete cable, because unpatching a
port and cutting a cable are different operations. The status line reports when the network will be
whole again.
Test
test/link-state.test.js— 67 assertions: the defect itself (a down link carries nothing, andthe drop names the link),
setLinkStaterefusals and idempotence, the tree healing around afailure, a network with no second path staying broken and recovering, the re-based schedule at
11/20/41 s, MAC table flush, the DHCP segment walk refusing to cross a cut cable, save/load of
state +
stateSinceMs+lastChangeAtMs, and the CLI surface including every refusal.test/link-state-drawing.test.js— 13 assertions: the renderer marks a down cable, keeps itsmedium class, stays clickable, and the stylesheet really dashes and recolours it.
Three failures while writing these, all real: STP was only rebuilt at run start (so a lab querying
straight after a change saw the old tree), and two were the test inspecting the 16 px transparent
grab band and calling it the drawing.
Docs
New
docs/LINK-STATE.md, with a What this does not model section: no degraded links (no CRCerrors, no flapping), no autonegotiation on recovery, no interface self-test failure, and no RSTP
fast convergence — re-convergence costs the same 30 s as a boot, because the timer model is
802.1D. That is the largest single inaccuracy here and it is stated rather than papered over.
docs/CONVERGENCE.mdgains the re-convergence case,docs/SIMULATION.mdgains §5.3b with thedefect and its enforcement points,
docs/CLI.mdthe commands, README the capability row.101 suites, 4 920 assertions, all passing.
Closes #1057.
71591e439824fe06e6b8