EEC 189Q

:
Computer Networks

Error Recovery
ARQ
Stop-and-Wait, Go-Back-End, Selective Repeat
Analyzing ARQ Efficiency

Reading: 5.1-5.2

Error Recovery

§ Reliable delivery over unreliable channel
- How to recover from corrupted/lost packets
§ Error detection and retransmission
- With acknowledgements and timeouts
- Also called Automatic Repeat Request (ARQ)
- Retransmission incurs round trip delay
§ Error correcting codes
- Also called Forward Error Correction (FEC)
- No sender retransmission required

Chuah, Fall 2004 2

Page 1

Error Control

§ Automatic Repeat Request (ARQ)
- Basic concept: detect error and request retransmission
of those erroneous frames
- Different retransmission strategies:
• Stop-and-wait, Go-back-N, Selective repeat

§ 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

Chuah, Fall 2004 3

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

When node A times out. B sends acknowledgement (ACK).Sender A sends next packet or retransmit when it receives ACK or NACK § Problem 1: ACK/NACK could get lost too! . it retransmits the packet Chuah. B sends a negative acknowledgement (NACK) . else. Fall 2004 6 Page 3 . Stop-and-Wait § Basic idea: .Solution: Timer at sender! . then wait .Sender A transmits a packet.If frame is error -free. Fall 2004 5 Potential problems with the basic scheme § Unnumbered frames have problems! Node A times out and resends frame P P Node A t ACK Node B Does this frame contain packet 0 or 1? Release 1 st packet to higher layer § Solution: Add sequence number in the frame header Chuah.

Fall 2004 7 Stop-and-Wait ARQ Timeout Timeout Sequence Number (SN) t 0 0 1 1 Node A RN=1 RN=1 RN=2 Node B X Request Number (RN) Release Discard duplicate Packet 0 § Note: .Node A delays retransmitting packet 1 on the second request of it to avoid unnecessary retransmission. Fall 2004 8 Page 4 . Chuah. Potential problems with the basic scheme § Not good enough => Unnumbered ACKs also have problems! Node A times out and resends frame Sequence Number 0 0 1 2 t Node A ACK ACK NACK Node B X Release Discard duplicate Packet 0 § Solution: Return Sequence # of the next packet expected instead of ACK/NACK Chuah.

Fall 2004 10 Page 5 . error detection bits § Frames and Ack’s are numbered with . the receiver . seqno’s (0/1).Alternating 0 and 1 § At each instant.Modulo 2 is sufficient! Timeout 1 t 0 1 0 Node A RN=1 RN=0 RN=0 RN=1 Node B Release Release Discard Packet 0 Packet 1 Chuah.Discards frames with wrong/unexpected seqno Chuah. Alternating Bit Protocol § Stop-And-Wait principles § Uses timers.Send number modulo an integer . Fall 2004 9 Stop-and-Wait ARQ § Remaining problem: SN & RN can become arbitrarily large with increasing time .Expects a particular seqno .

called window Sender Receiver … Time … Chuah.5Mbps link x 45ms RTT = 67.1.Utilization is low when bandwidth-delay product is large => not very efficient § Example .5Kb (8KB) . Fall 2004 12 Page 6 . Problem with Stop-and-Wait Sender Receiver § Can’t keep the pipe full . Fall 2004 11 Pipelining § Allow multiple outstanding (un-ACKed) frames § Upper bound on un-ACKed frames.1KB frames implies 1/8th link utilization § Can we do something else while waiting for an ACK? Chuah.

Range of sequence numbers must be increased .Go-Back -N and Selective-Repeat Chuah.Data will be lost unless flow control is implemented .What happens if the sender tries to transmit faster than the receiver can accept? .Buffering at sender and/or receiver § Two generic forms of pipelined (sliding window) protocols: .Allow Sender to keep transmitting a “window” of packets while waiting for ACKs § Another function of sliding window protocols => Flow Control . Pipelined Protocols Sender allows multiple. Fall 2004 13 Window-based ARQs § Idea: . yet-to-be-acked pkts . “in-flight”. Fall 2004 14 Page 7 .We will get back to this when we talk about TCP Chuah.

§ Receiver Window: Keeps track of sequence numbers for frames that the receiver is allowed to accept § Maximum Sender Window Size (W S): The maximum number of frames the sender can transmit without receiving any ACKs § Maximum Receiver Window Size (W R): The maximum number of frames the receiver may receive before returning an ACK to the sender Chuah. the sender can transmit up to WS frames before being blocked. the sender waits for an ACK before sending another frame. Fall 2004 15 Maximum Sender Window Size § With maximum window size of 1.allows sender to transmit several frames before receiving an ACK .also a form of “pipelining” => keeps the link from being idle Chuah. . Fall 2004 16 Page 8 . Sliding Window Protocols: Some Definitions § Sequence Number (SN): each frame is assigned a SN that is incremented as each frame is transmitted § Sender Window: Keeps track of SNs for frames that have been sent but not yet acknowledged. § With maximum window size of WS .

the receiver window always remains at its maximum size. the receiver must receive and process every frame in sequence. § With a maximum window size of WR. Maximum Receiver Window Size § With a maximum window size of 1. § Unlike the sender window. Fall 2004 17 Sliding Window Protocol: General Remarks § The sending and receiving windows do not necessarily have the same maximum size.Allow “piggybacking” of ACK onto the header of an outgoing data frame in the reverse direction • Full duplex transmission Chuah. Fall 2004 18 Page 9 . Chuah.The receiver can still accept and buffer frames received after a frame that is lost/erroneous. § The sender window’s size grows and shrinks as frames are transmitted and acknowledged. . § Any frame whose SN falls outside of the receiver window is discarded by the receiver. the receiver can receive and process up to frames before acknowledging them. .

Selective Repeat Chuah. What About Errors? § What if a data or acknowledgement frame is lost when using a sliding window protocol? .retransmit all the frames in its sending window (packet i and all frames after that with higher SNs ) § Cumulative ACK .It discards ALL frames with greater SNs and sends no ACK § Sender timeout(i): . Fall 2004 19 Go-Back-N Protocol § Sender keeps copy of up to W S outstanding packets .k-bit sequence number.Go-Back-N . Fall 2004 20 Page 10 . SN in packet header § When the receiver notices a missing/erroneous frame .ACK(i): ACKs all packets up to. including SN # i WS Chuah.

WR = 1 Chuah. Fall 2004 22 Page 11 . 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 Chuah. Fall 2004 21 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 .

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! Chuah. Fall 2004 23 Go-Back-N with Negative ACKs 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! Chuah. Fall 2004 24 Page 12 .

but not all its successors .When receiver notices a skipped SN.. the sender will spend time retransmitting frames the receiver has already seen! Chuah. it keeps acknowledging the last good SN § Sender only resends packets for which ACK not received.Sender timer for each unACKedpacket § Sender window . for eventual in-order delivery to upper layer . It is wasteful! If there are errors.buffers all the correct frames that arrive following the bad one. Remarks on Go-Back-N § Go-Back-N can recover from missing frames But .N consecutive SN’s . unACKed pkts Chuah... Fall 2004 25 Selective Repeat § Receiver individually acknowledges all correctly received packets . Fall 2004 26 Page 13 .limits SN’s of sent.

Fall 2004 28 Page 14 .More complicated buffer management by both sides . retransmit just k § Comments .W S has been acknowledged (to avoid overloading receiver buffer) 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.3 to upper layer Chuah.Out-of-order (but otherwise correct) is ACKed . Selective Repeat ARQ § As in Go-Back-N .2.Packet sent when available up to window limit § Unlike Go-Back-N .Sender: on timeout of packet k.Saves bandwidth • no need to retransmit correctly received packets Chuah.More receiver buffering than Go-Back-N .Receiver: buffers out-of-order packets . Fall 2004 27 Selective Repeat: Example 1 § Packet n must not be sent until packet n.

LAR <= SWS ≤ SWS … … LAR LFS § Advance LAR when ACK arrives § Buffer up to SWS frames Chuah. Fall 2004 30 Page 15 .5 Chuah. Fall 2004 29 SW: Sender § Assign sequence number to each frame (SeqNum) § Maintain three state variables: .4.send window size (SWS) . 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.last frame sent (LFS) § Maintain invariant: LFS .last acknowledgment received (LAR) .3.

Two important factors: a) Correctness (safety & liveness) b) Efficiency Chuah. Fall 2004 32 Page 16 .LFR <= RWS ≤ RWS … … LFR LAF § Frame SeqNum arrives: .receive window size (RWS) .Stop-and-wait.if LFR < SeqNum < = LAF accept .largest frame acceptable (LAF) .if SeqNum < = LFR or SeqNum > LAF discarded § Send cumulative ACKs Chuah. Go-Bank-N. Selective Repeat .last frame received (LFR) § Maintain invariant: LAF . Fall 2004 31 Summary § Data Link Control (DLC) Layer takes care of: .Framing . SW: Receiver § Maintain three state variables .Error correction or retransmission § ARQ Retransmission Strategies: .Error detection .

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. Fall 2004 34 Page 17 . waiting & retransmissions) Efficiency Without Errors S Proc TransP Trans_P Node A Node B TransA Prop Proc Prop Efficiency = ________________TransP________________ TransP + 2(Prop + Proc) + TransA = TransP S Chuah.

E = ___t pkt_____ Nr (t pkt + 2 tprop ) where Nr = expected # of transmission for a frame. E (stop-and-wait. Efficiency with Error Timeout. Fall 2004 35 Efficiency of Stop-and-Wait ARQ § Without error. E = ___tpkt_____ tpkt + 2 tprop Let a = tprop / t pkt . E = 1/(1+2a) § With Error p. Fall 2004 36 Page 18 . T p S A 1-p B § Let p = Prob (error) & τ = time to send a packet § E[τ] = (1-p)S + p (T+E[τ]) E[τ] = p/(1-p)T + S § Efficiency = __TransP_ E[τ] § Choose T ~ S => Efficiency = (1-p)TransP S Chuah. Nr = 1/(1-p) So. p) = _1-p_ 1+2a Chuah.

Fall 2004 37 Analysis (Cont’d) S W = infinity Node A Node B § Let p = Prob(error). Selective Repeat Protocol: Efficiency Analysis S W Node A Node B § Without error: Efficiency = min { (W x TransP)/S . 1 } Chuah. W = infinity _1__ § Expected number of attempts to send a packet =? 1-p § Efficiency = ? ____TransP_____ = 1 . Fall 2004 38 Page 19 .p TransP/(1-p) Chuah.

the error free equation needs to be divided by N r which is 1/(1-p): . p) = (1-P) if W > 2a+1 .E=1 if W > 2a+1 . § Without error. t pkt > t pkt + 2 t prop . if W. . Fall 2004 40 Page 20 . the link is always “full” with packets. and assume S > tpkt + 2 tprop So. Efficiency of Sliding Window Protocol Let § W = window size § S = timeout.E = __W_ if W < 2a+1 2a+1 Chuah. Fall 2004 39 Efficiency of Selective Repeat (SR) § With Error p.E (SR. p) = _W(1-p_) if W < 2a+1 2a+1 Chuah.E (SR.

E (GBN.E (GBN.K=W if W<2a+1 § Efficiency of Go-Back-N with probability of error p: . p) = _ W if W < 2a+1 N r ( 2a+1) 1− p 1− p § If W > 2a+1. p) = 1/N r if W > 2a+1 .K = 2a+1 if W > 2a+1 . ∞ Nr = ∑ f ( i) p i−1 (1 − p ) i =1 where f(i) = total # of frames transmitted if original frame must be transmitted i times f (i ) = 1 + (i − 1) K = (1 − K ) + Ki So. Efficiency of Go-Back-N § Similar to the case of SR. p) = = 1− p + Wp (1− p + Wp )( 2a + 1) ( 2a + 1) 1− p Chuah. except that we have to be careful in approximating Nr. Each error requires a retransmission of K frames rather than just one frame. p) = = 1− p + ( 2a + 1) p 1+ 2ap W W (1− p) § If W < 2a+1. Fall 2004 41 Efficiency of Go-Back-N § K depends on the window size! . E (GBN. E (GBN. ∞ 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) Chuah. Fall 2004 42 Page 21 .