How TCP makes sure data arrives
TCP numbers the bytes it sends and waits for the receiver to confirm them. The idea to keep: no confirmation in time, so send again.
The short version
Every byte in a TCP connection has a sequence number. The receiver answers with an acknowledgment number, the next byte it expects. The sender keeps data that is not confirmed yet and runs a retransmission timer. If the timer runs out first, it sends the oldest unconfirmed segment again.
Step by step
- The sender numbers its bytes, not its segments. The SYN and FIN flags use up one number each.
- The receiver acknowledges the next byte it expects. Acknowledgments are cumulative.
- A segment that arrives ahead of the expected number is held and processed later.
- The sender keeps unconfirmed data and a timer. An acknowledgment of new data restarts the timer; when everything is acknowledged, it stops.
- If the timer expires, the sender resends the oldest unconfirmed segment and restarts the timer with the timeout doubled.
Why it matters
TCP does not need to know why a segment went unconfirmed: a timer running out is enough to try again. That is my reading of the specs, not a quoted line. Simplified: flow control, congestion control and timer values are left out.
Sources
- RFC 9293: Transmission Control Protocol (TCP) — sequence numbers count bytes (SYN and FIN use one each), the acknowledgment number is the next byte expected, retransmission, segments ahead of sequence held for later
- RFC 6298: Computing TCP's Retransmission Timer — timer restart and stop rules, resending the oldest unacknowledged segment, doubling the timeout