A converging path is not packet loss, and an instant is not session state (#1383) #1384

Merged
jaylouisw merged 1 commit from feat/ping-convergence into main 2026-11-10 21:00:32 +00:00
Owner

A converging path is not packet loss, and an instant is not session state. Fixes #1383.

1. The instant stuck to the session

ping <address> at 0 called sim.setRunTime(0), which persists on the simulator. Every later command in that
console session was answered at t=0 — the next plain ping, a later show ip route, anything — and nothing said so:

SW1> ping 10.9.0.2 2 at 0
Success rate is 0 percent (0/2)
% Still converging at t=0 ms: stp on SW1 (ready at 30000 ms)
SW1> ping 10.9.0.2 2
Success rate is 0 percent (0/2)          <- no instant was named; this should be 100%

Now at <ms> applies to the command that said it. The console captures runAtMs on the way in and restores it in a
finally, whatever the ping did.

2. The line read the command, not the answer

The convergence line printed at t=<what you typed>, so that second ping said at t=null ms. Simulator.ping()
now returns runAtMs — the instant the answer belongs to, null when it belongs to no particular instant
(Infinity, a settled lab, which can never be converging) — and the console prints that.

3. The browser called convergence packet loss

The Simulate dialog drew Success rate 0% (0/4) for a path that was still settling — the lie the API stopped telling
in #1377 and #1381, one surface further out. It now shows the sentence and no percentage at all for a converging
answer, while genuine loss still reads as loss and a good path still reads 100%.

The sentence is written once — pingConvergenceSentence(replies) in engine/simulator.js:
Still converging: <process> on <device> (ready at <ms>) — printed once per ping however many echoes were held
up, and mirrored by the browser. The dialog's rendering became a pure function, pingResultHtml(answer, dst, askedCount), so the awkward cases are checked directly instead of by driving a form.

Evidence

test/ping-convergence.test.js — 33 checks:

  • the engine's sentence names the process, the device and the instant the path is ready, appears exactly once for
    two held-up echoes, and is null for a settled path;
  • runAtMs is 0 when asked at 0 and null for a ping with no instant (not 0);
  • the console prints the sentence once, with at t=0 ms, and never t=null;
  • after ping … at 0, the next plain ping succeeds because it is asked at Infinity — the behavioural proof
    that the instant no longer sticks;
  • the browser's rule and the engine's produce the same string across eight shapes of answer (one converging,
    two converging on one process, two on different processes with the later instant winning, no instant, nothing
    pending, a timeout, all answered, empty);
  • the rendering: converging → sentence and no percentage; timeout → 0% (0/4); good → 100% (2/2); unresolvable
    name → no percentage; half-converging → 50% and the reason.

Reverting engine/cli.js fails 3 of 33, and the failure printout shows the old behaviour verbatim —
% Still converging at t=null ms: … twice, then Success rate is 0 percent for the next plain ping. Reverting
web/app.js fails on the missing rule; engine/simulator.js on the missing instant.

test/convergence-timing.test.js moves with the sentence it pins (it now checks the process, when the path will be
ready, and which instant the answer belongs to). docs/CLI.md and docs/CONVERGENCE.md quote the new line and state
that at <ms> applies to one command.

Suite: 195 suites, 7,501 assertions, 0 failed. Syntax: 263 files, OK.

A converging path is not packet loss, and an instant is not session state. Fixes #1383. ## 1. The instant stuck to the session `ping <address> at 0` called `sim.setRunTime(0)`, which **persists** on the simulator. Every later command in that console session was answered at t=0 — the next plain `ping`, a later `show ip route`, anything — and nothing said so: ``` SW1> ping 10.9.0.2 2 at 0 Success rate is 0 percent (0/2) % Still converging at t=0 ms: stp on SW1 (ready at 30000 ms) SW1> ping 10.9.0.2 2 Success rate is 0 percent (0/2) <- no instant was named; this should be 100% ``` Now `at <ms>` applies to the command that said it. The console captures `runAtMs` on the way in and restores it in a `finally`, whatever the ping did. ## 2. The line read the command, not the answer The convergence line printed `at t=<what you typed>`, so that second ping said `at t=null ms`. `Simulator.ping()` now returns **`runAtMs`** — the instant the answer belongs to, `null` when it belongs to no particular instant (`Infinity`, a settled lab, which can never be converging) — and the console prints that. ## 3. The browser called convergence packet loss The Simulate dialog drew `Success rate 0% (0/4)` for a path that was still settling — the lie the API stopped telling in #1377 and #1381, one surface further out. It now shows the sentence and **no percentage at all** for a converging answer, while genuine loss still reads as loss and a good path still reads 100%. The sentence is written once — `pingConvergenceSentence(replies)` in `engine/simulator.js`: `Still converging: <process> on <device> (ready at <ms>)` — printed **once per ping** however many echoes were held up, and mirrored by the browser. The dialog's rendering became a pure function, `pingResultHtml(answer, dst, askedCount)`, so the awkward cases are checked directly instead of by driving a form. ## Evidence `test/ping-convergence.test.js` — **33 checks**: * the engine's sentence names the process, the device and the instant the path is ready, appears exactly once for two held-up echoes, and is `null` for a settled path; * `runAtMs` is `0` when asked at 0 and **`null`** for a ping with no instant (not `0`); * the console prints the sentence once, with `at t=0 ms`, and never `t=null`; * after `ping … at 0`, the **next plain ping succeeds** because it is asked at `Infinity` — the behavioural proof that the instant no longer sticks; * the browser's rule and the engine's produce **the same string** across eight shapes of answer (one converging, two converging on one process, two on different processes with the later instant winning, no instant, nothing pending, a timeout, all answered, empty); * the rendering: converging → sentence and no percentage; timeout → `0% (0/4)`; good → `100% (2/2)`; unresolvable name → no percentage; half-converging → `50%` **and** the reason. Reverting `engine/cli.js` fails **3 of 33**, and the failure printout shows the old behaviour verbatim — `% Still converging at t=null ms: …` twice, then `Success rate is 0 percent` for the next plain ping. Reverting `web/app.js` fails on the missing rule; `engine/simulator.js` on the missing instant. `test/convergence-timing.test.js` moves with the sentence it pins (it now checks the process, when the path will be ready, and which instant the answer belongs to). `docs/CLI.md` and `docs/CONVERGENCE.md` quote the new line and state that `at <ms>` applies to one command. Suite: **195 suites, 7,501 assertions, 0 failed**. Syntax: 263 files, OK.
A converging path is not packet loss, and an instant is not session state (#1383)
All checks were successful
CI / Classify the change (pull_request) Successful in 13s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 16s
CI / Test (Node 20) (pull_request) Successful in 2m36s
CI / Test (Node 18) (pull_request) Successful in 2m43s
CI / Server smoke test (pull_request) Successful in 34s
CI / Docker build (pull_request) Successful in 45s
CI / Test (Node 22) (pull_request) Successful in 2m29s
f0ae355c06
Three defects in the same corner of the console and the browser.

1. `ping <address> at 0` called `sim.setRunTime(0)`, which persists on the simulator. Every later
   command in that console session was then answered at t=0 - the next plain ping, a later
   `show ip route`, anything - and nothing said so. Measured: `ping 10.9.0.2 2 at 0` followed by a plain
   `ping 10.9.0.2 2` answered "Success rate is 0 percent" with the path still converging at t=0, forever.

2. The convergence line printed `at t=<what you typed>`, so that same plain ping said
   `% Still converging at t=null ms` - the number was taken from the command instead of the answer.

3. The browser's Simulate dialog drew `Success rate 0% (0/4)` for a path that was still settling. That is
   the lie the API stopped telling in #1377 and #1381, one surface further out.

What changed:

- `Simulator.ping()` now returns `runAtMs` - the instant the answer belongs to, `null` when it belongs to
  no particular instant. `Infinity` means a settled lab and can never be converging.
- One sentence, written once: `pingConvergenceSentence(replies)` in engine/simulator.js -
  `Still converging: <process> on <device> (ready at <ms>)`. The console prints it once per ping,
  however many echoes were held up, with the answer's own instant. The browser mirrors it, and
  test/ping-convergence.test.js checks the two produce the same string for every shape of answer.
- The console restores `runAtMs` in a `finally`, so `at` applies to the command that said it and the
  session is left as it was found.
- The dialog's rendering is now a pure function, `pingResultHtml(answer, dst, askedCount)`, so the awkward
  cases can be checked without driving a form: a converging answer gets a sentence and no percentage, a
  timeout still reads as loss, a good path reads 100%, an unresolvable name is not 0% loss, and a
  half-converging path shows both the rate and the reason.

Evidence: test/ping-convergence.test.js, 33 checks. Reverting engine/cli.js fails 3 of 33 and the failure
printout shows the old behaviour verbatim (`% Still converging at t=null ms: ...` twice, then
`Success rate is 0 percent` for the next plain ping). Reverting web/app.js fails on the missing rule;
reverting engine/simulator.js fails on the missing instant.

test/convergence-timing.test.js moves with the sentence it pins: it now checks the process name, when the
path will be ready, and which instant the answer belongs to. docs/CLI.md and docs/CONVERGENCE.md quote the
new line and state that `at <ms>` applies to one command.

Suite: 195 suites, 7,501 assertions, 0 failed. Syntax: 263 files, OK.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-10 21:00:29 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1384
No description provided.