Network Jam — Web Fundamentals

Set TCP's cwnd at the village bridge: 20 levels of slow start, AIMD, RTT and RTO, the bandwidth-delay product and bufferbloat.

What you learn in this game

TCP doesn't wait for each packet's receipt (ACK) before sending the next. It may have cwnd packets on the road at once: the congestion window. Each packet makes one round trip per RTT, so receipts per second ≈ cwnd × (1 second ÷ RTT), until the path is full. A small cwnd leaves the bridge empty and the bus waiting; a cwnd far beyond the bridge gets bikes turned back at the gate.

BDP (Bandwidth-Delay Product) = rate × RTT: how many packets are on the road when the path is used at that rate. A bridge that lets 200 bikes a second across with an RTT of 50 ms is full with 200 × 0.05 = 10 bikes. The 11th bike and the ones after it add no speed: they queue at the gate.

Slow start is used while the sender doesn't know the path's capacity. cwnd starts small and grows by 1 per ACK, so it doubles every RTT: 2, 4, 8, 16. Once cwnd reaches ssthresh, it grows by only 1 per RTT (congestion avoidance). If the path fills first and a packet is lost, cwnd is cut in half.

Loss: a packet that doesn't arrive. The sender doesn't see it fall; it only finds out once the RTO (how long it waits for a receipt) runs out, and then sends a copy (a retransmit). Loss rate = copies ÷ (receipts + copies).

AIMD = Additive Increase, Multiplicative Decrease. With no lost packets, cwnd grows by 1 every RTT. When a packet is lost, cwnd is cut in half, once for one window. On a jammed path that's right: fewer packets, and the queue clears. But AIMD can't tell a packet lost to a jam from one lost to a faulty path.

A buffer is where packets wait in front of the narrowest part of the path (here: the bridge's gate). Packets above the BDP don't get more packets across; they queue. When the buffer is full, the next packet is dropped, and the sender only finds out after the RTO.

What the levels ask

  1. One bike makes the round trip in 100 ms (the RTT), so each bike brings back 10 receipts a second. The bridge lets 100 bikes a second across and its gate's queue holds 5: a bike that arrives when the queue is full is turned back.
  2. The RTT is still 100 ms, the bridge lets 400 bikes a second across, and the gate's queue holds 10. The first round trip brings no receipts yet: work out how many bikes must be on the road at once.
  3. A long RTT is no reason to send little: each bike brings back only 2 receipts a second. The bridge lets 160 bikes a second across, and the gate's queue holds 20.
  4. Start from 1 bike. Bikes beyond what the bridge can take across only queue at the gate, and the gate's queue holds 8: the next bike is turned back.
  5. With the slow start rule, every receipt that comes back sends one more bike out: the convoy doubles every round trip until ssthresh, or until a parcel is lost. The bridge lets 400 bikes a second across, and the gate's queue holds 15.
  6. The convoy only doubles up to ssthresh; after that it grows by one bike per round trip. On this bridge ssthresh = 4 × the starting cwnd, at least 16. The bridge lets 800 bikes a second across, and the gate's queue holds 20.
  7. Time is short: the convoy must get big as fast as it can. Slow start from 2 bikes stops doubling at 16. The bridge lets 600 bikes a second across, and the gate's queue holds 15.
  8. A parcel that falls is never signed for. Mbak Wulan waits 500 ms (the RTO) before sending its copy, and meanwhile its bike waits at the gate, still counted in the convoy. The bridge lets 200 bikes a second across, and the gate's queue holds 10.
  9. Run it and watch the cwnd line on the chart. Do the parcels fall because the bridge is too busy? The bridge lets 300 bikes a second across, and the gate's queue holds 10.
  10. Compare AIMD with a fixed convoy. Watch how many bikes are still on the road after each cut. The bridge lets 200 bikes a second across, and the gate's queue holds 10.
  11. Run it, then follow ssthresh on the board: three parcels lost from one window cut the convoy once, and after that it climbs by one bike per round trip. The bridge lets 200 bikes a second across, and the gate's queue holds 10.
  12. The bridge lets 100 bikes a second across and the round trip is 100 ms. A bike that arrives when the queue is full is turned back, and its parcel is only sent again after the 300 ms RTO.

And more, 20 levels in all.