Skip to content
Home » Framing in Data Link Layer

Framing in Data Link Layer

1. What is Framing?

Framing is the process of dividing a continuous stream of bits received from the Network Layer into small, manageable units called frames.

The Data Link Layer takes a packet from the Network Layer and adds a header and trailer to create a frame.

Simple diagram

Network Layer
      ↓
   Packet
      ↓
Data Link Layer
      ↓
┌────────┬──────────────┬─────────┐
│ Header │     Data     │ Trailer │
└────────┴──────────────┴─────────┘
             Frame
      ↓
 Physical Layer
      ↓
   Bits/Signals

In simple words:

Framing means marking the beginning and end of each data unit so that the receiver knows where one frame starts and where it ends.


2. Why is Framing Needed?

Suppose the sender wants to send:

101101110010101001011010...

This is just a continuous stream of bits.

The receiver needs to know:

Frame 1        Frame 2        Frame 3
┌────────┐     ┌────────┐     ┌────────┐
│  Data  │     │  Data  │     │  Data  │
└────────┘     └────────┘     └────────┘

Without framing, the receiver may not know:

  • Where a frame starts
  • Where a frame ends
  • Which bits belong to which frame

Therefore, framing provides boundaries between data units.


3. Basic Structure of a Frame

A typical frame can be represented as:

┌──────────┬────────────────┬──────────┐
│  Header  │      Data      │ Trailer  │
└──────────┴────────────────┴──────────┘

Header

May contain:

  • Source MAC address
  • Destination MAC address
  • Control information
  • Other protocol information

Data

Contains the actual information received from the Network Layer.

Trailer

Usually contains error-detection information, such as FCS/CRC.


4. Main Framing Methods

There are several ways to identify frame boundaries.

The important methods are:

  1. Character Count
  2. Character Stuffing
  3. Bit Stuffing
  4. Physical Layer Coding Violations

Let’s understand each one simply.


5. Character Count

In this method, a field in the frame tells the receiver how many characters/bytes are present in the frame.

Example

Suppose:

5 A B C D E

The first value 5 tells the receiver:

“The next 5 characters belong to this frame.”

So:

┌──────┬─────────────────┐
│  5   │ A B C D E       │
└──────┴─────────────────┘
 Count       Data

Problem

If the count field becomes corrupted, the receiver may lose synchronization.

For example:

5 A B C D E  4 P Q R S

If 5 accidentally becomes 7, the receiver may interpret the next frame incorrectly.

Advantage

  • Very simple.

Disadvantage

  • Error in the count field can disturb the entire framing process.

6. Character Stuffing

This method is mainly used when frames contain characters/bytes.

Special characters are used to indicate:

Start of Frame
End of Frame

Suppose FLAG indicates the boundary:

FLAG  DATA  FLAG

But what happens if FLAG appears inside the actual data?

The sender inserts an escape character (ESC) before it.

Example

Original data:

A B FLAG C D

After character stuffing:

A B ESC FLAG C D

The receiver sees:

ESC FLAG

and understands that this FLAG is data, not the end of the frame.

Diagram

Original:

FLAG | A B FLAG C D | FLAG

After stuffing:

FLAG | A B ESC FLAG C D | FLAG
       ↑
     Stuffed

7. Bit Stuffing

Bit stuffing is commonly used in bit-oriented protocols such as HDLC.

A special bit pattern is used as a frame boundary.

HDLC commonly uses:

01111110

This is called a flag.

The problem

What if the same pattern occurs inside the actual data?

The sender inserts an extra 0 after every sequence of five consecutive 1s.

Example

Suppose data contains:

01111110

The sender sees five consecutive 1s:

0 11111 0

It inserts a 0 after the five 1s:

011111010

The receiver removes the stuffed 0 and recovers the original data.

Simple rule

After every five consecutive 1s in the data, insert a 0.

Diagram

Sender:

Data:       01111110
                 ↓
Bit stuffing
                 ↓
Sent:       011111010

Receiver:

011111010
      ↓
Remove stuffed 0
      ↓
01111110

8. Physical Layer Coding Violations

Some physical-layer encoding schemes have signal patterns that are not normally used for data.

These unused patterns can be used to indicate:

  • Start of frame
  • End of frame
  • Special control information

Basic idea

Normal signals → Data

Unused signal pattern → Frame boundary

Advantage

  • No extra bits or characters may be required.

Disadvantage

  • Depends on the physical-layer encoding technique.
  • Not applicable to all systems.

9. Comparison of Framing Methods

MethodBasic IdeaMain Problem
Character CountCount field tells frame lengthCount error can cause synchronization loss
Character StuffingAdd ESC before special character in dataExtra characters
Bit StuffingAdd 0 after five consecutive 1sExtra bits
Coding ViolationsUse unused physical signal patternsDepends on physical encoding

10. Easy Real-Life Example

Think of a long train carrying passengers.

Without separate coaches:

Passenger Passenger Passenger Passenger Passenger...

It is difficult to identify groups.

With coaches:

Coach 1 | Coach 2 | Coach 3

Each coach has a clear beginning and end.

Similarly:

Continuous Bits
       ↓
┌────────┐ ┌────────┐ ┌────────┐
│ Frame 1│ │ Frame 2│ │ Frame 3│
└────────┘ └────────┘ └────────┘

Frames organize the continuous bit stream into separate units.


11. Framing and Error Detection Are Different

Students often confuse these two.

Framing

Answers:

“Where does the frame start and end?”

Error Detection

Answers:

“Has the frame been damaged during transmission?”

For example:

┌────────┬────────────┬─────────┐
│ Header │    Data    │   CRC   │
└────────┴────────────┴─────────┘
    ↑                    ↑
 Framing              Error
 information         detection

So, framing identifies boundaries, while CRC/FCS checks errors.


⭐ Exam Summary

Definition

Framing is the process of dividing a continuous stream of bits into manageable units called frames and identifying the beginning and end of each frame.

Main framing methods:

              FRAMING
                 │
     ┌───────────┼────────────┐
     ↓           ↓            ↓
Character    Character     Bit
 Count       Stuffing     Stuffing
                              │
                              ↓
                     Coding Violations

Remember:

  • Character Count → tells frame length
  • Character Stuffing → uses ESC
  • Bit Stuffing → insert 0 after five 1s
  • Coding Violation → uses unused signal patterns

One-line memory:

Framing = separating the continuous bit stream into clearly identifiable frames.