Ceng210 SP25 LCN11
Ceng210 SP25 LCN11
CENG210
Chapter 03 – Lecture 11
Flow And Error Control
Hassan Nasreddine
Spring 2025
1
It has been said
Outline
• Data Link Control Services
– Framing
– Flow and Error Control
• Flow and Error Control Protocols
– Simplest
– Stop-and-Wait
– Stop-and-Wait ARQ
– Go-Back-N ARQ
– Selective Repeat ARQ
2
It has been said
3
It has been said
Framing
• The data-link layer, on the other hand, needs to pack bits
into frames, so that each frame is distinguishable from
another.
• Framing in the data-link layer separates a message from
one source to a destination by adding a sender address
and a destination address.
• The destination address defines where the packet is to
go; the sender address helps the recipient acknowledge
the receipt.
• Large messages are divided into smaller frames to make
flow and error control very efficient.
4
It has been said
Frame Size
• Frames can be of fixed or variable size.
• In fixed-size framing, there is no need for defining the
boundaries of the frames; the size itself can be used as
a delimiter.
• In variable-size framing, we need a way to define the
end of one frame and the beginning of the next. Two
approaches were used for this purpose: a character-
byte
5
It has been said
Character-Oriented Framing
• In character-oriented (or byte-oriented) framing, data to
be carried are 8-bit characters from a coding system
such as ASCII.
Byte Stuffing
• In byte stuffing (or character stuffing), a special byte is
added to the data section of the frame when there is a
character with the same pattern as the flag.
• This byte is usually called the escape character (ESC)
and has a predefined bit pattern.
• Whenever the receiver encounters the ESC character, it
removes it from the data section and treats the next
character as data, not as a delimiting flag.
7
It has been said
Bit-Oriented Framing
• In bit-oriented framing, the data section of a frame is a
sequence of bits to be interpreted by the upper layer as
text, graphic, audio, video, and so on.
• Most protocols use a special 8-bit pattern flag, 01111110,
as the delimiter to define the beginning and the end of the
frame.
8
It has been said
Bit Stuffing
• If the flag pattern appears in the data, we need to
somehow inform the receiver that this is not the end of the
frame. We do this by stuffing 1 single bit (instead of 1 byte)
to prevent the pattern from looking like a flag. The strategy
is called bit stuffing.
• In bit stuffing, if a 0 and five consecutive 1 bits are
encountered, an extra 0 is added. This extra stuffed bit is
eventually removed from the data by the receiver.
9
It has been said
10
It has been said
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. Flow control is related to the first issue.
• Flow control refers to a set of procedures used to restrict
the amount of data that the sender can send before
waiting for acknowledgment.
11
It has been said
12
It has been said
Error Control
• Error control is both error detection and error correction.
It allows the receiver to inform the sender of any frames
lost or damaged in transmission and coordinates the
retransmission of those frames by the sender.
• In the data link layer, the term error control refers primarily
to methods of error detection and retransmission.
• Error control in the data link layer is often implemented
simply: Any time an error is detected in an exchange,
specified frames are retransmitted. This process is called
automatic repeat request (ARQ).
13
It has been said
14
It has been said
Simplest Protocol
• Simple protocol is a protocol with neither flow nor error
control. The receiver can immediately handle any frame
it receives. The receiver can never be overwhelmed
with incoming frames.
15
It has been said
Stop-and-Wait Protocol
• Stop-and-Wait protocol uses both flow and error control.
• In this protocol, the sender sends one frame at a time and
waits for an acknowledgment before sending the next
one.
• To detect corrupted frames, we need to add a CRC to
each data frame.
• When a frame arrives at the receiver site, it is checked.
If its CRC is incorrect, the frame is corrupted and silently
discarded.
Every time the sender sends a frame, it starts a timer. If an
acknowledgment arrives before the timer expires, the timer is
stopped and the sender sends the next frame.
If the timer expires, the sender resends the previous frame,
assuming that the frame was either lost or corrupted.
16
It has been said
Stop-and-Wait Protocol
start
restart
17
It has been said
18
It has been said
Stop-and-Wait ARQ
• Stop and wait with ARQ: Automatic Repeat reQuest
(ARQ), an error control method, is incorporated with stop
and wait flow control protocol.
– If error is detected by receiver, it discards the frame and send a
negative ACK (NAK), causing sender to re-send the frame.
– In case a frame never got to receiver, sender has a timer: each
time a frame is sent, timer is set!
• If no ACK or NAK is received during timeout period, it re-sends the
frame.
– Timer introduces a problem: Suppose timeout and sender
retransmits a frame but receiver actually received the
previous transmission! Receiver has duplicated copies.
– To avoid receiving and accepting two copies of same frame,
frames and ACKs are alternatively labeled 0 or 1: ACK0 for
frame 1, ACK1 for frame 0
19
It has been said
receiver discarded
because he has it
already
20
It has been said
The system can send 20,000 bits during the time it takes for the data
to go from the sender to the receiver and the acknowledgment to
come back. However, the system sends only 1,000 bits. We can say
that the link utilization is only 1,000/20,000, or 5 percent.
For this reason, in a link with a high bandwidth or long delay, the use
of Stop-and-Wait wastes the capacity of the link.
21
It has been said
22
It has been said
23
It has been said
have 3 bit
https://rb.gy/yfd6mx
24
It has been said
Go-Back-N ARQ
• The Go-Back-N protocol simplifies the process at the
receiver. The receiver keeps track of only one variable,
and there is no need to buffer out-of-order packets; they
are simply discarded.
• The basic idea of Go-Back-N error control is: If frame i is
damaged, receiver requests retransmission of all frames
starting from frame i
negative
25
It has been said
Go-Back-N ARQ
2 discarded
https://rb.gy/19a7be
26
It has been said
27
It has been said
2 discarded
28