Show a good concise example when tcp_reordering is set to 4 and it play a role independent of fast retransmit so doe to trigger of tcp_reordering two packets are retransmitted together.
Assistant
The tcp_reordering variable in the Linux kernel's TCP implementation defines the number of duplicate acknowledgments (ACKs) needed to trigger a fast retransmit without waiting for the standard number of duplicate ACKs which is three. When tcp_reordering is set to a value lower than the default, the TCP stack assumes that the network is experiencing more reordering, and it will wait longer before deciding that a packet has been lost and needs to be retransmitted.
User
Is it correct?
Assistant
My previous explanation was not entirely accurate with respect to the role of tcp_reordering. Let me clarify:
The tcp_reordering is a Linux-specific TCP variable that defines how many packets beyond the current 'not yet acknowledged' packet can be received before the network is considered to be reordering packets. It does not directly correspond to duplicate ACKs but rather to out-of-order packet delivery.
User
In a case of trigger of tcp_reordering, can it lead to multiple packet retransmit if tcp_reordering is high?
Assistant
Let's first clarify what reordering does in the context of TCP. The tcp_reordering variable in Linux's TCP stack does not trigger retransmissions directly. Instead, it adjusts the TCP stack's tolerance for how out-of-order packets can be before the stack assumes there is a packet loss and decides to retransmit.
User
If a sender sends packets from 1 to 10 and receiver received them but sender got SCKs in sequence 124689 and tcp_reordering is set to 4, what packets will be retransmit in the case?
Assistant
User
If a sender sends packets from 1 to 9 and receiver received them but sender got SCKs in sequence 13579 and tcp_reordering is set to 4, what packets will be retransmit in the case?
Assistant
User
If a sender sends packets from 1 to 9 and receiver received them but sender got SCKs in sequence 13579 without retransmission expired, tcp_reordering is set to 4, what packets will be retransmit in the case?
Assistant
User
Does tcp_reordering can trigger retransmission of a single packet only?
Assistant
No, the setting itself does not trigger retransmissions directly. Instead, it influences the behavior of the TCP stack in terms of how it interprets packet loss in the presence of packet reordering within the network.
User
If a sender sends packets from 1 to 9 and receiver received 13579 packets then the sender got SCKs in sequence 13579 without retransmission expired, tcp_reordering is set to 4, what packets will be retransmit in the case?
Assistant
User
If a sender sends packets from 1 to 9 and receiver received 135796 packets then the sender got SCKs in sequence 135769 without retransmission expired, tcp_reordering is set to 4, what packets will be retransmit in the case? Answer shortly
Assistant
Given that tcp_reordering is set to 4, and the sender has SACKs for packets 1, 3, 5, 7, 6, and 9 without any retransmission timeout expiring, the sender will likely retransmit packets 2, 4, and 8. These are the packets missing from the sequence based on the received SACKs, and their absence is confirmed by receiving a SACK for a packet (packet 9) that exceeds the reordering window. Packet 6 being out of order but acknowledged does not change the packets that need to be retransmitted.
User
If a sender received 3 duplicated SCKs for 10 packets, will they all be retransmitted due to fast retransmit mechanism? Answer shortly
Assistant
No, upon receiving 3 duplicate SACKs for the same data, typically only the packet immediately following the last packet that was acknowledged would be retransmitted due to the fast retransmit mechanism—not all 10 packets.
User
Why? They all received 3 ACK duplicated.
Assistant
I apologize for the confusion. It seems there might be a misunderstanding related to SACKs (Selective Acknowledgments) and standard duplicate ACKs.
If the sender receives three duplicate standard ACKs for a single packet, it implies that the receiver has received a packet that follows a gap in the sequence (it has received at least three packets beyond the gap since TCP typically generates an ACK for the highest in-order packet received). The fast retransmit mechanism would then be triggered, resulting in retransmission of what appears to be the missing packet – the earliest packet after the last acknowledged one.
However, if the sender receives three duplicate SACKs, this indicates the receipt of out-of-order packets but does not necessarily trigger a fast retransmit since SACKs provide more precise information about which specific packets have arrived at the receiver.
User
If a sender received 3 duplicated SCKs for 10 packets that are gaps, will they all be retransmitted due to fast retransmit mechanism? Answer shortly
Assistant
If the sender receives 3 duplicate SACKs indicating gaps for all 10 packets, then the fast retransmit mechanism would likely be triggered for each gap, resulting in the retransmission of all the packets for which gaps were reported. However, the specific behavior may depend on the exact TCP implementation and the details provided in each SACK.
User
What's tcp_frto?
Assistant
tcp_frto (Forward RTO-Recovery) is a TCP extension designed to mitigate the problem of spurious retransmissions due to overestimation of packet loss on wireless and satellite networks where reordering, high delay variation, and sudden temporary disconnections are common.
Traditional TCP uses the retransmission timeout (RTO) to detect lost packets. If an acknowledgment (ACK) is not received within the RTO interval after a packet is sent, the packet is assumed to be lost and is retransmitted. However, in networks with high variability in delay, this can lead to premature and unnecessary retransmissions, as delayed packets might still be en route.
In the scenario where tcp_reordering is set to 4, it means the system will be more tolerant to out-of-order packet delivery before triggering retransmission. Here's a conceptual illustration of how it plays a role independently of fast retransmit:
A sender sends packets 1, 2, 3, 4, 5, and 6 to the receiver.
The packets are sent through the network, and due to conditions like load-balancing or temporary route changes, packet 4 arrives after packet 5.
The receiver acknowledges packet 3 (the last in-order packet it received) and starts sending duplicate ACKs for packet 3 when it receives packet 5, and continues to do so for each out-of-order packet (normally an indication of packet loss).
Normally, with the standard tcp_reordering value (which is 3), upon receiving the third duplicate ACK, the sender would perform a fast retransmit of packet 4 as it assumes it is lost.
However, because tcp_reordering is set to 4, the sender waits for one more duplicate ACK before triggering a retransmission.
In the meantime, packet 4 finally arrives at the receiver before the additional duplicate ACK is sent.
The receiver can now acknowledge packets up to packet 6 all at once, without the sender having performed any unnecessary retransmissions.
By setting tcp_reordering to 4, the example demonstrates a case where slightly higher tolerance to packet reordering prevents unnecessary retransmissions that might have occurred with the standard settings. It's important to note that while this setting can help in networks with a high amount of reordering, it can also increase the latency in detecting actual packet loss, potentially reducing the performance of TCP connections if set improperly.
When TCP receives packets out of order, it will send an ACK for the last in-sequence packet received. This is not necessarily an indication of packet loss; it could be due to the network reordering packets.
When tcp_reordering is set to 4, it means the TCP stack can tolerate up to 4 packets being out of order before considering that a packet is lost and retransmissions should be considered.
Let's do a thought experiment with tcp_reordering set to 4 to show how TCP might behave:
The sender transmits packets 1, 2, 3, 4, 5, and 6 to the receiver.
The packets may take different paths and packets 1, 2, and 5 arrive at the receiver first.
Now the receiver will act with packet acknowledgments like this:
It sends an ACK for packet 2 because packets 1 and 2 have arrived.
The receiver then gets packet 5 out of order and will send another ACK for packet 2 since it has not yet received packet 3. This is a duplicate ACK.
Packets 3 and 4 are delayed, and the receiver gets packets 6 next.
The receiver sends another duplicate ACK for packet 2.
Assuming tcp_reordering is set to 4, the sender is still waiting because it has not hit the threshold where it decides the network is too out of order and the packet is considered lost.
Finally, packets 3 and 4 arrive, and the receiver acknowledges packet 6, since all previous packets have now been received in sequence.
With tcp_reordering set higher like this, we see it helps the network to tolerate misordering up to a certain extent. If packet loss were inferred too early, unnecessary retransmissions would occur whenever there's a slight reordering, even when the network might deliver the packets correctly if given a chance. The limitation, however, is that any actual packet loss would be detected later than with a lower tcp_reordering value, which could decrease the overall performance if packet loss is usual in the network and not reordering.
When tcp_reordering is set to a higher value, it means the network stack will tolerate more out-of-order packets—it will wait for more out-of-order packets before deciding that a packet has been lost and needs to be retransmitted.
Here's an example scenario where a high tcp_reordering value might lead to multiple packet retransmissions:
Sender sends packets: 1, 2, 3, 4, 5, 6, 7, 8
Receiver gets them out of order, receiving: 1, 2, 5, 6, 3, 8, 7 (packet 4 is delayed or lost)
Receiver sends an ACK for packet 2, continuously, since it has not received packet 3 yet.
The sender sees multiple duplicate ACKs for packet 2 but does not yet retransmit because the tcp_reordering threshold has not been reached.
Finally, packet 3 arrives and is acknowledged by the receiver. But packets 4, 7, and 8 are still outstanding.
If packet 4 remains missing, the sender may eventually retransmit it if the retransmission timeout (RTO) expires or if an acknowledgment for a packet higher than the tcp_reordering threshold is received, which clearly indicates packet 4 is lost.
If tcp_reordering is set too high and multiple packets are lost (not just reordered), the TCP stack might be slow to identify that a loss occurred. This will delay the retransmission of lost packets, which could adversely affect the connection’s throughput, as it waits longer than necessary for retransmissions due to the high reordering threshold. In an extreme case, if the threshold is higher than the number of out-of-sequence packets in the network, loss may only be detected by the RTO.
The fast retransmit mechanism, typically triggered by receiving several duplicate ACKs, is affected by how tcp_reordering is set, in that it alters when the TCP stack considers that a fast retransmit is necessary. However, tcp_reordering and fast retransmit are not directly connected; instead, the stack uses tcp_reordering to determine how conservative or aggressive it should be regarding retransmissions when out-of-order packets are received.
Let's clarify the scenario and the behavior of the TCP stack when tcp_reordering is set to 4. In your example, we have a sender transmitting packets numbered 1 through 10. The receiver gets all of them, but the sender only receives selective acknowledgments (SACKs) indicating in-sequence delivery for packets 1, 2, 4, 6, 8, and 9. Given that tcp_reordering is set to 4, let's see what would happen:
The sender transmits packets 1-10 successfully.
The receiver receives all the packets successfully.
The receiver sends SACKs which inform the sender that packets 1, 2, 4, 6, 8, and 9 have been received in good order. However, we are missing information about packets 3, 5, 7, and 10 in the SACK messages.
Based on the Linux TCP stack behavior and assuming Selective Acknowledgment (SACK) is enabled:
When the sender receives a SACK for packet 4 but not for packet 3, it assumes packet 3 has been lost (unless it's covered by a later SACK).
If the sender receives a SACK for packets 6, 8, and 9, but hasn't received SACK information for 3, 5, and 7 yet, it still assumes these packets may just be out of order, not lost, because tcp_reordering is set to 4, which allows for more out-of-order packets.
In this example, without knowing further details about when the SACKs for 1, 2, 4, 6, 8, and 9 were received and what happened to packets 3, 5, 7, and 10, it's difficult to say exactly which packets will be retransmitted. But let me explain how the thought process would generally work:
If no further SACKs or duplicate ACKs are received for a while, the sender will likely trigger a timeout retransmission, starting with the lowest numbered packet assumed to be lost, which in this case would be packet 3.
If the sender then receives a SACK for packet 10 before the timeout for packet 3 occurs, and still there are no SACKs or ACKs for packets 3, 5, and 7, it would conclude that these packets are indeed lost (despite tcp_reordering being set to 4), because their loss can no longer be attributed to simple reordering.
It would then retransmit packets 3, 5, and 7 upon timeout or potentially upon receiving a SACK for packet 10, as their loss is confirmed by the receipt of the SACK for a packet beyond the reordering window.
So, in the case where the sender never receives any acknowledgment for packets 3, 5, 7, and 10 (no duplicate ACKs, no SACKs), it would eventually retransmit these packets once the retransmission timer for each expired.
It's important to note that if the sender receives a cumulative ACK that acknowledges the reception of all the previous packets or SACKs covering the missing ranges, then it may not need to retransmit anything as long as it knows the receiver got all the packets.
Furthermore, the sender may adjust its retransmission strategy based on the pattern of SACKs or ACKs received, which help determine whether a packet might have been lost or merely reordered. The tcp_reordering setting principally prevents the sender from hastily retransmitting on the receipt of out-of-order packets and hence, affects the sender's response to the situation rather than causing the retransmissions directly.
In the scenario you've described, the sender transmits packets 1 to 9, the receiver successfully receives all of them, but the sender gets selective acknowledgments (SACKs) for packets 1, 3, 5, 7, and 9 in sequence. Given that tcp_reordering is set to 4, let's examine the likely behavior of the sender.
The SACK mechanism in TCP allows a receiver to report to the sender which packets have been received successfully, even if they're out of order. The sender uses this information to retransmit only the packets that have been lost or are assumed to be lost.
In your scenario, the SACKs for packets 1, 3, 5, 7, and 9 are acknowledging the reception of the odd-numbered packets, but there are no SACKs for the even-numbered packets 2, 4, 6, and 8.
Here's how the sender would handle this situation:
When the sender receives the first SACK for packet 1, it knows that packet 1 has been received correctly.
Upon receiving the SACK for packet 3 without prior acknowledgment for packet 2, it might suspect that packet 2 is lost. However, because tcp_reordering is set to 4, it won't immediately retransmit packet 2. Instead, it will wait for additional SACKs to determine whether packet 2 is merely delayed (reordered) rather than lost.
As subsequent SACKs for packets 5, 7, and 9 are received, the absence of SACKs (or cumulative ACKs) for packets 2, 4, 6, and 8 will lead the sender to presume packet loss, given that packets beyond those potentially missing ones have been acknowledged and the reordering threshold (4 packets) has been surpassed.
The decision to retransmit packets 2, 4, 6, and 8 will depend on multiple factors, including how the TCP stack is implemented. Here are two possible triggers for retransmission in this scenario:
Retransmission Timer: If the retransmission timer expires for packet 2 (the smallest unacknowledged packet), the sender will retransmit it. Subsequent timers for packets 4, 6, and 8 may also expire, leading to their retransmission. This assumes that no further SACKs or cumulative ACKs are received to update the sender on the status of these packets.
Selective Acknowledgements: If additional SACKs are received that fail to acknowledge packets 2, 4, 6, and 8 but indicate that packets larger than 8 have been received, then the sender may proactively retransmit packets 2, 4, 6, and 8 even before their retransmission timers expire.
In practice, the sender may not retransmit all missing packets at once but instead might use an algorithm to determine the order and timing of retransmissions. If this situation occurred, the common TCP behavior would be to retransmit packet 2 first (after the retransmission timer for it expires or based on SACK information), and then, depending on subsequent acknowledgments, potentially retransmit packets 4, 6, and 8 when their respective timers expire or are deemed lost based on further SACKs.
With the tcp_reordering variable set to 4, the sender's TCP stack will allow some out-of-order packets without immediately triggering a retransmission, believing that the network might reorder packets within that threshold. However, selective acknowledgments (SACKs) change the dynamics somewhat by providing explicit feedback on which packets have been received.
Given the scenario where packets 1 to 9 are sent and the receiver has successfully received all of them but the sender only receives SACKs for packets 1, 3, 5, 7, and 9, here is what we would expect:
The sender sends packets 1 through 9.
The receiver receives all nine packets successfully.
For some reason, even-numbered packets' acknowledgments (ACKs) are not getting back to the sender, although the receiver has received them.
Now that the sender has received SACKs for 1, 3, 5, 7, 9 and tcp_reordering is 4, the following process is likely to take place:
Initial SACK Processing: As the sender receives the SACK for 1, it knows packet 1 has been received. It then gets a SACK for packet 3, but because the tcp_reordering value allows assuming reordering within 4 packets, and this is only one gap, it doesn't yet retransmit packet 2.
Continued SACK Processing: As SACKs for 5, 7, and 9 arrive, the sender is still not triggered to retransmit packets 2, 4, 6, and 8, because the gaps are within the reordering threshold. With tcp_reordering set to 4, the sender is waiting for more information before determining that packets are lost.
However, this situation is highly unusual because for the SACK mechanism to work and no retransmission timeouts to occur, there must be a continuous forward movement of the send window by way of additional acknowledgments or SACKs indicating receipt of new data.
If no further SACKs arrive AND if retransmission timers don't expire (which is what you've specified), the sender initially does not retransmit any packets. In reality, retransmission timers for unacknowledged packets would eventually expire, triggering the retransmission of missing packets starting from the lowest unacknowledged one, unless further SACKs are received.
Retransmission upon Further SACKs: In a more probable real-world scenario, as soon as the receiver sends a SACK for any packet beyond packet 9, or if there's a timeout for the smallest unacknowledged packet (packet 2 in this case), the sender would recognize that packets have been skipped, and it would retransmit starting from packet 2.
Explicit Retransmission Decision: If no additional SACKs are provided beyond packet 9 and no timeouts occur, the packets are considered to be acknowledged because of the SACKs received for the odd-numbered packets. In such a case, there is no retransmission because the sender has indications (though incomplete) that the receiver has received all packets.
In summary, with the provided scenario and conditions, there would not be a retransmission unless there is further information (like additional SACKs for packets beyond packet 9) or unless retransmission timers expire. However, it should be noted that this scenario is highly atypical for a standard TCP flow.
tcp_reordering
The tcp_reordering variable defines the number of packets that can be received out of order before the sender considers that a packet might be lost due to a gap in the sequence numbers. If tcp_reordering is set to a value like 3, it can tolerate three out-of-order packets before assuming that packet loss has occurred.
Here is what typically happens in the context of loss detection and retransmission in TCP:
DupACK Threshold: TCP uses the reception of duplicate ACKs to suggest that a packet has been lost. Without SACK, standard TCP will usually initiate a fast retransmit after receiving three duplicate ACKs, assuming that the network delivers segments in order.
RTO Timer: If the sender does not receive an acknowledgment within a certain period (the retransmission timeout, or RTO), it will retransmit the earliest unacknowledged packet.
tcp_reordering and DupACKs: When tcp_reordering is set higher, the sender waits for more evidence (more out-of-order packets or time passing) before it performs a retransmission. This is more tolerant to reordering, potentially leading to fewer unnecessary retransmissions due to reordering, but at the same time, could delay retransmission of actually lost packets.
In the presence of Selective Acknowledgments (SACKs), retransmissions can be more targeted as the receiver can indicate exactly which packets have been received. This results in the sender retransmitting only the missing packets, which could be single or multiple, depending on the SACK information.
To answer your question precisely: tcp_reordering does not trigger the retransmission of any packets by itself. It influences the decision-making process by specifying how many out-of-order packets the network can handle before considering retransmitting any lost packets.
Once loss is detected, either by too many out-of-order packets (beyond the tcp_reordering threshold) or by an expired retransmission timer, TCP will retransmit packets. Whether a single packet or multiple packets are retransmitted is determined by the state of acknowledgments—traditional TCP without SACK would retransmit a single packet (the one assumed lost), while with SACK, TCP can retransmit one or more packets specifically indicated as missing.
In this case, where the sender emits packets 1 through 9 and the receiver receives packets 1, 3, 5, 7, and 9, acknowledges them using SACKs, and the sender in turn receives these SACKs, the selective acknowledgment mechanism indicates which specific packets have been received out of order, suggesting that packets 2, 4, 6, and 8 are missing at the sender.
The tcp_reordering setting determines how many out-of-order packets the TCP stack is willing to tolerate before it presumes there is packet loss and considers retransmitting. If no retransmission timeout (RTO) has expired, the sender will not immediately retransmit the missing packets because tcp_reordering is set to 4, allowing for the possibility of a degree of reordering.
Usually, the receipt of SACKs for packets numbered higher than an unreceived packet prompts the sender to retransmit the missing packets, as follows:
SACK for Packet 3: Upon receiving the SACK for packet 3 without having received acknowledgment for packet 2, the sender notices packet 2 may be missing, but with tcp_reordering set to 4, it may wait for additional ACKs or SACKs before taking action.
SACKs for Packets 5, 7, and 9: Receiving these further SACKs without any acknowledgment for packets 2, 4, 6, and 8, tells the sender that these packets are missing from the stream. Since packet 9 has been received and acknowledged, it suggests at least 4 intervening packets could be out of order or lost.
Considering that tcp_reordering is set to 4, and given that the sender has received SACKs for packets up to 9, the sender interprets that there may indeed be packet loss because the acknowledgments are beyond the reordering window it is prepared to tolerate. Therefore, under normal operations and assuming the retransmission timer has not yet expired, the sender would retransmit packets 2, 4, 6, and 8 after receiving the SACK for packet 9 because the missing packets exceed the reordering threshold it was prepared to wait for.
However, the exact behavior can depend on the particular details of the TCP implementation and the settings of other related mechanisms, including the retransmission timeout (RTO) behavior and potentially TCP congestion control algorithms.
To summarize, in this scenario, assuming the SACKs are correctly processed and the sender's TCP stack follows common behaviors, packets 2, 4, 6, and 8 would be retransmitted due to being identified as missing from the sequence. This would happen once the TCP stack determines that the number of missing packets exceeds the tcp_reordering threshold and cannot be attributed to simple packet reordering.
If three duplicate SACKs were received and SACK blocks within those did not cover the entirety of the 10 packets, only the packets not yet SACKed, which are presumed lost, would potentially be subject to retransmission based on TCP's recovery mechanisms, not all 10 packets. The receipt of three duplicate SACKs implicates loss but does not provide the immediate impetus for the fast retransmit; instead, it informs the sender which segments need retransmission.
In summary, with SACK-enabled, only the specifically indicated missing packets would be retransmitted, rather than all packets following a duplicate ACK. With standard duplicate ACKs, without SACK, the fast retransmit would typically retransmit a single packet deemed lost just after the last successfully received packet indicated by those ACKs.
The FRTO enhancement helps to distinguish between a reordering of packets and actual packet losses. When an RTO event occurs and triggers a retransmission, FRTO also allows for the possibility that the RTO was caused by a delay spike and not necessarily by a lost packet. FRTO then waits for a short while for new ACKs to arrive before performing further retransmissions. If new ACKs are received that acknowledge new data, the algorithm infers that the original RTO was likely spurious, and it does not reduce the congestion window as drastically as it would after a confirmed packet loss.
Here's how FRTO generally works:
After an RTO expires, the sender retransmits the earliest unacknowledged packet (potentially due to loss) and enters the FRTO state.
If the sender receives a subsequent ACK that acknowledges new data (data sent after the retransmitted packet), it means there was likely no packet loss, and the RTO was spurious.
If the ACK only acknowledges previously transmitted data (not new transmissions), then the sender assumes the RTO was not spurious and proceeds with standard loss recovery by reducing the congestion window.
By avoiding unnecessary reductions of the congestion window and conserving the sender's sending rate, FRTO helps maintain throughput on links with high delay variability. This makes TCP more efficient and suitable for modern and diverse network conditions where traditional RTO-based loss recovery might perform suboptimally.