Reliable communication across physical channels requires robust management mechanisms to handle packet boundary identification, transmission rate mismatches, and physical signal degradation. This curriculum content details the theoretical and practical designs of framing, error control, and flow control protocols operating at the data link layer.
The data link layer translates a raw stream of bits from the physical layer into distinct, logical units of data called frames. This process is known as framing. To prevent receiver ambiguity, the boundaries of each frame must be clearly delineated.
In character-oriented protocols, data is packaged as a sequence of characters or bytes. Frame boundaries are established using unique control bytes called flags (often FLAG = 0x7E or similar).
If the payload payload contains the flag byte itself, the receiver might prematurely assume the frame has ended. To prevent this, byte stuffing (or character stuffing) is employed:
ESC = 0x1B) is inserted before any accidental flag or escape character present in the user payload.ESC byte, discards it, and treats the subsequent byte as raw data (unstuffing).Sender Side:
[Original Data] ---> FLAG ---> ESC FLAG ESC ESC ---> [Stuffed Data]
\ /
[ Stuffed Frame: FLAG | ESC FLAG | ESC ESC | FLAG ]
Receiver Side:
[Stuffed Frame] ---> Drops ESC before FLAG/ESC ---> [Original Data]Modern protocols operate on bit streams, where frames can contain an arbitrary number of bits. A unique bit pattern, typically 01111110 ( consecutive ones), serves as the start and end flag.
To prevent the payload from accidentally containing this flag sequence, bit stuffing is used:
11111) in the data stream, it automatically inserts (stuffs) a 0 bit immediately after the fifth 1.0, it is recognized as a stuffed bit. The receiver removes (unstuffs) it.1, the receiver checks the following bit:
0, it detects the flag pattern 01111110 (frame boundary).1, the frame is discarded as corrupted (error state).Input Payload: 0 1 1 1 1 1 1 0 1
^ ^ ^ ^ ^
(Five consecutive 1s)
Stuffed Bit Stream: 0 1 1 1 1 1 0 1 0 1
^
(Stuffed 0)Physical channels introduce noise, thermal interference, and signal attenuation, leading to single-bit or burst errors.
In block coding, we partition the original message into -bit blocks called datawords. We append redundant bits to each dataword, producing an -bit block called a codeword, where:
The coding scheme restricts the valid codewords to patterns out of the possible -bit combinations. If a received codeword is not in the set of valid codewords, an error is declared.
The Hamming distance between two binary words and of equal length is the number of bit positions in which they differ. It is calculated by finding the Hamming weight (number of ones) of the exclusive-OR (XOR) operation between and :
The minimum Hamming distance of a coding scheme is the smallest Hamming distance between any pair of valid codewords in the code set :
To guarantee the detection of up to arbitrary bit errors, the minimum Hamming distance must satisfy:
Valid Codeword 1 (radius s)
*-----------------------------> [Boundary of Detection]
If error falls inside, it's detected.
If s+1 errors occur, it may land on
another valid codeword (undetected).To guarantee the correction of up to arbitrary bit errors, the minimum Hamming distance must satisfy:
This ensures that a corrupted codeword with errors remains closer to its original codeword than to any other valid codeword in the vector space.
Codeword A Codeword B
( O ) <---------- t --------->*<--------- t ---------> ( O )
\___________________________|___________________________/
d_min >= 2t + 1Cyclic codes are a category of linear block codes where a cyclic shift of any valid codeword results in another valid codeword. The most common implementation is the Cyclic Redundancy Check (CRC), which can be easily implemented in hardware using shift registers.
In CRC, binary words are represented as polynomials with coefficients in Galois Field (where addition and subtraction are equivalent to bitwise XOR):
For example, the binary sequence 10111 corresponds to the polynomial:
Let be the dataword of degree , and be the generator polynomial of degree .
where is the quotient and is the remainder (syndrome) of degree . 3. The transmitted codeword is constructed by subtracting (XORing) the remainder from the appended dataword:
Since is perfectly divisible by , any error-free codeword received will yield a remainder of zero when divided by .
The error detection properties of a cyclic code depend entirely on the choice of :
Flow control refers to the set of procedures used to restrict the amount of data a sender can transmit before waiting for an acknowledgment (ACK).
This ideal, hypothetical protocol assumes a completely noiseless channel with infinite receiver buffer capacity. The sender transmits frames continuously without performing any flow or error control.
If the receiver has a finite buffer but the channel is still assumed to be noiseless, the Stop-and-Wait protocol prevents receiver buffer overflow.
ACK) from the receiver.ACK is received, the sender transmits the next frame.Sender Receiver
| |
|------ Frame 0 --------------------->|
| | (Process & Buffer)
|<----- ACK --------------------------|
| |
|------ Frame 1 --------------------->|
| |Real-world channels are noisy. Automatic Repeat Request (ARQ) adds error control (sequence numbers, timers, and retransmissions) to flow control protocols.
To handle lost or corrupted frames and acknowledgments, Stop-and-Wait ARQ introduces:
Sender Receiver
| |
|------ Frame 0 --------------------->| (Receives 0, expects 1)
|<----- ACK 1 ------------------------|
| |
|------ Frame 1 --------------------->| (Lost in transit!)
| X |
| (Timer Expires) |
|------ Frame 1 (Retransmit) -------->| (Receives 1, expects 0)
|<----- ACK 0 ------------------------|To improve utilization, Go-Back-N (GBN) allows the sender to transmit multiple frames before waiting for an acknowledgment.
Send Window Concept (m-bit sequence number):
[ S_f ... S_n - 1 ] S_n ...
| | |
First Outstanding | Next to Send
|
Outstanding Frames
(Max size = 2^m - 1)
Sender Receiver
|------ Frame 0 --------------------->|
|------ Frame 1 --------------------->| (Lost!)
|------ Frame 2 --------------------->| (Discarded: Out-of-order)
|------ Frame 3 --------------------->| (Discarded: Out-of-order)
| |
| (Timeout Frame 1) |
|------ Frame 1 --------------------->| (Now accepted!)
|------ Frame 2 --------------------->|
|------ Frame 3 --------------------->|To avoid the inefficient retransmission of correctly received out-of-order frames in GBN, Selective Repeat (SR) buffers out-of-order frames and retransmits only the specific frames that were lost or corrupted.
Sender Receiver (Window Size = 2)
|------ Frame 0 --------------------->| (Accepted, expected: 1)
|------ Frame 1 --------------------->| (Lost!)
|------ Frame 2 --------------------->| (Buffered out-of-order, sends NAK 1)
|<----- NAK 1 ------------------------|
| |
|------ Frame 1 (Retransmit) -------->| (Receives 1, delivers 1 & 2)
|<----- ACK 3 ------------------------|The efficiency of a data link protocol is measured by its channel utilization (), defined as the fraction of time the channel is actively conveying payload data.
Let:
In Stop-and-Wait, the total cycle time to send a single frame and receive its ACK (ignoring ACK transmission time and processing delays) is:
The utilization is:
where is the ratio of propagation delay to transmission delay:
The term is the Bandwidth-Delay Product (BDP), representing the number of bits that can fill the transmission link in both directions. If the BDP is high (e.g., in long-distance fiber or satellite links), , making Stop-and-Wait highly inefficient ().
With a sender window size of , the sender can transmit up to frames consecutively. If , the sender can transmit continuously without waiting. The utilization is:
To achieve theoretical efficiency on an error-free channel, we must choose:
HDLC is a standardized, bit-oriented protocol designed for both point-to-point and multipoint links. It supports full-duplex communication using sliding-window error recovery mechanisms.
HDLC defines three types of frames, distinguished by their Control field formats:
HDLC Frame Structure:
[ Flag: 8 bits ] [ Address: 8+ bits ] [ Control: 8/16 bits ] [ Information: Var ] [ FCS: 16/32 bits ] [ Flag: 8 bits ]SABM - Set Asynchronous Balanced Mode, - Disconnect, - Unnumbered Acknowledgment).PPP is a widely used, byte-oriented protocol designed to establish direct connections over point-to-point links (such as dial-up or fiber broadband lines).
PPP Frame Structure:
[ Flag: 0x7E ] [ Address: 0xFF ] [ Control: 0x03 ] [ Protocol: 16 bits ] [ Payload: Var ] [ FCS: 16/32 bits ] [ Flag: 0x7E ]0x7D.The process of encapsulating network-layer packets into data-link frames using physical/logical delimiters such as byte-stuffing or bit-stuffing.
Mechanisms that restrict the volume of data a sender can transmit before receiving an acknowledgment, protecting slow receivers from buffer overflow.
The combination of error detection (e.g., CRC, Checksum) and automatic repeat request (ARQ) retransmission strategies to ensure error-free delivery.
A sliding window protocol where the sender can transmit multiple outstanding frames defined by window size $2^m - 1$, retransmitting all unacknowledged frames upon timeout.
An optimized sliding window protocol where both sender and receiver windows are at most $2^{m-1}$, allowing individual frame retransmission to minimize overhead.
Test your understanding with 5 questions
In a sliding window protocol with a 4-bit sequence number field running Go-Back-N ARQ, what is the maximum sender window size ($S_{size}$) and receiver window size ($R_{size}$), respectively?
A channel has a transmission rate of 1 Mbps and a round-trip propagation delay of 20 ms. If the frame size is 1000 bits, what is the maximum channel utilization percentage under the Stop-and-Wait ARQ protocol?
Why must the maximum window size in Selective Repeat ARQ be limited to half of the sequence number space ($2^{m-1}$)?
A cyclic code uses the generator polynomial $g(x) = 1$. Which of the following statements is true regarding its error detection capability?
In a bit-oriented framing protocol, the data sequence to be sent is '011111101'. What is the stuffed bit sequence transmitted on the physical medium?
UA6 Modules
6 Modules