---
title: "Bit stuffing of a given string (1)"
subject: "Computer Networks and Security"
chapter: 3
key: "semester_7/computer_networks_and_security:bit-stuffing-numerical-1"
source: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/bit-stuffing-numerical-1
site: BCT Engineering
---

# Bit stuffing of a given string (1)

Computer Networks and Security · Chapter 3: Data Link Layer

- Asked in: 2073 Chaitra, 3 marks
- Video: [Lec-27: Framing in Data Link Layer | Bit Stuffing vs Byte(Character) Stuffing](https://www.youtube.com/watch?v=2U6kPu0dfqI) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/bit-stuffing-numerical-1
- Whole chapter: https://www.bctengineer.com/md/semester_7/computer_networks_and_security/chapter-3

## Question

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

## 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).

## Answer

**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 data | Run of 1s | Action |
|---|---|---|
| 0 | none | send 0 |
| 1 to 4 | 1111 (four 1s) | no stuffing; next bit is 0 |
| 5 | 0 | send 0 |
| 6 to 10 | 11111 (five 1s) | insert **0** after the fifth 1 |
| 11 | 0 | send 0 |
| 12 to 18 | 1111111 (seven 1s) | insert **0** after the first five 1s; the remaining two 1s are followed by 0 |
| 19 | 0 | send 0 |

Grouped:
```text
 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:
```text
 01111110 0111101111100111110110 01111110
```

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

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How many 0s are inserted into 01111011111011111110 by bit stuffing?
   A. 1
   B. 2
   C. 3
   D. 4
   Answer: B. One 0 after the five-1 run at positions 6-10 and one after the first five of the seven-1 run: 2 in total. (Key point: Stuffing rule)

2. What is the stuffed string?
   A. 0111101111100111110110
   B. 0111101111101111110
   C. 0111101111100111111010
   D. 01111011111011111110
   Answer: A. Insert 0 after each five 1s: 0 1111 0 11111[0] 0 11111[0] 11 0. (Key point: Result)

3. Why is no 0 inserted in the first run 1111?
   A. It is at the start
   B. It has only four consecutive 1s, fewer than five
   C. It is followed by 0
   D. Flags forbid it
   Answer: B. Stuffing only triggers after five consecutive 1s. (Key point: Run of four)

## Related in Computer Networks and Security

- [Error correction vs detection, bit stuffing](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Aerror-correct-detect-bitstuff) — Computer Networks and Security, chapter 3
- [Functions of data link layer](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Adll-functions) — Computer Networks and Security, chapter 3, asked 3×
- [Data link layer framing](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Aframing-mechanisms) — Computer Networks and Security, chapter 3, asked 3×
