You are on page 1of 12

1

1
Data Link Layer
Flow Control
Copyright by J org 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
perfect channel (no errors)
2
Copyright by J org 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.
Copyright by J org Liebeherr 98,99
4
Analysis of Stop-and-Wait
Frame ACK
Frame ACK
Receiver
Sender
propagation
delay
Last bit received End of Transmit of
ACK
Start Transmit End Transmit
Last bit of ACK received
transmission
delay
Efficiency = ?
3
Copyright by J org 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..2
k
-1], i.e.,
frames are counted modulo 2
k
Copyright by J org 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
received
4
Copyright by J org 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 are
accepted by receiver
Last frame
acknowledged
Window shrinks as
frames are received
Window expands as
acknowledgements are
sent
Copyright by J org Liebeherr 98,99
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
including) sequence number N
5
Copyright by J org 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
ACK4
3
Copyright by J org 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
4
6
Copyright by J org Liebeherr 98,99
11
Analysis of Sliding Windows
0 a
1st frame
received
a+1
...
0 1 2 W
2a+1
1st ACK
received
Receiver
Sender
Wth frame
received
a+W
W
Copyright by J org Liebeherr 98,99
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 Wframes every
2a+1time units
Analysis of Sliding Windows
1 efficiency normalized =
2a 1
W
efficiency normalized
+
=
7
Copyright by J org 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 J org 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
8
Copyright by J org Liebeherr 98,99
15
Stop-and-Wait ARQ
n Stop-and-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 SNis 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
Copyright by J org Liebeherr 98,99
16
Stop-and-Wait ARQ
F
r
a
m
e

1
n Lost Frame
A
B
A
C
K

0
F
r
a
m
e

0
Timeout
A
C
K

1
F
r
a
m
e

1
F
r
a
m
e

1
A
C
K

0
9
Copyright by J org Liebeherr 98,99
17
Stop-and-Wait ARQ
F
r
a
m
e

1
n Lost ACK
A
B
A
C
K

0
F
r
a
m
e

0
A
C
K

1
Timeout
F
r
a
m
e

0 A
C
K

1
Copyright by J org 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
10
Copyright by J org 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
Copyright by J org Liebeherr 98,99
20
Go-Back-N ARQ
F
r
a
m
e

0
n Lost Frame
A
B
F
r
a
m
e

2
F
r
a
m
e

4
F
r
a
m
e

1
F
r
a
m
e

3
A
C
K

3
F
r
a
m
e

5
F
r
a
m
e

6
N
A
K

4
F
r
a
m
e

4
F
r
a
m
e

5
F
r
a
m
e

6
Frames 4,5,6
are retransmitted
A
C
K

6
Frames 5 and 6
are discarded
11
Copyright by J org Liebeherr 98,99
21
Go-Back-N ARQ
F
r
a
m
e

0
n Lost ACK
A
B
F
r
a
m
e

2
F
r
a
m
e

1
F
r
a
m
e

3
A
C
K

3
F
r
a
m
e

0
F
r
a
m
e

5
F
r
a
m
e

4
F
r
a
m
e

3
F
r
a
m
e

4
Frames 0-4
are retransmitted
Timeout
F
r
a
m
e

1
F
r
a
m
e

2
A
C
K

3
A
C
K

5
Frames 3 and 4 are discarded
Copyright by J org 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)
n Receiver may receive frames out of sequence
12
Copyright by J org Liebeherr 98,99
23
only Frame 4
is retransmitted
Selective-Repeat ARQ
F
r
a
m
e

0
n Lost Frame
A
B
F
r
a
m
e

2
F
r
a
m
e

1
F
r
a
m
e

3
A
C
K

2
F
r
a
m
e

5
F
r
a
m
e

6
A
C
K

6
,

N
A
K

4
F
r
a
m
e

4
F
r
a
m
e

7
F
r
a
m
e

0
A
C
K

7
A
C
K

1
A
C
K

3
A
C
K

4
F
r
a
m
e

4
Frames 5 and 6
are buffered
A
C
K

5
A
C
K

0
A
C
K

1
Copyright by J org Liebeherr 98,99
24
Example of Selective-Repeat
ARQ
B A
2
1
3
2
Frames
received
Frames waiting
for ACK/NAK
3
ACK2
frame 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

You might also like