HDLC Frame Decoder
Decode raw HDLC frame bytes and inspect opening and closing flags, address field, I-frame, S-frame or U-frame control information, send and receive sequence numbers, Poll/Final bit, payload and optional 16-bit HDLC FCS.
7E
flags are optional. Spaces, commas, colons, hyphens, line breaks, continuous
hex and 0x-prefixed bytes are accepted.
—
—
—
—
What Is an HDLC Frame?
HDLC, or High-Level Data Link Control, is a bit-oriented data-link protocol. A conventional frame contains a flag sequence, address field, control field, optional information data and a frame check sequence before the closing flag.
Flag
Address
Control
Information
FCS
FlagHDLC Flag Byte
The standard HDLC flag pattern is binary 01111110, represented as
hexadecimal 0x7E when displayed as a reconstructed octet.
Binary:
01111110
Hex:
7EThe same pattern can delimit the end of one frame and the beginning of another.
HDLC Bit Stuffing
HDLC prevents the flag pattern from appearing accidentally inside frame data by inserting a zero bit after a run of five consecutive one bits during transmission.
The receiver removes those inserted bits before reconstructing the address, control, information and FCS octets. This decoder expects those reconstructed octets rather than a raw stuffed bit stream.
HDLC Address Field
HDLC supports address fields of one or more octets. In commonly used extended address representations, the least significant bit acts as an extension indicator. An octet with its low bit equal to one marks the final address octet.
Address octet LSB:
0
More address octets follow
1
Final address octetThe exact semantic interpretation of the address bits depends on the protocol profile using HDLC.
HDLC Frame Types
| Type | Name | Purpose |
|---|---|---|
| I | Information | Transfers user information and sequence acknowledgements |
| S | Supervisory | Flow control and acknowledgement functions |
| U | Unnumbered | Link management and unnumbered information |
HDLC I-Frame Control Field
For the common one-octet modulo-8 control format, an Information frame has bit 0 equal to zero.
Bit 0:
0 → I-frame
N(S):
bits 3:1
P/F:
bit 4
N(R):
bits 7:5N(S) is the transmit sequence number and N(R) carries the next expected receive sequence number.
HDLC Supervisory Frames
Supervisory frames have the low two control bits equal to binary 01. Two additional bits identify the supervisory function.
| S Bits | Frame | Meaning |
|---|---|---|
| 00 | RR | Receive Ready |
| 01 | RNR | Receive Not Ready |
| 10 | REJ | Reject |
| 11 | SREJ | Selective Reject |
HDLC Unnumbered Frames
Unnumbered frames have their low two control bits equal to binary 11. Their remaining function bits identify link-management commands and responses.
Common U-frame controls include UI, SABM, SABME, DISC, UA, DM and FRMR, although not every HDLC-derived protocol uses every command.
HDLC Poll/Final Bit
The P/F bit occupies bit 4 in the common one-byte control format. When a frame is sent as a command it can act as the Poll bit; in a response it can act as the Final bit.
HDLC Frame Check Sequence
HDLC frames commonly include an FCS for error detection. A widely used 16-bit HDLC FCS uses the reflected polynomial associated with CRC-16/X.25.
Common 16-bit parameters:
Polynomial:
0x1021
Reflected polynomial:
0x8408
Initial value:
0xFFFF
Input reflected:
Yes
Output reflected:
Yes
Final XOR:
0xFFFFOn the wire, the two FCS octets are commonly transmitted least-significant octet first. Different HDLC profiles can use different FCS widths or framing rules, so the decoder allows FCS checking to be disabled.
HDLC vs PPP
PPP uses HDLC-like framing but defines its own field conventions, including well-known address and control values and protocol identification fields. A generic HDLC decoder should therefore not assume that every HDLC-looking frame is a native ISO HDLC information frame.