TCP/IP study notes 8-tcp flow control

background

TCP/IPProtocols are the foundation of the current Internet era. All network products, or development languages, and development frameworks are based on tcp/ipprotocols. Therefore, learning well tcp/ipwill be of great help to individuals in the Internet industry in the future.

But this is a basic theoretical course, just like the course of operating system, after learning it may not have much impact on you, and it will not let you immediately have the skills to put into work. But precisely because this is a basic theory course, all Internet technologies are based on it. So if you understand the tcp/ipagreement, it will have a positive effect on your future development or troubleshooting problems at work.

flow control

For the sender and receiver, it is tcpnecessary to put the sent data into the sending buffer and the received data into the receiving buffer. What the flow control needs to do is to control the sending speed of the sending end by controlling the size of the receiving buffer.

tcpThe sliding window is divided into two types: sending window, receiving window

Send window

Insert picture description here
It contains four parts:

  1. Sent, confirmed
  2. Sent, but not confirmed
  3. Not sent, but can be sent
  4. Not sent, and cannot be sent

The part of the sending window is as follows:
Receive window

  • SND: That is send, the location that has been sent but not received
  • WND: That is window, the window size
  • UNA: That is unacknowledged, it has not been confirmed
  • NXT: That is next, it means the next sending location
Receive window

The window structure of the receiving end is as follows:
Insert picture description here

  • REV: That is Receive, the location to be received
  • NXT: That is next, it indicates the next receiving position
  • WND: That is window, the window size
Flow control process

Assuming that both parties have established a three-way handshake, the initial window size is all 200bytes

  1. S sends a 100byte to C , then for S, the byte is SND.NXTshifted to the right 100, that is, the currently available window is reduced 100. It's easy to understand
  2. After C receives the 100byte-sized data, it puts it in the buffer queue. However, due to the heavy load of C, C cannot process so much data, it can only process 40bytes, REV.NXTshift right 40, and the remaining 60bytes are left in the buffer queue.
  3. Note that at this time, since C's processing power is not enough, I hope S can send less data each time, so the receiving end window of C should be reduced at this time. Reduced 60byte from the original 200changes 140. Because there are still 60bytes in the buffer that have not been taken away. Therefore, C will ACKbring the reduced window size in the header of the message, ie140 . It's easy to understand
  4. S receives C's reply and knows that C has reduced the size of the receiving window 140. For S, the received and confirmed part increases by 40bytes, which is SND.UNAshifted to the right 40, and at the same time reduces the sending window140

This is the detailed process of flow control. No matter how many rounds there are, the entire control process and principle are the same! !

note

  • Flow control is to prevent the sender from sending too fast, thus exhausting the receiver's resources, so that the receiver is too late to deal with it.

to sum up

This is the eighth article of the tcp/ip series. It mainly introduces the tcpreceiving window and sending window in detail . Remember, flow control is to control the sending speed of the sending end by controlling the size of the receiving window. There will be more in-depth and more usage scene explanations later, this series of articles will be very long.
Let's start the next article.

Guess you like

Origin blog.csdn.net/Free_time_/article/details/107444089