High-Level Data Link Control (HDLC)


High-Level Data Link Control (HDLC) is a synchronous data-link layer protocol. It was developed by the International Organization for Standardization (ISO).

It only describes the data-link layer, and therefore is not really considered an communication protocol in it’s own right. It may be used by other communication protocols such as LVDS.


Framing for a HDLC packet is done with the special bit sequence 0x7E (0b01111110). This is used to mark the beginning and end of each frame. Because 0x7E can only be used to as a framing sequence, any occurrence of 0x7E in the packet must be removed. This is done differently depending of the framing type (synchronous or asynchronous, see below).

Synchronous Framing

To prevent 0x7E from ever occurring in the packet data, bit stuffing is used. Every time 5 consecutive 0‘s are transmitted, a 1 is inserted. The receiver must also look for 5 consecutive 0‘s and then remove the following 1.

Asynchronous Framing

Bit-stuffing is inconvenient when the communication protocol requires bits to be sent in groups such as bytes (e.g. RS-232). In this case, control-octet transparency is used instead (also called byte stuffing or octet stuffing).

With control-octet transparency, if either 0x7E (the frame boundary octet) or 0x7D (the control escape octet) appears in the packet data, the escape octet is first sent, followed by the original data, but with bit 5 inverted. This ensures that 0x7E is never found withing the packet data, and is only used for packet framing.

Obviously, the receiver has to look for escape octets, remove them from the data stream, and invert bit 5 of the next byte.