3error Control Mechanism
3error Control Mechanism
3error Control Mechanism
Stop‐and‐Wait Algorithm
Stop‐and‐Wait Algorithm
1
9/22/2014
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