0% found this document useful (0 votes)
13 views

09 Data Link LayerFlow Contro2 (2)

The document discusses the flow and error control mechanisms in the data link layer of computer networks, emphasizing the importance of matching sender and receiver speeds. It outlines various protocols for flow control, including Stop and Wait, Sliding Window, Go-Back-N, and Selective Repeat ARQ, detailing their operational principles and assumptions. Additionally, it introduces the concept of piggybacking for efficient acknowledgment in full-duplex communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

09 Data Link LayerFlow Contro2 (2)

The document discusses the flow and error control mechanisms in the data link layer of computer networks, emphasizing the importance of matching sender and receiver speeds. It outlines various protocols for flow control, including Stop and Wait, Sliding Window, Go-Back-N, and Selective Repeat ARQ, detailing their operational principles and assumptions. Additionally, it introduces the concept of piggybacking for efficient acknowledgment in full-duplex communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 58

CAP256: Computer Network

Data Link Layer – Flow Control

Dr. Manmohan Sharma


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 N ACK 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
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.
sliding window protocols allow a selected
number of packets, the window, to be sent
without having to wait for an ACK. Each
packet receives a sequence number, and
the ACKs send back that number.
The protocol keeps track of which packets
have been ACKed, and when they are
received, sends more packets.
Go Back-N ARQ

A station sends a series of frames sequentially


up to a maximum number
The number of unacknowledged frames
outstanding is determined by window size, using
the sliding window flow control technique.
In case of no error, the destination will
acknowledge incoming frames as usual.
In the Go-Back-N Protocol, the sequence
numbers are modulo 2m, where m is the size of
the sequence number field in bits.
The send window is an abstract concept defining
an imaginary box of size 2m − 1 with three
variables: Sf, Sn, and Ssize.
The send window can slide one or more slots when
a valid acknowledgment arrives.
The receive window is an abstract concept defining an
imaginary box of size 1 with one single variable Rn. The
window slides when a correct frame has arrived; sliding
occurs one slot at a time.
Design of Go-Back-N ARQ
Window size for Go-Back-N ARQ
Go-Back-N sender algorithm
Go-Back-N receiver algorithm
CASE-1
 Figure on next slide shows an example of Go-Back-N ARQ
flow control algorithm.
 This is an example of a case where the forward channel
is reliable, but the reverse is not. No data frames are
lost, but some ACKs are delayed and one is lost.
 The example also shows how cumulative
acknowledgments can help if acknowledgments are
delayed or lost.
 After initialization, there are seven sender events.
Request events are triggered by data from the network
layer; arrival events are triggered by acknowledgments
from the physical layer.
 There is no time-out event here because all outstanding
frames are acknowledged before the timer expires. Note
that although ACK 2 is lost, ACK 3 serves as both ACK 2
and ACK 3.
CASE-2
 Figure on next slide shows what happens when a frame is lost
Frames 0, 1, 2, and 3 are sent. However, frame 1 is lost.
 The receiver receives frames 2 and 3, but they are discarded
because they are received out of order.
 The sender receives no acknowledgment about frames 1, 2, or 3.
Its timer finally expires.
 The sender sends all outstanding frames (1, 2, and 3) because it
does not know what is wrong. Note that the resending of frames
1, 2, and 3 is the response to one single event.
 When the sender is responding to this event, it cannot accept the
triggering of other events. This means that when ACK 2 arrives,
the sender is still busy with sending frame 3.
 The physical layer must wait until this event is completed and
the data link layer goes back to its sleeping state.
 A vertical line is used to indicate the delay. It is the same story
with ACK 3; but when ACK 3 arrives, the sender is busy
responding to ACK 2.
 It happens again when ACK 4 arrives. Note that before the
second timer expires, all outstanding frames have been sent and
the timer is stopped.
Performance of Go-Back-N ARQ
Go-Back-N ARQ simplifies the process at the
receiver site.
The receiver keeps track of only one variable,
and there is no need to buffer out-of-order
frames; they are simply discarded.
However, this protocol is very inefficient for a
noisy link. In a noisy link a frame has a higher
probability of damage, which means the
resending of multiple frames.
This resending uses up the bandwidth and slows
down the transmission.
Selective Repeat ARQ
For noisy links, there is another mechanism that
does not resend N frames when just one frame is
damaged; only the damaged frame is resent.
This mechanism is called Selective Repeat ARQ.
It is more efficient for noisy links, but the
processing at the receiver is more complex.
The Selective Repeat Protocol also uses two
windows: a send window and a receive window.
In Selective Repeat ARQ, the size of the
sender and receiver window must be at
most one-half of 2m-1.
Sender-site Selective Repeat algorithm
Receiver-site Selective Repeat algorithm
 Figure on the next slides shows the situation. One main
difference is the number of timers.
 Here, each frame sent or resent needs a timer, which means
that the timers need to be numbered (0, 1, 2, and 3). The timer
for frame 0 starts at the first request, but stops when the ACK
for this frame arrives.
 The timer for frame 1 starts at the second request, restarts
when a NAK arrives, and finally stops when the last ACK arrives.
 The other two timers start when the corresponding frames are
sent and stop at the last arrival event.
 At the receiver site we need to distinguish between the
acceptance of a frame and its delivery to the network layer.
 At the second arrival, frame 2 arrives and is stored and marked,
but it cannot be delivered because frame 1 is missing.
 At the next arrival, frame 3 arrives and is marked and stored,
but still none of the frames can be delivered.
 Only at the last arrival, when finally a copy of frame 1 arrives,
can frames 1, 2, and 3 be delivered to the network layer.
 There are two conditions for the delivery of frames to the
network layer:
 First, a set of consecutive frames must have arrived.
 Second, the set starts from the beginning of the window.
 Another important point is that a NAK is sent after the
second arrival, but not after the third, although both
situations look the same.
 The reason is that the protocol does not want to crowd
the network with unnecessary NAKs and unnecessary
resent frames.
 The second NAK would still be NAK1 to inform the
sender to resend frame 1 again; this has already been
done.
 The first NAK sent is remembered (using the nakSent
variable) and is not sent again until the frame slides. A
NAK is sent once for each window position and defines
the first slot in the window.
 The next point is about the ACKs. Notice that only two
ACKs are sent here. The first one acknowledges only the
first frame; the second one acknowledges three frames.
 In Selective Repeat, ACKs are sent when data are
delivered to the network layer. If the data belonging to
n frames are delivered in one shot, only one ACK is sent
for all of them.
Piggybacking
In reliable full - duplex data transmission, the technique of
hooking up acknowledgments onto outgoing data frames
is called piggybacking.
Communications are mostly full – duplex in nature, i.e.
data transmission occurs in both directions.
A method to achieve full – duplex communication is to
consider both the communication as a pair of simplex
communication.
Each link comprises a forward channel for sending data
and a reverse channel for sending acknowledgments.
However, in the above arrangement, traffic load doubles
for each data unit that is transmitted. Half of all data
transmission comprise of transmission of
acknowledgments.
Piggybacking a solution that provides better utilization of
bandwidth.
Working Principle
 Suppose that there are two communication stations X and Y. The
data frames transmitted have an acknowledgment
field, ack field that is of a few bits length. Additionally, there are
frames for sending acknowledgments, ACK frames. The purpose
is to minimize the ACK frames.
 The three principles governing piggybacking when the station X
wants to communicate with station Y are:
 If station X has both data and acknowledgment to send, it sends a
data frame with the ack field containing the sequence number of the
frame to be acknowledged.
 If station X has only an acknowledgment to send, it waits for a finite
period of time to see whether a data frame is available to be sent. If
a data frame becomes available, then it piggybacks the
acknowledgment with it. Otherwise, it sends an ACK frame.
 If station X has only a data frame to send, it adds the last
acknowledgment with it. The station Y discards all duplicate
acknowledgments. Alternatively, station X may send the data frame
with the ack field containing a bit combination denoting no
acknowledgment.
Design of piggybacking in Go-Back-N
ARQ

You might also like