Computer Network & Network Security System β Data Link Layer, NEC licence examination syllabus (Nepal Engineering Council).
Data Link Protocol: HDLC and Framing Methods
How do you mark where one frame ends and the next begins?
π¦ HDLC (High-Level Data Link Control)
Frame formatFlag β Address β Control β Data β FCS (frame check sequence) β Flag.
Transfer modesNormal Response Mode (primary/secondary stations), Asynchronous Balanced Mode (peer-to-peer, most common today).
π§΅ Framing Methods
Character stuffingInsert a special escape character before any data character that accidentally matches a frame-boundary marker, so the receiver isn't confused.
Bit stuffingInsert an extra 0 after every five consecutive 1s in the data, so the data can never accidentally look like the 6-ones flag pattern (01111110) HDLC uses to mark frame boundaries.
π‘ Practice a bit-stuffing numerical: given a data bit stream, show exactly where stuffed 0s get inserted, and how the receiver removes them again.
The bit-stuffing numerical, worked
The rule has two halves, and questions ask for both directions.
SENDING β insert a 0 after every five consecutive 1s:
Data: 0 11111 111111 0 1111111 0
Reading left to right, count runs of 1s and stuff after each fifth:
Data : 011111111111011111110 (21 bits)
Stuffed : 011111011111010111110110 (24 bits)
β β β
three 0s inserted after each run of five 1s
RECEIVING β remove a 0 that follows exactly five 1s:
Received : 011111011111010111110110
After five 1s, the next bit is a stuffed 0 β discard it
Recovered: 011111111111011111110 β matches the original
The point of the whole exercise: the flag 01111110 contains six consecutive 1s, and after stuffing the data can never contain six in a row β a 0 is forced in after the fifth. So any six-1s pattern the receiver sees must be a real frame boundary, never data that happened to look like one.
π‘ Two marks are commonly lost here. First, stuffing happens after five 1s, not six β waiting for six would already have produced the flag. Second, the receiver removes a 0 only when it follows exactly five 1s; a 0 anywhere else is genuine data.
Character stuffing, and why bit stuffing replaced it
Character stuffing does the same job at byte granularity: an escape character is inserted before any data byte that matches the frame delimiter β and before any data byte that matches the escape character itself, which is the case students forget.
Its weakness is that it assumes data comes in whole characters of a fixed size, which ties the protocol to a particular character encoding. Bit stuffing works on an arbitrary bit stream, so it carries any data at all β which is why HDLC, PPP and their descendants all use it.
π‘ Worst-case overhead is worth knowing: bit stuffing adds at most one bit per five, so about 20% on data that is entirely 1s, and essentially nothing on typical mixed data. Character stuffing can double the frame in the worst case, since every byte might need an escape.
Syllabus points
HDLC: frame format, transfer modes
Framing methods (character/bit stuffing)
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.