There are several main TCP congestion control: slow start , congestion avoidance , fast retransmission, and fast recovery .
Slow start
To prevent network congestion, TCP uses a slow-start algorithm to control the amount of data sent. In order to adjust the amount of data sent by the sender, the Congestion window is introduced, the Congestion window is set to 1 packets to send the data at slow start, and then every acknowledgment response is received, and the value of the congestion window is added with 1 message segments. When sending a packet, compare the size of the congested window with the window size of the receiving host notification and select a smaller value to control the amount of data sent. The Congestion window is the traffic control used by the sending side, while the advertisement window is the traffic control used by the receiving end.
The slow start algorithm steps are as follows (CWnd full name congestion Window):
- The initialization of CWnd = 1, indicating that a MSS-sized data can be transmitted;
- Whenever a ack,cwnd++ is received, which increases by 1, it rises linearly;
- Whenever a rtt,cwnd = cwnd*2, it is exponential to rise;
- Ssthresh (slow start threshold), is an upper limit, when CWnd >= Ssthresh, it will enter the "Congestion Avoidance algorithm" (the algorithm will be said later);
Congestion avoidance
Congestion avoidance algorithm is to let the congestion window increase slowly, after receiving each round of confirmation, the congestion window of the value of 1, rather than doubling, so that the congestion window values in accordance with the linear law slowly increase. In a slow boot, when CWnd >= Ssthresh, it enters the "congestion avoidance algorithm". In general, the value of Ssthresh is 65535, the unit is byte, and when CWnd reaches this value, the algorithm is as follows:
- When an ACK is received, CWnd = CWnd + 1/cwnd;
- When each over a RTT, CWnd = CWnd + 1;
Fast re-transmission and fast recovery
The fast retransmission algorithm first requires the receiving party to send a repeat acknowledgment every time an out-of-order segment is received (the acknowledgement of the previous ordered part is repeated), rather than waiting for the data to be sent for a piggyback acknowledgement, or a cumulative acknowledgement if the sender receives three duplicate confirmations consecutively. It should be immediately re-transmission of the message received by the other party (there is a duplicate confirmation, indicating that the following message section is served, only the middle of the missing message segment is not delivered).
The fast recovery algorithm is used in conjunction with the Fast retransmission algorithm:
- When the sender receives three duplicate acknowledgments consecutively, the slow-start threshold Ssthresh is set to half of the current congested window CWnd. Re-transmit the missing message segment. Set CWnd to Ssthresh plus 3 times times the message segment size;
- Each time another duplicate ACK is received, CWnd increases the size of 1 segments and sends 1 packets;
- When the next acknowledgment of the new data is reached, the CWnd is set to Ssthresh (as in the 1th step). This ACK should be the confirmation of retransmission in step 1 within a round trip time after the retransmission. In addition, this ACK should also be the acknowledgment of the intermediate message segment between the missing packet and the first duplicate ACK received. This step uses the congestion avoidance algorithm.
Resources:
"TC/IP detailed"
Congestion control mechanism of TCP
TCP Congestion control on network protocol