Mod3 Flow Control PDF
Mod3 Flow Control PDF
Computer Networks
Module 3: Flow Control
If the items are produced faster than they can be consumed, the consumer can be
overwhelmed and may need to discard some items.
If the items are produced more slowly than they can be consumed, the consumer
must wait, and the system becomes less efficient.
Flow Control
Whenever an entity produces items and another entity consumes them, there
should be a balance between production and consumption rates.
If the items are produced faster than they can be consumed, the consumer can be
overwhelmed and may need to discard some items.
If the items are produced more slowly than they can be consumed, the consumer
must wait, and the system becomes less efficient.
Although we can have a complex relationship with more than one producer and
consumer, we ignore the relationships between networks and data-link layers and
concentrate on the relationship between two data-link layers.
Flow Control in Communication
In communication at the data-link layer, we are dealing with four entities:
Although we can have a complex relationship with more than one producer and
consumer, we ignore the relationships between networks and data-link layers and
concentrate on the relationship between two data-link layers.
Use of buffers
One possible solution for flow control can be to use two buffers: one at the
sending data-link layer and the other at the receiving data-link layer.
A buffer is a set of memory locations that can hold packets at the sender and
receiver.
Use of buffers
One possible solution for flow control can be to use two buffers: one at the
sending data-link layer and the other at the receiving data-link layer.
A buffer is a set of memory locations that can hold packets at the sender and
receiver.
How flow control is achieved?
The flow control communication can occur by sending signals from the consumer
to the producer. When the buffer of the receiving data-link layer is full, it informs
the sending data-link layer to stop pushing frames.
Error control
Why error control? Since the underlying technology at the physical layer is not
fully reliable, we need to implement error control at the data-link layer to prevent
the receiving node from delivering corrupted packets to its network layer.
Error control
Why error control? Since the underlying technology at the physical layer is not
fully reliable, we need to implement error control at the data-link layer to prevent
the receiving node from delivering corrupted packets to its network layer.
The lack of acknowledgment means that there is a problem in the sent frame.
In a connectionless protocol, frames are sent from one node to the next without
any relationship between the frames; each frame is independent.
● In this type of communication, the frames are numbered and sent in order. If
they are not received in order, the receiver needs to wait until all frames
belonging to the same set are received and then deliver them in order to the
network layer.
● Connection oriented protocols are rare in wired LANs, but we can see them in
some point-to-point protocols, some wireless LANs, and some WANs.
Flow control protocols
Flow control protocols
FSM is a machine with finite no. of states. Machine is always in one of the states
until an event occurs.
Stop and Wait protocol sends one frame, stops till it perceives confirmation from
receiver and then sends next frame.
Stop and Wait Protocol flow diagram
Noisy channels
1. Stop and Wait ARQ
2. Sliding Window
a. Go Back N ARQ
b. Selective Repeat ARQ
Sequence number
Error control requires sending layer to know which packet is to be sent and
receiving layer which frame needs to be resent, which is a duplicate packet or
which packet was received out of order ⇒ Packets need to be numbered
Sequence number
Error control requires sending layer to know which packet is to be sent and
receiving layer which frame needs to be resent, which is a duplicate packet or
which packet was received out of order ⇒ Packets need to be numbered
If header assigns m bits for sequence number than possible range of numbers is
Sequence number
Error control requires sending layer to know which packet is to be sent and
receiving layer which frame needs to be resent, which is a duplicate packet or
which packet was received out of order ⇒ Packets need to be numbered
If header assigns m bits for sequence number than possible range of numbers is
Sender sends one packet at a time, waits for an ACK before sending next. To
detect corrupt packets, we add checksum to each packet. At the receiver, data is
checked, if checksum is incorrect means packet is corrupted and is silently
discarded. So, silence of receiver indicates packet was corrupted.
Stop and wait ARQ
Connection-oriented, uses both flow and error control.
Sender sends one packet at a time, waits for an ACK before sending next. To
detect corrupt packets, we add checksum to each packet. At the receiver, data is
checked, if checksum is incorrect means packet is corrupted and is silently
discarded. So, silence of receiver indicates packet was corrupted.
● If ACK is received before timer expires, timer is stopped and sender sends
next (if it has something to send).
● If timer expires, sender resends previous frame assuming it was lost or
corrupt.
Stop and wait ARQ
At any time only one packet and one ACK can be on a channel.
Assume we have used x a s seq. no., we need only x+1 after that not x+2.
Sequence number for Stop and wait ARQ
Since sequence number needs to be added to frame, we need to look at the
smallest range possible that ensures unambiguous communication.
Assume we have used x a s seq. no., we need only x+1 after that not x+2.
● Packet arrives safe at receiver and it sends back ACK. So, sender sends
packet with x+1.
● Packet is corrupted or never arrived at receiver. After timeout receiver
resends packet no. x . Receiver returns ACK.
● Packet arrives safe at receiver and it sends back ACK but ACK is corrupted or
lost. Sender resends x after timeout. Receiver identifies it as duplicate.
So, x and x+1 are sufficient. If x=0, x+1=1 ⇒ mod 2 arithmetic and m=1 sufficient.
ACK number for Stop and wait ARQ
The convention followed by this protocol is that ACK no’s always announce the
seq. no. of next packet expected by receiver.
Example: If packet 0 arrived safe, receiver sends ACK with ACK no. 1, i.e., it
expects packet 1 next.
FSM for Stop and wait ARQ
Both ends should be in established state before exchanging data packets.
Flow diagram for Stop and wait ARQ
Efficiency
Can be measured using Bandwidth-delay product.
BWD= no. of bits sender can transmit through system while waiting for ACK.
Next two protocols will use pipelining and improve link utilization or efficiency.
Go Back N ARQ
To improve efficiency of transmission (to fill pipe) multiple packets must be in
transition while sender waits for ACK. We need to keep more than one packet to
be outstanding to keep channel busy while sender waits for ACK.
Go Back N ARQ
To improve efficiency of transmission (to fill pipe) multiple packets must be in
transition while sender waits for ACK. We need to keep more than one packet to
be outstanding to keep channel busy while sender waits for ACK.
Key idea: We can send several packets before receiving ACKs but receiver ca
only buffer one packet. We keep a copy of sent packet until ACK arrives.
Go Back N ARQ
To improve efficiency of transmission (to fill pipe) multiple packets must be in
transition while sender waits for ACK. We need to keep more than one packet to
be outstanding to keep channel busy while sender waits for ACK.
Key idea: We can send several packets before receiving ACKs but receiver ca
only buffer one packet. We keep a copy of sent packet until ACK arrives.
ACK number: It is cumulative and defines sequence no. of next expected packet.
E.g., ACK no. =7 means all packets upto sequence no. 6 have arrived safe and
receiver expects packet with sequence no. 7.
Go Back N ARQ
Send Window in Go Back N
It is an imaginary box covering sequence no.’s of data packets in transit and those
which can be sent.
Suppose m=3
Send Window in Go Back N
It is an imaginary box covering sequence no.’s of data packets in transit and those
which can be sent.
● S_f
● S_n
● S_size
Send Window in Go Back N
It is an imaginary box covering sequence no.’s of data packets in transit and those
which can be sent.
● S_f
● S_n
● S_size
Receiver Window in Go Back N
Makes sure correct data packets are received and correct ACKs are sent. In Go
Back N, receiver window is always 1.
Receiver is always looking for arrival of specific packet. Any packet arriving out of
order is discarded and needs to be resent.
Receiver Window in Go Back N
Makes sure correct data packets are received and correct ACKs are sent. In Go
Back N, receiver window is always 1.
Receiver is always looking for arrival of specific packet. Any packet arriving out of
order is discarded and needs to be resent.
Example: Suppose sender has already sent packet 6 and S_n=7 but the timer
expires and S_f=3, this means all packets
Timers in Go Back N
Although we can have a timer for each packet sent, in this protocol we use only
one timer because for first outstanding packet timer always expires first. We
resend all outstanding frames when this timer expires.
Resending packets - Whenever timer expires we send all outstanding packets.
Example: Suppose sender has already sent packet 6 and S_n=7 but the timer
expires and S_f=3, this means all packets 3,4,5,6 have not been ACKed, sender
goes back and resends 3,4,5,6.
This is why it is called Go Back N. On timeout machine goes back N locations and
resends all packets.
Why sender window size is <2^m?
FSM approach for Go Back N
Flow diagram for Go Back N
Flow diagram for Go Back N
Selective repeat ARQ
GBN simplifies the process of receiver as it has to keep track of only one variable
and no out of order packets are accepted.
Key idea: Resend only selective packet, those that are actually lost. So, receiver
becomes complex as it needs to allow out of order delivery.
Selective repeat ARQ
Sender and receiver window in Selective repeat ARQ
Both sender and receiver have window size greater than 1 but different than GBN.
Selective repeat (SR) allows as many packets out of order as the size of receiver
window. However, till all packets are received they are not delivered to higher
layers by reliable protocols.
Sender and receiver window in Selective repeat ARQ
Why Sender window in Selective repeat ARQ =2^(m-1)?
Timers and ACKs in Selective repeat ARQ
Timers: Theoretically, Selective repeat (SR) uses one timer for each outstanding
packet. So, when the timer expires only that packet is resent whereas in GBN
outstanding packets were sent as a group. However, many use SR with single
timer only.
Timers and ACKs in Selective repeat ARQ
Timers: Theoretically, Selective repeat (SR) uses one timer for each outstanding
packet. So, when the timer expires only that packet is resent whereas in GBN
outstanding packets were sent as a group. However, many use SR with single
timer only.
ACKs: In GBN, ACK no is cumulative and announces the sequence no. of next
packet expected and confirming receipt of all previous packets. In SR, ACK no.
Timers and ACKs in Selective repeat ARQ
Timers: Theoretically, Selective repeat (SR) uses one timer for each outstanding
packet. So, when the timer expires only that packet is resent whereas in GBN
outstanding packets were sent as a group. However, many use SR with single
timer only.
ACKs: In GBN, ACK no is cumulative and announces the sequence no. of next
packet expected and confirming receipt of all previous packets. In SR, ACK no.
defines the sequence no. of single packet received safe and sound. Example:
Suppose a sender sends 6 packets 0,1,2,3,4,5 and sender receives ACK no. 3
● GBN:
● SR:
Timers and ACKs in Selective repeat ARQ
Timers: Theoretically, Selective repeat (SR) uses one timer for each outstanding
packet. So, when the timer expires only that packet is resent whereas in GBN
outstanding packets were sent as a group. However, many use SR with single
timer only.
ACKs: In GBN, ACK no is cumulative and announces the sequence no. of next
packet expected and confirming receipt of all previous packets. In SR, ACK no.
defines the sequence no. of single packet received safe and sound. Example:
Suppose a sender sends 6 packets 0,1,2,3,4,5 and sender receives ACK no. 3
● GBN: N=2^m -1 ⇒ m=
● SR: N=2^(m-1) ⇒ m=
Questions: Stop and wait
Q1) Sender uses stop and wait protocol. Frame size is 1000 bytes and
transmission rate is 80 Kbps. Size of ACK is 100 bytes and transmission rate at
receiver is 8 Kbps. One way propagation delay is 100 msec. Assuming no frames
are lost, what is throughput of sender in bytes/sec? Ans: 2500 bytes/sec
Q2) For a given stop and wait system, we have: bit rate of channel is 1 Mbps. Tp
is 0.75 msec. Time to process each frame is 0.25 msec. Number of bytes in
information frame is 1980 having 20 overhead bytes and number of bytes in ACK
frame is 20. What is the transmission efficiency? Ans: 87.11%
Q3) Suppose stop and wait protocol is used on a link with bitrate 64 Kbps and 20
msec Tp. Assume negligible time for ACK transmission and processing. Then,
what is the minimum frame size in bytes to achieve a link utilization of at least
50%? Ans: 160 bytes
Link utilization and throughput: sliding window
For sliding window protocol:
Q5) A 20 Kbps link has Tp of 400 msec. Transmitter employs Go Back N ARQ with
N=10. Assuming each frame is 100 bytes long, what is the maximum data rate
possible?
Q6) Consider a 128 Kbps satellite link with Tp of 150 msec. SR is used to send
data with a frame size of 1 kbyte. Neglect the transmission time of ACK. What is
the minimum number of bits required for sequence number to achieve 100%
utilization?
Questions: Sliding window
Q4) Station A uses 32 byte packets to transmit messages to station B using a
sliding window protocol. The round trip delay is 80 msec and bottleneck bandwidth
on path between A and B is 128 Kbps. What is the optimal window size A should
use? Ans: 41
Q5) A 20 Kbps link has Tp of 400 msec. Transmitter employs Go Back N ARQ with
N=10. Assuming each frame is 100 bytes long, what is the maximum data rate
possible? Ans: 9.52 Kbps
Q6) Consider a 128 Kbps satellite link with Tp of 150 msec. SR is used to send
data with a frame size of 1 kbyte. Neglect the transmission time of ACK. What is
the minimum number of bits required for sequence number to achieve 100%
utilization? Ans: 4
References
● Chapter 11 [BAF]
● Chapter 11, 23 [BAF 5th Edition]
● Random access. http://bbcr.uwaterloo.ca/~lcai/ece418/5-2.pdf
[Accessed date: 10 March 2022]
● Flow control animations.
https://www2.tkn.tu-berlin.de/teaching/rn/animations/gbn_sr/
[Accessed date: 1 April 2022]
● Note: Source of all images unless specified is [BAF] book (4th Edition).