HDLC Framing

The High Level Link Control (HDLC) protocol defined by the International Standards Organisation (ISO) provides a transparent transmission service at the data link layer of the OSI reference model. Many protocol suites use an HDLC (or HDLC-based) link layer, including X.25, the IP point-to-point protocol (PPP) and SNA.

The users of the HDLC service provides PDUs which are encapsulated to form data link layer frames. These frames are separated by HDLC "flags" and are modified by "zero bit insertion" to guarantee transparency. These terms are defined below:


HDLC is a data link protocol which uses a unique bit sequence to delimit the start and end of each PDU transported by the data link layer service. In HDLC, frames are delimited by a sequence of bits known as a "flag". The flag sequence is a unique 8-bit sequence of the form 0111 1110. The way in which this is performed is described in the text and diagrams which follow.

The flags before and after an HDLC frame indicate the start and end of the frame


The flag sequence must never occur within the content of a frame otherwise it could be confused with an intentionally sent flag. A technique known as 0-bit insertion is used to prevent random data synthesising a flag. The technique is said to make HDLC transparent, since any stream of bits may be present between the open and closing flag of a frame. The transparency is achieved by encoding the data by inserting a 0-bit after any sequence of 5 consecutive 1's within the payload, as shown:

Insertion of a "zero-bit" into the content of a frame to ensure transparency

Hunt Mode

Normally a HDLC receiver starts in the idle state, waiting for the start of a frame. This is called "Hunt" mode, since the receiver is said to be hunting for a non-flag sequence. This may be achieved through a shift register and combinational logic as shown (a Finite State Machine (FSM) is usually used to implement this):

Detection of a start of frame

Abort & Idle Patterns

Valid frames are terminated by a closing flag. If the link layer protocol needs to transmit a higher priority frame before the current frame has been fully sent, it may "Abort" the frame. An "aborted" frame is terminated by an "abort sequence": 0111 1111 instead of the normal "flag sequence". Abort sequences may also be caused by bit errors which occur while the frame is travelling from the transmitter to the receiver. (For instance a flag may suffer a 1-bit inversion of the least significant bit, resulting in a bit sequence identical to an "abort").

A frame which is terminated by an abort is received by the receiver in the normal way, but marked as being "aborted". The frame is then discarded without further processing. This is shown below:

An HDLC frame terminated by an "abort" is discarded by the HDLC receiver

An abort sequence is often followed by a series of 1's. The sequence of all 1's may be used to fill the gaps between frames (or alternatively a continuous series of flags may be transmitted). The all 1's sequence is known as the "idle" sequence, since the line becomes idle (N.B. represented at the physical layer by 0 Volts). This is useful for applications requiring half duplex operation (also known as Two Way Alternate (TWA) operation).

See also:


Gorry Fairhurst - Date: 01/10/2001 EG3557