 Hello and welcome to the session on framing. It's a function of data link layer. At the end of this session, student will be able to simulate framing methods. Data link layer has a number of specific functions which include providing a well-defined service interface to the network layer, framing, physical addressing, error control, flow control, access control, etc. In this video, we are going to see the function framing in detail. The data link layer divides the stream of bits received from the network layer into manageable data units called frames. For synchronization between sender and receiver, one or more synchronization bits are usually added to the beginning of each frame. Data link layer takes the packets from the network layer and encapsulates them into frames for transmission. Each frame contains a frame header, a payload field for holding the packet and a frame trailer as shown in figure 1. Error control is achieved by adding a trailer at the end of the frame. Trailer contains control information. It is responsible for ensuring that frames are received intact or undamaged. Data link layer computes a short token called a checksum for each frame and includes the checksum in the frame when it is transmitted. When a frame arrives at the destination, the checksum is re-computed. 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 steps to deal with it. For example, it may discard the bad frame. Before going further, pause the video for some time and find the answer. Once you have done this, you may resume the video. As data travels on the media in a stream of 1s and 0s, how does a receiving node identify the beginning and end of a frame? Option A is, the transmitting node inserts synchronization bits at the beginning and end of each frame. Option B, the transmitting node sends a beacon to notify that a data frame is attached. Option C, the receiving node identifies the beginning of a frame by seeing a physical address. Option D, the transmitting node sends an out-of-bind signal to the receiver about the beginning of the frame. The answer is option A, for synchronization between sender and receiver, one or more synchronization bits are added at the beginning and end of each frame. The methods of framing are character count, character stuffing, bit stuffing, physical layer coding violations. Let us see these techniques in detail. The first framing method is character count, which uses a field in the header to specify the number of bytes in the frame. When the data link layer at the destination finds the byte count, it knows how many bytes follow and hence where the end of the frame is. This technique is shown in figure 2, where the data received from the network layer is 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. It is split into three frames of sizes, 5, 4 and 4 bytes respectively. The figure 3 shows one more example of character count technique with four small frames of sizes 5, 5, 8 and 8 bytes respectively. Figure 3A is without any error. The trouble with this algorithm is that the count can be garbled by the transmission error. For example, if the byte count of 5 in the second frame of figure 3B becomes 7 due to a single bit flip, the destination will get out of synchronization. It will then be unable to locate the correct start of the next frame. Even if the checksum is incorrect, the destination knows that the frame is bad. 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, since the destination does not know how many bytes to skip over to get to the start of the retransmission. For this reason, the character count method is rarely used. The second method that is character stuffing overcounts the drawbacks of the character count method. That is, it gets around the problem of re-synchronization after an error by having each frame start and end with special bytes. If the destination ever loses synchronization, it only has to look for DLE STX and DLE ETX characters. Each frame starts with the asking character sequence DLE STX and ends with the sequence DLE ETX, where DLE is data link escape, STX is start of text and ETX is end of text. However, if binary data is being transmitted, then there exists a possibility of the characters DLE STX and DLE ETX occurring in the data. Since this can interfere with the framing, the sender's data link layer inserts an ASCII DLE character just before the DLE character in the data. The receiver's data link layer removes this DLE before the data is given to the network layer. However, character stuffing is closely associated with 8-bit characters and this is a major hurdle in transmitting arbitrary sized characters. Figure 4 gives an example data stream before stuffing after stuffing and after de-stuffing. Figure 4A shows the data sent by the network layer, that is, A DLE V in this example. Figure 4B shows that each frame starts with DLE STX and ends with DLE ETX. Figure 4C shows the data at the network layer of the receiving side. The third method, bit stuffing, allows the data frames to contain an arbitrary number of bits. At the start and end of each frame, a flag byte consisting of special bit pattern 01111110 is inserted. Whenever the sender's data link layer encounters 5 consecutive ones in the data, it automatically stuffs a 0-bit into the outgoing bit stream. This technique is called as bit stuffing. When the receiver finds 5 consecutive ones in the incoming data stream followed by 0-bit, it automatically de-stuffs the 0-bit. The boundary between two frames can be determined by locating the flag pattern. Figure 5 gives an example of bit stuffing. Figure 5A shows the original data. Figure 5B after bit stuffing. Figure 5C shows the result after de-stuffing. Before going further, pause the video for some time and find the answer. Once you have done this, you may resume the video. If the bit string shown in the example is bit stuffed, what is the output string? The answer is shown here. It is computed by first inserting a flag byte, then the data 011110111, then a stuffed 0 after 5 consecutive ones, then remaining data 011111, once again a stuffed 0 after 5 consecutive ones, then the remaining data 10 and a flag byte. Once again pause the video for some time and find the answer. Bit stuffing adds an extra or stuffed 0 to the data section of the frame when there is a sequence of bits with the same pattern as dash. Option A, header, option B, trailer, option C, flag, option D, none of the above. The answer is option C that is flag. The last method of framing is only applicable to networks in which the encoding on the physical medium contains some redundancy. For example, some lands encode one bit of the data by using two physical bits. Normally, a one bit is high-low pair and a zero bit is a low-high pair. The scheme means that every data bit has a transition in the middle, making it easy for the receiver to locate the bit boundaries. The combinations high-high and low-low are not used for data. Many data link layer protocols use a combination of a character count with one of the other methods for extra safety. In this video we have seen framing which is a function of data link layer. Thank you.