Skip to main content

Bit stuffing of a given string (1)

Short answer

In HDLC, a 0 is inserted after every five consecutive 1s. Applying to 01111011111011111110 yields the transmitted string 0111101111100111110110 (20 bits become 22).

Suppose a bit string, 01111011111011111110, needs to be transmitted at the data link layer. What is the string actually transmitted after bit stuffing?

Rule: in bit stuffing (HDLC, flag = 01111110), the sender inserts a 0 after every five consecutive 1s in the data.

Given data (20 bits): 01111011111011111110

Step by step

Position in dataRun of 1sAction
0nonesend 0
1 to 41111 (four 1s)no stuffing; next bit is 0
50send 0
6 to 1011111 (five 1s)insert 0 after the fifth 1
110send 0
12 to 181111111 (seven 1s)insert 0 after the first five 1s; the remaining two 1s are followed by 0
190send 0

Grouped:

 original : 0 1111 0 11111 0 1111111 0
 stuffed  : 0 1111 0 11111[0] 0 11111[0] 11 0

Stuffed data (22 bits): 0111101111100111110110

With flags added at both ends (01111110), the frame on the line is:

 01111110 0111101111100111110110 01111110

Answer: 0111101111100111110110 (two extra 0s inserted, 20 bits become 22 bits).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Networks and Security chapter 3 questions →