HDLC.md

HDLC

Frame Format

Flag Address Control Information FCS Flag
01111110 1/more bytes 8/16bits variable, 8 x n bits 16/32bits 01111110

Flag Sequence

Use the flag sequence 01111110 to delimit frames.

If the flag sequence appears in the data, it is escaped by inserting a 0 after five consecutive 1s.

Address Field

For address field longer than 1 byte, the last byte has the last bit set to 1, and the previous bytes have the last bit set to 0.

Control Field

The control field is used to specify the type of frame.

Information Frames

0 N(S) P/F N(R)
bit(s) 1 3 1 3

Supervisory Frames

10 CODE P/F N(R)
bit(s) 2 2 1 3

here are some cases of supervisory frames:

ACK:  RR | RNR(N(R)=x) | I
REJ:  REJ(N(R)=x) | SREJ(N(R)=x) | I

POLL:     RR(P/F=1)
POLL.ACK: I
POLL.NAK: RR(P/F=1)

SEL:      RNR(P/F=1)
SEL.ACK:  RR(P/F=1)
SEL.NAK:  RNR(P/F=1)

Unnumbered Frames

11 CODE P/F CODE
bit(s) 2 2 1 3

Information Field

HDLC uses piggybacking to send data and control information in the same frame, which is more efficient.

Frame Check Sequence (FCS)

Example