All lessons · Guided routes

Simulator · Networking

Subnets and packet loss

A depot scanner sends scan events to Quillfern's tracking API over the depot subnet and an uplink. Change the subnet, the destination, the round-trip time, and the loss on the link.

At Quillfern Parcels. This is the system from chapter 2 of the Quillfern story, "Depots come online": Three depots get barcode scanners on their own subnets, connected to the office over the internet. Scans go missing when a firewall rule is wrong, and arrive late when an uplink drops packets.

What the model simplifies

The subnet maths is exact (a cloud subnet keeps 5 addresses, as AWS and Azure do). The transfer is 20 segments sent one at a time (stop and wait): a lost segment is resent after a timeout that doubles on each loss of the same segment. Real TCP keeps many segments in flight and recovers faster with fast retransmit, so it is quicker, but loss hurts it in the same way. Every number on this page comes from one shared set of calculations, which the simulation questions use too, so a question can never disagree with what the simulator shows.

The drills, written out

A damaged uplink drops packets
  1. Healthy state. Each batch of scans is 20 segments over a 40 ms round trip, delivered in 860 ms with no resends.
  2. Trigger. Rain gets into a connector on the depot uplink, and it starts losing about 15% of packets.
  3. What is affected. Every scanner in the depot, and the tracking page that customers read, because scans arrive late.
  4. Symptoms. Scanners show "sending" for seconds, the queue of unsent scans grows, and parcel tracking lags behind the real parcels. Nothing is fully down, which makes it slow to notice.
  5. Metrics. The same 20 segments now take 1.5 s with 3 retransmissions: 1.7 times slower. Each loss waits for a timeout, and the timeout doubles when the same segment is lost again.
    ping -c 100 tracking-api: 15% packet loss
    ss -ti: retrans:3 rto:200
  6. Logs. The transfer log shows segments lost and resent after growing timeouts.
    +0 ms  SYN, SYN-ACK, ACK: connection open after 1.5 round trips
    +60 ms  segment 1 delivered and acknowledged
    +100 ms  segment 2 lost; resent after 200 ms
    +300 ms  segment 2 delivered and acknowledged (try 2)
    +340 ms  segment 3 lost; resent after 200 ms
    +540 ms  segment 3 delivered and acknowledged (try 2)
    +580 ms  segment 4 delivered and acknowledged
    +620 ms  segment 5 delivered and acknowledged
    +660 ms  segment 6 delivered and acknowledged
    +700 ms  segment 7 delivered and acknowledged
    +740 ms  segment 8 delivered and acknowledged
    +780 ms  segment 9 delivered and acknowledged
  7. Reasoning. Latency alone would add a few milliseconds. Loss is worse: the sender stops and waits for a timeout each time. So a small loss rate makes a big delay, and the problem is the link, not the API.
  8. Mitigation. Move the depot to its backup uplink. The round trip is longer, 55 ms, but nothing is lost: the batch takes 1.2 s.
  9. Recovery. The scanners send their backlog, tracking catches up, and the damaged connector is replaced before traffic moves back.
  10. Prevention. Alert on packet loss and retransmission rate per link, not only on up or down, and keep a second uplink at every depot.
The API moves outside the allowed subnet
  1. Healthy state. The firewall allows the depot subnet 10.20.1.0/26, addresses 10.20.1.0 to 10.20.1.63, and the tracking API is at 10.20.1.40, inside it.
  2. Trigger. The API is redeployed and gets the address 10.20.1.70.
  3. What is affected. Every scanner that sends to the API through the depot firewall.
  4. Symptoms. Scans time out with no error from the API, because the firewall drops the packets silently.
  5. Metrics. The API's request rate from depots drops to zero; its error rate does not rise, because the requests never arrive.
  6. Logs. The firewall log shows the drops.
    DROP src=10.20.1.12 dst=10.20.1.70 proto=TCP dport=443 rule=depot-to-api
  7. Reasoning. A /26 has 64 addresses, so 10.20.1.0/26 ends at 10.20.1.63. The address 10.20.1.70 is in the next block, so the rule written for the /26 does not match it.
  8. Mitigation. Widen the rule to 10.20.1.0/25, which runs to 10.20.1.127, or give the API an address back inside the /26.
  9. Recovery. With the /25 rule 123 addresses are usable and the API at 10.20.1.70 is covered: scans flow again.
  10. Prevention. Give services fixed addresses or names, write firewall rules for named groups instead of raw ranges, and check every rule change with a test that sends a real request.

Learn it properly

All simulators · Curriculum map