1
Data Link Layer
Flow Control
Copyright by Jorg Liebeherr 98,99 2
Flow Control
n Flow Control is a technique for speed-matching
of transmitter and receiver. Flow control ensures that a transmitting station does not overflow a receiving station with data
n We will discuss two protocols for flow control:
n Stop-and-Wait n Sliding Window
n For the time being, we assume that we have a
Copyright by Jorg Liebeherr 98,99 3
Stop-and-Wait Flow Control
n Simplest form of flow control
n In Stop-and-Wait flow control, the receiver
indicates its readiness to receive data for each frame
n Operations:
1. Sender: Transmit a single frame
2. Receiver: Transmit acknowledgment (ACK) 3. Goto 1. 4
Analysis of Stop-and-Wait
Frame ACK Frame ACK Receiver Sender propagation delayLast bit received End of Transmit of ACK
Start Transmit End Transmit Last bit of ACK received transmission
delay
Copyright by Jorg Liebeherr 98,99 5
Sliding Window Flow Control
n Major Drawback of Stop-and-Wait Flow
Control:
n Only one frame can be in transmission at a time n This leads to inefficiency if propagation delay is
much longer than the transmission delay
n Sliding Window Flow Control
n Allows transmission of multiple frames
n Assigns each frame a k-bit sequence number n Range of sequence number is [0..2k-1], i.e.,
frames are counted modulo 2k
Copyright by Jorg Liebeherr 98,99 6
Operation of Sliding Window
n
Sending Window:
n At any instant, the sender is permitted to send
frames with sequence numbers in a certain range (the sending window)
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 Frames already
transmitted
Window of frames that may be transmitted Frame sequence number Last frame transmitted Window shrinks as
frames are sent
Window expands as acknowledgements are
Copyright by Jorg Liebeherr 98,99 7
Operation of Sliding Window
n
Receiving Window:
n The receiver maintains a receiving window
corresponding to the sequence numbers of frames that are accepted
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6
Frames already received Window of frames that areaccepted by receiver
Last frame acknowledged
Window shrinks as frames are received
Window expands as acknowledgements are
sent
8
Operation of Sliding Window
n How is “flow control” achieved?
n Receiver can control the size of the sending
window
n By limiting the size of the sending window data
flow from sender to receiver can be limited
n Interpretation of ACK N message:
n Receiver acknowledges all packets until (but not
Copyright by Jorg Liebeherr 98,99 9
Example
Receiver Transmitter 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 F0 F1 F2 ACK43Copyright by Jorg Liebeherr 98,99 10
Example Continued
Receiver Transmitter 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3 F3 ACK3 F4 F5 F6 4Copyright by Jorg Liebeherr 98,99 11
Analysis of Sliding Windows
0 a 1st frame received a+1 ... 0 1 2 W 1st ACK2a+1 received Receiver Sender Wth frame received a+W W 12 n If the window size is sufficiently large the sender
can continuously transmit packets:
n W ≥ 2a+1: Sender can transmit continuously
n W < 2a+1: Sender can transmit W frames every
2a+1 time units
Analysis of Sliding Windows
1 efficiency normalized = 2a 1 W efficiency normalized + =
Copyright by Jorg Liebeherr 98,99 13
ARQ Error Control
n Types of errors: Lost frames, damaged frames n Most Error Control techniques are based on (1)
Error Detection Scheme (e.g., Parity checks, CRC),
and (2) Retransmission Scheme
n Error control schemes that involve error detection
and retransmission of lost or corrupted frames are referred to as Automatic Repeat Request
(ARQ) error control
Copyright by Jorg Liebeherr 98,99 14
ARQ Schemes
n The most common ARQ retransmission
schemes:
n Stop-and-Wait ARQ n Go-Back-N ARQ n Selective Repeat ARQ
n The protocol for sending ACKs in all ARQ
protocols are based on the sliding window flow control scheme
Copyright by Jorg Liebeherr 98,99 15
Stop-and-Wait ARQ
n Wait ARQ is an addition to the
Stop-and-Wait flow control protocol:
n Frames have 1-bit sequence numbers (SN = 0 or 1) n Receiver sends an ACK (1-SN) if frame SN is correctly
received
n Sender waits for an ACK (1-SN) before transmitting
the next frame with sequence number 1-SN
n If sender does not receive anything before a timeout
value expires, it retransmits frame SN
16
Stop-and-Wait ARQ
Frame 1 n Lost Frame A B ACK 0 Frame 0 Timeout ACK 1 Frame 1 Frame 1 ACK 0Copyright by Jorg Liebeherr 98,99 17
Stop-and-Wait ARQ
Frame 1 n Lost ACK A B ACK 0 Frame 0 ACK 1 Timeout Frame 0 ACK 1Copyright by Jorg Liebeherr 98,99 18
Go-Back-N ARQ
n
Go-Back-N uses the sliding window
flow control protocol. If no errors
occur the operations are identical
to Sliding Window
Copyright by Jorg Liebeherr 98,99 19
Go-Back-N ARQ
n
Operations:
n A station may send multiple frames as allowed by
the window size
n Receiver sends a NAK i if frame i is in error. After
that, the receiver discards all incoming frames until the frame in error was correctly retransmitted
n If sender receives a NAK i it will retransmit frame i
and all packets i+1, i+2,... which have been sent, but not been acknowledged
20
Go-Back-N ARQ
Frame 0 n Lost Frame A B Frame 2 Frame 4 Frame 1 Frame 3 ACK 3 Frame 5 Frame 6 NAK 4Frame 4 Frame 5 Frame 6
Frames 4,5,6 are retransmitted
ACK 6
Frames 5 and 6 are discarded
Copyright by Jorg Liebeherr 98,99 21
Go-Back-N ARQ
Frame 0 n Lost ACK A B Frame 2 Frame 1 Frame 3 ACK 3 Frame 0 Frame 5 Frame 4 Frame 3 Frame 4Frames 0-4 are retransmitted Timeout
Frame 1 Frame 2
ACK 3 ACK 5
Frames 3 and 4 are discarded
Copyright by Jorg Liebeherr 98,99 22
Selective-Repeat ARQ
n Similar to Go-Back-N ARQ. However, the
sender only retransmits frames for which a
NAK is received
n Advantage over Go-Back-N:
n Fewer Retransmissions.
n Disadvantages:
n More complexity at sender and receiver
n Each frame must be acknowledged individually (no
cumulative acknowledgements)
Copyright by Jorg Liebeherr 98,99 23 only Frame 4 is retransmitted
Selective-Repeat ARQ
Frame 0 n Lost Frame A B Frame 2 Frame 1 Frame 3 ACK 2 Frame 5 Frame 6 ACK 6, NAK 4Frame 4 Frame 7 Frame 0
ACK 7 ACK 1 ACK 3 ACK 4
Frame 4
Frames 5 and 6 are buffered
ACK 5 ACK 0 ACK 1
24
Example of Selective-Repeat
ARQ
B A 2 1 3 2 Frames received Frames waiting for ACK/NAK 3 ACK2frame 1 is correct, send ACK 2
B A 3 2 4 3 4 NAK2
frame 2 is in error, send NAK2 1 1 2 4 3 B A 2 4 retransmit frame 2 1 3 5 5
Receiver must keep track of `holes’ in the sequence of delivered frames Sender must maintain one timer per outstanding packet