Professional Documents
Culture Documents
Computer Networks
Error Recovery
ARQ
Stop-and-Wait, Go-Back-End, Selective Repeat
Analyzing ARQ Efficiency
Reading: 5.1-5.2
Error Recovery
Page 1
Error Control
Two factors:
1) Correctness
- Do we succeed in releasing each packet, once and only
once, without errors?
2) Efficiency
- How much BW is wasted by unnecessary waiting and
unnecessary retransmission
Assumptions
To analyze different retransmission strategies,
we make the following assumptions:
1. The receiver knows when frames start and end.
2. All frames containing transmission errors are detected
3. Each transmitted frame experiences non-zero delay
before arriving at receiver. Some frames might be
lost. Those that arrive are assumed to arrive in the
same order as transmitted (with or without errors).
1 2 3 4 5
Node A
t
Lost X
Node B
X
Error detected
Chuah, Fall 2004 4
Page 2
Stop-and-Wait
Basic idea:
- Sender A transmits a packet, then wait
- If frame is error -free, B sends acknowledgement (ACK),
else, B sends a negative acknowledgement (NACK)
- Sender A sends next packet or retransmit when it
receives ACK or NACK
P P
Node A
t
ACK
Node B
Does this frame contain packet 0 or 1?
Release 1 st packet
to higher layer
Page 3
Potential problems with the basic scheme
Stop-and-Wait ARQ
Timeout Timeout
Sequence Number
(SN)
t
0 0 1 1
Node A
Note:
- Node A delays retransmitting packet 1 on the second
request of it to avoid unnecessary retransmission.
Page 4
Alternating Bit Protocol
Stop-And-Wait principles
Uses timers, seqnos (0/1), error detection bits
Frames and Acks are numbered with
- Alternating 0 and 1
At each instant, the receiver
- Expects a particular seqno
- Discards frames with wrong/unexpected seqno
Stop-and-Wait ARQ
1 t
0 1 0
Node A
Page 5
Problem with Stop-and-Wait
Sender Receiver
Pipelining
Page 6
Pipelined Protocols
Window-based ARQs
Idea:
- Allow Sender to keep transmitting a window of
packets while waiting for ACKs
Another function of sliding window protocols =>
Flow Control
- What happens if the sender tries to transmit faster than
the receiver can accept?
- Data will be lost unless flow control is implemented
- We will get back to this when we talk about TCP
Page 7
Sliding Window Protocols: Some Definitions
Sender Window: Keeps track of SNs for frames that have been sent
but not yet acknowledged.
Page 8
Maximum Receiver Window Size
Page 9
What About Errors?
Go-Back-N Protocol
Sender keeps copy of up to W S outstanding packets
- k-bit sequence number, SN in packet header
When the receiver notices a missing/erroneous frame
- It discards ALL frames with greater SNs and sends no ACK
Sender timeout(i):
- retransmit all the frames in its sending window (packet i and all
frames after that with higher SNs )
Cumulative ACK
- ACK(i): ACKs all packets up to, including SN # i
WS
Page 10
Go-Back-N: Example
Consider W S = 4
Sender keeps copy of up to 4 outstanding packets
0 0 0 0 1 2 3 4
1 1 1 2 3 4 5
2 2 3 4 5
t
Node A 3 4 5
0 1 2 3 4 5
0 1 2 3
Node B
OK OK OK OK
Go-Back-N: Example 1
Rule: when error occurs, retransmit packet plus
all subsequent packets
Timeout
0 0 0 0 0 0 0 0
1 1 1 1 1 1
2 2 2 2
t
Node A 3 3
0 1 2 3 0 1 2 3
X
0 1 2 3
Node B
Discard!
Receiver does not need to buffer packets
- WR = 1
Chuah, Fall 2004 22
Page 11
Go-Back-N: Example 2
Rule: when error occurs, retransmit packet plus
all subsequent packets
Timeout
0 0 0 0 1 2 2 2
1 1 1 2 3 3
2 2 3 4
t
Node A 3 4
0 1 2 3 2 3
4
X
0 1 2 3
Node B
Discard!
0 0 0 0 1 2 2 2
1 1 1 2 3 3
2 2 3 4 t
3 4
Node A
0 1 2 3 2 3
X 4
NACK
0 1 2 3
Node B
Discard!
Page 12
Remarks on Go-Back-N
Selective Repeat
Sender only resends packets for which ACK not received, but not
all its successors
- Sender timer for each unACKedpacket
Sender window
- N consecutive SNs
- limits SNs of sent, unACKed pkts
Page 13
Selective Repeat ARQ
As in Go-Back-N
- Packet sent when available up to window limit
Unlike Go-Back-N
- Out-of-order (but otherwise correct) is ACKed
- Receiver: buffers out-of-order packets
- Sender: on timeout of packet k, retransmit just k
Comments
- More receiver buffering than Go-Back-N
- More complicated buffer management by both sides
- Saves bandwidth
no need to retransmit correctly received packets
Timeout
0 0 0 0 0 0 0 0 4
1 1 1 1
2 2 2 2
t
Node A 3 3 3 3
0 1 2 3 0 4
X
1 2 3 0
Node B
OK OK OK OK
Receiver Buffer 1 1 1
2 2
3 Release packet 0,1,2,3 to upper layer
Page 14
Selective Repeat: Example 2
Timeout
0 0 0 0 1 2 2 2 2 6
1 1 1 2 3
2 2 3 4 4
Node A 3 4 5 5 5
0 1 2 3 2 6
4 5
X
3 4 5 2
0 1
Node B
OK OK OK OK OK OK
3 3 3
Release 4 4
5 Release 2,3,4,5
SW: Sender
Assign sequence number to each frame (SeqNum)
Maintain three state variables:
- send window size (SWS)
- last acknowledgment received (LAR)
- last frame sent (LFS)
Maintain invariant: LFS - LAR <= SWS
SWS
LAR LFS
Page 15
SW: Receiver
Maintain three state variables
- receive window size (RWS)
- largest frame acceptable (LAF)
- last frame received (LFR)
Maintain invariant: LAF - LFR <= RWS
RWS
LFR LAF
Summary
Page 16
Analyzing Efficiency of ARQ
Protocols
Let
t proc = time to process a packet ~ 0 at a node
t prop = one way propagation time
t pkt = transmission time of a packet
Efficiency or Utilization:
E= time spent transmitting useful data _
total time spent (incl. waiting & retransmissions)
S Proc
TransP Trans_P
Node A
Node B
TransA
Prop Proc Prop
Efficiency = ________________TransP________________
TransP + 2(Prop + Proc) + TransA
= TransP
S
Page 17
Efficiency with Error
Timeout, T
p
S
A 1-p B
E[] = p/(1-p)T + S
Efficiency = __TransP_
E[]
Choose T ~ S => Efficiency = (1-p)TransP
S
Chuah, Fall 2004 35
Without error,
E = ___tpkt_____
tpkt + 2 tprop
Let a = tprop / t pkt , E = 1/(1+2a)
Page 18
Selective Repeat Protocol: Efficiency Analysis
S
W
Node A
Node B
Without error:
Efficiency = min { (W x TransP)/S , 1 }
Analysis (Contd)
S
W = infinity
Node A
Node B
Page 19
Efficiency of Sliding Window Protocol
Let
W = window size
S = timeout, and assume S > tpkt + 2 tprop
So, if W. t pkt > t pkt + 2 t prop , the link is always full with packets.
Without error,
- E=1 if W > 2a+1
- E = __W_ if W < 2a+1
2a+1
Page 20
Efficiency of Go-Back-N
Similar to the case of SR, except that we have to be careful
in approximating Nr. Each error requires a retransmission
of K frames rather than just one frame.
Nr = f ( i) p i1 (1 p )
i =1
So,
Nr = (1+ K + Ki) pi 1 (1 p)
i=1
= (1+ K )(1 p) pi 1 + K (1 p) ipi 1
i =1 i =1
1 1
= (1+ K )(1 p ) + K (1 p )
1 p (1 p) 2
1 p + Kp
=
(1 p)
Efficiency of Go-Back-N
K depends on the window size!
- K = 2a+1 if W > 2a+1
- K=W if W<2a+1
Efficiency of Go-Back-N with probability of error p:
- E (GBN, p) = 1/N r if W > 2a+1
- E (GBN, p) = _ W if W < 2a+1
N r ( 2a+1)
1 p 1 p
If W > 2a+1, E (GBN, p) = =
1 p + ( 2a + 1) p 1+ 2ap
W W (1 p)
If W < 2a+1, E (GBN, p) = =
1 p + Wp (1 p + Wp )( 2a + 1)
( 2a + 1)
1 p
Page 21