Modern data link control protocols provide the logical administrative framework required to reliably move raw binary streams over physical channels. Without these mechanisms, receiver hardware cannot distinguish where one packet ends and another begins, nor can it manage transmission rates to prevent resource starvation.
Before transmission, the data link layer packs bits into independent chunks called frames. This process is analogous to placing physical letters into envelopes to serve as delimiters.
In character-oriented protocols, the frame is composed of an integer number of bytes. The start and end of a frame are marked by a dedicated control character called a flag (often denoted as FLAG or 0x7E).
If the actual binary payload contains a byte identical to the control FLAG, the receiver will prematurely conclude that the frame has ended. To prevent this, byte stuffing is used. Whenever a FLAG or an escape character (ESC, often 0x7D) appears in the payload, an extra ESC byte is inserted directly ahead of it.
Original Payload: [ Data ] ---> [ FLAG ] ---> [ Data ]
Stuffed Frame: FLAG [ Data ] [ ESC ] [ FLAG ] [ Data ] FLAGWhen the receiver detects an ESC character, it discards it and processes the subsequent byte as literal data.
Bit-oriented protocols view the frame as a continuous sequence of individual bits. Frame boundaries are delimited by a unique bit pattern, typically 01111110 ().
To ensure this pattern does not naturally occur in the user data, bit stuffing is executed at the transmitter. The rule is simple: whenever five consecutive s are encountered in the payload, a is automatically inserted immediately after them, regardless of the value of the next bit.
Sender Side:
Data to send: 0 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 0 0
Stuffed bitstream: 0 1 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0 0 0
^ ^
(Stuffed) (Stuffed)
Receiver Side:
Received bitstream: 0 1 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0 0 0
Unstuffed data: 0 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 0 0
^ ^
(0 discarded) (0 discarded)At the receiving node, if five consecutive s are detected followed by a , the bit is discarded. If five consecutive s are followed by a and then a (i.e., 01111110), it is processed as the frame boundary flag.
High-Level Data Link Control (HDLC) is a bit-oriented, synchronous protocol developed by the ISO to provide reliable node-to-node communication over point-to-point and multipoint links.
HDLC supports two primary station configurations:
These configurations operate under two fundamental transfer modes:
Under NRM, the station configuration is unbalanced. A secondary station cannot initiate transmissions on its own; it must wait for a explicit poll command from the primary station.
Primary Station Secondary Station
| |
|---- Command (Poll: P=1) ----------------->|
| | (Granted permission)
|<--- Response (I-Frame: F=1) --------------|Under ABM, the configuration is balanced. Either peer station can initiate transmission at any time without waiting for permission from the other. This is the dominant mode used on point-to-point physical links.
Node A Node B
| |
|---- I-Frame (Initiates Send) ------------>|
|<--- I-Frame (Simultaneous Send) ----------|An HDLC frame contains up to six fields: Flag, Address, Control, Information, Frame Check Sequence (FCS), and a closing Flag.
+----------+----------+----------+------------------+----------+----------+
| Flag | Address | Control | Information | FCS | Flag |
| 8 bits | 8/16 bits| 8/16 bits| Variable Length |16/32 bits| 8 bits |
+----------+----------+----------+------------------+----------+----------+01111110 () which synchronizes the receiver and identifies the starting and ending boundaries of the frame.
The Control field defines the primary function of an HDLC frame. Based on this field, frames are categorized into three types:
I-Frame (Information):
+---+---+---+---+---+---+---+---+
| 0 | N(S) |P/F| N(R) |
+---+---+---+---+---+---+---+---+
S-Frame (Supervisory):
+---+---+---+---+---+---+---+---+
| 1 | 0 | S |P/F| N(R) |
+---+---+---+---+---+---+---+---+
U-Frame (Unnumbered):
+---+---+---+---+---+---+---+---+
| 1 | 1 | M |P/F| M |
+---+---+---+---+---+---+---+---+I-frames carry user data from the network layer. They also implement flow and error control via piggybacking.
S-frames handle flow and error control when piggybacking is not possible (e.g., when a node has no outgoing data frames). They do not contain an Information field. The -bit S field determines the command type:
00 (Receive Ready - RR): Indicates the station is ready to receive and acknowledges frames up to .10 (Receive Not Ready - RNR): Acknowledges frames up to but signals that the receiver is temporarily busy and cannot accept more frames.01 (Reject - REJ): Sent in Go-Back-N ARQ to request the immediate retransmission of all outstanding frames starting from .U-frames manage the link itself. They do not have sequence numbers ( or ) and are used for session initialization, mode selection, and connection teardown. The modifier bits () define several control commands and responses:
| Command/Response | Name | Description | | :--- | :--- | :--- | | SABM | Set Asynchronous Balanced Mode | Sets up a balanced, connection-oriented link. | | UA | Unnumbered Acknowledgment | Acknowledges receipt of connection commands (e.g., SABM, DISC). | | DISC | Disconnect | Terminates an active connection. | | DM | Disconnect Mode | Signals that the station is offline or disconnected. | | FRMR | Frame Reject | Reports an unrecoverable protocol error (e.g., invalid control field). |
Establishing and tearing down a connection in HDLC requires a handshake of U-frames:
Node A Node B
| |
|--- SABM (Set Asynchronous Balanced Mode) --------------->|
|<-- UA (Unnumbered Acknowledgment) -----------------------| (Link Established)
| |
|================= DATA TRANSFER PHASE ====================|
| |
|--- DISC (Disconnect Command) ----------------------------|
|<-- UA (Unnumbered Acknowledgment) -----------------------| (Link Released)HDLC implements Automatic Repeat Request (ARQ) schemes to guarantee reliable, error-free delivery over noisy physical lines.
The following sequence demonstrates error-free communication between Node A and Node B using piggybacking:
Node A Node B
| |
|--- I-frame [N(S)=0, N(R)=0] --------------------------------->| (Recv 0, expect 1)
| |
|--- I-frame [N(S)=1, N(R)=0] --------------------------------->| (Recv 1, expect 2)
| |
|<-- I-frame [N(S)=0, N(R)=2] ----------------------------------| (Ack A's 0 & 1; expect 2)
| | (Recv B's 0, expect 1)
| |
|<-- I-frame [N(S)=1, N(R)=2] ----------------------------------| (Recv B's 1, expect 2)
| |
|--- S-frame: RR [N(R)=2] ------------------------------------->| (Ack B's 0 & 1; expect 2)If a frame is lost or corrupted during transit, HDLC uses S-frames to initiate recovery. This example shows Go-Back-N recovery after a frame is lost:
Node A Node B
| |
|--- I-frame [N(S)=0, N(R)=0] --------------------------------->|
| |
|--- I-frame [N(S)=1, N(R)=0] --XXXX (LOST) |
| |
|--- I-frame [N(S)=2, N(R)=0] --------------------------------->| (Out of order; discarded)
| |
|<-- S-frame: REJ [N(R)=1] -------------------------------------| (Requests retransmission from 1)
| |
|--- I-frame [N(S)=1, N(R)=0] --------------------------------->| (Retransmitting 1)
| |
|--- I-frame [N(S)=2, N(R)=0] --------------------------------->| (Retransmitting 2)While HDLC is a powerful protocol for point-to-point and multipoint configurations, it is primarily hardware-driven. For software-managed, dial-up, and broadband internet connections, the industry uses the Point-to-Point Protocol (PPP).
PPP is a byte-oriented protocol designed to run over IP networks, serial lines, and physical fiber links. Unlike HDLC, it supports multiple network-layer protocols simultaneously and provides built-in user authentication.
The PPP frame closely mirrors HDLC, but introduces crucial structural differences:
+----------+----------+----------+----------+------------------+----------+----------+
| Flag | Address | Control | Protocol | Information | FCS | Flag |
| 1 byte | 1 byte | 1 byte | 1/2 bytes| Variable Length | 2/4 bytes| 1 byte |
| (0x7E) | (0xFF) | (0x03) | | | | (0x7E) |
+----------+----------+----------+----------+------------------+----------+----------+01111110 ().11111111 (), representing the broadcast address. Point-to-point topologies do not require individual node addresses.00000011 (), mimicking HDLC's Unnumbered Information frame format.Because PPP is character-oriented, it uses byte stuffing with an escape character of 0x7D (). The stuffing mechanism operates as follows:
For example, a payload byte of 0x7E is transmitted as the two-byte sequence 0x7D 0x5E.
PPP functions as a container for several internal protocols. Rather than using a single monolithic design, it decouples link configuration from network-layer coordination.
+--------------------------------------------------------+
| Network Layer (IP, IPv6) |
+--------------------------------------------------------+
| IPCP (IP Control Protocol) | IPv6CP | ... | <--- NCPs
+--------------------------------------------------------+
| PAP / CHAP (Authentication Protocols) |
+--------------------------------------------------------+
| LCP (Link Control Protocol) | <--- LCP
+--------------------------------------------------------+
| Physical Link |
+--------------------------------------------------------+A PPP connection transitions through a well-defined sequence of states as it moves from physical silence to data transfer and back.
+-----------+
| DEAD | <---------------------------------+
+-----------+ |
| |
| Physical line detected | Link failed /
v | termination complete
+-----------+ |
| ESTABLISH | <------------+ |
+-----------+ | Option negotiation |
| | failed |
| LCP closed | |
v | |
+-----------+ | |
| AUTHENT- | --------------+ |
| ICATE | |
+-----------+ |
| |
| Auth succeeded |
v |
+-----------+ |
| NETWORK | |
+-----------+ |
| |
| NCP closed |
v |
+-----------+ |
| TERMINATE | -----------------------------------+
+-----------+This Python script implements the bit-stuffing and un-stuffing algorithms used by bit-oriented protocols like HDLC to ensure data transparency.
def hdlc_bit_stuff(data_bits: str) -> str:
"""
Stuffs a zero bit after every sequence of five consecutive ones.
"""
consecutive_ones = 0
stuffed_bits = []
for bit in data_bits:
if bit == '1':
consecutive_ones += 1
stuffed_bits.append(bit)
if consecutive_ones == 5:
stuffed_bits.append('0') # Stuff the 0 bit
consecutive_ones = 0
elif bit == '0':
consecutive_ones = 0
stuffed_bits.append(bit)
else:
raise ValueError
0), S-frames (starting with 10), and U-frames (starting with 11).0x7D as its escape character.A protocol mechanism used in bit-oriented systems (like HDLC) where a zero is stuffed after five consecutive ones to prevent data from being misconstrued as a frame flag.
A process used in character-oriented protocols (like PPP) where a special escape byte is inserted before control-like characters appearing within the data payload.
An HDLC configuration mode where both stations are treated as equals (peers), allowing either to initiate data transmission without prior permission.
The modular structure of PPP that employs LCP for link establishment and various NCPs to handle diverse network layer protocol configurations.
An optimization technique where acknowledgment numbers are embedded directly inside outgoing information (I-frames) rather than sent in separate control frames.
Test your understanding with 5 questions
If the raw data payload to be transmitted using HDLC is '01111110111110', what will be the resulting bitstream after applying the bit-stuffing algorithm?
Which of the following field patterns in the control byte of an HDLC frame uniquely identifies it as a Supervisory (S-frame)?
During byte stuffing in a standard Point-to-Point Protocol (PPP) frame, how is the flag byte 0x7E inside the payload transformed for transmission?
Which PPP sub-protocol is responsible for negotiating network-layer configurations, such as assigning dynamic IP addresses?
In HDLC's Go-Back-N ARQ implementation with a 3-bit sequence number, what is the maximum number of outstanding frames the sender can transmit without receiving an acknowledgment?
11 (Selective Reject - SREJ): Sent in Selective Repeat ARQ to request the retransmission of only the specific frame numbered .6 Modules
6 Modules