Ant Financial International Business Division
-
Do you know computer networks? Talk about the difference between UDP and TCP.
Blah, blah, blah, blah. Flow control and congestion control.
-
Speaking of flow control, talk about sliding Windows in TCP.
At this point I am confused…
“Sliding Windows I only know to use in flow control, did not understand his principle.”
The sliding window
Sliding window is a traffic control strategy for sender and receiver. In some cases, the receiver’s ability to process data is much lower than the sender’s ability to send it (or the sender has too much data), causing the receiver’s queue to fill up. So with a sliding window, the receiver tells the sender how much data can be sent at a time.
As shown above, there are four parts.
#1: Data has been sent and received to ACK
#2: Data that has been sent but has not received an ACK
#3: Data about to be sent, but not yet sent (receiver has space to accept)
#4: Data about to be sent, not yet sent (receiver has no space to accept)
The [#2 + #3] part is the sliding window.
There’s a Window size in the TCP header, and that’s what the receiver tells the sender, “What is my current capacity?” And the stream size you send must be smaller than my capacity. The Window size corresponds to the [#2 + #3] area in the image above, which is the representation of the Window at the sender.
Window update process
-
The size of the Window increases as the size of the receiver’s buffer increases.
-
When the sender receives an ACK from the receiver, the left edge of the Window moves to the right, and the right edge of the Window adjusts according to the Window size.
Special case: if the header Window size is 0, the sender cannot continue sending data. How does the sender know that the receiver has new space after my receiver has processed some data? When the Window size is 0, the sender will send a packet ZWP(Zero Window Probe) to the receiver. After receiving the packet, the receiver will return the current Window size in the form of ACK. If three ZWP’s are sent and all return zeros, the sender chooses to close the connection abnormally (RST). Abnormal closing of a connection (RST) does not wait for all the data in the buffer to be sent, nor does the receiver need to send an ACK.
Overall, sliding Windows are an end-to-end flow control strategy. At first, the two sides negotiate an initial window size, and then decide which data to send based on the window size. In the process of data transmission, the receiver constantly updates the Window size, and the sender updates its Window size according to the returned value to achieve a purpose of flow control.
Reference connection:
Coolshell. Cn/articles / 11…
www.tcpipguide.com/free/t_TCPS…
Photo credit: www.tcpipguide.com/