HDLC Encapsulation Protocol

Earlier in the previous article, I have discussed that HDLC is the default encapsulation protocol type on point-to-point connections, dedicated links, and circuit-switched links when the link uses two Cisco devices. It is a synchronous Data Link layer bit-oriented protocol originally developed from the Synchronous Data Link Protocol (SDLC) and became standardized by ISO as ISO 13239. It provides both connection-oriented and connectionless service. HDLC also provides flow control and error control by using acknowledgements. Cisco uses a proprietary version of the HDLC protocol known as Cisco HDLC (cHDLC).

HDLC uses synchronous serial transmission between two points to provide error-free communication. It defines a Layer 2 framing structure for flow control and error control through using the acknowledgements. Every HDLC frame has the same structure and format, whether it is a data frame or a control frame. For the beginning and end of frames, HDLC has no method, so for this reason, HDLC uses a frame delimiter, or flag, to mark the beginning and the end of each frame.

Figure 1 illustrates standard HDLC frame structure and format and figure illustrates cHDLC frame format and structure. The standard protocol support only one protocol, while the Cisco HDLC support multi-protocol environments. Multi-protocol is supported is possible due to the protocol field in the header, which identifies the different protocols.

HDLC Frame Types

As shown in figure 1 and Figure 2, each frame in HDLC may contain up to six and seven fields, a starting flag field, address field, control field, information field, frame check sequence (FCS) field, and an ending flag field. In multiple-frame transmissions, the ending flag of one frame can serve as the starting flag of the next frame. The Cisco HDLC (cHDLC) frame contains an extra protocol field.

HDLC Frame

Flag

The flag field of an HDLC frame is an 8-bit sequence with the bit pattern 01111110 that identifying both the starting and the end of a frame and serves as synchronization pattern for the receiver. This frame field initiates and terminates error checking. The 01111110 pattern occurs in the actual data, and the sending HDLC system always inserts a 0 bit after every five consecutive 1s in the data field, so in practice, the flag sequence can only occur at the frame ends. The receiving end strips out the inserted bits. When frames are transmitted repeatedly, the end flag of the first frame is used as the start flag of the next frame.

Address

The address field can be 1 byte or several bytes long contain the HDLC address of the secondary station. The address can be a group address or a broadcast address. A primary address is either a communication source or a destination, which eliminates the need to include the address of the primary. If a primary station created the frame, it contains a “to address”. If a secondary creates the frame, it contains a “from address”. If the address field is one byte long, it can identify up to 128 stations. Larger networks require multiple-byte address fields.

Control Field

The control field is a 1- or 2-byte long field identifies the type of frame including its functionality, flow control and error control. The control field uses three different formats, depending on the type of HDLC frame used:

  • Information (I) Frame – I-frames carry the user data from the upper layer including some control information like flow control and error control. This frame sends and receives sequence numbers, and the poll final bit. The send sequence number is the number of the frame to be sent next and the receive sequence number provides the number of the frame next to be received. Both source and destination maintain send and receive sequence numbers. A primary station uses the Poll Final bit to tell the secondary whether it requires an immediate response.
  • A secondary station uses the Poll Final bit to tell the primary whether the current frame is the last in its current response. The first bit of the control field defines the type of the control field. If the first bit of the control field is 0, this means the frame is an I-frame. Figure 3 illustrates the control field structure.   The next 3 bits known as N(S), identify the sequence number of the frame. The last 3 bits, known as N(R), match to the acknowledgement number when piggybacking is used. The single-bit between N(S) and N(R) is called the poll Final bit.
  • Supervisory (S) Frame –S-frames or supervisory frame provide control information. An S-frame can request and suspend transmission, report on status, and acknowledge receipt of I-frames. S-frames do not have an information field. Whenever piggybacking is either impossible or inappropriate, a supervisory frame is used for flow control and error control. If the first two bits of the control fields are set to “10”, this means the frame is an S-frame. The last three bits known as N(R), defines the ACK or NACK, depending on the type of S-frame. The 2 bits define the type of S-frame and 1 bit is for poll final. The figure-5 illustrates the supervisory (S) frame.
  • Unnumbered (U) Frame U-frames are used for link management and including some frame are used for the transfer of user data. Depending on the function of the U-frame, its control field is 1 or 2 bytes. U-frames exchange session management and control information between connected devices. The first 2 bits (11) defines that the frame is a U-frame. The 2 code bits before P/F bit and 3 bit after P/F bit create different types of U-frame. In a few cases, the same encoding is used for different things as a command and a response.

Protocol

This frame defines that the frame belongs to cHDLC and specifies the protocol type encapsulated within the frame (e.g. 0x0800 for IP).

Data

The data frame carries data from the network layer. Its length may vary from one network to another.

Frame Check Sequence (FCS)

The frame check sequence is the HDLC error detection field. It can contain be  2 or 4-byte long. It precedes the ending flag delimiter and is generally a Cyclic Redundancy Check (CRC) calculation remainder. The CRC calculation is rechecked in the receiving side. If the result of recheck is different from the value in the original frame, an error is assumed.

Configuring HDLC Encapsulation

Cisco devices used cHDLC is the default encapsulation method for synchronous serial lines.  If connecting non-Cisco devices, use synchronous PPP. We can change the default encapsulation method. If it is changed to some other encapsulation type and now want to change back to HDLC encapsulation, the following commands can be used.

  • Router>enable
  • Router#configure terminal
  • Router(config)#interface serial 0/0/0
  • Router(config-if)encapsulation hdlc
  • Router(config-if)exit
  • Router(config)exit
  • Rotuer#wr