0% found this document useful (0 votes)
17 views4 pages

3error Control Mechanism

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 4

9/22/2014

Stop‐and‐Wait Algorithm

Timeline showing four different scenarios for the stop-and-wait algorithm.


(a) The ACK is received before the timer expires; (b) the original frame is lost; (c) the
ACK is lost; (d) the timeout fires too soon. In (c) and (d), duplicate frames are delivered

Stop‐and‐Wait Algorithm

Timeline for stop-and-wait with 1-bit sequence number

1
9/22/2014

Sliding Window Algorithm

Timeline for Sliding Window Algorithm

Sliding Window Algorithm: Sender

Sender maintains 3 variables and 1  Sender actions:
invariant: • Associate a timer with each 
• SWS (Send window size): Upper  transmitted frame; retransmit 
bound on the number of  the frame upon timeout.
outstanding (un‐ACKed) frames  • Buffer un‐ACKed frames.
that the sender can transmit
• LAR: last ACK received • When an ACK of frame K arrives, 
• LFS: last frame sent send up to (K ‐ LAR) frames and 
• Invariant: LFS – LAR ≤ SWS set LAR to K 

2
9/22/2014

Sliding Window Algorithm: Receiver

Receiver actions:
Receiver maintains 3 variables and  If LFR < SeqNum ≤ LAF, accept the frame
1 invariant: – If the frame is the next frame expected
• RWS (Receive Window Size):  – ACK the receipt of SeqNumToAck, 
which is the seq no. of the highest 
Upper bound on the number of  numbered frame received in order. 
out‐of‐order frames that the  (Cumulative ACK)
receiver is willing to accept – Set LFR = SeqNumToAck and LAF = 
• LAF: largest acceptable frame LFR + RWS
• LFR: last in‐order frame  – Else, no ACK needs to be sent. 
received However, resending last ACK allows 
early detection of frame loss.
• Invariant: LAF – LFR = RWS
Else discard the frame and ACK LFR

The Receiver Algorithm: An 
Example
• Suppose LFR = 5 and RWS = 4, so LAF = 9

• If frames 7 and 8 arrive, they will be buffered because they 
are within the receiver window
– No ACK will be sent since frame 6 is yet to arrive
– Frames 7 and 8 are out of order

• When frame 6 arrives (it is late because it was lost first time 
and had to be retransmitted)
– ACK 8 is sent 
– LFR is set to 8 and LAF is set to 12 

3
9/22/2014

Go‐Back‐N
Sender:  Receiver: 
• Associate a timer with  • If SeqNum = LFR + 1, 
each transmitted frame;  accept the frame
upon timeout for frame n,  – ACK the receipt of 
retransmit frame n and all  (LFR+1)
outstanding frames with 
higher seq no.  – LFR = LFR + 1
• Buffer un‐ACKed frames. • Else discard the frame 
and ACK LFR
• When an ACK of frame K 
arrives, send up to (K ‐ • No need to maintain LAF
LAR) frames and set LAR  because LAF=LFR+1 
to K 

You might also like