Also known as: HDLC, High-level Data Link Control
HDLC (High-level Data Link Control) is a bit-oriented data-link framing protocol that delimits frames with a reserved flag byte, guarantees that flag can never appear inside the data by bit-stuffing, and protects each frame with a frame check sequence.1 It is the framing layer that sits beneath AX.25 — and therefore APRS and packet radio — turning a raw stream of demodulated bits into cleanly delimited, integrity-checked frames.
How it works
HDLC solves the framing problem — where does a frame start and end? — with three interlocking mechanisms:
- Flag delimiter. The byte
0x7E(binary01111110) marks the start and end of every frame. Back-to-back frames can share one flag as both closing and opening. - Bit-stuffing. So the flag’s six-consecutive-1s pattern can never occur inside the
payload, the transmitter inserts a
0after any run of five1bits in the data; the receiver removes it. This makes the flag genuinely unique and keeps the frame transparent — any byte value can be carried. - Frame check sequence. A trailing 16-bit CRC (CRC-CCITT) computed over the frame lets the receiver discard corrupted frames rather than pass bad data upward.
Bit ordering matters: AX.25 sends each byte least-significant-bit first on the wire, so an HDLC framer for it packs and unpacks bits LSB-first. HDLC is bit-oriented — it operates on the bit stream itself, not on byte boundaries — which is why it can bit-stuff and why frames need not be a whole number of bytes until the FCS is validated.
In practice
On the receive side, an HDLC deframer slides a shift register through the incoming bits looking
for the flag pattern, then collects bits between two flags, removes stuffed zeros, and checks
that the result is byte-aligned and long enough to be a real frame before validating the FCS.
Note what HDLC does not do: it does not demodulate, and it does not undo line coding such as
NRZI — an AFSK modem handles NRZI in the demod-to-bits step, so by the time
bits reach the HDLC layer they are plain {0,1}.
Relevance to SDR
HDLC is the framing an SDR decoder must reproduce to recover packet radio. Decoding an APRS transmission means demodulating the 1200-baud AFSK, recovering bits, undoing NRZI, and then running HDLC deframing to extract the AX.25 frame whose FCS you verify before parsing the position report. The same framing underlies KISS TNCs and classic packet BBS traffic. Beyond amateur radio, HDLC’s flag-and-bit-stuffing idea reappears in PPP and X.25 LAPB.
GopherTrunk implements HDLC directly in its AX.25/APRS path: the internal/radio/aprs/hdlc
package is a sync-aware framer that finds 0x7E flags, removes bit-stuffing, enforces byte
alignment and length limits, and emits one frame body per flag-delimited sequence, leaving FCS
validation to the AX.25 parser. It is a clean, real instance of the flag/bit-stuffing/FCS
packet framing model in a working pure-Go receiver.
Sources
-
High-Level Data Link Control — Wikipedia, on flag delimiting, bit-stuffing, and the frame check sequence. ↩