link down says the cable was pulled at t=0, whatever instant the session is standing at #1385

Closed
opened 2026-11-10 21:11:43 +00:00 by jaylouisw · 0 comments
Owner

Simulator.setLinkState() reads Number(o.atMs) || 0, so a cable change with no instant named is stamped t=0,
always. Typed into a console standing at t=60000:

R1#link down l1
Link l1 (...) is now down.
Network converges again at 30000 ms.        <- half a minute before the moment it was asked about

The same board, asked the same question through the API with atMs: 60000, answers 90000. The two doors
disagree and one of them is nonsense.

markTopologyChange() — two methods up, written for exactly this reason in #1331 — already has the right rule: the
operator's instant, else 0.

Three defects in one call:

  1. The default instant is 0 instead of the instant of the question.
  2. atMs: "abc" is coerced to 0 (Number(...) || 0), so a mistyped instant moves the cable and stamps it at
    zero, silently. The server does the same coercion before the engine ever sees the value, and maps every failure
    to 404 no such link.
  3. link state tests l.stateSinceMs for truth, so a cable pulled at t=0 — the first change in a run's life —
    prints its state with no instant at all, while every later change prints one.

What must be true instead

  • an instant that is named is used; one that is not named is the instant of the question; a settled board (no
    instant) starts at 0 — the rule markTopologyChange() already applies;
  • an atMs that is not a time at or after 0 is refused as E_BAD_INSTANT by the engine and answered 400 by the
    API, with the cable untouched;
  • link state prints changed at 0 ms (N ms ago) when that is the truth.
`Simulator.setLinkState()` reads `Number(o.atMs) || 0`, so a cable change with no instant named is stamped **t=0**, always. Typed into a console standing at t=60000: ``` R1#link down l1 Link l1 (...) is now down. Network converges again at 30000 ms. <- half a minute before the moment it was asked about ``` The same board, asked the same question through the API with `atMs: 60000`, answers **90000**. The two doors disagree and one of them is nonsense. `markTopologyChange()` — two methods up, written for exactly this reason in #1331 — already has the right rule: the operator's instant, else 0. Three defects in one call: 1. The default instant is 0 instead of the instant of the question. 2. `atMs: "abc"` is coerced to 0 (`Number(...) || 0`), so a mistyped instant **moves the cable** and stamps it at zero, silently. The server does the same coercion before the engine ever sees the value, and maps every failure to `404 no such link`. 3. `link state` tests `l.stateSinceMs` for truth, so a cable pulled at t=0 — the first change in a run's life — prints its state with **no instant at all**, while every later change prints one. ## What must be true instead * an instant that is named is used; one that is not named is the instant of the question; a settled board (no instant) starts at 0 — the rule `markTopologyChange()` already applies; * an `atMs` that is not a time at or after 0 is refused as `E_BAD_INSTANT` by the engine and answered `400` by the API, with the cable untouched; * `link state` prints `changed at 0 ms (N ms ago)` when that is the truth.
Sign in to join this conversation.
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#1385
No description provided.