TCP congestion control - slow start, congestion avoidance, fast retransmission, fast start

General principle: Reasons why congestion control occurs: Demand for resources (bandwidth, buffers of switching nodes, processors) > available resources.

Function: Congestion control is to prevent too much data from being injected into the network, so that the routers or links in the network will not be overloaded. Congestion control has a premise: that the network can bear the existing network load.

Contrast flow control: Congestion control is a global process that involves all hosts, routers, and all factors related to reducing the network. Flow control often refers to the control of point-to-point traffic. It's an end-to-end problem.

congestion window

The sender is a dynamically changing window called the congestion window, and the size of the congestion window depends on the degree of network congestion. The sender makes its own sending window = congestion window, but the sending window is not always equal to the congestion window. When the network condition is good, the congestion window continues to increase, and the sender's window naturally increases, but the receiver's ability to accept Limited, no changes are made when the sender's window reaches a certain size.

What if the sender knows that the network is congested? When the sender sends some segments, if the sender does not receive the acknowledgement segment from the receiver within the time interval, the network can be congested artificially.

slow start

When a host develops to send a datagram, if a large amount of data is injected into the network immediately, network congestion may occur. The slow-start algorithm is to detect the network condition when the host first starts sending datagrams. If the network condition is good, the sender can correctly receive the acknowledgement segment every time it sends a segment. Then, increase the size of the congestion window from small to large, that is, increase the size of the sending window.

Example: At the beginning, the sender first sets cwnd (congestion window) = 1, and sends the first segment M1. After the receiver receives M1, after the sender receives the confirmation from the receiver, the cwnd is increased to 2, and then the sender Sending M2 and M3, after the sender receives the acknowledgment sent by the receiver, the cwnd is increased to 4, and the congestion window cwnd is doubled every time the slow-start algorithm passes a transmission round (it is considered that the sender has successfully received the acknowledgment from the receiver).

congestion avoidance

In order to prevent cwnd from increasing too fast and causing network congestion, it is necessary to set a slow start threshold ssthresh state variable (I don't know what this is, I think it is a congestion control identifier), its usage:

  1. When cwnd < ssthresh, use slow start algorithm,
  2. When cwnd > ssthresh, use the congestion control algorithm and disable the slow start algorithm.
  3. Both algorithms are fine when cwnd = ssthresh.

The idea of ​​congestion avoidance is to make cwnd increase slowly instead of doubling, and increase cwnd by 1 instead of doubling each time the round-trip time is experienced, so that cwnd grows slowly, which is much slower than slow start.

Whether it is a slow start algorithm or a congestion avoidance algorithm, as long as it is judged that the network is congested, the slow start threshold (ssthresh) should be set to half of the sending window (>=2), cwnd (congestion window) should be set to 1, and then When using the slow-start algorithm, the purpose of doing so can quickly reduce the data transmission of the host to the network, so that the congested router can process the packets accumulated in the queue. The congestion window grows according to a linear law, which is much larger than that of the slow-start algorithm.

Example:
1. When the TCP connection is initialized, cwnd=1, ssthresh=16.
2. At the beginning of the slow start algorithm, the initial value of cwnd is 1, and the congestion window is increased by 1 every time the sender receives an ACK. When ssthresh = cwnd, the congestion control algorithm is started, and the congestion window grows according to the law,
3. When cwnd=24, the network times out and the sender cannot receive the confirmation ACK. At this time, set ssthresh=12, (half cwnd), set cwnd=1, and then start the slow start algorithm, when cwnd=ssthresh=12 , The slow start algorithm becomes a congestion control algorithm, and cwnd grows at a linear speed.

AIMD (addition increase multiplication decrease)

  1. Multiplication reduction: Whether in the slow start phase or the congestion control phase, as long as the network times out, set cwnd to 1 and ssthresh to half of cwnd, and then start to execute the slow start algorithm (cwnd<ssthresh).
  2. Additive increase: When the network frequently times out, ssthresh drops rapidly. In order to reduce the number of packets injected into the network, the additive increase means that the congestion window slowly increases after the congestion avoidance algorithm is executed. to prevent premature network congestion.
    The combination of these two is the AIMD algorithm, which is the most widely used algorithm. Congestion avoidance algorithms cannot completely avoid network congestion. By controlling the size of the congestion window, it can only make the network less prone to congestion.

fast retransmission

The fast retransmission algorithm requires the receiver to send a duplicate acknowledgment immediately after receiving an out-of-sequence segment, instead of waiting for a piggyback acknowledgment when it sends data. The receiver successfully accepts M1 and M2 sent by the sender and sends ACK respectively. Now the receiver does not receive M3, but receives M4. Obviously, the receiver cannot confirm M4 because M4 is an out-of-sequence segment. If the receiver does nothing according to the principle of reliable transmission, but according to the fast retransmission algorithm, when receiving M4, M5 and other message segments, it repeatedly sends the ACK of M2 to the sender. Three duplicate ACKs, then the sender does not have to wait for the retransmission timer to expire, since the sender retransmits unacknowledged segments as early as possible.

quick recovery

  1. When the sender receives three consecutive acknowledgments, the multiplicative reduction algorithm is performed to halve the slow start threshold (ssthresh), but the slow start algorithm is not performed subsequently.
  2. At this time, the slow start algorithm is not executed, but cwnd is set to half of ssthresh, and then the congestion avoidance algorithm is executed to slowly increase the congestion window.

Guess you like

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