TCP Sliding Window Protocol _tcp

Source: Internet
Author: User
Tags ack

What is a sliding window protocol.
A picture wins thousand words, look at the figure below. Simply explained, the sending and receiving parties maintain a sequence of data frames, called Windows. The sender's window size is determined by the receiving party, which is designed to control the speed of the transmission, lest the receiver's cache is not large enough to cause overflow, while controlling traffic can also avoid network congestion. The 4,5,6 data frame in the following figure has been sent out, but the associated ack,7,8,9 frame is not received until it is sent. You can see that the sender's window size is 6, which is informed by the receiving end (in fact, you must consider the Congestion window CWnd, for the moment consider Cwnd>rwnd). If the sender receives a 4th ACK at this point, the left edge of the window shrinks to the right and the right edge of the window expands to the right, at which point the window "slides", that is, the data frame 10 can also be sent.

The following is a more detailed description of the Sliding window protocol, here for the sake of simplicity, set the sender window size to 2 and the receiver size to 1. Look at the picture below:


First: The initial state, the sender does not have frames issued, the sending window is coincident with each other. Receiver No. 0 window open, waiting to receive frame No. 0;
Second: The sender opens window No. 0, indicating that 0 frames have been issued but the return information is still confirmed. The Receive window status is unchanged at this time;
Third: The sender opens the window 0, 1th, indicating that 0, 1th frames are waiting for confirmation. At this point, the number of windows that the sender has opened has reached a specified limit, and the sender suspends sending a new data frame until a new confirmation return frame is received. The Receive window is still unchanged at this time;
IV: The receiver has received frame No. 0, window No. 0 is closed, window 1th opens, indicating ready to receive 1th frames. The status of the Send window does not change at this time;
V: the sender received the receiver sent to the No. 0 frame confirmation return information, close the No. 0 window, indicating the deletion from the re-publication frame No. 0. The Receive window status is still unchanged at this time
Six: The sender continues to send frame 2nd, window 2nd opens, indicating that frame 2nd is also included in the list to be confirmed. At this point, the sender opened a window has reached the specified limit, before the new confirmation returned to the frame, the sender will suspend the sending of new data frames, the reception window state is still unchanged;
Seven: The receiver has received frame 1th, window 1th is closed, window 2nd opens, indicating that it is ready to receive 2nd frames. The status of the Send window does not change at this time;
Eight: the sender received the receiver sent to the 1th frame received confirmation information, close window 1th, to remove from the re-publication of frame 1th. The Receive window status is still unchanged at this time.

1-bit sliding window protocol?
The above is just the theory of Sliding window protocol, which is different in practical application. The first is the Stop and Wait Protocol (stop-and-wait), when the receiver's window and the sender's window size is 1, 1 bits is enough to represent, so also called 1-bit sliding window protocol. The sender can send only one at a time, and must wait for the packet's ACK to send the next. Although the efficiency is relatively low, bandwidth utilization is significantly lower, but in the network environment is poor, or the bandwidth itself is very low, still applicable. Look at the flowchart below:

Back N protocol?
Although the implementation of the Stop protocol is simple, it can also be used in bad network environment, but it is obviously inefficient. So with the back N protocol, which is also the real use of the sliding window protocol, the window sent here is N and the receiver's window is still 1. Look at the figure below, assuming n=9:
First send the square in one breath sent 10 data frames, the previous two frames correctly returned, data frame 2 error, when the sender was forced to resend 2-8 of these 7 frames, the recipient must also discard previously accepted 3-8 of these frames.
The benefit of the back N protocol is undoubtedly improved efficiency, but once the network situation is bad, it will lead to a large number of data, but not as above the stop protocol, in fact, this is very common, specific reference to TCP congestion control.

Select the retransmission protocol.
Another problem with the back N protocol is that when there is an error frame, all the frames after that frame are always repeated, and it is no doubt that the network condition will deteriorate further when the internet is not very good, and the retransmission protocol is used to solve the problem. The principle is also very simple, the receiver will always cache all the received frames, when a frame error, only request the retransmission of this frame, only after a certain number of frames are correctly received, will be submitted to the high-level application. The disadvantage of retransmission protocol is that the receiving end requires more caching.


From:http://www.cnblogs.com/ulihj/archive/2011/01/06/1927613.html

Related Article

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.