---
title: "Data link layer framing"
subject: "Computer Networks and Security"
chapter: 3
key: "semester_7/computer_networks_and_security:framing-mechanisms"
source: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/framing-mechanisms
site: BCT Engineering
---

# Data link layer framing

Computer Networks and Security · Chapter 3: Data Link Layer

- Asked in: 2069 Chaitra, 8 marks; 2072 Chaitra; 2071 Shrawan, 5 marks (asked 3 times)
- Video: [Framing (Part 1)](https://www.youtube.com/watch?v=NhpzBldHOYo) — Neso Academy
- 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/framing-mechanisms
- Whole chapter: https://www.bctengineer.com/md/semester_7/computer_networks_and_security/chapter-3

## Question

Explain the different types of data link layer framing mechanisms (framing in detail).

## Short answer

Framing mechanisms include character count (prone to desynchronisation), byte stuffing with flag and ESC bytes, bit stuffing where a 0 follows five consecutive 1s inside 01111110 flags, and physical coding violations using invalid signal patterns.

## Answer

**Framing** is the data link layer function of splitting the bit stream from the network layer into discrete units called frames, so the receiver can identify where each frame starts and ends and check it for errors. Each frame has a header, data and trailer.

#### 1. Character (byte) count
A field in the header tells the number of characters in the frame.
```text
| 5 | a b c d | 6 | e f g h i | 4 | j k l |
```
Problem: if the count is corrupted, the receiver loses synchronization and cannot find the next frame. Rarely used.

#### 2. Flag bytes with byte stuffing
Each frame starts and ends with a special **FLAG byte** (for example 01111110). If the flag pattern (or escape byte) appears in the data, the sender inserts an **ESC** byte before it. The receiver removes the ESC.
```text
 FLAG | A FLAG B | FLAG   -->   FLAG | A ESC FLAG B | FLAG
```
Used in PPP. Weakness: tied to 8-bit characters.

#### 3. Flag bits with bit stuffing
Each frame starts and ends with the flag **01111110**. Whenever the sender sees **five consecutive 1s** in the data, it inserts a **0**. The receiver deletes a 0 that follows five 1s. This allows frames of any bit length. Used in HDLC.
```text
 data    : 0111111 0 1111110
 stuffed : 01111101 0 11111010
```

#### 4. Physical layer coding violations
Uses signal patterns not used for data, such as high-high or low-low in Manchester encoding, to mark frame boundaries. Used in LANs; wastes no bits, but only works where redundancy exists in the encoding.

| Method | Data unit | Issue |
|---|---|---|
| Character count | Bytes | Count error is fatal |
| Byte stuffing | Bytes | Overhead, fixed byte size |
| Bit stuffing | Bits | Small overhead, flexible |
| Coding violation | Signal | Needs special encoding |

In practice many protocols combine character count and another method for safety.

## Check yourself

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

1. What is the main problem with the character (byte) count framing method?
   A. It cannot be used with bytes
   B. If the count field is corrupted the receiver loses synchronization
   C. It needs a flag pattern inserted into the data
   D. It requires Manchester encoding
   Answer: B. A corrupted count makes the receiver misjudge where the frame ends, so it cannot find the next frame. (Key point: Character count weakness)

2. In byte stuffing, what does the sender do when the FLAG pattern appears in the data?
   A. Deletes the FLAG byte
   B. Inserts an ESC byte before it
   C. Inserts a 0 after it
   D. Ends the frame early
   Answer: B. An ESC byte is inserted before the FLAG so the receiver treats it as data; the receiver removes the ESC. (Key point: Byte stuffing)

3. In bit stuffing with flag 01111110, when does the sender insert a 0?
   A. After every two consecutive 1s
   B. After every five consecutive 1s
   C. After every six consecutive 1s
   D. After every 0 that follows a 1
   Answer: B. Five consecutive 1s in the data trigger a stuffed 0, so six 1s never appear in the data and the flag stays unique. (Key point: Bit stuffing rule)

4. Which framing method uses signal patterns such as high-high or low-low in Manchester encoding?
   A. Physical layer coding violations
   B. Byte stuffing
   C. Character count
   D. Bit stuffing
   Answer: A. These patterns never occur in valid data under Manchester encoding, so they mark frame boundaries without extra bits, but need redundancy in the encoding. (Key point: Coding violations)

## Related in Computer Networks and Security

- [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×

## Related in other subjects

- [Basic data transfer mechanisms in USB](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Ausb-transfer-mechanisms) — Instrumentation II, chapter 3
- [USB standards and data transfer mechanisms](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Ausb-standards-transfer-mech) — Instrumentation II, chapter 3
- [Flow control mechanisms in data communication](https://www.bctengineer.com/question.md?key=semester_8%2Ftelecommunications%3Aflow-control-mechanisms) — Telecommunications, chapter 8
- [Bowditch balancing of link traverse XABCY](https://www.bctengineer.com/question.md?key=semester_4%2Fsurveying_ii%3Abowditch-link-traverse-xabcy) — Surveying II, chapter 1, asked 2×
