2.1Framing and stuffing
The idea
Framing tells the receiver where a frame starts and ends. A special flag pattern marks the boundary, so the data must never contain that pattern: stuffing hides it.
Think of it like this: Quoting someone in a letter: if the quote contains a quotation mark, you put a backslash in front of it so the reader does not think the quote ended.
Why it exists
Questions ask for the stuffed bit string or the frame length after stuffing.
How it works
- Flag in HDLC is 01111110.
- Bit stuffing: after five 1s in the data, insert a 0.
- The receiver deletes a 0 that comes right after five 1s.
- Byte stuffing puts an ESC byte before every FLAG or ESC byte in the data.
Worked example: Stuff the data 0111110111111.
The first run of five 1s gets a 0 after it, and so does the second: 011111001111101. 13 data bits became 15, so 2 bits were added.
Now play with it
- →Type an all-ones string to see maximum stuffing (one extra bit per five).
- →Try a string with no five 1s: nothing is inserted.
Bit stuffing (HDLC, flag 01111110): after five 1s in a row the sender inserts a 0, so the flag can never appear inside the data.
Byte stuffing: every FLAG (F) or ESC (E) byte inside the data gets an ESC placed in front of it. Type bytes separated by spaces.
Check yourself
Data 111111 is bit-stuffed to
Exam notes (the dense version)
The link layer must mark where a frame starts and ends. Bit stuffing (HDLC, flag 01111110): after five consecutive 1s in the data the sender inserts a 0, and the receiver removes a 0 that follows five 1s. Byte stuffing: an escape byte is placed before every data byte that looks like the flag or the escape. The overhead depends on the data: all-ones data stuffs the most (one extra bit per five).
Previous year questions: Framing & Error Control (2)
PYQs are grouped by topic, so this is the full set for Framing & Error Control; try the ones that match this subtopic. Open all 2 on the topic page.