Data Link

HDLC Protocol

High-Level Data Link Control frame structure, commands, and operation modes.

What is HDLC?

High-Level Data Link Control (HDLC) is a data-link protocol, operating at layer 2 of the OSI model. It defines frame formats and exchange procedures for one link between devices, such as a leased line between two routers. The scope of reliable delivery depends on the procedure class and operating mode.

Its main purpose is to place a packet from the Network Layer into a standardized structure called a frame. The frame contains data, an address, a control field, and a check sequence for error detection. HDLC procedures support point-to-point and multipoint links, and HDLC-derived solutions were used in PPP, Frame Relay, and ISDN. The procedure class determines how frames are numbered, acknowledged, and recovered after errors.

Stations and operational modes

Before examining the frame, distinguish the roles that devices, called stations, can play and the modes in which an HDLC link operates.

Station types

  • Primary station: Controls the data link, issues commands, initiates transfers, and handles error-recovery procedures.
  • Secondary station:Operates under the control of a primary station. It responds to the primary station's commands and transmits after polling in NRM.
  • Combined station: Combines primary and secondary functions. It can send and receive commands and responses, allowing both stations to act as peers.

Operational modes

  • Normal Response Mode (NRM): An unbalanced configuration for point-to-multipoint links. It has one primary station and at least one secondary station. A secondary transmits only after polling, meaning explicit permission from the primary.
  • Asynchronous Response Mode (ARM): Another unbalanced mode. It allows a secondary station to initiate transmission without waiting for a poll. The primary station retains control over link setup and error-recovery procedures.
  • Asynchronous Balanced Mode (ABM): Uses two combined stations acting as peers, especially on point-to-point links. Either station can initiate transmission without separate permission from the other, supporting full-duplex communication.

HDLC frame structure

HDLC places data and control messages in a defined structure called a frame. Each field has a function specified by the selected procedure. The field order is fixed for a given format, and flags separate frames in the bit stream.

  • Flag (8 bits): The frame begins and ends with the sequence 01111110. The flag delimits a frame in a continuous bit stream. One flag may simultaneously mark the end of one frame and the beginning of the next.
  • Address (8 or 16 bits): The basic format uses 8 bits; an extended format may use 16 bits or more. The field identifies the destination station. On a point-to-point link it may have a standard value because the destination is unambiguous. In a multipoint configuration it selects one of several secondary stations. In procedures that support broadcast, an all-ones value may serve as a broadcast address.
  • Control (8 or 16 bits):This field defines the frame's function and may contain sequence numbers for flow and error control. The first bits distinguish Information (I), Supervisory (S), and Unnumbered (U) frames.
  • Information (variable length): This field carries higher-layer data, typically a Network Layer packet such as an IP packet. It appears in Information frames and some Unnumbered frames. Its length can vary up to a negotiated maximum.
  • Frame Check Sequence (FCS) (16 or 32 bits): This field detects errors. The sender calculates a value using a algorithm over the Address, Control, and Information fields. The receiver performs the same calculation. A mismatch indicates a corrupted frame, which is discarded. The selected FCS length and generator are part of the procedure format.

Bit stuffing

If the flag sequence 01111110 appeared in user data, the receiver could treat it as the end of a frame. HDLC uses bit stuffing, also called zero-bit insertion, to prevent this interpretation. Stuffing applies between flags, so the delimiter remains available to mark frame boundaries.

  • Sender's action: The sender scans the data stream between flags. After five consecutive 1 bits, it inserts an extra 0 before transmission.
  • Receiver's action: The receiver scans the incoming stream. After five consecutive 1 bits, it removes a following 0 when that bit belongs to the stuffed data. It recognizes the flag as the delimiter 01111110at a frame boundary, so the flag's final 0 is not removed as a stuffed bit. Other sequences may indicate an abort or an error according to the procedure.

In validly stuffed data, the flag sequence does not occur as an unintended part of the frame. Removing inserted zeros restores the original data stream.

Control field and frame types

The Control field has 8 bits in the basic format and 16 bits in the extended format. Its structure determines the frame's function.

Information Frames (I-frames)

I-frames carry user data from the Network Layer. The control field starts with a 0. Their send and receive numbers support acknowledged, ordered delivery when the selected procedure enables it.

  • N(S) - Send Sequence Number: A 3-bit sequence number for the outgoing frame. The field has 8 values (232^3), but the maximum window in modulo-8 operation is 7 so that new frames can be distinguished from repeats. The extended format uses 7 bits, modulo-128 numbering, and a maximum window of 127.
  • N(R) - Receive Sequence Number: A 3-bit sequence number that acknowledges received frames. It identifies the next frame expected by the station, implicitly acknowledging frames through N(R)-1. This is part of HDLC's sliding-window mechanism. In the extended format, N(R) also has 7 bits.
  • P/F - Poll/Final bit: In unbalanced modes, a primary station sets it to 1 to poll a secondary station for a response. The secondary station sets it to 1 in the final response frame. In balanced mode, the meaning follows whether the frame is a command or a response.
Supervisory Frames (S-frames)

S-frames are used for flow and error control. They do not carry user data. The control field starts with 10. Their N(R) field can acknowledge several consecutive frames and report receiver readiness.

  • Type (2 bits): Defines the function of the S-frame:
    • Receive Ready (RR): Acknowledges received frames up to N(R)-1 and indicates readiness to receive more.
    • Receive Not Ready (RNR): Acknowledges received frames but tells the sender to temporarily stop transmitting (flow control).
    • Reject (REJ): A negative acknowledgment requesting retransmission of frames starting from N(R), the first missing frame.
    • Selective Reject (SREJ): In procedures that support it, requests retransmission of a selected frame identified by its sequence number.
  • N(R) - Receive Sequence Number: Same function as in I-frames, used for acknowledging data.
Unnumbered Frames (U-frames)

U-frames are used for link management purposes, such as establishing and terminating connections. They do not have sequence numbers. The control field starts with 11. Depending on the procedure, they may carry management information and establish the operating mode.

Common U-frames include:

  • SABME (Set Asynchronous Balanced Mode Extended): A command to establish an HDLC link in ABM mode with extended (7-bit) sequence numbers.
  • DISC (Disconnect): A command to terminate the logical link.
  • UA (Unnumbered Acknowledgment): A response used to confirm the acceptance of a U-frame command like SABME or DISC.

Related articles