Master the fundamental concepts of tcp/ip from scratch through this focused micro-challenge.
TCP guarantees delivery over unreliable networks by retransmitting missing segments. Two detection paths exist: timer expiry (RTO) and three duplicate ACKs (fast retransmit).
RFC 6298 defines:
RTO = SRTT + 4 * RTTVARKarn's algorithm skips RTT samples from retransmitted segments and doubles RTO on each timeout (capped around 64 seconds on Linux).
Sender transmits SEQ 1000, 1100, 1200 (each 100 bytes). Segment 1100 is lost. Receiver gets 1000 and 1200, so it sends ACK=1100 repeatedly. After the third duplicate ACK, the sender retransmits SEQ 1100 immediately without waiting for the timer.
Exponential backoff doubles RTO on each consecutive timeout (1s, 2s, 4s, up to roughly 64s on Linux) until the missing segment is acknowledged. Retransmitted segments reuse the same sequence number so the receiver knows which data is being replayed.
This task requires you to simulate retransmission on packet loss. Fast retransmit on three duplicate ACKs is what keeps a video call or SSH session usable during transient loss instead of stalling for a full timeout. RFC 6298's RTO formula and Karn's algorithm for skipping RTT samples from retransmitted segments are implemented nearly verbatim in the Linux kernel's tcp_rtt_estimator().
Implement a simulation of TCP retransmission on packet loss.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github