Sliding Window Protocol

Sliding window is a general protocol used with bit-oriented protocols. In this
protocol, the transmitter maintains a variable, S, which denotes the sequence number
of the next frame to be transmitted. Similarly, the receiver maintains a variable, R,
which denotes the sequence number of the next frame it expects to receive. Both
variables are restricted to a limited range of values (e.g., 0 through 7) by using
modulo arithmetic (e.g., modulo 8).

A window denotes a continuous subrange within the permitted range of values
for the sequence numbers. For example, the ranges 0-3 and 6-1 both represent
windows of size 3. Both the transmitter and the receiver have their
own window:

* The transmitter window denotes the frames that have been transmitted but
remain unacknowledged. This window can vary in size, from empty to the entire
range. The transmitter must have enough buffer space to store the maximum
possible number of unacknowledged frames.

* The receiver window denotes frames that are expected to be received. The
receiver window size is fixed. A receiver window size of 1 means that frames
must be received in transmission order. Larger window sizes allow the receiver
to receive as many frames out of order. The receiver must have enough buffer
space to store the maximum possible number of frames that can be received out
of order.

The sliding window protocol operates as follows. When the transmitter sends a
frame, it increments S (and the upper bound of its window). When the receiver
receives a frame whose sequence number falls within its window, it increments R and
sends an ACK to the transmitter. If the frame's sequence number matches any
position other than the lower bound of the window, it notes the fact that the
corresponding frame has now been received. If the frame's sequence number
matches the lower bound of the window, the window is rotated clockwise by one
position (or more positions if succeeding frames within the window have already
been received).

When the transmitter receives an ACK for a transmitted frame, it increments the
lower bound of its window. It should be now clear that flow control is straightforward in the sliding window
protocol. If the receiver withholds ACK frames, the transmitter soon reaches its
maximum window size and has to stop transmitting. Once it receives further ACK
frames, it can reduce its window size and transmit more frames.