A frame is the basic unit of data transmission at the Data Link Layer. Framing is the process of dividing a continuous stream of bits into smaller units called frames so that the receiver can identify and process the data correctly.
- Frames contain data along with control information such as addresses and error-detection fields.
- Framing helps the receiver identify the beginning and end of each frame.

Purpose of Framing
Framing helps the Data Link Layer organize data for transmission between devices.
- Frame Identification: Marks the beginning and end of each frame.
- Addressing: Carries source and destination addresses when required.
- Error Detection: Helps detect transmission errors using mechanisms such as CRC or checksums. Error correction and retransmission depend on the protocol.
- Synchronization: Helps the receiver correctly process incoming frames.
Types of Framing
There are two common approaches to framing:
- Fixed-Size Framing
- Variable-Size Framing
1. Fixed-Size Framing
In fixed-size framing, every frame has the same predefined length. The receiver knows the frame boundary from its fixed size, so separate start and end delimiters are not required.
- Simple to implement because every frame has the same length.
- If the data does not completely fill a frame, padding can be added.
Example: ATM cells use a fixed size of 53 bytes.

2. Variable-Size Framing
In variable-size framing, frames can have different lengths. The receiver needs a way to identify where each frame starts and ends.
Two common methods are:
a. Length Field
A length field in the frame header specifies the size of the frame.
- The receiver uses this value to determine where the frame ends.
- If the length field is corrupted, the frame boundary may be interpreted incorrectly.
b. End Delimiter
A special pattern or character is used to mark the end of a frame.
- The delimiter separates one frame from the next.
- If the same pattern appears inside the data, stuffing is used to avoid confusion.
To resolve delimiter ambiguity, stuffing techniques are applied:
(a) Character/Byte Stuffing
Byte stuffing is used when a special character is used as a frame delimiter. If the delimiter appears in the actual data, an escape character is inserted before it so that the receiver does not mistake it for the end of the frame.
Example: If $ is the delimiter and $ appears in the data, an escape character can be inserted before it.
(b) Bit Stuffing
Bit stuffing is used when a special bit pattern is used as a frame delimiter. A 0 bit is inserted after a sequence of five consecutive 1s in the data. The receiver removes the inserted bit when the frame is received.

Example: If the data contains 11111, a 0 is inserted to prevent the delimiter pattern from appearing accidentally.
Challenges in Framing
- Overhead: Headers, trailers, and stuffing add extra bits to the frame.
- Synchronization: The receiver must correctly identify frame boundaries.
- Error Handling: Noise can affect frame data or boundary information.

