background
TCP/IP
Protocols are the foundation of the current Internet era. All network products, or development languages, and development frameworks are based on tcp/ip
protocols. Therefore, learning well tcp/ip
will 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/ip
agreement, it will have a positive effect on your future development or troubleshooting problems at work.
flow control
For the sender and receiver, it is tcp
necessary 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.
tcp
The sliding window is divided into two types: sending window, receiving window
Send window
It contains four parts:
- Sent, confirmed
- Sent, but not confirmed
- Not sent, but can be sent
- Not sent, and cannot be sent
The part of the sending window is as follows:
SND
: That issend
, the location that has been sent but not receivedWND
: That iswindow
, the window sizeUNA
: That isunacknowledged
, it has not been confirmedNXT
: That isnext
, it means the next sending location
Receive window
The window structure of the receiving end is as follows:
REV
: That isReceive
, the location to be receivedNXT
: That isnext
, it indicates the next receiving positionWND
: That iswindow
, the window size
Flow control process
Assuming that both parties have established a three-way handshake, the initial window size is all 200
bytes
- S sends a
100
byte to C , then for S, the byte isSND.NXT
shifted to the right100
, that is, the currently available window is reduced100
. It's easy to understand - After C receives the
100
byte-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 process40
bytes,REV.NXT
shift right40
, and the remaining60
bytes are left in the buffer queue. - 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
60
byte from the original200
changes140
. Because there are still60
bytes in the buffer that have not been taken away. Therefore, C willACK
bring the reduced window size in the header of the message, ie140
. It's easy to understand - 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 by40
bytes, which isSND.UNA
shifted to the right40
, 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 tcp
receiving 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.