2024 Flow Control
2024 Flow Control
2024 Flow Control
chap-7
Data Link Control Protocols
• Physical layer concentrates on sending signals over
transmission link
• More control and management is needed to send data over
data communications link
– Frame synchronization: start and end of each frame
– Flow control: ensure sender does not send too fast for
receiver
– Error control: correct bit errors introduced by transmission
system
– Addressing: must specify identity of two stations
communicating
– Control and data: receiver must distinguish between
control and data information
– Link management: setup and maintain the link
• We will focus on Flow Control and Error Control
Flow Control
• Flow control aims to ensure sending entity
does not overwhelm receiving entity.
– If sender sends too fast for receiver, then buffer
may overflow
– Result of buffer overflow: data is lost, possibly
need to retransmit, which reduces performance
– Flow control tries to prevent buffer overflow
– Assume no errors but varying delays
Model of Frame Transmission
Stop-and-Wait Flow Control
• Frame Types
– DATA: contains information to be sent
– ACKnowledgement: acknowledges receipt of data
• Rules
– Source transmits a DATA frame
– Source waits for ACK frame before sending next DATA
frame
– Destination receives DATA frame and replies with an
ACK if ready for more data
– Destination can stop flow of data by not sending ACK
Stop-and-Wait Flow Control
Stop and Wait Link Utilization
• Propagation delay is the time it takes for a bit to travel from sender to
receiver, depends on
– transmission media and
– the distance between sender and receiver
• B = R x (d/V)
– B: length of the link in bits
– R: data rate of the link, in bps
– d: length or distance of the link in meters
– V: velocity of propagation, in m/s
• a = B/L
– a: the propagation delay (with frame tx time = 1)
– L: the number of bits in the frame
– Propagation delay=d/V
– Round-Trip Time = 2 × propagation delay
Stop and Wait Link Utilization
Maximum potential efficiency of a half-duplex point-to-point line using
the stop-and-wait
and-Wait
Flow
Control
Efficiency for considering payload only.
Example
• Source has 3×1000 Byte messages to be sent
immediately. Destination takes 1 𝜇𝑠 to process
each frame. DATA frame contains 1000 Bytes
of data plus 20 Byte header. ACK frame is 20
Bytes. Link is 2 km, 1 Mb/s, and velocity of
2×108 𝑚/𝑠
• What is the efficiency?
What Size Frames To Use?
• Protocols often limit size of packets (frames), i.e.
maximum number of bytes of data or payload
• Large frames minimize header overheads
• Small frames:
– Allow more data to be sent when receive buffers are
limited
– Introduce small overhead if a retransmission is
required
– Allow fair sharing amongst multiple users
• Optimal packet size depends on overheads, and
desired throughput and delay performance
Stop-and-wait allows
1 2 3 4 5 6
Station sends F1 Station sends an Station sends F2 Station sends an Station sends Fn Station sends an
acknowledgment. acknowledgment. acknowledgment.
Error Control
• Need to detect and correct errors such as:
– Lost frames: frame not received
– Damaged frames: frame received with errors
• Common techniques used:
– Error detection and FEC
– Positive acknowledgment: destination returns a positive
ACK after successfully receiving error-free frames
– Retransmission after timeout: source retransmits a frame
that has not been ACKed after predetermined time
– Negative acknowledgement and retransmission:
destination returns negative ACK for frames in which an
error is detected
• Last 3 techniques are called automatic repeat
request (ARQ). Three versions:
– Stop-and-wait ARQ
– Go-back-N ARQ
– Selective-reject ARQ
Stop-and-Wait ARQ
• Based on Stop-and-Wait flow control
• Source transmits single frame, starts timer and maintains
copy
– If ACK received, stop timer and transmit next frame
– If no ACK received before timer expires, retransmit copy of
frame
• Destination sends ACK if frame received (with no errors); if
damaged frame, then discard frame
• Frames have 1-bit sequence number (alternate between 0
and 1)
– Used for destination to distinguish between duplicate DATA
frames in case of damaged ACK
• Stop-and-Wait ARQ is simple, but inefficient
Go-Back-N ARQ
• Based on Sliding Window flow control
• If no error, ACK as in sliding window (contains sequence number of
next expected frame, Receive Ready(RR) acknowledgement)
• If error detected by Destination, reply with negative ACK (NACK or
rejection, REJ)
• Destination will discard that frame and all future frames until error
frame received correctly
• Transmitter must go back and retransmit that frame and all
subsequent frames
• If no response from Destination after timeout, then Source may
send special ACK (ACKRequest or RR(P bit = 1))
– The ACKRequest from Source to Destination, is a request for an ACK
from the Destination
– Upon receipt of ACKRequest, the Destination sends an ACK
• Maximum window size: 2k -1
Go Back N - Handling
• Suppose that station A is sending frames to
station B. After each transmission,
• A sets an acknowledgment timer for the frame
just transmitted. Suppose that B has
previously successfully received frame (i –
1)and A has just transmitted frame i.
Go Back N - Handling
1. Damaged Frame
– error in frame i so receiver rejects frame i
– transmitter retransmits frames from i
(a) Within a reasonable period of time, A subsequently sends frame (i
+ 1).B receives frame (i + 1)out of order and sends a REJ i. A must
retransmit frame i and all subsequent frames.
(b) A does not soon send additional frames. B receives nothing and
returns neither an RR nor a REJ. When A’s timer expires, it
transmits an RR frame that includes a bit known as the P bit,
which is set to 1. B interprets the RR frame with a P bit of 1 as a
command that must be acknowledged by sending an RR indicating
the next frame that it expects, which is frame i. When A receives
the RR, it retransmits frame i. Alternatively, A could just retransmit
frame i when its timer expires.
Go Back N - Handling
2. Damaged RR. There are two subcases:
(a) B receives frame i and sends RR which suffers an error in transit. Because
acknowledgments are cumulative (e.g., RR 6 means that all frames through 5
are acknowledged), it may be that A will receive a subsequent RR to a
subsequent frame and that it will arrive before the timer associated with
frame i expires.
(b) If A’s timer expires, it transmits an RR (i+1) command as in Case 1b. It sets
another timer, called the P-bit timer. If B fails to respond to the RR command,
or if its response suffers an error in transit, then A’s P-bit timer will expire. At
this point, A will try again by issuing a new RR command and restarting the P-
bit timer. This procedure is tried for a number of iterations. If A fails to obtain
an acknowledgment after some maximum number of attempts, it initiates a
reset procedure.
3. Damaged REJ. If a REJ is lost, this is equivalent to Case
Go Back N
• Setup – Sender sliding window
• Frames are numbered sequentially using m-bit in the frame header
– For m bits frame sequence numbers 0 – (2m –1), repeated
– m=3 ➔ (0,1,2,3,4,5,6,7,0, 1,2,3,4,5,6,7,…)
• Sender can send multiple frames while waiting for ACK, but total number
of unacknowledged frames should not exceed 2m –1 which is called
window
• Window is an imaginary placeholder that covers the frames sequence
numbers which can be in transit
• The frames to the left of the window are already acknowledged and to the
right can not be sent until window slides over them
• Frames inside the window are outstanding (have been sent but not yet
acknowledged OR will be sent soon once received from upper-layer)
• Sender window will slide to frame number (i ) when (ACK i) is received.
Go Back N - Handling
• Setup –Receiver sliding window
• The size of the receiver window is always 1 and points to the next expected frame
number to arrive
• This means that frames should arrive in order
• If the expected frame is received without errors, the receiver window slides over the next
sequence number.
• Operation
• The receiver sends a positive ACK if a frame has arrived without error and in order
(with the expected sequence number )
• Receiver does not have to acknowledge each individual frame received correctly and in
order.
• Receiver can send cumulative ACK for several frames (ACK 5 acknowledges frames
(0,1,2,3,4) and expecting frame 5)
• If the frame is damaged or out-of-order, the receiver discards it (and stay silent) and
also discards all subsequent frames until it receives the one expected.
– In this case, no ACK will be transmitted
• If the sender timer expires before receiving an ACK, it will resend ALL frames
beginning with the one expired until the last one sent (Go-Back-N).
Go-Back-N ARQ, normal operation
• Better than Stop and wait because it keeps the sender busy
while waiting for acknowledgement
• Does not allow error free but out of order frames to be
accepted by the receiver
• This protocol can waste a lot of bandwidth if the error
rate is high because it requests the sender to retransmit the
frame in error and all the subsequently transmitted frames
Selective-Reject ARQ
• Also called selective retransmission or selective repeat
• Only frames that are rejected or timeout are retransmitted
• Subsequent frames are accepted by the destination and
buffered
• Maximum window size: 2k-1
• Minimizes retransmission (GOOD)
• Destination must maintain large enough buffer for frames
received out- of-order (BAD)
• More complex logic in transmitter (BAD)
• Not as widely used as Go-Back-N; useful for satellite links
with long propagation delays
Selective-Reject ARQ
• Setup-Window size (for both sender and receiver)
– For m bit sequence number the maximum window size 2m-1
• Operation
– Sender in case of damaged or lost frame retransmits
• Those which are negatively acknowledged
• Those for which timer expires
– Receiver can accept out of order frames and buffer (store) them until
the lost, damaged, or delayed frame arrives.
– Receiver does not acknowledge out of order frames but buffers
them only
– If the receiver receives an out-of-order, error free frame, it will send
a frame called Negative Acknowledge (NAK) with the number of the
frame to be retransmitted only.
– NAK improves the performance because it requests retransmission of
the lost frame before the corresponding sender timer expires
Selective Repeat ARQ, lost frame
Selective Repeat ARQ, window size
Performance
• More efficient than the other two protocols
because it reduces number of retransmissions
for noisy links
• The receiver and transmitter processing logic is
more complex
– Receiver must be able to reinsert the retransmitted
(lost, delayed, damaged) frame in the proper sequence
after it arrives
– The sender should be able to send out of order frame
when requested by the sender using NAK
– Needs more memory than Go-Back-N ARQ at the
receiver side. The receiver memory is large if the
window size is large
Error-Free Sliding-Window Flow
Control
For sliding-window flow control, the throughput
on the line depends on both the window size W
and the value of a. For convenience, let us again
normalize frame transmission time to a value of
1; thus, the propagation time is a.
• Case 1: The acknowledgment for frame 1 reaches
B before A has exhausted its window. Thus, A can
transmit continuously with no pause.
• Case 2: A exhausts its window at and cannot send
additional frames until Thus, normalized
throughput is W time units out of a period of
time units.
• Therefore, we can express the utilization as
– U=1 , W >= 2a + 1
– U= W/2a + 1 , W < 2a + 1
Example
• Consider the use of 1000-bit frames on a 1-
Mbps satellite channel with a 270-ms delay.
What is the maximum link utilization for
a) Stop-and-wait flow control?
b) Continuous flow control with a window size of
7?
c) Continuous flow control with a window size of
127?
d) Continuous flow control with a window size of
255?
L=103, R=106
• a= propagation Time/(L/R)
• a=270 ×10−3/(103/ 106) = 270
a) U = 1/(1 + 2a) = 1/541 = 0.002
b) U = W/(1 + 2a) = 7/541 = 0.013
c) U = 127/541 = 0.23
d) U = 255/541 = 0.47
Example
• A system uses the Stop-and-Wait ARQ
Protocol. If each frame carries 1000 bits of
data, how long does it take to send 1 million
bits of data if the distance between the sender
and receiver is 5000 Km and the propagation
speed is 2 x 108 m? Ignore transmission,
waiting, and processing delays. We assume no
data or control frame is lost or damaged.
• Propagation delay=d/V
• d=5000km=5 x 106 m, V= 2 x 108 m
• Propagation delay=5 x 106 / 2 x 108 =25ms
• Nr of frame=1000000/1000=1000
• Time delay for one successful frame delivery is
50ms(Ignore transmission, waiting, and processing
delays. We assume no data or control frame is lost or
damaged)
• For 1000 frame, time delay=1000x50ms=50s
Example
• Repeat using the Go-back-N ARQ Protocol
with a window size of 7.Ignore the overhead
due to the header and trailer. (Assume
transmission time of frame=1ms)
• We need to send w=7 frame
• 1000000/7000=143 windows
• Transmission time of window =7x1ms=7ms
• Delay for 1 window
• =twframe+2tprop =7+50=57ms
• Delay for 143 windows
• =143x57ms=8.151s
Example
• Using 5-bit sequence numbers, what is the
maximum size of the send and receive
windows for each of the following protocols?
a. Stop-and-Wait ARQ
b. Go-Back-NARQ
c. Selective-Repeat ARQ
a) Stop-and-Wait ARQ=20
b) Go-Back-NARQ=25 -1
c) Selective-Repeat ARQ=25-1
Example
• A sender sends a series of frame to the same
destination using 5-bit sequence numbers. If
the sequence number starts with 0, what is
the sequence number after sending 100
frame?
• A five-bit sequence number can create
sequence numbers from 0 to 31
• The sequence number in the Nth frame is (N
mod 32)
• 101th frame has the sequence number (101
mod 32) or 5.
HDLC Station Types
• Primary station
– Controls operation of link
– Frames issued are called commands
– Maintains separate logical link to each secondary
station
• Secondary station
– Under control of primary station
– Frames issued called responses
• Combined station
– May issue commands and responses
HDLC Link Configurations
• Unbalanced
– One primary and one or more secondary stations
– Supports full duplex and half duplex
• Balanced
– Two combined stations
– Supports full duplex and half duplex
HDLC Transfer Modes (1)
• Normal Response Mode (NRM)
– Unbalanced configuration
– Primary initiates transfer to secondary
– Secondary may only transmit data in response to
command from primary
HDLC Transfer Modes (2)
• Asynchronous Balanced Mode (ABM)
– Balanced configuration
– Either station may initiate transmission without
receiving permission
– Most widely used
HDLC Transfer Modes (3)
• Asynchronous Response Mode (ARM)
– Unbalanced configuration
– Secondary may initiate transmission without
permission form primary
– Primary responsible for line
Frame Structure
• Synchronous transmission
• All transmissions in frames
• Single frame format for all data and control
exchanges
Frame Structure
Flag Fields
• Delimit frame at both ends
• 01111110
• May close one frame and open another
• Receiver hunts for flag sequence to synchronize
• Bit stuffing used to avoid confusion with data containing
01111110
– 0 inserted after every sequence of five 1s
– If receiver detects five 1s it checks next bit
– If 0, it is deleted
– If 1 and seventh bit is 0, accept as flag
– If sixth and seventh bits 1, sender is indicating abort
Bit Stuffing
• Example with
possible errors
Address Field
• Identifies secondary station that sent or will receive frame
• Usually 8 bits long
• May be extended to multiples of 7 bits
– LSB of each octet indicates that it is the last octet (1) or not (0)
• All ones (11111111) is broadcast
Control Field
• Different for different frame type
– Information - data to be transmitted to user (next
layer up)
• Flow and error control piggybacked on information
frames
– Supervisory - ARQ when piggyback not used
– Unnumbered - supplementary link control
• First one or two bits of control filed identify
frame type
Control Field Diagram
Poll/Final Bit
• Use depends on context
• Command frame
– P bit
– 1 to solicit (poll) response from peer
• Response frame
– F bit
– 1 indicates response to soliciting command
Information Field
• Only in information and some unnumbered
frames
• Must contain integral number of octets
• Variable length
Frame Check Sequence Field
• FCS
• Error detection
• 16 bit CRC
• Optional 32 bit CRC
HDLC Operation
• Exchange of information, supervisory and
unnumbered frames
• Three phases
– Initialization
– Data transfer
– Disconnect
Examples of Operation (1)
Examples of Operation (2)