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

02 Flow Control

Control Flow chart

Uploaded by

Kid
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

02 Flow Control

Control Flow chart

Uploaded by

Kid
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 55

Flow Control and Error

Control
Unit -2
Flow Control and Error Control

Flow Control

 Flow control coordinates the amount of data


that can be sent before receiving
acknowledgement

 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


Computer Networks 29/04/2025 2
process incoming data and a limited amount
of memory in which to store incoming data.
Flow Control and Error
Control

Error Control

 It allows the receiver to inform the sender if a frame


is lost or damaged during transmission and
coordinates the retransmission of those frames by
the sender.

 Error control in the data link layer is based on


automatic repeat request (ARQ). Whenever an
error is detected, specified frames are
retransmitted. 29/04/2025

Computer Networks 3
Flow Control and Error Control

Protocols

(Data Link Elementary Protocols)


(Sliding Window Protocols)
Computer Networks 29/04/2025 4
Flow Control and Error Control
Data Link Elementary or Noiseless Channel
1. Simplest Protocol

The design of the simplest protocol with no flow or error


control

Computer Networks 29/04/2025 5


Flow Control and Error Control
Sender-site algorithm for the simplest protocol

Receiver-site algorithm for the simplest


protocol

Computer Networks 29/04/2025 6


Flow Control and Error Control
Example: Simplest Protocol

This diagram 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
Computer Networks 29/04/2025 7

time difference between the


first bit and the last bit in the
Flow Control and Error Control
2. Stop-and-Wait Protocol(Data Link Elementary)

The design of the stop-and-wait protocol

Computer Networks 29/04/2025 8


Flow Control and Error Control
Sender-site algorithm for the stop-and-wait protocol

Computer Networks 29/04/2025 9


Flow Control and Error Control
Receiver-site algorithm for the stop-and-wait protocol

Computer Networks 29/04/2025 10


Flow Control and Error Control
Example: Stop-and-Wait

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.

Computer Networks 29/04/2025 11


Flow Control and Error Control

Noisy Channel (Sliding Window Protocols)

 Sliding window refers to imaginary boxes at the


transmitter and the receiver.

 Window holds the frames at the both sides.

 Sender window provides upper limit on the number of


frames that can be transmitted before requiring an
acknowledgement.

 Receiver window corresponds to the set of frames ,it is


permitted to accept.
Computer Networks 29/04/2025 12
Flow Control and Error Control
Example: Send window for Go-Back-N ARQ

Computer Networks 29/04/2025 13


Flow Control and Error Control
Noisy Channel (Sliding Window Protocols)

1. Stop-and-Wait Automatic Repeat Request

 Sequence Number = 0 to -1, where m =number


of bits.

 Stop-and-wait is 1 bit sliding window. Sender


and receiver window size is 1 then m=1.

 Then the sequence number are 0, 1 , 0, 1, 0,


1……….
Computer Networks 29/04/2025 14
Flow Control and Error
Control
Design of Stop-and-Wait
ARQ

Computer Networks 29/04/2025 15


Flow Control and Error
Control
Sender-site algorithm for Stop-and-
Wait ARQ

Computer Networks 29/04/2025 16


Flow Control and Error
Control
Sender-site algorithm for Stop-and-
Wait ARQ

Computer Networks 29/04/2025 17


Flow Control and Error
Control
Receiver-site algorithm for Stop-and-
Wait ARQ

Computer Networks 29/04/2025 18


Flow Control and Error Control
Flow diagram 1 : Stop-and-Wait ARQ

Computer Networks 29/04/2025 19


Flow Control and Error Control
Example 1: Stop-and-Wait ARQ

Flow diagram 1 shows an example of Stop-and-Wait


ARQ in next slide. 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.

Computer Networks 29/04/2025 20


Flow Control and Error Control
Example 2: Stop-and-Wait ARQ

i. 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.

Solution:- The bandwidth-delay product is

ii. The system can send 20,000 bits during the time it takes for the data to go from the
sender to the receiver and then back again. However, the system sends only 1000 bits.
We can say that the link utilization is only 1000/20,000, or 5 percent. For this reason,
for a link with a high bandwidth or long delay, the use of Stop-and-Wait ARQ wastes
the capacity of the link.
Computer Networks 29/04/2025 21
Flow Control and Error Control
Example 3: Stop-and-Wait ARQ

What is the utilization percentage of the link in Example 2 if we


have a protocol that can send up to 15 frames before stopping and
worrying about the acknowledgments?

Solution
The bandwidth-delay product is still 20,000 bits. The system can send
up to 15 frames or 15,000 bits during a round trip. This means the
utilization is 15,000/20,000, or 75 percent. Of course, if there are
damaged frames, the utilization percentage is much less because
frames have to be resent.
Computer Networks 29/04/2025 22
Flow Control and Error Control
2. Go-Back-N ARQ

 Sequence Number = 0 to -1, where m =number


of bits.

 The sender window size is -1 with three


variables: Sf, Sn, and Ssize.

 The sender window can slide one or more slots


when a valid acknowledgment arrives.

 The receiver window size 1 with one single


variable Rn.
The Computer
window Networks slides when a correct frame 29/04/2025
has 23

arrived; sliding occurs one slot at a time.


Flow Control and Error Control
Sender window for Go-Back-N ARQ

Computer Networks 29/04/2025 24


Flow Control and Error Control
Receiver window for Go-Back-N ARQ

Computer Networks 29/04/2025 25


Flow Control and Error
Control
Design of Go-Back-N ARQ

Computer Networks 29/04/2025 26


Flow Control and Error
Control
Why the Window size < for Go-Back-N ARQ

Computer Networks 29/04/2025 27


Flow Control and Error Control

Note:

In Go-Back-N ARQ, the size of the


sender window must be less than
2m; the size of the receiver window
is always 1

Computer Networks 29/04/2025 28


Flow Control and Error
Control
Sender-site algorithm for Go-Back-N
ARQ

Computer Networks 29/04/2025 29


Flow Control and Error
Control
Sender-site algorithm for Go-Back-N
ARQ

Computer Networks 29/04/2025 30


Flow Control and Error
Control
Receiver-site algorithm for Go-Back-N
ARQ

Computer Networks 29/04/2025 31


Flow Control and Error
Control Diagram 2
Flow of Go-Back-N ARQ

Computer Networks 29/04/2025 32


Flow Control and Error Control
Example 1: Go-Back-N ARQ

Flow diagram 2 shows an example of Go-Back-N.


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
Computer Networks 29/04/2025 33

timer expires. Note that although ACK 2 is lost, ACK


3 serves as both ACK 2 and ACK 3.
Flow Control and Error
Control Diagram 3
Flow of Go-Back-N ARQ

Computer Networks 29/04/2025 34


Flow Control and Error Control
Example 2: Go-Back-N ARQ

i. Flow diagram 3 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.
Computer Networks 29/04/2025 35
Flow Control and Error Control
Continue…………Example 2: Go-Back-N ARQ

ii. Flow diagram 3 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.
Computer Networks 29/04/2025 36
Flow Control and Error Control

Note:

Stop-and-Wait ARQ is a special case of Go-Back-


N ARQ in which the size of the send window is
1.

Computer Networks 29/04/2025 37


Flow Control and Error Control
3. Selective Repeat ARQ

 Sequence Number = 0 to -1, where m =number


of bits.

 The sender window size and receiver window


size is

 The sender window can slide one or more slots


when a valid acknowledgment arrives.

Computer Networks 29/04/2025 38


Flow Control and Error Control
Sender and Receiver window for Selective Repeat ARQ

Computer Networks 29/04/2025 39


Flow Control and Error
Control
Design of Selective
Repeat ARQ

Computer Networks 29/04/2025 40


Flow Control and Error
Controlthe Window
Why size < for Selective Repeat
ARQ

Computer Networks 29/04/2025 41


Flow Control and Error
Control
Sender-site algorithm for Selective
Repeat ARQ

Computer Networks 29/04/2025 42


Flow Control and Error
Control
Sender-site algorithm for Selective
Repeat ARQ

Computer Networks 29/04/2025 43


Flow Control and Error
Control
Sender-site algorithm for Selective
Repeat ARQ

Computer Networks 29/04/2025 44


Flow Control and Error
Control
Receiver-site algorithm for Selective
Repeat ARQ

Computer Networks 29/04/2025 45


Flow Control and Error
Control
Receiver-site algorithm for Selective
Repeat ARQ

Computer Networks 29/04/2025 46


Flow Control and Error Control
Delivery of data in Selective Repeat ARQ

Computer Networks 29/04/2025 47


Flow Control and Error
Control Diagram 4
Flow of Selective-Repeat-ARQ

Computer Networks 29/04/2025 48


Flow Control and Error Control
Example 1 : Selective Repeat ARQ

i. This example is similar to Example 1 of Stop-and-


Wait in which frame 1 is lost. We show how
Selective Repeat behaves in this case. Flow
Diagram 4(Stop-and-wait) 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
Computer Networks 29/04/2025 49

arrives. The other two timers start when the


corresponding frames are sent and stop at the
Flow Control and Error Control
Continue …...Example 1 : Selective Repeat ARQ

ii. 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
Computer Networks 29/04/2025 50

must have arrived. Second, the set starts from


the beginning of the window.
Flow Control and Error Control
Continue …...Example 1 : Selective Repeat ARQ

iii. 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 NAK
Sent 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.
Computer Networks 29/04/2025 51
Flow Control and Error Control
Continue …...Example 1 : Selective Repeat ARQ

iv. 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.

Computer Networks 29/04/2025 52


Flow Control and Error
Control
Design of piggybacking in Go-Back-N
ARQ

Computer Networks 29/04/2025 53


Flow Control and Error
Control
Case Study
For example, Let the window size is 7 (see below diagram (a)), if frames 0
through 3 have
been sent and no acknowledgment has been received, then the sender’s
window contains
three frames – 4,5,6.
• Now, if an ACK numbered 3 is received by source, it means three frames (0, 1,
2) have been
received by receiver and are undamaged.
• The sender’s window will now expand to include the next three frames in its
buffer. At this
point the sender’s window will contain six frames (4, 5, 6, 7, 0, 1). (See below
diagram (b))

Computer Networks 29/04/2025 54


Flow Control and Error
Control
Numerical
A sender sends a series of packets to the same destination
using 5-bit sequence numbers. If the sequence number
starts with 0, what is the sequence number after sending
100 packets?

Solution:- A 5-bit sequence number can create


sequence numbers from 0 to 31. The sequence number in
the Nth packet is (N mod 32). This means that the
101th packet has the sequence number (101 mod 32) or
5.
Computer Networks 29/04/2025 55

You might also like