Framing In Computer Network Data Link Layer With Types

In order to provide services to the Network Layer, the Data Link Layer must use the service provided to it by the Physical Layer. What the Physical Layer does is, accept a raw bit stream and attempt to deliver the data to the destination. The bit stream is not guaranteed to be error-free. the numbers of bits received may be less than or equal to or more than the number of bits that were transmitted and they have different values. It is the task of the Data Link Layer to provide the error-free transmission of the data. The usual approach is for the Data Link Layer to break the bitstream up into discrete frames and compute the checksum for each frame. When the frame arrives at the destination the checksum is recomputed. If the newly computed checksum is different from the one contained in the frame, the Data Link Layer knows that an error has occurred and takes the necessary steps to deal with it.

Breaking, the bit stream up into frames is more difficult. One way to achieve this framing is to insert time gaps between frames, much like the spaces between words in ordinary text. However, networks rarely make any guarantee about timing so it is possible these gaps might have vanished or other gaps might be inserted during transmission. Since it is too risky to count on timing to make the start and end of each frame, other methods have been divided following are some of the methods used:-

  • Character Count
  • Starting and Ending Characters, with characters stuffing
  • Starting and ending flags, with bit stuffing
  • Physical Layer Violation

Character Count

This method uses a field in the Header to specify the number and character in the frame. When the Data Link Layer at the destination sees the character count it knows how many characters follow and hence where the end of the frame is.


The trouble with this algorithm is that the count can be affected by a transmission error. For e.g., if a character count of 5 in the frame becomes 7, the destination will be unable to locate the starting of the next frame. Even if the checksum is incorrect so the destination knows that the frame is the bad one, it still has no way of telling where the next frame starts. Sending a frame back to the source asking for retransmission does not help either, since the destination does not know how many characters to skip over to get to the start of retransmission.

Starting and Ending Characters, with characters stuffing

This method gets around the problem of unsynchronized data after an error by having each frame start with the ASCII Character sequence DLE STX and end with sequence DLE ETX (DLE is Link Escape, STX is Start of text and ETX is the End Of Text). In this way, if the destination loses track of frame boundary all it has to do is look for DLE, STX or DLE ETX characters to figure out the problem.

Starting and ending flags, with bit stuffing

This technique allows data frames to contain arbitrary numbers of bits and allows character codes with an arbitrary number of bits/sec characters. It works like this:-

Each frame begins and ends with a special bit pattern 0111110 called as FLAG BYTES. Whenever the sender Data Link Layer encounters five constitutive 1s in the data, it automatically stuffs a zero bit into the outgoing bit stream. This bit stuffing in which DLE is stuffed into the outgoing character stream before DLE in the data. When the receiver sees the five consecutive incoming 1 bits by a zero bit. Just as Character stuffing is completely transparent to the network layers in both computers. If the user data contains a flag pattern 01111110 then this flag is transmitted as 011111010 but stored in the receiver’s memory as 01111110.

Physical Layer Violation

This method of framing is only applicable to networks in which the encoding on the physical medium contains some redundancy (duplication). For e.g. some LANs encode one bit of the data by using two physical bits. Normally one bit is a high-low value and zero is a low-high pair. The combination of Low-Low and High-High is not used for data. This scheme means that every data bit has a transition in the middle, making it easy for the receiver to locate the bit boundaries.