>_
EngineeringNotes
Back to Data Link Layer
Module 01

Framing and Ethernet

Understanding how data is packed into frames and the fundamentals of Ethernet.

Framing

  • In the Data Link Layer, data is packed into frames to distinguish one from another. Rather than packing an entire message into a single large frame, it is divided into smaller frames. This improves error control since a single-bit error in a large frame would require retransmitting the entire message, while in smaller frames, only the affected frame needs retransmission.
  • Types of Framing:

Fixed-Size Framing:

  • No need for explicit frame boundaries as the frame size itself acts as a delimiter.

Variable-Size Framing:

  • Boundaries of frames need definition.
  • Two approaches:
    • Character-Oriented Approach: Uses special characters to indicate the start and end of frames.
    • Bit-Oriented Approach: Utilizes specific bit patterns to mark frame boundaries.

Character-Oriented Protocols

  • Data Composition: Carries 8-bit characters (like ASCII). It includes a header, trailer, and a frame-delimiting flag (8 bits) to indicate the start and end of a frame.
  • Issue with Flags: If the flag pattern appears within the data, the receiver might mistakenly consider it as the frame boundary.
  • Solution - Byte Stuffing: Adds an escape character (ESC) before any data pattern that matches the flag. The ESC character is also added to genuine ESC sequences to differentiate them.
  • Challenge with Unicode: As modern data uses wider characters (16-bit, 32-bit), character-oriented protocols face compatibility issues. The industry is shifting towards bit-oriented protocols to address this.
Data from upper layer
Variable number of characters
Flag
Header
...
Trailer
Flag
Data from upper layer
Flag
ESC
Stuffed
Sent frame
Flag
Header
ESC
Extra byte
Flag
ESC
Extra byte
ESC
Trailer
Flag
Received frame
Flag
Header
ESC
Flag
ESC
ESC
Trailer
Flag
Unstuffed
Flag
ESC

Bit-Oriented Protocols

  • Bit-Oriented Protocol Definition: Data is treated as a sequence of bits, which can represent various types of information like text, graphics, or video. A special 8-bit pattern (01111110) is used as a delimiter to mark the start and end of frames.
  • Challenge with Delimiters: If this delimiter pattern (01111110) appears in the data, it could be misinterpreted as a frame boundary.
  • Bit Stuffing Solution: To avoid confusion, a technique called "bit stuffing" is used. Whenever five consecutive 1s are detected in the data, a 0 is inserted. This ensures that the delimiter pattern does not accidentally appear within the data. Upon receiving, the extra bit is removed to restore the original data.
Data from upper layer
Variable number of bits
Flag01111110
Header
01111010110
...
11011110
Trailer
Flag01111110
Data from upper layer
0001111111001111101000
Stuffed
Frame sent
Flag
Header
00011111011001111101000
Trailer
Flag
Two extra
bits
Frame received
Flag
Header
00011111011001111101000
Trailer
Flag
Unstuffed
0001111111001111101000
Data to upper layer