Computer Networks LEC #8 DataLink Layer PDF

Summary

This document is a lecture on Computer Networks, specifically focusing on the Data Link Layer. It covers framing concepts, including character count, byte stuffing, and various framing methods.

Full Transcript

Computer Networks LEC #8 Computer Networks LEC #2 DataLink Layer Communicating Over the Network Lecture Outlines  DataLink Layer. Framing Method of Framing Next Lecture Error Control Medium Access Control The Data Link Layer...

Computer Networks LEC #8 Computer Networks LEC #2 DataLink Layer Communicating Over the Network Lecture Outlines  DataLink Layer. Framing Method of Framing Next Lecture Error Control Medium Access Control The Data Link Layer Two basic functions: Allows the upper layers to access the media using framing. Controls how data is placed on the media and received from the media using media access control (MAC) and logical link control (LLC) for flow control and error control. Framing  The data link layer takes the packets it gets from the network layer and encapsulates them into frames for transmission.  Framing in the data link layer add a source and destination MAC addresses.  Data Link layer translates the physical layer’s raw bit stream into discrete units (message) called frames. 4 Framing: Role of the Header Specific bit sequence that indicates to the receiving device that the frame starts here. Header Data Trailer Start Address Type/length The source and destination A code identifying the type (fixed size MAC addresses (physical or variable size of the frame. OR the address). They are only used total length of the frame. for local delivery. 5 Framing: Role of the Trailer Frame Check Sequence (FCS): Used to provide basic error checking, usually with a Cyclic Redundancy Check (CRC).  Sending device uses an algorithm on the bits of the header and data portions.  The resulting value is placed in the FCS field.  Receiving device does the same thing.  If the values match – no error.  If the values do not match – frame discarded. Trailer Header Data FCS Stop A specific sequence of bits that indicate the end of the frame. Methods of Framing  To perform framing task there are Different methods : 1. Character Count. 2. Flag byte with Byte Stuffing. 3. Starting and ending flag with byte Stuffing. 4. Physical layer coding violations 7 Framing – Character Count Character Count : First field in the frame’s header = the length of the frame. Problem:  Receivers loses synchronization when bits become garbled by transmission error.  So, if the bits in the count become corrupted during transmission, the receiver will think that the frame contains fewer or more bits than it actually does. 8 Framing – Character Count - Example For the following data create frames using character count with size 5, 5, 8, and 8 bytes, respectively. 1 2 3 4 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 Answer 5 1 2 3 4 5 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3 Frame-1 Frame-2 Frame-3 Frame-4 Note that the counted number is included in the length of the frame. 9 Framing – Character Count problem, in the previous example. if the byte count of 5 in the second frame becomes a 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..Figure 4. A byte stream. (a) Without errors. (b) With one error 10 Framing – Byte Stuffing Flag byte with Byte Stuffing:  The data frames can be fixed length or variable length. In variable length framing, the size of each frame to be transmitted may be different. So, a pattern of bits is used as a delimiter to mark the end of one frame and the beginning of the next frame.  Problem: What happens if the pattern occurs in the message?  Solution: A byte is stuffed in the message to differentiate from the delimiter. There should be a strategy so that the receiver does not consider the pattern as the end of the frame  a special byte called the escape character (ESC) is stuffed before every byte in the message (How?) 11 Framing – Byte Stuffing To make things simpler we will consider only three types of byte sequences in the sent data, as : F : Flag Sequence E : Escape Sequence D : Any other Data Sequence At Sender (Client) Side 1.Data of each frame is first stuffed with 8-bit flag sequence (‘F’) at the beginning and end of each frame. 2.Next, the data is scanned to see if any similar flag sequence (‘F’) forms a part of it or not. If yes, then before each such flag sequence, an extra escape sequence (‘E’) is stuffed. 3.Now, if any similar escape sequence (‘E’) is found to form a part of the data to be sent, then an extra escape sequence (‘E’) is stuffed before the occurrence of each such escape sequence. 4.Finally, this stuffed data is sent by the sender. Framing – Byte Stuffing At Receiver (Server) Side 1. The receiver skips over the first and last bytes of data received, as they are merely for signaling the beginning and end of one frame, respectively and does not carry any useful data. 2. From the next byte on wards data is scanned and if two escape sequences (‘E’) are found in succession, the first one is de-stuffed. Similarly, if an escape sequence is followed by a flag sequence (‘F’), the former is de-stuffed. 3. This strategy helps the receiver recover the actual sent data, accurately. Framing – Byte Stuffing The following figure shows the original characters before framing and after framing using byte stuffing in different situations. 14 15

Use Quizgecko on...
Browser
Browser