# Sliding Window Protocol
## What is the Sliding Window Protocol
The sliding window protocol is a flow control and error control technique that allows the sender to transmit multiple frames before waiting for acknowledgments. Unlike stop-and-wait, which allows only one unacknowledged frame at any time, sliding window allows the sender to have a number of frames outstanding, up to the window size. As acknowledgments are received, the window slides forward and new frames can be sent. The sliding window protocol significantly improves the utilization of the network link compared to stop-and-wait, especially on high-latency links.
## Sender Window and Receiver Window
The sender window represents the range of frames that the sender is permitted to send without receiving acknowledgments. The sender can transmit frames from the beginning of the window up to the end. When an acknowledgment is received, the lower edge of the window advances, allowing a new frame to be transmitted from the upper edge. The receiver window represents the range of frames the receiver is prepared to accept. The receiver advertises its window size to the sender, allowing it to adjust transmission rate based on available receiver buffer space.
## Go-Back-N
Go-Back-N is a sliding window protocol in which the receiver only accepts frames in order. If a frame arrives out of order or with an error, the receiver discards it and all subsequent frames until the missing frame is correctly received. The sender must retransmit the frame in error and all subsequent frames. This simplifies the receiver design because it does not need to buffer out-of-order frames, but it wastes bandwidth by retransmitting frames that were successfully received.
## Selective Repeat
Selective Repeat is a more efficient sliding window protocol in which the receiver can accept and buffer out-of-order frames. When a frame with errors is received, the receiver sends a negative acknowledgment for that specific frame but continues to receive and buffer subsequent frames. The sender retransmits only the specific frame that was in error, not all subsequent frames. This makes more efficient use of the network link but requires more complex buffer management at the receiver. TCP uses a selective acknowledgment extension that functions similarly to selective repeat.
## Window Size and Performance
The window size directly affects link utilization. To fully utilize a link, the window size must be at least large enough to fill the bandwidth-delay product of the link. The bandwidth-delay product is the amount of data that can be in transit on the link at any time, calculated as the link speed multiplied by the round-trip time. A window smaller than the bandwidth-delay product means the sender runs out of window space and must stop before filling the link, leaving the link idle.Back to Subject