10 Data Link LayerFlow Control
10 Data Link LayerFlow Control
Professor
School of Computer Applications
Lovely Professional University
Flow and Error Control
Data-link layer is responsible for implementation of point-to-point
flow and error control mechanism.
When a data frame (Layer-2 data) is sent from one host to another
over a single medium, it is required that the sender and receiver
should work at the same speed.
That is, sender sends at a speed on which the receiver can process and accept the
data.
What if the speed (hardware/software) of the sender or receiver
differs?
If sender is sending too fast the receiver may be overloaded, (swamped) and data
may be lost.
Flow Control
Flow control refers to a set of procedures used to restrict
the amount of data that the sender can send before
waiting for acknowledgment.
Two types of mechanisms can be deployed to control the flow:
Stop and Wait: This flow control mechanism forces the sender after
transmitting a data frame to stop and wait until the acknowledgement
of the data-frame sent is received.
Sliding Window: In this flow control mechanism, both sender and
receiver agree on the number of data-frames after which the
acknowledgement should be sent. As we learnt, stop and wait flow
control mechanism wastes resources, this protocol tries to make use of
underlying resources as much as possible.
Error Control
When data-frame is transmitted, there is a probability that data-frame may be
lost in the transit or it is received corrupted.
In both cases, the receiver does not receive the correct data-frame and sender
does not know anything about any loss. In such case, both sender and receiver are
equipped with some protocols which helps them to detect transit errors such as
loss of data-frame.
Hence, either the sender retransmits the data-frame or the receiver may request
to resend the previous data-frame.
Requirements for error control mechanism:
Error detection: The sender and receiver, either both or any, must ascertain that
there is some error in the transit.
Positive ACK :When the receiver receives a correct frame, it should acknowledge it.
Negative ACK: When the receiver receives a damaged frame or a duplicate frame, it
sends a NACK back to the sender and the sender must retransmit the correct frame.
Retransmission: The sender maintains a clock and sets a timeout period. If an
acknowledgement of a data-frame previously transmitted does not arrive before the
timeout the sender retransmits the frame, thinking that the frame or it’s
acknowledgement is lost in transit.
Protocols used for Flow Control
Now let us see how the data link layer can combine framing,
flow control, and error control to achieve the delivery of data
from one node to another.
The protocols are normally implemented in software by using
one of the common programming languages.
Noiseless Channels
Noiseless channel is an ideal channel in which no frames are
lost, duplicated, or corrupted.
Two protocols are available for this type of channel.
Simplest Protocol: This type of protocol has no flow or
error control
Stop-and-Wait Protocol: In this type of protocol sender
sends one frame, stops until it receives agree from receiver
and then sends the next frame
Simplest Protocol
Our first protocol, which we call the Simplest Protocol, is one that
has no flow or error control. Like other protocols, it is a
unidirectional protocol in which data frames are traveling in only
one direction-from the sender to receiver.
The receiver can immediately handle any frame it receives with a
processing time that is small enough to be negligible.
The data link layer of the receiver immediately removes the header
from the frame and hands the data packet to network layer, which
can also accept the packet immediately.
In other words, the receiver can never be fill out with incoming
frames.
Assumptions for Simplest Protocol
The channel is a perfect noiseless channel.
Hence an ideal channel in which no frames are lost, duplicated, or
corrupted.
No flow control and error control used.
It is a unidirectional protocol in which data frames are traveling in
only one direction- from the sender to receiver.
Both transmitting and receiving network layer are always ready.
Processing time that is small enough to be negligible.
Infinite buffer space is available.
Sender-site algorithm for the simplest protocol
Receiver-site algorithm for the simplest protocol
Following figure shows an example of communication using this
protocol. It is very simple. The sender sends a sequence of frames
without even thinking about the receiver. To send three frames,
three events occur at the sender site and three events at the
receiver site. Note that the data frames are shown by tilted boxes;
the height of the box defines the transmission time difference
between the first bit and the last bit in the frame.
Stop and Wait Protocol
This flow control mechanism forces the sender after transmitting a
data frame to stop and wait until the acknowledgement of the data-
frame sent is received.
The following assumption has been made for developing the Stop-
and-Wait Protocol
The channel is a perfect noiseless channel.
Flow control used
It is a bidirectional protocol in which frames are traveling in both direction
Both transmitting and receiving network layer are always not ready.
Processing time considerable
Finite buffer space is available
The receiver may not be always ready to receive the next frame (finite buffer
storage).
Receiver sends a positive acknowledgment frame to sender to transmit the next
data frame which showed in the below figure(3.4).
Error-free communication channel assumed. No retransmissions used.
Sender-site algorithm for Stop-and-Wait Protocol
Receiver-site algorithm for Stop-and-Wait Protocol
Following figure shows an example of communication using this
protocol. It is still very simple. The sender sends one frame and
waits for feedback from the receiver. When the ACK arrives, the
sender sends the next frame. Note that sending two frames in the
protocol involves the sender in four events and the receiver in two
events.
Noisy Channels
Although the Stop-and-Wait Protocol gives us an idea of how to
add flow control to its predecessor, noiseless channels are non-
existent.
Three protocols are discussed to use error control while
transmission using noisy channels:
Stop-and-Wait Automatic Repeat Request
Go-Back-N Automatic Repeat Request
Selective Repeat Automatic Repeat Request
Stop-and-Wait ARQ
Automatic Repeat Request (ARQ), an error control method, is
incorporated with stop and wait flow control protocol.
Error correction in Stop-and-Wait is done by keeping a copy of the
sent frame and retransmitting of the frame when the timer expires
In Stop-and-Wait ARQ, we use sequence numbers to number the
frames.The sequence numbers are based on modulo-2 arithmetic.
In Stop-and-Wait ARQ the ARQ, acknowledgment number always
announces in modulo-2 arithmetic the sequence number of the next
frame expected.
Sender-site algorithm for Stop-and-Wait ARQ
Receiver-site algorithm for Stop-and-Wait ARQ Protocol
Following figure shows an example of Stop-and-Wait ARQ. Frame 0 is sent and
acknowledged. Frame 1 is lost and resent after the time-out. The resent frame 1 is
acknowledged and the timer stops. Frame 0 is sent and acknowledged, but the
acknowledgment is lost. The sender has no idea if the frame or the acknowledgment is
lost, so after the time-out, it resends frame 0, which is acknowledged.
Stop-and-Wait ARQ, lost frame
Stop-and-Wait ARQ, lost ACK frame
Sliding Window Protocols
Sliding window protocol is a flow control protocol.
It allows the sender to send multiple frames before needing the
acknowledgements.
Sender slides its window on receiving the acknowledgements for the
sent frames.
This allows the sender to send more frames.
It is called so because it involves sliding of sender’s window.
Working Principle
In these protocols, the sender has a buffer called the sending window
and the receiver has buffer called the receiving window.
The size of the sending window determines the sequence number of
the outbound frames.
If the field is m bits long, the sequence numbers start from 0 to 2m-1,
and then are repeated.
Therefore the window size is 2m-1.
Go Back-N ARQ