Original: http://blog.csdn.net/yujun00/article/details/636495
(1). Window mechanism
The basic principle of the sliding window protocol is that at any given moment, the sender maintains a sequential sequence of allowed frames, called the sending window, and the receiver maintains a sequential sequence of allowed frames, called the receive window. The upper and lower bounds of the sequence number of the sending and receiving windows do not have to be the same, even the size can be different. Different Sliding window Protocol window sizes are generally different. The serial number in the sender's window represents the frames that have been sent, but not yet confirmed, or those that can be sent. Here's an example (assuming the Send window size is 2 and the receive window size is 1):
Analysis: ① initial state, the sender has no frame emitted, the sending window coincides with the front and back. Receiver No. 0 window opens, waiting to receive frame No. 0; The ② sender opens window No. 0, indicating that 0 frames have been emitted but the return information is still acknowledged. The receiving window state is not changed at this time, and the ③ sender opens Windows 0, 1th, indicating that 0, 1th frames are waiting for confirmation. At this point, the number of Windows opened by the sender has reached a specified limit, and the sender pauses to send a new data frame before the new acknowledgement returns the frame. The Receive window is still unchanged at this point, the ④ receiver has received frame No. 0, window No. 0 closes, and window 1th opens, indicating that it is ready to receive frame 1th. The sending window state is not changed at this time, and the ⑤ sender receives a NO. 0-frame acknowledgement from the receiving Party, closes window No. 0, and removes frame No. 0 from the re-publication. At this point the receiving window state remains unchanged; ⑥ 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 the window has reached the specified limit, the sender will pause to send a new data frame before the new confirmation return frame, the receiving window state is still unchanged; ⑦ receiver has received frame 1th, window 1th closes, window 2nd opens, indicating that it is ready to receive frame 2nd. The sending window state is not changed at this time, the ⑧ sender receives a confirmation message received from the receiving party at Frame 1th, closes window 1th, indicating that frame 1th is removed from the re-publication. The receive window state remains unchanged at this time.
If you look at the 1-bit sliding window from the perspective of the sliding window, back N and choose to retransmit three protocols, they differ only in the size of their respective windows. 1-bit Sliding window protocol: Send window = 1, receive window = 1; Back N protocol: Send window >1, receive window >1; Select Retransmission Protocol: Send window >1, receive window >1.
(2). 1-Bit Sliding window protocol
When the size of the send and receive Windows is fixed to 1 o'clock, the sliding window protocol degrades to a stop-and-wait Protocol (stop-and-wait). This protocol requires the sender to stop after each frame is sent, waiting for the receiver to receive a confirmation (acknowledgement) to return before continuing to send the next frame. Because the receiver needs to determine whether the received frame is a new frame or a resend frame, the sender will add an ordinal to each frame. Because the stop-and-wait protocol stipulates that only one frame is sent successfully before a new frame is sent, it is sufficient to number only one bit. The flowchart on which the sender and receiver run.
(3). Back N protocol
Since the Stop protocol to confirm each frame to continue to send the next frame, greatly reducing the channel utilization, and therefore proposed back N protocol. In the back N protocol, after sending a data frame, the sender stops waiting for the reply frame, but sends several data frames continuously, even if it receives the reply frame from the receiving party during the continuous sending process, it can continue to send. and the sender sets a timeout timer for each data frame that is sent. As long as the confirmation frame is still received within the set timeout period, the corresponding data frame will be re-sent. For example, when the sender sends N frames, if the previous frame of the n frame is found to have not returned its confirmation after the timer timeout, the frame is condemned as an error or loss, at which point the sender has to resend the error frame and its n frames.
It is not difficult to see from here that the backward n protocol improves efficiency by transmitting data frames continuously, but on the other hand, it is necessary to re-transmit the data frames that have been correctly transmitted (only because there is a data frame error before these data frames), which reduces the transmission efficiency. Therefore, if the transmission channel transmission quality is poor and therefore the error rate is large, the continuous test protocol is not necessarily better than the stop waiting protocol. The size of the Send window in this protocol is k, and the Receive window is still 1.
(4). Select Retransmission Protocol
In the back n protocol, it is obviously wasteful for the receiver to find the error frame and no longer receive subsequent frames, even if the frames are correctly arrived. Another more efficient strategy is that when the receiver finds a frame error, the correct frame that continues to be sent is not immediately delivered to the receiver's upper level, but the receiver can still receive it, store it in a buffer, and require the sender to re-transmit the wrong frame. Once a re-transmitted frame is received, the remaining frames that were already in the buffer can be submitted to the upper level in the correct order. This method is called the selective re-send (Selectice REPEAT), its working process. Obviously, the choice of re-sending reduces waste, but requires the receiver to have large enough buffer space.
Sliding window mechanism [go]