www.pragsoft.com Chapter 3: The Data Link Layer
43
device to another so that the receiver has enough time to consume the data in its receive buffer, before it overflows.
In character-oriented protocols, flow control is usually based on two control characters: XON and XOFF. When the receiver senses that it can no longer accept
incoming data, it sends an XOFF character to the transmitter, which causes the latter to stop transmitting. Once the receiver has consumed enough of the data in its
receive buffer so that it can receive more, it sends an XON character to the transmitter, causing it to resume transmission.
In bit-oriented protocols, flow control is handled through the use of ACK frames. Since the transmitter needs to keep a copy of its transmitted but yet
unacknowledged frames in a buffer in case they are corrupted and need to be retransmitted, the size of the buffer imposes an upper limit on the number of such
frames. When necessary, the receiver can use this fact to slow down the transmitter by withholding ACK frames. The protocol described in the next section uses exactly
such a strategy.
3.3. 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 see Figure 3.30. 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.
Figure 3.30 Two windows of size 3.
44 Communication Networks
Copyright © 2005 PragSoft
1 2
3 4
5 6
7
Range 0-3
1 2
3 4
5 6
7
Range 6-1
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. Figure 3.31 illustrates the protocol for a sliding window
of size 3, with the sequence number range 0-7. 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.
www.pragsoft.com Chapter 3: The Data Link Layer
45
Figure 3.31 Sliding window of size 3, with sequence numbers 0-7. Transmitter
Receiver
1 2
3 4
5 6
7
Sl = 0 Sh = 0
Transmitter is idle
1 2
3 4
5 6
7
Rl = 0 Rh = 3
Receiver is idle
1 2
3 4
5 6
7
Sl = 0 Sh = 1
Transmitter sends frame 1
1 2
3 4
5 6
7
Rl = 0 Rh = 3
Receiver is idle
1 2
3 4
5 6
7
Sl = 0 Sh = 2
Transmitter sends frame 2
1 2
3 4
5 6
7
Rl = 1 Rh = 4
Receiver receives frame 1 and returns ACK
1 2
3 4
5 6
7
Sl = 1 Sh = 2
Transmitter receives ACK for frame 1
1 2
3 4
5 6
7
Rl = 2 Rh = 5
Receiver receives frame 2 and returns ACK
1 2
3 4
5 6
7
Sl = 2 Sh = 2
Transmitter receives ACK for frame 2
1 2
3 4
5 6
7
Rl = 2 Rh = 5
Receiver is idle
3.4. Data Link Layer Standards