Analysis of Several TCP Congestion Control Algorithms

Analysis of Several TCP Congestion Control Algorithms

Congestion control algorithm is an important component to realize TCP . There are many TCP Congestion Control Algorithm. Different algorithms have their own optimization characteristics and working areas. First, this article briefly introduces the working principle of the TCP congestion avoidance algorithm; secondly, the algorithm implementation of Reno, Vegas, Veno, Westwood and Cubic is introduced; finally, this article briefly analyzes the working framework of the tcp_boost algorithm.

1. How the TCP congestion avoidance algorithm works


Without considering F ACK (selective ACK) [ Note 1] , tcp congestion control generally includes three stages: slow start, congestion avoidance and fast recovery. In layman 's terms, slow start is an exponential growth window ( snd_cwnd ), Until slow start threshold (ssthresh) , congestion avoidance is an additive growth window until packet loss ( 3 dupACK, enter fast recovery ) or timeout (over RTO, enter slow start ) , fast recovery is to reset snd_cwnd and ssthresh after packet loss . Its working state machine is shown in Figure 1 :


Figure 1 : TCP Congestion Control State Machine

        2. Reno, Vegas , Veno, Westwood and Cubic

Reno is a basic AIMD ( Additive Multiplying Subtraction Algorithm ) , exponentially growing the window in the slow start phase, snd_cwnd = snd_cwnd + 1 (#per ack), and linearly growing the window in the congestion avoidance phase, snd_cwnd = snd_cwnd + 1/snd_cwnd ( #per ack) . After entering fast recovery , ssthresh = snd_cwnd/2, snd_cwnd = ssthress(+ 3)[ Note 2] .

Vegas is still an exponential growth window ( Reno slow start) in the slow start stage, and will make a judgment after entering the congestion avoidance . Its judgment is based on N_que  ( the queue size on the intermediate forwarding device ) . The calculation logic of N_que is to subtract the bandwidth from the sending window snd_cwnd (approximate value, obtained by snd_cwnd /RTT_actual ) *RTT ( value when there is no queue, you can use the monitored min RTT) . The formula is as follows:


Vegas ' idea is to control the size of N_que by regulating snd_cwnd so that it satisfies:


When the algorithm is implemented, when , snd_cwnd++, when, when, snd_cwnd. 

Veno combines the characteristics of Vegas and Reno algorithms for congestion control. In slow start is the Reno slow start method. In the congestion avoidance stage, use N_que to make judgments:



After entering fast recovery , it is also used to make judgments:



The Westwood algorithm is based on Reno 's slow start and congestion avoidance phase algorithms, but after entering fast recovery , it will make judgments based on bandwidth. Different from Vegas, Veno 's rough bandwidth calculation method, Westwood uses snd_una ( the left border window where the data in the TCP socket has been confirmed, pay attention to its byte value, so finally need to remove mss_cache) to calculate the bandwidth. In the case of ACK Compression , smoothing is performed to avoid excessive bandwidth fluctuations (BWE = alpha * BW(k-1) + (1-alpha) * BW(k)). According to the calculated bandwidth, make the following assignments in fast recovery :


PS:There is a small trick in the implementation of Westwood 's algorithm . The previous congestion algorithm generally set the ssthresh function in struct tcp_congestion_ops when setting the fast recovery algorithm. In actual operation, after the ssthresh value is obtained by calling back this function, snd_cwnd sets a new value according to ssthresh , generally ssthresh+3[ Note 2] . And westwood precisely sets the values ​​of snd_cwnd and ssthresh by hooking the CA_EVENT_COMPLETE_CWR of the TCP event .

PS: Westwood is the window value set when tcp_ca_event is CA_EVENT_COMPLETE_CWR. At this point, the lost packet has been retransmitted, and the send window has been halved (using the Reno ssthresh method).

The fast recovery phase is about to end, and it is about to enter congestion avoidance. So it's still quite confusing, I don't know why it should be set here, not in the ssthresh method.

Cubic algorithm is the default tcp congestion avoidance algorithm in linux . The principle is very simple, using the cubic function to control the growth of the window. In the slow start phase, Cubic implements the hystart algorithm, which grows faster than the Reno slow start algorithm. Its growth function in the congestion avoidance phase is as follows:



The value of C is 0.4 (set in the bic_scale of the source code ). In the code implementation, the growth function (new epoch start, t=0) will be redesigned every time after the fast recovery is completed , and a new K value will be calculated. The formula is



The way to control the growth rate of snd_cwnd is to control the growth rate by setting the w value in tcp_cong_avoid_ai(socket, w, acked) , so that snd_cwnd = snd_cwnd + 1/w (per ack) ≈snd_cwnd + snd_cwnd/w (per RTT) . In the fast recovery phase, snd_cwnd ≈ 0.7 * snd_cwnd (0.7 is beta/1024 in the source code) .


        Note 1 :accomplishThe algorithm of selective ACK is SACK , but since selective ACK needs to modify the TCP protocol stack of the receiving end, the general TCP congestion control algorithm does not use selective ACK .do the processing.There is not much difference between SACK and Reno ack (non-SACK) when entering fast recovery. FACK will revoke fast recovery, and there are generally fewer client implementations.

Note 2 : Regarding how snd_cwnd is finally obtained in the fast recovery phase , the whole process is very complicated. This conclusion refers to the discussion on page 421 of " Linux Network Architecture : Design and Implementation of Network Protocols in the Linux Kernel" .

Note 2: Regarding the fast recovery phase, you can refer to my next blog.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326051843&siteId=291194637