Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
Chapter 5 Peer-to-Peer Protocols
and Data Link Layer Error and Flow Control
CSE 3213, Winter 2010Instructor: Foroohar Foroozan
2
Error ControlApproaches
(2) Error Detection + Automatic Retransmission Req. (ARQ)• not enough redundant info to enable error correction
case (a) receiver detects no errorsan ACK packet is sent back to sender
case (b) receiver detects errorsno ACK sent back to sendersender retransmits frame after a ‘time-out’
(1) Forward Error Correction (FEC)
Error Control
frame
ACK
frame
3
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
• send multiple frames at once
better channel usage, but more complex to implement -sender must keep (all) sent but unACKed frame(s) in a buffer, as such frame(s) may have to be retransmitted
frame
ACK
frame
frame
ACK
framebuffer of finite size
How many frames should be sentat any point in time?
How should frames be released fromthe sending buffer?
Error Control (Cont.)
4
Flow Control– set of procedures used to restrict the amount of data that
sender can send while waiting for acknowledgment
• two main strategies (1) Stop-and-Wait: sender waits until it receives ACK
before sending next frame(2) Sliding Window: sender can send W frames before
waiting for ACKs
Error Detection + ARQ (error detection with retransmissions)must be combined with methods that intelligently limit the number of
‘outstanding’ (unACKed) frames.
Fewer unACKed frames ⇒ fewer packets buffered at sender and receiver.
Flow and Error Control
Chapter 5Peer-to-Peer Protocols
and Data Link Layer
ARQ Protocols and Reliable Data Transfer
Purpose: to ensure a sequence of information packets is delivered in order and without errors or duplications despite transmission errors & lossesWe will look at:
Stop-and-Wait ARQGo-Back N ARQSelective Repeat ARQ
Basic elements of ARQ:Error-detecting code with high error coverageACKs (positive acknowledgmentsNAKs (negative acknowlegments)Timeout mechanism
Automatic Repeat Request (ARQ)
CRCInformation
packet
Header
Information frame Control frame: ACKs
CRCHeader
Packet Error-freepacketInformation frame
Control frame
Transmitter(Process A)
Receiver(Process B)
Stop-and-Wait ARQ
Timer set after each frame
transmission
• 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
8
Lost Acknowledgment• frame is received correctly, but ACK undergoes
errors / lossafter time-out period, sender resends framereceiver receives the same frame twice
• frames must be numbered so that receiver canrecognize and discard duplicate frames
sequence number are included in packet header
ACK
How will receiver knowthat this is NOTa new packet?!
ACK
ACK
retransmittedframe
ACK
0
ACK
ACK
Receiver has alreadyreceived frame 2 –
it resends an ACK and discards the duplicate.
1
2
2
without packet numbering with packet numbering
frame 0
frame 1
frame 2
frame 2
frame
frame
frame
frame
• abnormalities:(1) lost acknowledgment(2) delayed acknowledgment
Stop-and-Wait ARQ (Cont.)
9
ACKreceiver sees this asACK for 2nd frame-0
and sends frame-1
Delayed Acknowledgment(Premature Timeout)
• ACKs can be delayed due to problems withlinks or network congestion
time-out expires early, sender resends frame
when delayed ACK arrives, sender assumesthat given ACK corresponds to last frame sent
• ACKs must be numbered to prevent gaps indelivered packet sequence
0
0
1receiver sees this asACK for frame-1
and sends frame-2
ACK
2
frame-1 not delivered !!!
ACK 1
0
0
1 ACK 1
cannot send frame-2
0
0
How large should the packet / ACK sequence be? Only 1-bit long !!!without ACK numbering with ACK numbering
frame 0
frame 0
frame 0
frame 0
Stop-and-Wait ARQ (Cont.)
10
Stop-and-Wait ARQ (Cont.)
frametf time
A
B
tprop tacktproc tprop
tproc
t0 = total time to transmit 1 frame
Stop-and-Wait Model
Rn
Rn
tt
ttttt
afprocprop
ackfprocprop
+++=
+++=
22
220 bits/info frame
channel transmission rate
bits/ACK frame
S&W Efficiency on Error-free channel
.)(21
10
0
f
procprop
f
a
f
oof
eff
nRtt
nn
nn
Rt
nn
RR
+++
−=
−
==η
bits for header & CRC
,bitsn informatio edeliver th torequired timetotal
ndestinatio todelivered bitsn informatio ofnumber
0
0
tnn
R ofeff
−==
Effect offrame overhead
Effect ofACK frame
Effect ofDelay-Bandwidth Product
Effective transmission rate:
Transmission efficiency:
13
Bandwidth-delay product = 2*(tprop + tproc)*R = = capacity of the transmission pipe from the sender to the receiver and back.
Stop-and-Wait ARQ (Cont.)
14
frame size in comparisonto bandwidth-delay product
max number of bits in transit –‘the pipe is full’
tprop + tproc > tframe tprop + tproc < tframe
Stop-and-Wait ARQ becomes inadequate when data is fragmented into small frames, such that nf / R = tframe is small relative to tprop .
Stop-and-Wait ARQ (Cont.)
15
Example [ impact of delay-bandwidth product ]
nf = 1250 bytes = 10000 bitsnACK = nheader = 25 bytes = 200 bits
Efficiency 200 km
(tprop = 1 ms)2000 km
(tprop = 10 ms)20000 km
(tprop = 100 ms)200000 km
(tprop = 1 sec)
1 Mbps103
88%104
49%105
9%106
1%
1 Gbps106
1%107
0.1%108
0.01%109
0.001%
Stop-and-Wait does NOT work well for very high speeds or long propagation delays.
0.02n
nn
n
f
header
f
ACK ==⇒
f
procprop
f
procprop
f
ACK
f
header
effSW
n)Rt(t2
1.02
0.98
n)Rt(t2
nn1
nn1
RR
+⋅+
=+⋅
++
−==η
Stop-and-Wait ARQ (Cont.)
16
• Pf = probability that transmitted frame has errors and need to be retransmitted
(1-Pf) – probability of successful transmission
– average # of (re)transmission until first correct arrival
total delay per frame:
Stop-and-WaitEfficiency inChannel with Errors
fP1-1
f00 P1-
1tretrans.) of #(averaget ⋅=⋅
f
procprop
f
ACK
f
header
ff
0
headerf
eff_errorSW_error
n)Rt2(t
nn1
nn1
P(1-RP(1-
tnn
RR
+++
−⋅=
−
== ))η
0fSW_error P(1- ηη ⋅= )
Pf increases ⇒ ηSW decreases
(∗)
and including
Stop-and-Wait ARQ (Cont.)
170
ff
f00 t
P1-1
P1-Pout-timet]E[out-timet error in transmiss of# ≈⋅+=⋅+
successfultransmission
Probability that i transmission are needed to deliver frame successfully( i-1 transmission in error and the ith transmission is error free ):
P[ # of trans. in error = i-1 ] = (1-Pf) Pfi-1
Total averagedelay per frame:
f
f
2f
ff1n
1nfff
1n
nff
1i
1iff
1i
1iff
1ierror in trans
P1P
)P(11P)P(1PnP)P(1
Pn)P(1P1)-(i)P(1
)PP(11)-(i1]-iP[n1)-(ierror] in onstransmissi of E[#
−=
=−
⋅⋅−=⋅⋅⋅−=
=⋅⋅−=⋅⋅−=
=−⋅==⋅=
∑
∑∑
∑∑
∞
=
−
∞
=
∞
=
−
∞
=
−∞
=
time-out time-out time-out t0
average # of transmissions in errorbefore a successful transmission
Stop-and-Wait ARQ (Cont.)
18
Piggybacking • Stop-and-Wait discussed so far was ‘unidirectional’
• in ‘bidirectional’ communications, both parties send andacknowledge data, i.e. both parties implement flow control
• piggybacking method: outstanding ACKs are placed in theheader of information frames
• piggybacking can save bandwidth since the overhead froma data frame and an ACK frame (addresses, CRC, etc) canbe combined into just one frame
S(0)
0
R(0)S(1)
01
R(1)S(2)
1
S(0)
R(0)
S(1)
R(1)
S(2)
without piggybacking with piggybacking
Stop-and-Wait ARQ (Cont.)
Applications of Stop-and-Wait ARQ
IBM Binary Synchronous Communications protocol (Bisync): character-oriented data link controlXmodem: modem file transfer protocolTrivial File Transfer Protocol (RFC 1350): simple protocol for file transfer over UDP
Go-Back-N ARQImprove Stop-and-Wait by not waiting!Keep channel busy by continuing to send framesAllow a window of up to Ws outstanding framesUse m-bit sequence numberingIf ACK for oldest frame arrives before window is exhausted, we can continue transmittingIf window is exhausted, pull back and retransmit all outstanding framesAlternative: Use timeout
21
Go-Back-N ARQ – overcomes inefficiency of Stop-and-Wait ARQ –sender continues sending enough frames to keepchannel 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= 41) sender sends frames one by one2) frame 3 undergoes transmission error – receiver ignores frame 3 and all subsequent frames3) sender eventually reaches max number of outstanding frames, and takes following action:
go back N=Ws frames and retransmit all frames from 3 onwards
Go-Back-N ARQ
22
Sender Sliding Window • all frames are stored in a buffer, outstandingframes are enclosed in a window
frames to the left of the window are already ACKedand can be purged
frames to the right of the window cannot be sentuntil the window slides over them
whenever a new ACK arrives, the window slidesto include new unsent frames
once the window gets full (max # of outstandingframes is reached), entire window gets resent
Receiver Sliding Window
before ACKs for frames 0 and 1 arrive
after ACKs for frames 0 and 1 arriveand window slides
• the size of receiver window is always 1
receiver is always looking for a specific frameto arrive in a specific order
any frame arriving out of order is discardedand needs to be resent
The complexity of the receiver in Go-Back-N is the same as that of Stop-and-Wait!!!Only the complexity of the transmitter increases.
Go-Back-N ARQ (Cont.)
23
Problems with Go-Back-N(Go-Back-N with Timeout)
• Go-Back-N works correctly (retransmission ofdamaged frames gets triggered) as long as thesender has an unlimited supply of packets that need to be transmitted
but, in case when packets arrive sporadically, there may not be Ws-1 subsequent transmissions⇒ window will not be exhausted, retransmissionswill not be triggered
this problem can be resolved by modifyingGo-Back-N such that:1) set a timer for each sent frame2) resend all outstanding frames either when
the window gets full or when the timer offirst frame expires
Go-Back-N ARQ (Cont.)
24
Example [ lost frame in Go-Back-N with time-out ]
Note: • ACKs number always defines the number of the next expected frame !!!• 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.)
25
Sequence Numbers and Window Size • m bits allotted within a header for sequence numbers
⇒ 2m possible sequence numbers
how big should the sender window be!?
W > 2m cannot be accepted – multiple frames withsame seq. number in the window ⇒ ambiguous ACKs
W = 2m can still cause some ambiguity – see below
W = 2m – 1 acceptable !!!
ACK1
ACK2
ACK3
ACK0
ACK1
ACK1
ACK2
ACK3
ACK3
window size 2m = 4 window size 2m-1 = 3
Go-Back-N ARQ (Cont.)
26
• completely efficient if Ws is large enough to keep channel busy,and if channel is error free
• in case of error-prone channel, with Pf frame loss probability,time to deliver a frame is:
- if 1st transmission succeeds – prob. (1-Pf)
- if 1st transmission does NOT succeeds –prob. Pf
• total average time required to transmit a frame:
• transmission efficiency
Go-Back-NEfficiency
framesf
frame tWP1
1t ⋅⋅−
+
frametaverage # of
frame/window (re)transmission
until a successful transmission
framesf
fframes
fframefframefGBN tW
P1PtW
P11tPt)P(1t ⋅⋅
−+=⎟⎟
⎠
⎞⎜⎜⎝
⎛⋅
−+⋅+⋅−=
)P(11)P(W1
nn1
Rtnn
ffs
f
header
GBN
headerf
GBN −−+
−=
−
=η (∗∗)
Go-Back-N ARQ (Cont.)
27
0 1 2 3 4 5 6 7 8 9 1011
f
f
P1Perror] in onstransmissi of E[#−
=
frameGBN tt =
frameSf
fframeGBN tW
P1Ptt ⋅−
+=
What is total average time required to transmit a frame, assuming Pf?successful
transmission
0 1 2 3 4 5 6 7 R R R R R R R R 1110
WS WS
8 9
successfultransmission
tframe
1st attempt successful:
frameSframeGBN tWtt ⋅+=2nd attempt successful:
frameSframeGBN tWerror] in onstransmissi of E[#tt ⋅⋅+=average case:
)P(11)P(W1
nn1
Rtnn
ffs
f
header
GBN
headerf
GBN −−+
−=
−
=η⇒
tframeACK keeps window ‘sliding’
Go-Back-N ARQ (Cont.)
28
Example [ Stop-and-Wait vs. Go-Back-N ]
nf = 1250 bytes = 10000 bitsnACK = nheader = 25 bytes = 200 bits
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.
Efficiency pb=0 pb=10-6 pb=10-5 pb=10-4
S&W 8.9% 8.8% 8.0% 3.3%GBN 98% 88.2% 45.4% 4.9%
• Go-Back-N provides significant improvement over Stop-and-Wait for large delay-bandwidth product
• Go-Back-N becomes inefficient as error rate increases
Go-Back-N ARQ (Cont.)
Applications of Go-Back-N ARQ
HDLC (High-Level Data Link Control): bit-oriented data link controlV.42 modem: error control over telephone modem links
Selective Repeat ARQGo-Back-N ARQ inefficient because multiple frames are resent when errors or losses occurSelective Repeat retransmits only an individual frame
Timeout causes individual corresponding frame to be resentNAK causes retransmission of oldest un-acked frame
Receiver maintains a receive window of sequence numbers that can be accepted
Error-free, but out-of-sequence frames with sequence numbers within the receive window are buffered Arrival of frame with Rnext causes window to slide forward by 1 or more
31
Selective Repeat ARQ • Go-Back-N is NOT suitable for ‘noisy links’ – incase of a lost/damaged frame a whole windowof frames need to be resent
excessive retransmissions use up the bandwidthand slow down transmission
• Selective Repeat ARQ overcomes the limitationsof Go-Back-N by adding 2 new features
(1) receiver window > 1 frame, so that out-of-orderbut error-free frames can be accepted
(2) retransmission mechanism is modified – only individual frames are retransmitted
• Selective Repeat ARQ is used in TCP !!!
sender window of size WS receiver window of size WR
Selective Repeat ARQ
32
Receiver:• window advances whenever next
in-order frame arrives• out-of-order frames are accepted only
if their sequence numbers satisfy
Rnext < Rframe < Rnext + Ws
• a negative ACK (NAK) with sequencenumber Rnext is sent whenever anout-of-sequence frame is observed
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 frameis resent
Selective Repeat ARQ Operation
Rnext
Rnext + WS -1
Selective Repeat ARQ
33
Window Sizes – WS and WR • m bits allotted within a header for sequencenumbers ⇒ 2m possible sequence numbers
how big should the windows be!?
WS and WR = 2m-1 cannot be accepted dueto possible ambiguity as shown below
W = 2m/2 = 2m-1 acceptable !!!
ACK1
ACK2
ACK3
ACK1
ACK2
window size 2m-1 = 3 window size 2m-1 = 2
Selective Repeat ARQ
34
Selective RepeatEfficiency
• completely efficient if Ws is large enough to keep channelbusy, and if channel is error free
of course, sequence number space must be 2X sequencesequence number space of Go-Back-N
• in case of error-prone channel, total average time requiredto transmit a frame:
• transmission efficiency
)P(1Rn
P1tt
f
f
f
frameSR −⋅
=−
=
)P(1n
n1Rtnn
RRη f
f
headerSR
headerf
effSR −⋅⎟⎟
⎠
⎞⎜⎜⎝
⎛−=
−
== (∗∗∗)
Selective Repeat ARQ
35
0 1 2 3 4 5 6 7 8 9 1011
f
f
P1P−
frameSR tt =
Rn
P11t
P1Ptt f
fframe
f
fframeSR ⋅
−=⋅
−+=
What is total average time required to transmit a frame, assuming Pf?successful
transmission
0 1 2 3 4 5 6R 8 9 1011127
on NAK or time-out
successfultransmission
tframe
1st attempt successful:
frameframeSR ttt +=2nd attempt successful:
frameframeSR terror] in onstransmissi of E[#tt ⋅+=average case:
)P(1n
n1Rtnn
ff
headerSR
headerf
SR −⎟⎟⎠
⎞⎜⎜⎝
⎛−=
−
=η⇒
NAK 0
Selective Repeat ARQ
36
PerformanceComparison
• assume nACK and nheader are negligible relative to nf, and
• efficiencies of three ARQ techniques are
• for 0 < Pf < 1, Selective Repeat provides best performance
• for Pf → 0 Go-Back-N as good as Selective Repeat
size of the “pipe” inmultiples of frames
( )fSW P1-L1
1⋅
+=η
)P(1LP11
ff
GBN −+
=η
)P(1 fSR −=η
ηSW < ηGBN < ηSR
1−==+
sf
procprop WLn
)Rt2(t WS is for 1 less than thenumber of frames currently in transit
Stop-&-Wait vs. Go-Back-N vs. Selective Repeat
37
ARQ Efficiency Comparison
0
0.5
1
1.5
-9 -8 -7 -6 -5 -4 -3 -2 -1
- LOG(p)
Effic
ienc
y
SelectiveRepeat
Go Back N 10
Stop and Wait100
Go Back N 100
Stop and Wait10
10-9 10-8 10-7 10-6 10-5 10-4 10-3 10-2 10-1
p
Delay-Bandwidth product = 10, 100