Flow and Error Control - 4
Flow and Error Control - 4
Flow and Error Control - 4
Flow Control
Flow control tells the sender how much data to send. It makes the sender wait for
some sort of an acknowledgment (ACK) before continuing to send more data.
There are two primary methods of flow control: Stop-and-wait, and Sliding
Window.
• Flow control coordinates the amount of data that can be sent before receiving
acknowledgement
• It is one of the most important functions of data link layer.
• Flow control is a set of procedures that tells the sender how much data it can
transmit before it must wait for an acknowledgement from the receiver.
• Receiver has a limited speed at which it can process incoming data and a
limited amount of memory in which to store incoming data.
• Receiver must inform the sender before the limits are reached and request
that the transmitter to send fewer frames or stop temporarily.
• Since the rate of processing is often slower than the rate of transmission,
receiver has a block of memory (buffer) for storing incoming data until they
are processed.
Stop And Wait is a simple scheme, where the sender has to wait for an
acknowledgment of every frame that it sends. It sends a frame, waits for
34
Computer Networks - Fourth Year
acknowledgment, and then it sends another frame, and again, waits for
acknowledgment. The trouble with this scheme is that it’s very slow. For every
frame that is sent, there needs to be an acknowledgment, which takes a similar
amount of propagation time to get back to the sender. The advantage is simplicity.
Sliding Window
The whole idea behind Sliding Window is not to wait for an acknowledgment for
individual frames, but to send a few frames (and then get an acknowledgment that
acknowledges several frames at the same time).
It works by having the sender and receiver have a “window” of frames. The sender
can send as many frames as would fit into a window. The receiver, upon receiving
enough frames, will respond with an acknowledgment of all frames up to a certain
point in the window. The window it then said to “slide”, and the whole thing starts
again (the sender sends more frames, the receiver gets more frames, sends an
acknowledgment of those frames, etc.)
Each frame has to be numbered in relation to the sliding window. For a window of
size N, frames get a number from 0 to N − 1. Subsequent frames get a number mod
N.
Error Control
Error control involves retransmission of the lost, damaged, or corrupted frame. The
scheme is called ARQ, for Automatic Repeat Request. The general scheme works
in this way: the sender sends the data. If data arrives without any problems, the
receiver sends out an ACK message (acknowledgment). If the data has a problem
(corrupt), the receiver sends out an NAK (negative acknowledgment). Upon getting
a NAK message, the sender retransmits. There is also a timer; which allows for data
retransmission if the original message or ACK or NAK got lost.
35
Computer Networks - Fourth Year
There are several forms: Stop-and-Wait ARQ, and Sliding Window ARQ.
• Stop-and-Wait
• Go-Back-N ARQ
• Selective-Repeat ARQ
1. Stop-and-Wait
Sender keeps a copy of the last frame until it receives an acknowledgement.
For identification, both data frames and acknowledgements (ACK) frames
are numbered alternatively 0 and 1.
Sender has a control variable (S) that holds the number of the recently sent
frame. (0 or 1)
Receiver has a control variable that holds the number of the next frame
expected (0 or 1).
Sender starts a timer when it sends a frame. If an ACK is not received within
a allocated time period, the sender assumes that the frame was lost or
damaged and resends it
Receiver send only positive ACK if the frame is intact.
ACK number always defines the number of the next expected frame
36
Computer Networks - Fourth Year
Stop-and-Wait ARQ,
Damaged frame:
• When a receiver receives a damaged frame, it discards.
• After the timer at the sender expires, another copy of frame 1 is sent.
Lost Frame:
37
Computer Networks - Fourth Year
38
Computer Networks - Fourth Year
Piggybacking
39
Computer Networks - Fourth Year
Disadvantage of Stop-and-Wait
• In stop-and-wait, at any point in time, there is only one frame that is sent and
waiting to be acknowledged.
• This is not a good use of transmission medium.
• To improve efficiency, multiple frames should be in transition while waiting
for ACK.
• Two protocol use the above concept,
– Go-Back-N ARQ
– Selective Repeat ARQ
2. Go-Back-N ARQ
• We can send up to W frames before worrying about ACKs.
• We keep a copy of these frames until the ACKs arrive.
• This procedure requires additional features to be added to Stop-and-Wait
ARQ.
Sequence Numbers
• Frames from a sender are numbered sequentially.
• We need to set a limit since we need to include the sequence number of each
frame in the header.
• If the header of the frame allows m bits for sequence number, the sequence
numbers range from 0 to 2m – 1. for m = 3, sequence numbers are: 1, 2, 3, 4,
5, 6, 7.
• We can repeat the sequence number.
• Sequence numbers are:
0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, …
40
Computer Networks - Fourth Year
• The size of the window is at most 2m -1 where m is the number of bits for the
sequence number.
• Size of the window can be variable, e.g. TCP.
• The window slides to include new unsent frames when the correct ACKs are
received
Control Variables
• Sender has 3 variables: S, SF, and SL
• S holds the sequence number of recently sent frame
• SF holds the sequence number of the first frame
41
Computer Networks - Fourth Year
42
Computer Networks - Fourth Year
43
Computer Networks - Fourth Year
• If ACK1, ACK2, and ACk3 are lost, ACK4 covers them if it arrives before
the timer expires.
• If ACK4 arrives after time-out, the last frame and all the frames after that are
resent.
• Receiver never resends an ACK.
• A delayed ACK also triggers the resending of frames
Lost Frame
Example
44
Computer Networks - Fourth Year
Accepts as t
1st frame
in the
next
cycle‐an
error
• Go-Back-N ARQ simplifies the process at the receiver site. Receiver only
keeps track of only one variable, and there is no need to buffer out-of-order
frames, they are simply discarded.
• However, Go-Back-N ARQ protocol is inefficient for noisy link. It
bandwidth inefficient and slows down the transmission.
• In Selective Repeat ARQ, only the damaged frame is resent. More bandwidth
efficient but more complex processing at receiver.
• It defines a negative ACK (NAK) to report the sequence number of a
damaged frame before the timer expires.
45
Computer Networks - Fourth Year
46
Computer Networks - Fourth Year
47