[Computer network]-TCP congestion control VS flow control

TCP provides three more functions than UDP, namely: reliable transmission, congestion control and flow control. There are many similarities between congestion control and flow control. This article will discuss the details of the two. A comparison is given at the end of the article.

window

Before that, it is necessary to clarify the concept of three windows in TCP. The two parties of a TCP connection are called the receiver and the sender respectively. The receiver maintains a receiving window, and the sender maintains a sending window. You can simply understand the window as a memory unit.

1. Receiving window : This is the value set by the receiver according to its own buffer size, and the sender should be told to reflect the receiver's receiving ability.

2. Congestion window : This is the window value set by the sender according to the degree of network congestion estimated by the sender , which reflects the current network capacity.

3. Sending window : sending window = min (congestion window, receiving window). Let's understand this formula. The congestion window is calculated by the sender itself, and the receiving window is told by the receiver to the sender. The sending window takes the minimum of the two, which means that the data sent can neither exceed the capacity of the network nor the capacity of the receiver. .

For example, there is a study room with a capacity of 30 people on the top floor of the library. The conditions are very good. There are 20 people in our class who want to go there for self-study. They all line up at the elevator entrance on the first floor. There is an LED screen in the lobby on the first floor. Show how many seats are left in this study room in real time. At this time, 20 seats in the study room have been taken away by others ! There are only 10 left (the reception window in the study room is 10) , then the people in our class must hurry up to take up positions! But the elevator in the library can only transport 12 people at a time (the congestion window of the network is 12) , otherwise it will be overloaded. So how many people can we send up to the study room in one trip? The first one cannot exceed 10, because there are only 10 seats left in the study room, and the second cannot exceed 12, because the elevator can only hold 12 people, so the maximum number of people we can go up this trip is: min(10,12) also That is 10 people, that is, the sending window is 10.

Note that these three windows are dynamically changed, and will change every time, we will talk about this later

flow control

What flow control needs to do : According to its own receiving buffer, notify the sender of its own receiving window size, thereby dynamically adjusting the size of the sender's sending window (in bytes)

Method of flow control : sliding window

1. The receiver informs the sender of the receiving window rwnd in the window field of the confirmation message segment

2. The sending window of the sender takes the minimum value of the receiving window rwnd and the congestion window cwnd

The elevator brought up 10 people. These 10 people entered the study room and took up 10 positions and started to study hard. At this time, the 30 seats in the study room were full, but at this time, 5 students finished their study and left the study room. There are 5 empty seats left on the board. However, the LED screen downstairs still shows 10 seats left. If ten people are sent up, wouldn’t someone have no seats? That’s not okay. At this time, the administrator of the study room will modify the number on the LED screen and inform the students on the first floor that there are now only 5 seats (receiving window 5) . At this time, the students in line will know that they can only go up to 5 at most. Personally.

So the flow control is: the process by which the administrator of the study room modifies the remaining seats on the LED screen

Congestion control

What flow control should do : monitor network conditions and use four algorithms to estimate the value of the congestion window

Since it is a library, the students who are going to the reading room of other floors are also queuing here. Assume that before our classmates enter the elevator, there are already 8 other people standing in the elevator. At this time, we stand at the door and count: the elevator has a limit of 12 people, and there are 8 people, then 4 people can still be accepted (congestion control algorithm), cleverly we calculated that the congestion window is 4, and the remaining seats are displayed on the LED screen. 5. Then the sending window=min(4,5)=4, that is, only 4 of us can go up.

Therefore, congestion control is the process of estimating how many people can be installed in the elevator. However, the network is very complicated, and estimating the congestion window is not a simple addition and subtraction.

Algorithm for estimating the congestion window:

The abscissa is the transmission sequence (that is, every time the elevator goes up and down), and the ordinate is the congestion window (the remaining capacity of the elevator). It should be noted that the reason why these four algorithms present the law shown in the above figure (linear growth, exponential growth) has an assumption that: the receiver has enough buffer space, and the size of the sending window depends on the degree of congestion.

1. Slow start algorithm : When the connection is just established, cwnd increases exponentially, and when the slow start threshold ssthresh is reached, congestion avoidance is used instead

2. Congestion avoidance algorithm : after the threshold, cwnd increases linearly (addition increases), timeout occurs (when network congestion), adjust cwnd=1, ssthresh=cwnd/2 (multiplication decreases), use slow start algorithm

3. Fast retransmission algorithm : It does not wait until the network congestion actually occurs to execute the slow start, but the receiver changes to the slow start after receiving three redundant ACKs.

4. Fast recovery algorithm : cwnd becomes a new threshold, and congestion avoidance continues

Do you have a question when you see this? Since the congestion window is equivalent to the remaining capacity of the elevator, why is the congestion window larger than once in these four algorithms?

In the above example, we know the elevator’s load limit, and we also know that the elevator has already stationed several other people, so we can accurately calculate how many people can be in our class each time, but in the actual network, the maximum capacity of the network is as well as At present, the number of messages already being transmitted on the network is unknown, which means that we can't see how many people are already standing in the elevator, and we don't know the elevator's load limit . So we can only test one at a time. One person went up on the first trip and found that there was no overload, eh! Good thing, we went up with 4 people on the second trip, and there was no overload. It seems that it is not very crowded now~ the next time we go up with 8 people (start slowly), oh roar! The elevator called the police and couldn't get up. It is estimated that there are many other people standing there. Then 4 of them are good this time (congestion avoidance). Let's see if it is overloaded this time.

Finally, summarize the similarities and differences between congestion avoidance and flow control

1. Different purposes : congestion control control amount, flow control control speed. Congestion control is to control the elevator to not be overloaded, and flow control is to control the speed of the transporter to come up too fast, resulting in too late to receive

2. The scope is different : congestion control is oriented to the entire network, and flow control is oriented to the current connection . The people standing in the elevator include not only those who go to the study room on the top floor, but also those who go to other floors. They are facing the entire library, that is, congestion control is facing the entire network. Only the remaining seats in the study room are displayed on the LED, so the flow control is for the current connection.

3. Different tasks : the task of congestion control is that the sender monitors the network according to four algorithms and continuously adjusts the size of the congestion window; the task of flow control is to dynamically modify the window field in the message to inform the sender of the size of the receiving window in time. Congestion control is to constantly calculate the remaining number of people that can be carried by the elevator, and flow control is to dynamically update the remaining number of seats on the LED screen by the study room administrator.

4. The result is the same : The final result is to change the sending window (sending window = min (congestion window, receiving window) to control the speed at which the sender sends data . Whether it is limiting the number of people entering the study room or limiting the number of people entering the elevator, All are achieved by changing the number of people transported each time.

 

Guess you like

Origin blog.csdn.net/qq_39328436/article/details/114669660