HDLC (High-level Data Link Control) is a OSI Layer 2 Data Link Control Protocol. It is responsible for ensuring that the data passed through it from the data source (Layers 3 and up) through the physical medium (Layer 1) makes it through with no errors, omissions, or sequencing problems.
HDLC is a highly efficient, synchronous, transparent bit oriented protocol, enabling it to carry any data stream regardless of its origin. It sends data in frames that have the following general structure:
(flag) (address) (control) (..payload..) (CRC) (flag)
The flags are a bit sequence that identifies the beginning and end of a frame. HDLC uses a technique known as transparent bit stuffing to ensure that the flag does not appear anywhere but at the ends of a frame. It will insert bits in a known pattern if any portion of the frame would contain the flag sequence. The receiver then removes the extra bits before presenting the data as output.
The address bits are available for use by the HDLC connected devices to enable multiple devices to share one physical link. Each device can be assigned its own address, and will only receive those frames addressed to it.
The control bits provide for retransmission and sequencing information. The CRC bytes are calculated by performing a predetermined arithmetic on every bit in the frame, excluding the flags. The receiver then performs the same calculation to verify that the CRCs received match the data they were made from. If not, a resend is requested.
HDLC can achieve near ideal data rates as the frame size increases, since the framing overhead remains nearly constant. 4096 bits is an average frame size used in common implementations. A sliding window technique is used to allow several frames to be sent before an acknowledgment is required or a frame is resent. This allows the protocol to operate efficiently on high latency links such as satellite hookups. Commonly, 28 frames are allowed to be sent before requiring an acknowledgment on terrestrial lines, and 128 frames can be sent over satellite links.