Transcript DLL

Data link layer (basic)
– no MAC sublayer
Malathi Veeraraghavan
Univ. of Virginia
• Outline
– Two functions
• Error control
• Flow control
Some of the figures in this talk are from A. Tanenbaum's book
and a few from A. Leon-Garcia and I. Widjaja’s book
1
Error control
• Error detection
– Parity check
– Cyclic Redundancy Code (CRC) or polynomial
codes
• Error correction
 Automatic Repeat reQuest (ARQ)
– Forward Error Correction (FEC)
Slides mainly from web site of textbook by A. Leon-Garcia and I. Widjaja
(with modifications by M. Veeraraghavan)
2
ARQ error/loss detection
and recovery
•
•
•
•
Send a frame
Hold frame in a retransmission buffer at the sender so that if
there is a loss/error, the frame can be resent
Wait for Acknowledgment (ACK) from receiver
If a received frame had errors, the receiver detects the presence
of errors using CRC, and then sends a notification
– sender resends errored frame
•
•
But what happens if the frame itself was lost or the receiver's
notification of an error is lost?
Solution:
– Start a timer at the sender upon sending a frame
– If timer times out before ACK arrives, retransmit frame
3
Error correction:
Different ARQ schemes
• Stop-and-Wait
• Sliding window
4
Stop-and-Wait ARQ
Transmit a frame, wait for ACK
Timer set after
each frame
transmission Transmitter
Information frame
(user data frame)
Receiver
(Process B)
(Process A)
ACK expected
before timer
expires
Error-free
frame
Control frame
ACK: Acknowledgment
Header
Information
bits
CRC
Header
CRC
5
Information frame; also called user data frame
Control frame: ACKs
Stop-and-Wait Efficiency
First frame bit
enters channel
Last frame bit
enters channel
ACK
arrives
Channel idle while transmitter
waits for ACK
t
A
B
First frame bit
arrives at
receiver
t
Last frame bit
arrives at
receiver
Receiver
processes frame
and
prepares ACK
6
Stop-and-Wait Model
t0 = total time
A
tproc
B
tprop
data frame
emission
time tf
tproc
tack
tprop
one-way propagation delay
t 0  2 t prop  2 t proc  t f  t ack
 2 t prop  2 t proc 
processing delay
nf
R

na
user data frame size
ACK frame
size
R
channel transmission rate
7
Stop-and-Wait efficiency on an
error-free channel
bits for header & CRC
Effective transmission rate:
0
R eff
no. of info bits


total time to deliver bits
t0
Transmission efficiency:
n f  no
0
0 
R eff
R

t0
R
1
Effect of
frame overhead
no
nf

1
na

2 ( t prop  t proc ) R
nf
Effect of
ACK frame
n f  no
.
nf
Effect of
Bandwidth-delay product
8
Propagation vs.
processing delays
• Propagation delay is determined by speed
of light
– If distance = 1000km, propagation delay is on
the order of milliseconds
• Processing delays are on the order of
micro-seconds
• Therefore, we often ignore tproc
• 2tprop = Round-trip propagation delay
– Because tprop is one-way propagation delay
9
Examples
(ignoring processing delay)
Bandwidth-delay product = Round-trip prop. delay x BW = ( 2 t prop )r
Round-trip
prop.delay
BW = r
1 ms
10 ms
100 ms
1 sec
1 Mbps
103
104
105
106
1 Gbps
106
107
108
109
In Physical Layer lecture, we learned the word
1 sec x 109 b/s
"bandwidth" as H in Hz. We used the word "transmission rate" as r
= 109 bits
in bits/sec, which determines emission (transmission) delay.
On this slide, we are using the word "Bandwidth" for transmission rate, r.
10
Commonly accepted language in networking community.
Transmission efficiency, 0
nf = 1250 bytes = 10000 bits
na =no= 25 bytes = 200 bits
Round-trip
prop. delay
1 ms
10 ms
100 ms
1 sec
1 Mbps
88%
49%
9%
1%
1 Gbps
1%
0.1%
0.01%
BW
0.001%
The higher the bandwidth-delay product, the lower the
transmission efficiency or effective transmission rate
11
We conclude that
• Stop-and-Wait ARQ solution does not
work well on high bandwidth-delay
product paths
12
Error correction:
Different ARQ schemes
• Stop-and-Wait
Sliding window
13
Sliding window scheme
 Basic operation (no errors/losses)
• Relation between sending window size and
sequence number
14
Basic operation
• Improve Stop-and-Wait by not waiting!
• Keep channel busy by continuing to send frames
• Transmit a window of Ws frames before waiting
for an ACK
• If ACK for oldest frame arrives before window is
exhausted (which means before sender has
transmitted out Ws frames), then there is no
"WAIT" period. Leads to an efficient use of the
link.
15
Sequence numbers and ACKs
• Sequence numbers in frame headers
– Add a sequence number in each frame header
– Use an m-bit sequence number to identify frames
• Example: if m=3, sequence numbers are 0, 1, 2, 3, 4, 5, 6, 7. The next
frame will start over with sequence number 0.
• ACK frames
– ACK frame carries the sequence number of the next expected
frame
• Called cumulative ACK
• More efficient to say "I received everything up to this frame and am
expecting this next frame" rather than to ACK every frame one-byone.
16
New term: outstanding frames
• Means unacknowledged
• At any instant of time, there can be
only Ws outstanding frames
– these frames were transmitted but the
sender has not yet received an ACK for
any of the frames
17
Operation of
Sliding Window Scheme
•
Sending window vs. permitted-to-send window:
– Permitted-to-send window: set of frames that the sender is permitted to
send
– Sending window: permitted-to-send frames + outstanding frames (already
transmitted but as-yet unacknowledged frames)
Frames already
transmitted and ACK’ed
Window of frames that are
permitted to be transmitted
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6
Frame
sequence
number
Last frame
transmitted
Window moves as ACKs
arrive
sending window size
Ws = 7
Wp = 7
permitted-to-send
window size
18
No outstanding frames at this point in time
Operation of Sliding Window
• Operations at the sender:
Ws = 7
Wp = 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6
send out frames 6, 7, 0
Wp changes to 4
(note Ws is still 7;
frames 6, 7, 0 are
outstanding)
ACKs not yet received for 6, 7, 0
permitted-to-send window
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6
sending window
19
Operation of Sliding Window
• Operations at the sender:
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6
Receives acknowledgement (ACK 1),
which means receiver is expecting the
next frame to have a sequence number 1
Notice how the window slides with time
- hence the name "Sliding window"
ACK 1 is cumulative ACK
It means frames 6, 7, 0
have all been received
No more outstanding
frames; therefore
Ws = Wp = 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
20
Analysis of Sliding Windows
1
2
3
W
?
...
tprop
Frame
emission
delay
...
Sender
tprop
Receiver
Use nf as size of each frame and R as transmission rate
Processing delays are neglected
21
Analysis of Sliding Windows
• If the window size is sufficiently large the sender can
transmit packets continuously
• If:
W 
nf
R
 2  t prop 
(W  1) 
nf
R
nf
R
 2  t prop
• Ignoring frame header/CRC overhead, ACK frame size and
processing delays:
– transmission efficiency = 100%
22
Sending window size
• Sending window size, Ws, should be at
least as large as W (previous slide) so
that no time is wasted waiting for an
ACK with the sender idling
Ws  W
 2  t prop  R

Ws  
 1


nf


In most protocols, frames are of variable length, and therefore
window size is usually expressed in bytes. For simplicity, in this
lecture, we have assumed that all frames are of equal length (size
Sf). Under this assumption, Ws should always be an integer, as it
represents a number of fixed-length frames.
23
Sliding window scheme
outline check
• Basic operation (no errors/losses)
Relation between sending window size
and sequence number
24
What happens if sending window size Ws = 2m?
Sender timer times out for frame 0 since ACK is not received
and sender retransmits frame 0
Example: m=2 and Ws = 4
A
fr
0
fr
2
fr
1
fr
3
fr
0
Time
ACKs
lost
A
C
K
1
B
Rnext
0
1
A
C
K
2
2
A
C
K
3
3
A
C
K
0
Receiver has Rnext= 0; so it will accept
the frame assuming it is a new frame,
when in reality it is a duplicate frame
0
Rnext: Sequence number of the next expected frame
25
Conclusion: Maximum Allowable Sending Window Size
max(Ws) = 2m-1
Example: m=2 and Ws = 3
A
fr
0
fr
3
fr
0
fr
2
fr
1
Sender timer times out for frame 0 since ACK is not received
and sender retransmits frame 0
Time
ACKs
lost
B
Rnext
0
A
C
K
1
A
C
K
2
1
2
A
C
K
3
3
A
C
K
3
Receiver has Rnext= 3 , so it
rejects the duplicate frame 0,
and sends ACK 3. If this ACK
reaches the sender, sender will
conclude that frames 0, 1 and 2
were successfully received and
it will send frame 3
26
Relation between sending window size
and sequence number
• Sending window size, Ws
• Sequence number is m-bits long
Ws  2
m
1
27
ACK Piggybacking in
Bidirectional Communication
Frames have sequence numbers; ACKs have numbers
Piggybacking means carrying an ACK number within data-carrying frame header
A
Transmitter
Trailer
DATA
Receiver
S
B
B
R next
Header
S
A
B
A
R next
Receiver
Transmitter
DATA
S: Sequence number of frame
Rnext: Next expected frame at the receiver: ACK number
In normal operation,
what can we say about the relation between SB and RAnext?
28
Status check
• Outline
– Two functions
• Error control
Flow control
29
Flow control problem
Host
Switch or host
Rsnd
Data units
Data-link layer (DLL)
T
Receive
buffer
Rrcv
Data-link layer (DLL)
H
T
Physical layer
•
•
H
T
transmission rate: r
Physical layer
H
Rates of the transmitter and receiver at the physical layer are matched.
The flow control problem arises because the layer above the DLL at the receiver
does not deplete the buffer at the same rate at which data is being passed to the
DLL at the sender (Rsnd  Rrcv)
30
Different rates
• Rsnd: Rate at which the higher layer
passes data to the DLL at the sender
• Rrcv: Rate at which the higher layer
removes data from the DLL buffer at
the receiver
• r: physical-layer transmission rate
31
Techniques for flow control
• Flow control mechanisms prevent buffer
overflow by regulating the rate at which
source is allowed to send information
–
–
–
–
Stop-and-wait flow control
ON-OFF flow control
Sliding window flow control
Rate based flow control (skip for this class)
32
Stop-and-wait flow control
• No problem if ACK is sent back after
higher layer depletes the buffer
holding the single frame’s payload
33
ON /OFF flow control
Sender
Receiver
Recall:
What is Rsnd?
What is Rrcv?
Round-trip
propagation
delay
B
2tprop
OFF
Assume that the physical-layer
transmission rate, r, is same as Rsnd
Bleft
Bleft=2tprop(Rsnd – Rrcv)
When should the OFF signal be sent?
34
Sliding Window Flow Control
• Sliding Window Flow Control
– Receiver has a receive buffer
– Receiver sends reports of available space in
this buffer to the sender
• This is called flow window or advertised window
– Sender uses this number to determine the
maximum number of frames it can have
outstanding (i.e., unacknowledged)
35
Sliding window FC illustrated
Ws=7
Receiver notifies the
sender as to how much
space is available
in its receive buffer
Receive
buffer
can
hold
11 frames
flow window = 11
Sending buffer
If m=3, i.e. 3-bit sequence number,
then Ws can be 7, why?
Receiving buffer
(flow control)
36
Sliding window FC illustrated
Because the receiving buffer
has space to hold 8 more packets
Ws=7
6
5
4
3
2
1
0
Sending buffer
Because the receiver is expecting
packet with sequence number 3
Since 0, 1, 2 are ACK'ed, they can
be removed from the send buffer
flow window = 8; ack 3
2
1
0
Receiving buffer
37
Flow window
• Flow window is the:
– Left-over space in the receiver’s buffer
– In previous slide, flow window of 8 is a report
of how much space is left in the receiver’s
buffer (enough to hold 8 frames)
• Flow window is also called "advertised window" or
"receiver’s window"
38
Sliding window FC illustrated
Ws=7
1
1
0
7
6
5
4
3
0
7
6
5
4
3
2
1
0
Sending buffer
flow window = 4; ack 2
Receiving buffer
Watch with animation; frames 0, 1, 2 are read out
of the receive buffer by the higher-layer, which is
why the flow window indication is 4
39
At any instant in time, what is the maximum number
of frames that the sender is permitted to send?
•
•
•
Maximum number of outstanding frames at any instant in time is a minimum
of sending window,Ws, and the flow window indicated by the receiver
Three steps:
1. Find X = min (Ws, flow window)
2. Find Y = number of outstanding frames (already sent but
unacknowledged)
3. Maximum number of frames that the sender is permitted to
send = X- Y
•
Result: if X-Y frames are sent, then the number of outstanding frames
will become X (which is the max. limit for no. of outstanding frames)
After the sender receives the indication that flow window = 4 and ACK = 2 as
shown on the previous slide, how many frames can the sender send? What are
the sequence numbers of the frames that it will send (assume that the higherlayer keeps passing frames down to the DLL at the sender)?
40