1 / 138

Chapter 4

Chapter 4. Data Link Layer. 2. Functions of DLL • Providing a well-defined service interfaci to the network layer. • Dealing with transmission errors. • Regulating the flow of data so that slow receivers are not swamped by fast senders. Compiled By: Ashish Kr. Jha. 3.

jena
Download Presentation

Chapter 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4 Data Link Layer Compiled By: Ashish Kr. Jha

  2. 2 Functions of DLL • Providing a well-defined service interfaci to the network layer. • Dealing with transmission errors. • Regulating the flow of data so that slow receivers are not swamped by fast senders. Compiled By: Ashish Kr. Jha

  3. 3 Data Flow • To the Network Layer, it looks as though the path to the new machine happens at the DLL level, when it is really happening at the physical level. Compiled By: Ashish Kr. Jha

  4. How the data is sent? • Takes the packets of information from the Network Layer. • Convert them into frames for transmission. • Each frame holds the payload(packet) plus a header and a trailer (overhead). • Transmit frames over the physical layer. Compiled By: Ashish Kr. Jha

  5. 5 DLL Services • Framing ° Encapsulate datagram into frame, adding hiadir(MAC address) and trailir(irror control bits) • Link Access ° Channel access for shared medium • Flow control ° Pacing between adjacent sending and receiving nodes • Error Detection ° Signal attenuation, noise may cause error ° On detection of error, receiver sends signal to sender for retransmission • Error Correction ° Receiver identifies and corrects bit errors without resorting to retransmission Compiled By: Ashish Kr. Jha

  6. 6 DLL Services • DLL can offer many different services which may vary from system to system. • Types of DLL services: ° Unacknowledged connectionless service ° Acknowledged connectionless service ° Acknowledged connection-oriented service Compiled By: Ashish Kr. Jha

  7. 7 Unacknowledged Connectionless Service • No acknowledgement from the receiving machine. • No logical connection is set up between the two machines. • The DLL will make no attempt to detect the loss of or recover a lost frame. • This service is useful for low error rate networks and for real-time traffic where late data is worse than no data. Compiled By: Ashish Kr. Jha

  8. 8 Acknowledged Connectionless Service • The receiver acknowledges the arrival of each frame. • If it hasn't arrived correctly (or within the correct time) it can be resent. • This is a useful service when the connection is unreliable (such as wireless). • There is no requirement for such an acknowledgement service to be implemented by the Data Link Layer. Compiled By: Ashish Kr. Jha

  9. 9 Acknowledged Connection-oriented Service • A connection is established between the two machines. • The frames are then transmitted and each frame is acknowledged. • The frames are guaranteed to arrive only once and in order. • This is the same as a “reliable” bit stream. • The connection is released once the communication is complete. Compiled By: Ashish Kr. Jha

  10. 10 Framing • The usual approach is for the data link layer to break 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. 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 steps to deal with it. • Breaking the bit stream up into frames is more difficult than it at first appears. One way to achieve this framing is to insert time gaps between frames, much like the spaces between words in ordinary text. Compiled By: Ashish Kr. Jha

  11. 11 Framing Methods • Character count • Flag bytes with byte stuffing • Starting and ending flags, with bit stuffing Compiled By: Ashish Kr. Jha

  12. 12 Character Count Method • Fields in header specify no. of characters in the frame. 5 characters 5 characters 8 characters 8 characters Error A character stream. (a) Without errors. (b) With one error. Compiled By: Ashish Kr. Jha

  13. 13 Character Count • The trouble with this algorithm is that the count can be garbled by a transmission error. • For example, if the character count of 5 in the second frame of (b) becomes a 7, the destination will get out of synchronization and will be unable to locate the start of the next frame. • Even if the checksum is incorrect so 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 a retransmission does not help either, since the destination does not know how many characters to skip over to get to the start of the retransmission. • For this reason, the character count method is rarely used anymore. Compiled By: Ashish Kr. Jha

  14. 14 Flag Byte with Byte Stuffing • The second framing method gets around the problem of resynchronization after an error by having each frame start and end with special bytes. • In the past, the starting and ending bytes were different, but in recent years most protocols have used the same byte, called a flag byte, as both the starting and ending delimiter, as shown in Fig. (a) as FLAG. • In this way, if the receiver ever loses synchronization, it can just search for the flag byte to find the end of the current frame. Two consecutive flag bytes indicate the end of one frame and start of the next one. Compiled By: Ashish Kr. Jha

  15. 15 Flag Byte with Byte Stuffing (a) Original characters After stuffing (b) (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing. Compiled By: Ashish Kr. Jha

  16. 16 Byte Stuffing • It may easily happen that the flag byte's bit pattern occurs in the data. This situation will usually interfere with the framing. • 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. • Same is done if escape byte/character itself is present in message. • The data link layer on the receiving end removes the escape byte before the data are given to the network layer. • This technique is called byte stuffing or character stuffing. • Thus, a framing flag byte can be distinguished from one in the data by the absence or presence of an escape byte before it. • Problem: ° two communicating machine might use 8-bit or 16-bit characters Compiled By: Ashish Kr. Jha

  17. 17 Starting and ending flags with Bit Stuffing • The new technique allows data frames to contain an arbitrary number of bits and allows character codes with an arbitrary number of bits per character. • It works like this. Each frame begins and ends with a special bit pattern, 01111110 (in fact, a flag byte). • Whenever 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 bit stuffing is analogous to byte stuffing, in which an escape byte is stuffed into the outgoing character stream before a flag byte in the data. Compiled By: Ashish Kr. Jha

  18. Bit Stuffing (a) 0 110 11111111111111110 0 10 (b) o 1 1 o 1 1 1 1 1 orn 11 o 1 1 iijk) 10010 Stuffed bits (c) 0 110 11111111111111110 0 10 Bit stuffing (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in receiver's memory after destuffing. Compiled By: Ashish Kr. Jha

  19. 19 Error Control Types of Error: • Content Error : 1. Error in bits of data 2. Eg: 0 is received in place of 1 • Flow integrity error: 1. Data blocks missing 2. Loss during transmission • On the basis of no. of bits error ° Single bit error : error in only one bit • 10110 -> 10100 ° Burst Error : error in two or more bits in a data unit • 11001010->11011001 ° Extra bits are added in order to detect/correct errors. Compiled By: Ashish Kr. Jha

  20. Error Detecting Process •Transmitter ° For a given frame, an error-detecting code (check bits) is calculated from data bits ° Check bits are appended to data bits •Receiver ° Separates incoming frame into data bits and check bits ° Calculates check bits from received data bits ° Compares calculated check bits against received check bits ° Detected error occurs if mismatch • Parity Checking • Checksum Error Detection • Cyclic Redundancy Check(CRC) Compiled By: Ashish Kr. Jha

  21. Error Detecting Codes • Parity Checking : ° Simplest technique ° Adding a parity bit ° 8-bit word Data Bit Parity Bit n Even Parity : makes no. of 1's in entire word even. n Odd parity : makes no. of 1's in entire word odd. No. of 1's = 4(Even) No. of 1's = 5(Odd) Odd Parity Compiled By: Ashish Kr. Jha

  22. Parity Checking Parity Odd (i.e. Error) Even Parity Even (but Error) • Limitations: • Cannot detect error in 2,4 or 6 bits • Cannot correct the error (error location unknown) • Not suitable for burst error which are more common Compiled By: Ashish Kr. Jha

  23. 23 Checksum Error Detection • All the bytes of messages are added to generate a checksum which is then sent after all the messages. • Receiver separately calculates checksum and compares with the one sent by sender. • If both checksum matches, there is no error. • Example: " 10101101,00101101,10011101 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 0 1 0 0 1 1 1 0 1 1 0 1 1 1 0 1 1 1 Limitations: ■ Can only detect error but ■ Not able to correct error Ignored Compiled By: Ashish Kr. Jha

  24. 24 Cyclic Redundancy Check (CRC) • Type of polynomial code in which bit string is represented in the form of polynomials with coefficients 0 and 1. • Much powerful than parity and checksum • Based on binary division • Sequence of redundant bits called CRC are appended at the end of data. •Requirement of CRC ° It should be exactly one less bit than divisor ° Appending CRC to end of data unit should result in bit sequence exactly divisible by the divisor. Compiled By: Ashish Kr. Jha

  25. 25 CRC CRC Generator: • Append n 0’s to the data unit where n is 1 less than the number of bits in the predecided divisor(n+1 bit). • Divide zero padded data by predetermined divisor(While dividing- addition and subtraction must be modulo 2 operation (i.e. XOR). • Obtain remainder CRC • This CRC will replace the n 0‘s appended to data unit. Fig : CRC Generator Compiled By: Ashish Kr. Jha

  26. 26 CRC CRC checker • Received codeword is divided by same (n+1) bit divisor which was used at the transmitter. • If remainder is zero, then the received codeword is error free and hence should be accepted. • But non-zero remainder indicates presence of errors and hence corresponding codeword should be rejected. Received Codeword Data CRC Divisor (n+1)bits Remainder If remainder is 0 then there is no error Fig: CRC checker Compiled By: Ashish Kr. Jha

  27. 27 CRC Example • Here number of bits in generator G(x) is 5. So we need to append n(G(x)) -1 Zeros at the end of the Frame. • Perform XOR • CRC Value is: 1110 • Generator = x4 + x1 + 1 =10011 Compiled By: Ashish Kr. Jha

  28. 28 CRC Example • Let's assume that we have received the same bits i.e. T(x) = 11010110111110. Now let's check the remainder by using XOR method with G(x). • Here Remainder is Zero so, the frame is transmitted successfully. Compiled By: Ashish Kr. Jha

  29. Error Correcting Codes • Error-correcting codes are widely used on wireless links, which are notoriously noisy and error prone when compared to copper wire or optical fibers. • Without error-correcting codes, it would be hard to get anything through. • However, over copper wire or fiber, the error rate is much lower, so error detection and retransmission is usually more efficient there for dealing with the occasional error. • Hamming Code is Example of error Correcting Code Compiled By: Ashish Kr. Jha

  30. Hamming Code • P1=(1,3,5,7) -> first least significant bit • P2=(2,3,6,7) -> second least significant bit • P4=(4,5,6,7) -> Third least significant bit Compiled By: Ashish Kr. Jha

  31. 31 Hamming Code Compiled By: Ashish Kr. Jha

  32. 32 Hamming Code • Data To be encoded 10101101011 • After placing the data in the table we find that in positions 3, 6, 9, 10, 12, 14 and 15 we have a ‘1’. Using our previous conversion table we obtain the binary representation for each of these values. • We then exclusive OR the resulting values (essentially setting the parity bit to 1 if an odd # of 1 ’s else setting it to 0). Compiled By: Ashish Kr. Jha

  33. 33 Hamming Code • Encoded Data Compiled By: Ashish Kr. Jha

  34. 34 Hamming Code 110 0 3 0 110 6 10 0 19 010110 001112 1111 15 XOR 1 0 1 0 110 1 10 10 XOR 0111 sent/received new calculated this bit was flipped (14) Compiled By: Ashish Kr. Jha

  35. 35 #Assignment • Generate CRC code for data 110010101. The divisor is 10101. Also check whether there are errors in the received codeword 1100101011011. Compiled By: Ashish Kr. Jha

  36. 36 Flow Control • Dials with the issue where sender sends data at higher rate than receiver can receive • One way is to implement buffer. ° Receiver should able to inform sender when the buffer is full. • Two approaches: ° Feedback-based flow control • Feedback to the sender telling how receiver is doing ° Rate-based flow control • Transfer rate is fixed by sender • Not used often in DLL Compiled By: Ashish Kr. Jha

  37. 37 Data Link Layer Protocols • Unrestricted Simplex Protocol • Simplex Stop and wait Protocol • Simplex Protocol for Noisy Channel • Duplex Protocol • Piggybacking • Sliding Window Protocol Compiled By: Ashish Kr. Jha

  38. 38 Unrestricted Simplex Protocol • Data are transmitted in one direction only. • Both the transmitting and receiving network layers are always ready. • Processing time can be ignored. Infinite buffer space is available. • And best of all, the communication channel between the data link layers never damages or loses frames. • This thoroughly unrealistic protocol. Compiled By: Ashish Kr. Jha

  39. 39 Simplex Stop-and-wait Protocol • Simplest form of flow control. • In Stop-and-Wait flow control, the receiver indicates its readiness to receive data for each frame. • Sender waits for ACK(Empty frame) for sometime • If it do not receive ACK, retransmits the frame. • Problem: if ACK get lost, same frame is received twice • Operations: ° Sender: Transmit a single frame ° Receiver: Transmit acknowledgment (ACK) ° Goto 1. Compiled By: Ashish Kr. Jha

  40. 40 Simplex Stop-and-wait Protocol Figure shows an example of communication using this 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 Sender Receiver Request ► Arrival Arrival Request ► Arrival Arrival two events. Time Time Compiled By: Ashish Kr. Jha

  41. Major Drawbacks of stop and wait protocol • Only one frame can be in transmitted at a time. • This leads to inefficiency if propagation delay is much longer than the transmission delay. End of Transmit of ACK Last bit receivec Receiver Efficiency = ? Sender Last bit of ACK received Start Transmit End Transmit Compiled By: Ashish Kr. Jha

  42. 42 Simplex Protocol for Noisy Channel • We must be able to deal with dropped and mangled frames from a noisy channel. ° What do we do if the data arrives damaged? ° What do we do if the frame header is damaged? ° What do we do if the frame is dropped? • The receiver must be able to determine if a frame is an original or a retransmission. • To do this, Sequential numbers are given to each frame • If the receiver does not receive a frame, it can ask for that specific frame to be retransmitted. • If the frame arrives twice, the receiver can ignore the second frame. Compiled By: Ashish Kr. Jha

  43. 43 Duplex Protocol • As opposed to sending information in only one direction, wi should make full use of the connection. • Data is sent both ways • Wi are already sending ACK back, so why not the data • Use header to determine if it is data or ACK • Piggybacking: ° Not to send separate frame for ACK rather, piggyback ACK on next data frame ° Gives free ride to ACK and decrease overhead. Compiled By: Ashish Kr. Jha

  44. 44 Sliding Window Flow Control • Allows transmission of multiple frames. • Sequence number ranging from 0 to 2k-1 (allowing k-bit field for sequence number) is assigned to each frame. • Sliding Window : An imaginary boxes at transmitter and receiver sides. These window holds number of frames that are allowed to be sent or received at a time. • Operations: ° Sending Window ° Receiving Window • Transmitter and receiver windows need not be of same size. They may even sink or grow. • Frames in sending window need to be stored in memory in case, they need to be re-transmitted. Compiled By: Ashish Kr. Jha

  45. 45 Sending Window • At any instant, the sender is permitted to send frames with sequence numbers in a certain range (the sending window) Frames already transmitted Window of frames that may be transmitted Frame sequence number Last frame transmitted Window expands as acknowledgements are received Window shrinks as frames are sent Compiled By: Ashish Kr. Jha

  46. 46 Receiving Window • The receiver maintains a receiving window corresponding to the sequence numbers of frames that are accepted ,_ , , . , Window of frames that are Frames already reserved >cceMed b< recelrer 7 Last frame acknowledged^ window— ds as Window shrinks as acknowledgements are frames are received sent Compiled By: Ashish Kr. Jha

  47. 47 How is flow control achieved ? • Receiver can control the size of the sending window. • By limiting the size of the sending window data flow from sender to receiver can be limited. Compiled By: Ashish Kr. Jha

  48. 48 ARQ Error Control • Types of errors: Lost frames, damaged frames • Most Error Control techniques are based on (1) Error Detection Scheme (e.g., Parity checks, CRC),and (2) Retransmission Scheme • Error control schemes that involve error detection and retransmission of lost or corrupted frames are referred to as Automatic Repeat Request (ARQ) error control. • The most common ARQ retransmission Schemes: ° Stop-and-Wait ARQ ° Go-Back-N ARQ ° Selective Repeat ARQ • The protocol for sending ACKs in all ARQ protocols are based on the sliding window. Compiled By: Ashish Kr. Jha

  49. 49 Stop-and-wait ARQ • Stop-and-Wait ARQ is an addition to the Stop-and-Wait flow control protocol: ° Frames have 1-bit sequence numbers (SN = 0 or 1) i.e. maximum window size = 1. ° Sender sends the frame and waits to get ACK. ° Receiver sends an ACK (1-SN) if frame SN is correctly received. ° Sender waits for an ACK (1-SN) before transmitting the next frame with sequence number 1-SN. ° Frame is retransmitted if transmitter receives negative acknowledgement (NAK) or if no ACK is received for certain time. ° Transmit next frame only after getting positive ACK for previous frame. Compiled By: Ashish Kr. Jha

  50. Stop-and-wait protocol Sender Receiver Sender Receiver Error in frame 1 Fig : For Damaged Frame Fig : Under Normal Condition Compiled By: Ashish Kr. Jha

More Related