Traffic control and congestion control for TCP

Source: Internet
Author: User

1. TCPthe Flow control

Generally speaking, we always want to transfer data faster. But if the sender bar data sent too fast, the receiver may be too late to receive, it will cause the loss of data. The so-called flow control is to let the sender of the transmission rate is not too fast, to let the receiver and receive.

Set atoBsend data. When the connection is established,Btold theA: "My receive Windowwnd=400”。 Therefore, the sender's send window cannot exceed the value of the receiver's given receive window. Please note thatTCPThe window unit is a byte, not a message segment. We should note that the host of the receiving partyBthree flow control was performed. For the first time, reduce the window torwnd=300, and the second time was reduced torwnd=100, and finally it was reduced torwnd=0, that is, the sender is not allowed to send the data again. The state that causes the sender to pause sending continues to the hostBre-issue a new window value. We should also note thatBtoAthe three message segments sent are setack=1, only inack=1

1.1, now we consider a situation, b to a Shortly after the 0-window message segment was sent, b The receive cache has some storage space. So b to a sent rwnd=400 a waiting to receive b notification of non-0 windows sent, and b also has been waiting for a data sent, if there are no other measures, This deadlock that waits for each other will continue.

To solve this problem,TCP has a continuous timer for each connection, as long as the TCP connection receives a 0 window notification from the other party, it starts the continuous timer. If the duration of the timer set expires, send a 0 window to explore the text segment, carrying only one byte of data, and the other side will confirm the detection segment when the current window value is given. If the window value is still 0, then the party receiving this segment will reset the persistent timer. If the window value is not 0, the deadlock can be broken.

2. TCPthe Congestion control

Network congestion is often caused by a number of factors. For example, when a node caches a capacity that is too small, the groupings that arrive at that node have to be discarded because of storage space. It is now envisaged to extend the capacity of the node cache to a very large size, so that any grouping that reaches that node can be queued in the cache queue of the node without any restrictions. Because of the capacity of the output link and the speed of the processor has not been improved, so in this queue, the vast majority of packet queuing time will be greatly increased, the result is that the upper software has to re-transmit them, thus, simply expanding the cache of storage space will also cause serious waste of network resources, Therefore, the problem of network congestion cannot be solved.

As if, the processor speed is too slow may cause network congestion, the simple processor speed increases, may make the above situation alleviate some, but often will also transfer the bottleneck to other places. The essence of the problem is often the mismatch of the various parts of the system. Only when all the parts are balanced will the problem be solved.

2.1. The relationship between congestion control and flow control

The so-called congestion control is to prevent too much data from being injected into the network, so that routers or links in the network will not be overloaded. Congestion control has to do with a premise that the network can withstand the existing network load. It is a global process that involves all the hosts, all routers, and all the factors that reduce network transmission performance.

In contrast, traffic control often directs the control of point traffic, which is an end-to-end problem. The flow control is to suppress the sending side to send the data rate, so that the receiving end time to receive.

Congestion control and flow control are often confused because some congestion control algorithms send control messages to the sender and tell the sending side that the network is already in trouble and must slow down the sending rate. This is very similar to flow control.

3. Several congestion control methods

1) slow start

The idea of a slow-start algorithm is this. When the host sends data, if a large number of data bytes are injected into the network immediately, then it is possible to cause network congestion, because it is not clear that the network load situation. Experience proves that the better method is to detect first, that is, from small to large primary key to increase the sending window, that is, small to large gradually increase the congestion window value, usually in the beginning to send the message segment, the Congestion window is first added to more than one MSS value, Using this method to gradually increase the congestion window to send rice CWnd, can make packet injection to the network more reasonable rate.

2) Congestion avoidance algorithm is the idea is to let the congestion window CWnd slowly increase, and each pass a round trip time RTT will send the sender of the congestion window CWnd plus 1 , not doubled. In this way, the congestion window CWnd grows slowly by linear law, and the rate of congestion window growth is much slower than the slow-start algorithm.

No matter in the slow start or congestion avoidance phase, as long as the sender to determine the network congestion, is not on time to receive confirmation, it is necessary to set the slow start threshold Ssthresh to congestion when the sending window is worth half, but not less than 2, . Then the congestion window CWnd is reset to execute the slow start algorithm. The purpose of this is to quickly reduce the number of packets sent to the network by the host, so that the congested routers have enough time to complete the backlog of packets in the queue.

3) Fast re-transmission

Fast retransmission algorithm first requires the receiving party each received a sequence of messages, immediately issued a duplicate confirmation, in order to be able to know early on the message segment did not reach the other side, and do not wait for themselves to send the data when the piggyback confirmation, fast retransmission algorithm rules, send hair as long as received 3 A duplicate acknowledgment should immediately retransmit the message segment that has not yet been received, without having to wait for the missing message segment to set the retransmission timer to expire.

4) Fast Recovery

The fast recovery algorithm is used in conjunction with the fast retransmission, and when the sender receives three consecutive confirmations, the multiplication reduction algorithm is executed, and the slow-start threshold Ssthresh is halved. This is to prevent congestion on the network. Note that the slow start algorithm will not be executed next. Since the sender now thinks that the network is probably not congested, the difference from slow start is that the slow start algorithm is now not executed, which is to set the value of the congested window CWnd to 1, instead of The CWnd value is set to the value after the slow start threshold Ssthresh halved, and then the congestion avoidance algorithm is started to make the congestion window grow linearly.

3.1. Examples in practical applications:

Why is the HTTP download not being downloaded directly at the maximum speed that can be used, but at a 1.1 point speed? What happens if you download directly at the maximum speed you can use?

Simply put, when a user establishes a connection to the server, no one knows how much effective bandwidth can be--maybe 1G fiber, or the 2G cellular network of the pit daddy ...
There are two types of strategies that you can adopt:
First, the default link rate is very large, the first to use the maximum amount of traffic can be supported, found that the other side can not connect to try smaller traffic;
The second is the default link rate is very small, with the lowest flow of hair; After the discovery of the other side of the response quickly, did not lose the packet, try to increase the rate of hair; If congestion occurs, switch to congestion control algorithm to continue trying until you find the maximum rate that the link allows.
The former is prone to waste of resources, in case there is a network attack will also sharply magnify the threat of attack ability; the latter is much better.
Do not be misled by the name of slow start (slow start), which means to test traffic from low speed, not "slowly increase the download rate". In fact, the correlation algorithm requires the detection of the link rate limit as soon as possible, but also to deal with a variety of unexpected conditions for the best.

Traffic control and congestion control for TCP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.