Introduction to Data Communications & Networking Data Link Layer (Set 5) Chapter 10 and Chapter 11 Dr. Ali Maqousi, Dr. Tatiana Balikhina amaqousi@uop.edu.jo, tbalikhina@uop.edu.jo Department of Computer Networks Faculty of Information Technology Petra University Dr. Maquosi & Dr. Balikhina 1
Data Link Layer The need for Data Link layer 1) Communication circuits make errors occasionally. 2) Communication circuits have a limited date rate. Dr. Maquosi & Dr. Balikhina 2
The two main functions of the data link layer are data link control and media access control. Data Link Layer The first, data link control, deals with the design and procedures for communication between two adjacent nodes: node-to-node communication. The second function of the data link layer is media access control, or how to share the link (MAC sublayer). We discuss MAC in the Set 6. Dr. Maquosi & Dr. Balikhina 3
Services Provided to Network Layer(1) Framing (a) Virtual communication. (b) Actual communication. Dr. Maquosi & Dr. Balikhina 4
Services Provided to Network Layer (2) Framing Placement of the data link protocol. Dr. Maquosi & Dr. Balikhina 5
Functions performed on Data Link Control are: 1- Framing 2- Flow Control 3- Error Control 4- Error Detection & Correction Data Link Layer Dr. Maquosi & Dr. Balikhina 6
The transmitted bit stream by the physical layer is not guaranteed to be error free. It is up to the data link layer to detect, and if necessary, to correct errors. The data link layer needs to pack bits into frames, so that each frame is distinguishable from another. The data link layer breaks the bit stream up into discrete frames and compute the checksum for each frame. When a frame arrives at the destination, the checksum is recomputed. Framing Dr. Maquosi & Dr. Balikhina 7
Framing Sending machine Receiving machine Packet Packet Frame Header Payload field Trailer Header Payload field Trailer Relationship between packets and frames Dr. Maquosi & Dr. Balikhina 8
The easiest way to achieve framing is to insert time gaps between frames. Networks rarely make any guarantees about timing. Other Framing Methods are: 1) Character count. 2) Flag bytes with byte stuffing 3) Flags with bit stuffing Framing Dr. Maquosi & Dr. Balikhina 9
Framing Frames can be of fixed or variable size. In fixed-size framing, there is no need for defining the boundaries of the frames; the size itself can be used as a delimiter. Variable-size framing, prevalent in local area networks. In variable-size framing, we need a way to define the end of the frame and the beginning of the next. Historically, two approaches were used for this purpose: a character-oriented (byte) approach and a bit-oriented approach. Dr. Maquosi & Dr. Balikhina 10
Framing Character count framing uses a field in the header to specify the number of characters in the frame. Character count 4 1 2 3 6 1 2 3 4 5 2 1 Frame 1 4 Characters Frame 2 6 Characters Frame 3 2Characters Dr. Maquosi & Dr. Balikhina 11
Framing The problem with Character count algorithm is that the count can be distorted by a transmission error. Error 4 1 2 3 8 1 2 3 4 5 2 1 Frame 1 4 Characters Frame 2 (wrong) 6 Characters Frame 3 Dr. Maquosi & Dr. Balikhina 12
Framing In variable-size framing character-oriented (byte) approach data to be carried are 8-bit characters. This method uses in each frame start and end special bytes (Flag byte). - Flag bytes used as a delimiters. A Frame delimited by flag bytes Dr. Maquosi & Dr. Balikhina 13
Framing - Aproblem occurs with this method when binary data are being transmitted. It may easily happen that the flag byte s bit pattern occurs in the data. - one way to solve this problem is to have the sender s data link layer insert a special escape byte (ESC) just before each accidental flag byte in the data. - this technique is called byte stuffing or character stuffing. Dr. Maquosi & Dr. Balikhina 14
Framing Byte stuffing is the process of adding 1 extra byte whenever there is a flag or escape character in the text. Dr. Maquosi & Dr. Balikhina 15
Framing The byte-stuffing scheme with a slight simplification is used in the PPP (point-topoint) protocol. Today, millions of Internet users who need to connect their home computers to the server of an Internet service provider use PPP. - A major disadvantage of this framing method is that it is closely tied to the use of 8- bit characters. Dr. Maquosi & Dr. Balikhina 16
Framing The universal coding systems in use today, such as Unicode, have 16-bit and 32-bit characters that conflict with 8-bit characters. We can say that in general, the tendency is moving toward the bitoriented protocols. Dr. Maquosi & Dr. Balikhina 17
Framing This flag can create the same type of problem we saw in the byte-oriented protocols. That is, if the flag pattern appears in the data, we need to somehow inform the receiver that this is not the end of the frame. We do this by stuffing 1 single bit (instead of 1 byte) to prevent the pattern from looking like a flag. This process is called bit stuffing adds one extra 0 whenever five consecutive 1s follow a 0 in the data, so that the receiver does not mistake the pattern 0111110 for a flag. Dr. Maquosi & Dr. Balikhina 18
Framing Bit stuffing and unstuffing Dr. Maquosi & Dr. Balikhina 19
Error Control - Error Control is needed to make sure all frames are eventually delivered to the network layer at the destination and in the proper order. - The technique of acknowledgment and retransmission is used to ensure reliable delivery. - This can be achieved by using timer and assigning sequence number for each frame. Dr. Maquosi & Dr. Balikhina 20
Flow control - Flow Control is needed to deal with the situation when the sender is running on a fast computer and the receiver is running on a slow machine. - The sender keeps transmitting the frames out at a higher rate until the receiver is completely swamped (flooded). - At a certain point the receiver will simply be unable to cope with the frames as they arrive, and will start to lose them. Dr. Maquosi & Dr. Balikhina 21
Flow control There are two approaches for flow control: 1) Feedback-based flow control, where the receiver sends back information to the sender giving it permission to send more data. 2) Rate-based flow control, where there is a rate limit at which senders may transmit data, without using feedback from the receiver. Dr. Maquosi & Dr. Balikhina 22
Error detection and correction In a single-bit error, only 1 bit in the data unit has changed. Dr. Maquosi & Dr. Balikhina 23
Error detection and correction A burst error means that 2 or more bits in the data unit have changed. Dr. Maquosi & Dr. Balikhina 24
Error detection and correction To detect or correct errors, we need to send extra (redundant) bits with data. The correction of errors is more difficult than the detection. - In error detection, we are looking only to see if any error has occurred. - In error correction, we need to know the exact number of bits that are corrupted and more importantly, their location in the message. Dr. Maquosi & Dr. Balikhina 25
The structure of encoder and decoder Error detection and correction Dr. Maquosi & Dr. Balikhina 26
Error detection and correction Two basic strategies to deal with errors: 1) Error-correcting codes, includes enough redundant information with each sent data, to enable receiver to deduce what the transmitted data must have been. 2) Error-detecting codes, includes only enough information to allow the receiver to deduce that an error occurred, but not which error, and have it request a retransmission. Dr. Maquosi & Dr. Balikhina 27
Error detection and correction - The simplest error-detection scheme is a Parity Check. - In this scheme a single parity bit is appended to the data. - The parity bit is chosen so that the number of 1 bits in the code is even (or odd). Dr. Maquosi & Dr. Balikhina 28
Error detection and correction A code for error detection An error-detecting code can detect only the types of errors for which it is designed; other types of errors may remain undetected. Dr. Maquosi & Dr. Balikhina 29
Error detection and correction E=f(DATA) Transmitter DATA DATA E E, E = Error-detecting codes Receiver DATA E f = Error-detecting code function E =f(data) Dr. Maquosi & Dr. Balikhina 30 Compare
Error detection and correction - Error-detection and retransmission is efficient where error rate is low (over copper wire or optical fiber). - With wireless links, where unacceptable delay caused by repetitive retransmissions Error-correction is more suitable. Dr. Maquosi & Dr. Balikhina 31
Protocols Now let us see how the data link layer can combine framing, flow control, and error control to achieve the delivery of data from one node to another. The protocols are normally implemented in software by using one of the common programming languages. To make our discussions language-free, we have written in pseudocode a version of each protocol that concentrates mostly on the procedure instead of delving into the details of language rules. Dr. Maquosi & Dr. Balikhina 32
Protocols Noiseless channel is an ideal channel in which no frames are lost, duplicated, or corrupted. We discuss protocols for noiseless channel: 1) Simplest Protocol 2) Stop-and-Wait Protocol Dr. Maquosi & Dr. Balikhina 33
Protocols Simplest Protocol is one that has no flow or error control. Dr. Maquosi & Dr. Balikhina 34
Protocols Sender-site algorithm for the simplest protocol Dr. Maquosi & Dr. Balikhina 35
Protocols Receiver-site algorithm for the simplest protocol Dr. Maquosi & Dr. Balikhina 36
Protocols Next slide shows an example of communication using this protocol. It is very simple. The sender sends a sequence of frames without even thinking about the receiver. To send three frames, three events occur at the sender site and three events at the receiver site. Note that the data frames are shown by tilted boxes; the height of the box defines the transmission time difference between the first bit and the last bit in the frame. Dr. Maquosi & Dr. Balikhina 37
Protocols Dr. Maquosi & Dr. Balikhina 38
Protocols Stop-and-Wait Protocol adds flow control to Simplest protocol. To be able to send a new frame sender waits for permission from receiver - ACK frame (acknowledgement). ACK acknowledgment. NAK negative acknowledgment. Dr. Maquosi & Dr. Balikhina 39
Design of Stop-and-Wait Protocol Dr. Maquosi & Dr. Balikhina 40
Sender-site algorithm for Stop-and-Wait Protocol Dr. Maquosi & Dr. Balikhina 41
Receiver-site algorithm for Stop-and-Wait Protocol Stop-and-Wait Dr. Maquosi & Dr. Balikhina 42
Protocols Next slide shows an example of communication using Stop-and-Wait protocol. It is still very simple. The sender sends one frame and waits for feedback from the receiver. When the ACK arrives, the sender sends the next frame. Note that sending two frames in the protocol involves the sender in four events and the receiver in two events. Dr. Maquosi & Dr. Balikhina 43
Protocols Dr. Maquosi & Dr. Balikhina 44