Fast Retransmit/Fast Recovery:
When a TCP connection has been established and TCP segments are being sent/received, the two involved nodes keep track of how much data has been sent through Sequence and Acknowledgment numbers. If the receiver finds an out of order segment has arrived (wrong sequence number from sender) then it will immediately send a duplicate ACK back to the sender. This duplicate ACK occurs to let the sender know about the out of order segment.
The sender will not know immediately whether the duplicate ACK is due to reordering of the segments/stream or if there’s traffic loss happening over the connection. The sender in this scenario will wait until it receives 3 duplicate ACKs back from the receiver to deem there is actual segment loss. Once this happens the sender will set the Slow Start Treshold (ssthresh) to half the current send window, Congestion Window (CWND), and then retransmit the missing segment. When the segment has been retransmitted the sender then sets CWND to the current ssthresh + 3 maximum segment sizes (mss). The addition of 3 mss is to inflate the window to suffice the segments that have already reached the receiver’s buffer. From here on every duplicate ACK received by the sender will add an additional 1 mss to the window. Also the sender will attempt to transmit a new packet if the CWND will allow it.
When the next ACK arrives to the sender that is for actual new data and not duplicate, the sender sets the CWND to the current ssthresh. Per previous notes, if CWND and ssthresh are the same then the TCP connection is in the congestion avoidance phase again. In the Congestion Avoidance phase the CWND is increased by 1 segment only if ALL segments in the window have been acknowledged by the receiver. The Congestion Avoidance phase runs to find out the capacity of the connection.
- 3 Duplicate ACKs are received and Fast Retransmit is Kicked off.
- Set ssthresh to half the current send window and retransmit the missing segment.
- Sender sets Congestion Window to value of ssthresh plus 3 mss for segments already in receiver’s buffer.
- Transmit a new packet if allowed by Congestion Window and add 1 mss per each new duplicated ACK.
- Once ACK for new actual data arrives to sender, set Congestion Window to same value as ssthresh, continue Congestion Avoidance phase.