TCP Congestion Control(RFC 5681)27 Feb 2022
I was going through the specification of TCP Congestion Control cause I studied a few times before and forget details every single time 😅.
This time, I would like to make a note to myself as a reminder.
So here we go:
RFC 5681 highlights four TCP congestion control algorithms:
Slow start / Congestion avoidance
TCP sender takes advantage of the slow start and congestion avoidance algorithms in order to monitor the amount of data sent to the network.
CWND (congestion window) is a parameter on the sender side limit that determines the amount of data the sender can transmit before receiving an ACK.
On the receiver end there is a limit receiver’s advertised window (RWND).
There is a critical threshold defined that control should we use
slow start or
congestion avoidance algorithm
sthresh slow_start << || << congestion_avoidance.
At the beginning of the connection, the
slow start algorithm is utilised. Another case again after repairing loss detected.
MSS (maximum segment size): Size is the largest TCP segment that can be transported in a single IP packet.
The slow start algorithm increases the CWND by one MSS for every acknowledgement received. Basically this doubles the TCP Window size for each round trip of the network.
The slow-start algorithm increases the transmission rate until either:
- a packet loss is detected,
- or the receiver’s advertised window (rwnd) is the limiting factor.
- once we reach ssthresh », we start using TCP congestion avoidance.
In TCP Congestion avoidance: the window is increased linearly by 1 segment for each RTT.
CWND = the size of the RWND once we pass we start losing packages. Once we start losing packages, TCP uses congestion avoidance.
Fast Retransmit and Recovery(FRR)
Without FRR, the TCP uses a timer that requires a retransmission timeout if a packet is lost.
Whenever a TCP receiver received out-of-order segment arrives, then the TCP receiver should send an immediate duplicate ACK. By using duplicated ACK, the TCP sender should use the “fast retransmit algorithm” to detect and repair loss based on incoming duplicate ACKs.
When a sender receives three duplicate acknowledgements, it can be reasonably confident that the segment carrying the data that followed the last in-order byte specified in the acknowledgement was lost. A sender with fast retransmit will then retransmit this packet immediately without waiting for its timeout.