Professional Documents
Culture Documents
Peer-to-Peer Protocols
and Data Link Layer
Error and Flow Control
frame
2
Error Control (Cont.)
Challenges of ARQ-based Error Control
send one frame at the time, wait for ACK
easy to implement, but inefficient in terms of channel usage
frame frame
ACK ACK
frame frame
buffer of
finite size
4
Chapter 5
Peer-to-Peer Protocols
and Data Link Layer
ARQ Protocols and Reliable
Data Transfer
Automatic Repeat Request (ARQ)
z Purpose: to ensure a sequence of information
packets is delivered in order and without errors or
duplications despite transmission errors & losses
z We will look at:
z Stop-and-Wait ARQ
z Go-Back N ARQ
z Selective Repeat ARQ
z Basic elements of ARQ:
z Error-detecting code with high error coverage
z ACKs (positive acknowledgments
z NAKs (negative acknowlegments)
z Timeout mechanism
Stop-and-Wait ARQ
sender sends an information frame to receiver
sender, then, stops and waits for an ACK
if no ACK arrives within time-out, sender resends the frame, and again stops
and waits time-out period > roundtrip time
Error-free
Packet
packet
Information frame
Transmitter Receiver
Timer set after (Process A) (Process B)
each frame
Control frame
transmission
Header
CRC
Information Header
packet CRC
Information frame Control frame: ACKs
Stop-and-Wait ARQ (Cont.)
abnormalities: Lost Acknowledgment
(1) lost acknowledgment frame is received correctly, but ACK undergoes
(2) delayed acknowledgment errors / loss
after time-out period, sender resends frame
receiver receives the same frame twice
0
frame frame 0
ACK ACK
1
frame frame 1
ACK ACK
2
frame frame 2
ACK ACK
retransmitted 2
Receiver has already
frame frame 2
frame How will receiver know received frame 2
that this is NOT it resends an ACK and
a new packet?! discards the duplicate.
8
without packet numbering with packet numbering
Stop-and-Wait ARQ (Cont.)
Delayed Acknowledgment ACKs can be delayed due to problems with
(Premature Timeout) links or network congestion
time-out expires early, sender resends frame
0 0
frame 0 frame 0
receiver sees this as
0
ACK for 2nd frame-0 ACK ACK 1
and sends frame-1 0 0
frame 0 frame 0
receiver sees this as 1 ACK 1 ACK 1 0
ACK for frame-1
and sends frame-2 frame-1 not
delivered !!! cannot send
2
frame-2
10
Stop-and-Wait Model
t0 = total time to transmit 1 frame
A
tproc
B
frame
tprop tproc tack tprop
tf time
nf na bits/ACK frame
= 2 t prop + 2 t proc + +
R R
Transmission efficiency:
Effect of
n f no no
1 frame overhead
Reff t0 nf
0 = = = .
R R na 2(t prop + t proc ) R
1+ +
nf nf
Effect of
Effect of
Delay-Bandwidth Product
ACK frame
Stop-and-Wait ARQ (Cont.)
Bandwidth-delay product = 2*(tprop + tproc)*R =
= capacity of the transmission pipe from the sender to the receiver and back.
13
Stop-and-Wait ARQ (Cont.)
frame size in comparison max number of bits in transit
to bandwidth-delay product the pipe is full
nheader
1
R eff nf 0.98
SW = = =
R n ACK 2 (t prop + t proc )R 2 (t prop + t proc )R
1+ + 1.02 +
nf nf nf
15
Stop-and-Wait does NOT work well for very high speeds or long propagation delays.
Stop-and-Wait ARQ (Cont.)
Stop-and-Wait
Pf = probability that transmitted frame has errors and
Efficiency in
need to be retransmitted
Channel with Errors
(1-Pf) probability of successful transmission
and including
1
1- P average # of (re)transmission until first correct arrival
f
1
total delay per frame: t 0 (average # of retrans.) = t 0
1- Pf
nf nheader
t0 nheader
1
R eff_error (1- Pf ) nf
SW_error = = = (1- Pf ) ()
R R n ACK 2(t + t )R
1+ + prop proc
nf nf
SW_error = (1- Pf ) 0
16
Pf increases SW decreases
Stop-and-Wait ARQ (Cont.)
successful
average # of transmissions in error
before a successful transmission transmission
time-out time-out time-out t0
E[# of transmissi ons in error] = (i - 1) P[n trans in error = i - 1] = (i - 1) (1 Pf )Pfi1 =
i=1 i=1
= (1 Pf ) (i - 1) P f
i1
= (1 Pf ) n Pfn =
i=1 n =1
1
= (1 Pf ) Pf n Pfn1 = (1 Pf ) Pf =
n =1 (1 Pf )2
Pf
=
1 Pf
Total average Pf 1
delay per frame: t 0 + time - out E[# of transmiss in error] = t 0 + time - out 17 t 0
1- Pf 1- Pf
Stop-and-Wait ARQ (Cont.)
Piggybacking Stop-and-Wait discussed so far was unidirectional
S(0) S(0)
0 R(0)
S(1) R(0) S(1)
0
1 R(1)
S(2) R(1) S(2)
1
18
without piggybacking with piggybacking
Applications of Stop-and-Wait
ARQ
z IBM Binary Synchronous Communications
protocol (Bisync): character-oriented data
link control
z Xmodem: modem file transfer protocol
z Trivial File Transfer Protocol (RFC 1350):
simple protocol for file transfer over UDP
Go-Back-N ARQ
z Improve Stop-and-Wait by not waiting!
z Keep channel busy by continuing to send frames
z Allow a window of up to Ws outstanding frames
z Use m-bit sequence numbering
z If ACK for oldest frame arrives before window is
exhausted, we can continue transmitting
z If window is exhausted, pull back and retransmit all
outstanding frames
z Alternative: Use timeout
Go-Back-N ARQ
Go-Back-N ARQ overcomes inefficiency of Stop-and-Wait ARQ
sender continues sending enough frames to keep
channel busy while waiting for ACKs
a window of Ws outstanding frames is allowed
m-bit sequence numbers are used for both - frames
and ACKs, and Ws = 2m-1
Assume: Ws= 4
1) sender sends frames one by one
2) frame 3 undergoes transmission error receiver ignores frame 3 and all subsequent frames
3) sender eventually reaches max number of outstanding frames, and takes following action:
21
go back N=Ws frames and retransmit all frames from 3 onwards
Go-Back-N ARQ (Cont.)
Sender Sliding Window all frames are stored in a buffer, outstanding
frames are enclosed in a window
frames to the left of the window are already ACKed
and can be purged
before ACKs for frames 0 and 1 arrive frames to the right of the window cannot be sent
until the window slides over them
23
Go-Back-N ARQ (Cont.)
Example [ lost frame in Go-Back-N with time-out ]
Note:
ACKs number always defines the number of the next expected frame !!!
24
in Go-Back-N, receiver does not have to acknowledge each frame received
it can send one cumulative ACK for several frames
Go-Back-N ARQ (Cont.)
Sequence Numbers
m bits allotted within a header for sequence numbers
and Window Size 2m possible sequence numbers
how big should the sender window be!?
W = 2m 1 acceptable !!!
ACK1
ACK1
ACK2
ACK2
ACK3
ACK3
ACK0
ACK3
ACK1 25
1 P
t GBN = (1 Pf ) t frame + Pf t frame + Ws = t frame + f Ws t frame
1 Pf 1 Pf
transmission efficiency
n f nheader n
1 header
t GBN nf ()
GBN = = (1 Pf ) 26
R 1+ (Ws 1)Pf
Go-Back-N ARQ (Cont.)
What is total average time required to transmit a frame, assuming Pf?
successful successful
transmission transmission
WS WS
0 1 2 3 4 5 6 7 8 9 1011 0 1 2 3 4 5 6 7 R R R R R R R R 8 9 10 11
Pf
E[# of transmissions in error] =
1 Pf
n f nheader n
1 header
t GBN = t frame +
Pf
1 Pf
WS t frame GBN =
t GBN
=
nf
(1 Pf )27
R 1+ (Ws 1)Pf
Go-Back-N ARQ (Cont.)
Example [ Stop-and-Wait vs. Go-Back-N ]
Compare S&W with GBN efficiency for random bit errors with pb = 0, 10-6, 10-5, 10-4 and
bandwidth-delay product R*2*(tprop+tproc) = 1 Mbps * 100 ms = 100000 bits = 10 frames
use Ws = 11.
31
sender window of size WS receiver window of size WR
Selective Repeat ARQ
Selective Repeat ARQ Operation
Receiver:
window advances whenever next
in-order frame arrives
Rnext out-of-order frames are accepted only
Rnext + WS -1 if their sequence numbers satisfy
Rnext < Rframe < Rnext + Ws
Sender:
window advances whenever an ACK
arrives
if a timer expires, the corresponding
frame is resent, and the timer is reset
whenever a NAK arrives, Rnext frame
is resent
32
Selective Repeat ARQ
Window Sizes WS and WR m bits allotted within a header for sequence
numbers 2m possible sequence numbers
how big should the windows be!?
ACK1
ACK1
ACK2
ACK2
ACK3
33
transmission efficiency
nf nheader
R t SR n ()
SR = eff = = 1 header (1 Pf )
R R nf
34
Selective Repeat ARQ
What is total average time required to transmit a frame, assuming Pf?
successful
successful transmission
transmission
on NAK or time-out
0 1 2 3 4 5 6 7 8 9 1011 0 1 2 3 4 5 R 6 7 8 9 101112
tframe
NAK 0
nf nheader
t SR = t frame +
Pf
1 Pf
t frame =
1 nf
1 Pf R
SR =
t SR n
= 1 header
(1 Pf ) 35
R nf
Stop-&-Wait vs. Go-Back-N vs. Selective Repeat
assume nACK and nheader are negligible relative to nf, and
Performance
Comparison 2(t prop + t proc )R WS is for 1 less than the
= L = Ws 1
nf number of frames currently in transit
1
SW = (1- Pf )
1+ L
1
GBN = (1 Pf ) SW < GBN < SR
1+ LPf
SR = (1 Pf )
- LOG(p)
p Stop and Wait
10