What Is a Sliding Window Protocol?
Sliding Window Protocol, an application of the TCP protocol, is used for flow control during network data transmission to avoid congestion. The protocol allows the sender to send multiple data packets before stopping and waiting for an acknowledgement. Because the sender does not have to stop and wait for confirmation every time a packet is sent, this protocol can speed up data transmission and improve network throughput.
Sliding window protocol
- If too many sources send a large number of data packets at a fast speed at the same time, and the receiver does not have such a high ability to receive data at this time, it is easy to cause network congestion. Therefore, in order to control the sending speed of the sender, prevent the sender, and take into account the limitation of the size of the sending buffer, etc., it is required to limit the number of frames that the sender has sent but not yet confirmed, while improving the transmission efficiency of the network The sliding window protocol came into being, which enables the sender to send multiple data packets at the same time without receiving an acknowledgment, thereby greatly improving the network throughput.
- In any communication protocol that performs error control based on automatic retransmission requests, the receiver must acknowledge the received data packet. If the sender does not receive the acknowledgement within a reasonable time, the data is retransmitted. The sender who does not hear the acknowledgment does not know whether the receiver actually received the packet (data may be lost or corrupted during transmission). If the error detection shows corruption, the packet is ignored by the receiver and no acknowledgement is sent. Because of the network transmission delay, a lot of time will be spent waiting for confirmation, resulting in low transmission efficiency.
- Each part of the transmission is assigned a unique consecutive sequence number, the receiver uses the numbers and places the received packets in the correct order, discards duplicate packets and identifies the missing data.
- The agreement stipulates that retransmission is required for unconfirmed packets within the window. The number of such packets can be at most equal to the size of the sending window, that is, the size of the sliding window n minus 1 (because the sending window cannot be greater than (n-1), at least the receiving window must be greater than or equal to 1).
- The sliding window protocol must guarantee the sequential transmission of data packets. The sequence number in the sending window represents the data packets that have been sent but not yet received. The sending window can sustain a series of unconfirmed data packets because the sender window The data packets may be lost or damaged during transmission, so the sending process must save all the data packets in the sending window for retransmission. Once the sending window reaches the maximum value, the sending process must stop receiving new data packets until there is a free buffer area. Data packets outside the receiving window are discarded. When a packet with a sequence number equal to the lower limit of the receiving window arrives, it is submitted to the application and an acknowledgement is sent to the sender. The receiving window moves forward by one. The upper and lower limits of the sending window and receiving window need not be the same, and the size need not be the same, but the receiving window size needs to be fixed, and the sending window size can change with the data packet. [1]
- The sliding window protocol is characterized by a packet-based data transmission protocol. Therefore, this protocol is suitable for environments that have high reliability requirements for the sequential transmission of packets, such as in the data link layer (OSI model) and transmission control protocol (TCP). [2]
- [1] stop-and-wait protocol
- (1) The sender does not have to send a full window size data.
- (2) A message from the receiver confirms the data and slides the window to the right, because the size of the window is relative to the confirmation sequence number.
- (3) The size of the window can be reduced, but the right edge of the window cannot be moved to the left.
- (4) The receiver does not have to wait for the window to be filled before sending an ACK.
- Because the performance of the "sliding window" protocol depends on the window size and the speed at which the network receives data packets, in an unstable traffic environment, the performance degradation may even cause network conflicts. To avoid and provide end-to-end flow control, a "slow start" protocol can be suggested.
- The improvement of this protocol is mainly focused on how to reduce the retransmission of TCP packets. At present, each packet transmitted in TCP requires the receiver to confirm. A large number of short and frequent confirmation packets bring a lot of overhead to the network. Therefore, a delayed ACK strategy is adopted to reduce the number of ACKs. After receiving a message, the receiver does not immediately send an ACK, but waits for 1 ~ 200ms. If there is a data packet returned during this period, it will carry an acknowledgement but receive An independent acknowledgement is sent for two consecutive data messages or waiting timeout. Effectively reduce the number of ACKs and improve the overall performance of TCP. [4]