Let's consider a similar scenario but with proper support for SACK (Selective Acknowledgment), which allows the receiver to indicate exactly which segments have been received out of order. Here's a more concise example where tcp_reordering set to 4 interacts with network conditions to ultimately lead to the retransmission of two packets:
-
Sender transmits segments: The sender emits segments in order: Seg1, Seg2, Seg3, Seg4, Seg5, Seg6, ...
-
Network reorders packets: The segments are received by the receiver in the following order due to network-induced reordering: Seg1, Seg4, Seg2, Seg5, Seg3, Seg7, Seg6, Seg8, ...
-
Receiver acknowledges Seg1: The receiver sends an ACK for Seg1, the only segment received in order so far.
-
Receiver sends SACK for out-of-order segments: Upon receiving Seg4, the receiver sends a duplicate ACK for Seg1 but includes a SACK for Seg4 to inform the sender that Seg4 has been received.
-
More SACKs for subsequent segments: With the arrival of Seg2, Seg5, and Seg3, the receiver continues to send duplicate ACKs for Seg1 but updates the SACKs to include these segments.
-
Exceeding tcp_reordering: Seg7 is received, and it's the fourth out-of-order segment, which is currently the limit set by the tcp_reordering parameter. The receiver sends another duplicate ACK for Seg1 with SACKs for Seg2, Seg3, Seg4, Seg5, and now Seg7.
-
Retransmission based on SACK due to further reorder: When Seg6 arrives (which has been delayed and now an additional packet beyond the reordering limit), the SACK option communicated to the sender includes Seg2, Seg3, Seg4, Seg5, Seg6, and Seg7. Seg8's arrival further indicates potential segment loss, but the sender uses the SACK information to deduce that only Seg1 has been cumulatively acknowledged and now Seg8 is expected next.
-
Retransmission decision: As per TCP's logic, the sender is still waiting for an ACK for Seg6. However, based on SACK options received earlier, it knows Seg7 and Seg8 have been received after it. Given that tcp_reordering is set to 4, it will now consider Seg6 as potentially lost due to reordering.
-
First retransmission: The sender retransmits Seg6, which is then properly acknowledged by the receiver.
-
Discovery of another missing segment: Suppose next that Seg10 is missing, and the receiver has continued to receive packets, including Seg11. The receiver would then notify the sender through the SACK that Seg11 has been received while Seg10 is missing.
-
Second retransmission: Once the sender realizes that Seg10 has been skipped (after waiting for a potential reordering window), it retransmits Seg10.