Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Fundamentals 12 min read

Visualizing TCP Retransmission: MSS, Fast Retransmit, and SACK Explained

This article explains TCP retransmission mechanisms with visual examples, covering MSS calculation (1460 bytes), sequence number wraparound solved by timestamps, fast retransmit triggered by three duplicate ACKs, and SACK for selective acknowledgment of non-contiguous data segments.

Due to IP and MAC layer packet size limits, TCP must split large data into segments before handing them to IP. The article illustrates how an 18-byte HTTP payload is segmented, encapsulated with TCP and IP headers, and transmitted.

Maximum Segment Size (MSS)

MSS defines the maximum payload length per TCP segment, excluding headers. To avoid IP fragmentation, MSS is derived from Ethernet MTU (1500 bytes) minus IP header (20 bytes) and TCP header (20 bytes): MSS = 1500 - 20 - 20 = 1460 bytes.

MSS is negotiated during the TCP three-way handshake via the TCP options field. The client advertises its SMSS (Sender MSS) in the SYN packet (e.g., 1460), and the server replies with its RMSS (Receiver MSS) in the SYN-ACK (e.g., 1400). The effective MSS is the smaller of the two.

Basic Retransmission with Timers

TCP ensures reliability through ACKs and retransmission. The sender starts a timer after transmitting a segment. If the timer expires before receiving an ACK, the segment is retransmitted. This stop-and-wait approach is simple but inefficient because the sender must wait for each ACK before sending the next segment.

Pipelining with Sequence Numbers

To improve throughput, TCP assigns a sequence number to each byte, enabling multiple in-flight segments. Each segment carries its own sequence number and timer. If segment #3 is lost, only #3 is retransmitted, not the entire sequence.

Example: A segment of 647 bytes is sent after 1461 bytes have already been transmitted. The next sequence number becomes 2108 (1461 + 647). Sequence numbers are 32-bit unsigned integers (0 to 2³²-1) and wrap around.

Sequence Number Wraparound and Timestamps

Wraparound creates ambiguity: after the sequence space cycles, a retransmitted old segment (e.g., #2) may have the same sequence number as a new segment. The receiver cannot distinguish them.

TCP solves this with the Timestamp option. Each segment carries a timestamp. The receiver compares the incoming timestamp (B) with the last valid timestamp (E). If B ≤ E, the segment is a retransmission of old data; if B > E, it is new data. This allows correct handling even when sequence numbers repeat.

Fast Retransmit

Fast Retransmit avoids waiting for the retransmission timer. Rules:

Receiver rule: Always ACK the next expected sequence number. If segments 3, 4, 5 arrive but 2 is missing, the receiver repeatedly sends ACK 2 for each subsequent segment.

Sender rule: Upon receiving three duplicate ACKs (e.g., three ACK 3s), the sender infers segment 3 is lost and retransmits it immediately.

Illustration: Segments 1-2 arrive; segment 3 is lost. Segments 4, 5, 6 arrive, each triggering a duplicate ACK 3. After the third duplicate ACK, the sender retransmits segment 3. The receiver then sends ACK 7, acknowledging all data up to segment 6.

Limitation: Fast retransmit does not confirm whether segments 5 and 6 were received. If they were also lost, the sender must still wait for their timers to expire.

Selective Acknowledgment (SACK)

SACK, implemented via TCP options, lets the receiver explicitly report non-contiguous blocks of data that have been received. For example, a SACK block 2872-3393 tells the sender that bytes 2872 through 3393 arrived successfully, even though earlier bytes are missing. The sender can then retransmit only the truly missing ranges, avoiding unnecessary retransmissions and reducing recovery latency.

Summary

MSS caps TCP segment payload size; negotiated during handshake.

Timer-based retransmission guarantees reliability but limits throughput.

Sequence numbers enable pipelining; 32-bit space wraps around.

Timestamps resolve wraparound ambiguity by marking segment generation.

Fast retransmit triggers on three duplicate ACKs, cutting recovery time.

SACK informs the sender of exactly which non-contiguous blocks arrived, enabling precise retransmission.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

TCPtimestampnetwork protocolsMSSsequence numberretransmissionSACKfast retransmit

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion