Framing in the Data Link Layer
Framing is a crucial process in the Data Link Layer that organizes raw bit streams into discrete units called frames. This organization is essential for effective communication between devices. The Data Link Layer relies on the services provided by the Physical Layer, which accepts a raw bit stream and attempts to deliver it to the destination. However, the bit stream received by the Data Link Layer is not guaranteed to be error-free. Some bits may have different values, and the number of bits received may be less than, equal to, or more than the number of bits transmitted.
To manage this, the Data Link Layer must detect and, if necessary, correct errors. The usual approach is for the Data Link Layer to break up the bit stream into discrete frames, compute a short token called a checksum for each frame, and include the checksum in the frame when it is transmitted. When a frame arrives at the destination, the checksum is recomputed. If the newly computed checksum differs from the one contained in the frame, the Data Link Layer knows that an error has occurred and takes steps to deal with it, such as discarding the bad frame and possibly sending back an error report.
Methods of Framing
1. Byte Count
This method uses a field in the header to specify the number of bytes in the frame. When the Data Link Layer at the destination sees the byte count, it knows how many bytes follow and where the end of the frame is. However, this method can lead to synchronization issues if the byte count is garbled by a transmission error.

2. Flag Bytes with Byte Stuffing
This method uses special bytes, called flag bytes, to indicate the start and end of each frame. If the receiver loses synchronization, it can search for two consecutive flag bytes to find the end of the current frame and the start of the next frame. To prevent confusion with flag bytes that may appear in the data, the sender’s Data Link Layer inserts an escape byte (ESC) before each accidental flag byte in the data. This technique is known as byte stuffing.

3. Flag Bits with Bit Stuffing
This method operates at the bit level, allowing frames to contain an arbitrary number of bits. Each frame begins and ends with a special bit pattern, such as 01111110
. When the sender’s Data Link Layer encounters five consecutive 1s in the data, it automatically stuffs a 0 bit into the outgoing bit stream. This ensures that the flag pattern remains unique and helps maintain synchronization.

4. Physical Layer Coding Violations
This method uses reserved signals from the physical layer to indicate the start and end of frames. By utilizing coding violations, the Data Link Layer can delimit frames without the need for stuffing, making it an efficient approach.
Conclusion
Framing is a fundamental aspect of the Data Link Layer that ensures effective communication between devices. By organizing raw bit streams into frames and employing various methods such as byte counting, flag bytes with byte stuffing, bit stuffing, and physical layer coding violations, the Data Link Layer can manage data transmission efficiently. Understanding these framing techniques is essential for grasping the complexities of network communication.