1 / 105

Data Link Layer

Data Link Layer. Dr. K.Raghava Rao Professor, Dept. of ECM raghavarao@kluniversity.in. Data link Layer Design Issues. Providing a well-defined service interface to the network layer. Dealing with transmission errors.( Error Control )

Download Presentation

Data Link Layer

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. Data Link Layer Dr. K.Raghava Rao Professor, Dept. of ECM raghavarao@kluniversity.in

  2. Data link Layer Design Issues • Providing a well-defined service interface to the network layer. • Dealing with transmission errors.(Error Control) • Regulating the flow of data so that slow receivers are not swamped by fast senders.(Flow Control) • To accomplish these goals, the data link layer takes the packets it gets 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

  3. Functions of the Data Link Layer • Relationship between packets and frames.

  4. Services to Network Layer • Transferring data between network layers of machines

  5. Types of Services 1. Unacknowledged Connectionless Service. 2. Acknowledged connectionless Service. 3. Acknowledged connection-oriented Service.

  6. Services • Unacknowledged connectionless service • Real-time traffic, e.g., speech, video • Most LANs, such as Ethernet • Acknowledged connectionless service • Useful over unreliable channels • Each frame sent individually acknowledged • e.g., wireless systems, e.g. 802.11 (WiFi)

  7. Services • Acknowledged connection-oriented service • Guarantees • Each frame sent is received without error • All frames sent are received in right order • Three phases: • Connection establishment • Variables and counters initialization • Frame transmission • Connection release • Variables, buffers, resources freed up

  8. Placement of Data link protocol • When a frame arrives at a router, the hardware checks it for errors, then passes the frame to the data link layer software • The data link layer software checks to see if this is the frame expected, and if so, gives the packet contained in the payload field to the routing software. • The routing software then chooses the appropriate outgoing line and passes the packet back down to the data link layer software, which then transmits it

  9. Framing • Fact • Raw bit stream delivered by physical layer is not error free • Data link layer detects/corrects errors • Framing • Computing checksum • Handling error if any

  10. Framing • Approaches • Character Count. • Flag bytes with byte stuffing. • Starting and ending flags, with bit stuffing. • Physical layer coding violations.

  11. Character Count • A field in header specifies number of characters in a frame. • Problem?

  12. Example The following character encoding is used in a data link protocol: • A: 01000111; • B: 11100011; • FLAG: 01111110; • ESC: 11100000 • Show the bit sequence transmitted (in binary) for the four-character frame: A B ESC FLAG • When Character count framing method is used: Answer 00000100 01000111 11100011 11100000 01111110

  13. Flag Bytes with Byte Stuffing • A frame delimited by flag bytes • Four examples of byte sequences before and after stuffing

  14. Byte Stuffing / Character Stuffing • A serious problem 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. • 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.

  15. Example The following character encoding is used in a data link protocol: • A: 01000111; • B: 11100011; • FLAG: 01111110; • ESC: 11100000 Show the bit sequence transmitted (in binary) for the four-character frame: A B ESC FLAG When Flag bytes with byte stuffing framing method is used: Answer 01111110 01000111 11100011 11100000 11100000 11100000 01111110 01111110

  16. Flag Bits with Bit Stuffing • Each frame begins and ends with special bit pattern (flag byte): 01111110 • Problem: 6 consecutive 1s in data • Solution: Bit Stuffing: inserting a 0 after 5 consecutive 1s Original Data After Stuffing After received and destuffed

  17. Example • The following character encoding is used in a data link protocol: • A: 01000111; • B: 11100011; • FLAG: 01111110; • ESC: 11100000 • Show the bit sequence transmitted (in binary) for the four-character frame: A B ESC FLAG • When Starting and ending flag bytes, with bit stuffing framing method is used: Answer 01111110 01000111 110100011 11100000 011111010 0111110

  18. Exercises The following character encoding is used in a data link protocol: A: 11010101; B: 10101001; FLAG: 01111110; ESC: 10100011 • Show the bit sequence transmitted (in binary) for the five-character frame: A ESC B ESC FLAG when each of the following framing methods are used: (a) Flag bytes with byte stuffing. (b) Starting and ending flag bytes, with bit stuffing. ANSWER: • a) 01111110 11010101 10100011 10100011 10101001 10100011 10100011 10100011 01111110 01111110 • b) 01111110 11010101 10100011 10101001 10100011 011111010 0111110

  19. Exercises 1.Given the output after byte-stuffing: FLAG A B ESC ESC C ESC ESC ESC FLAG ESC FLAG D F FLAG. What is the original data? ANSWER: • A B ESC C ESC FLAG FLAG D F 2. Given the output after byte-stuffing: FLAG A B ESC ESC C ESC ESC ESC FLAG ESC FLAG D FLAG. What is the original data? ANSWER: • A B ESC C ESC FLAG FLAG D 3. A bit string, 0111101111101111110, needs to be transmitted at the data link layer. What is the string actually transmitted after bit stuffing? ANSWER: • The output is 011110111110011111010

  20. Physical Layer Coding Violations • Encoding on physical medium • Framing by invalid physical code • Use some code that does not represent 0 nor 1 Example • A 1 bit is a high-low pair and a 0 bit is a low-high pair. • The combinations of low-low and high-high which are not used for data may be used for marking frame boundaries

  21. Error Control • Using acknowledgement • Positive- If the sender receives a positive acknowledgement about a frame, it knows the frame has arrived safely. • Negative-On the other hand, a negative acknowledgement means that something has gone wrong, and the frame must be transmitted again. • Problem: In some cases, sender waits for acknowledgement forever if a frame is lost for ever. • Solution: Timer • Problem: Duplicate transmission (receiver will accept the same frame two or more times) • Solution: Sequence number

  22. Positive Acknowledgement • Sender sends a message, waits for acknowledgement from receiver, and then sends next message • There’s no free lunch, though  overhead, delay • How does it work?

  23. Reliability and Acknowledgement • Case 2: data lost Sender Receiver • Case 1: no error Sender Receiver Time Data Time Data X Timeout Ack. Data Ack. Timeout and retransmission

  24. Reliability and Acknowledgement • Case 3: data error Sender Receiver • Case 4: ack. lost Sender Receiver Time Data Time Data Error Timeout Timeout X Data Data Ack. Ack. Timeout and retransmission New problem? Duplicate Solution: Sequence number

  25. Flow Control • Needed • Problem • When frames are transmitted faster than receiver can accept, frames will be lost • Solution • Flow control by feedback mechanism • The protocol contains well-defined rules about when a sender may transmit the next frame

  26. Introduction • Transmission impairments (errors) • Attenuation • Loss of energy as signal propagates • Delay Distortion • Components travel at different speeds • Noise • Unwanted energy from other sources

  27. Attenuation, distortion, and noise Attenuation Delay Distortion Noise

  28. Types of Errors

  29. Single-bit error

  30. Burst error

  31. Error Correcting/Detecting Codes • Error correction • Referred to as forward error correction • Detect and correct error • Error detection • Detect error and request retransmission • Redundancy added to message • Codeword (n bits) • message + redundancy (m bits) (r bits) • n = m + r • Code rate = m / n

  32. Error Correcting/Detecting Codes • Where are error correction/detection used? • Correcting: physical layer and higher layers • Detecting: data link, network, and transport • Error correcting or error detecting? • Circumstances, application, etc.

  33. Error-Correcting Codes • Hamming codes (our focus) • Binary convolution codes • GSM mobile phone system, satellite communication, 802.11 • Reed-Solomon codes • DSL, data over cable, satellite communications • CDs, DVDs, Blue-ray disks • Low-density parity check codes • Digital video broadcasting, 10 Gbps Ethernet, power-line networks, 802.11

  34. Hamming Distance • The number of bit positions in which two codeword differ is called the Hamming distance . • Its significance is that if two codeword are a Hamming distance ‘d’ apart, it will require ‘d’ single-bit errors to convert one into the other

  35. Error Correction • Hamming Code • Linear systematic block code • For m-bit message we need r-bit redundancy, where (m +r + 1)  2r  Why? • Redundancy bits are placed in position of 2’s power • Example: If m = 7, then r = 4

  36. Hamming Code Example 7-bit data word "0110101“(d -data bits, p -parity bits)

  37. Combination p1 : bits 1, 3, 5, 7, 9, 11.. p2 : bits 2,3,6,7,10,11.. p4 : bits 4,5,6,7.. p8 : bits 8,9,10,11..

  38. Hamming Code Example (Cont.) • Assume the final bit gets corrupted and turned from 1 to 0 • Flag each parity bit as 1 when the even parity check fails

  39. Hamming Code Example • How to construct codeword • message: m = 7 bits • 1. find r using the formula  r = 4 • 2. place data bits in codeword • 3. calculate P bits: even parity Sum should be even P1+1+0+0+0+1  P1 = 0 P2+1+0+0+0+1  P2 = 0 P4+0+0+0  P4 = 0 P8+0+0+1  P8 = 1

  40. Hamming Code Example (Cont’d) • How to correct error and retrieve message • 1. compute syndrome similar to codeword construction  error position • 2. flip the bit in the error position • 3. remove P bits from codeword Example of an (11, 7) Hamming code correcting a single-bit error

  41. Use of a Hamming code to correct burst errors.

  42. Error-Detecting Codes • Parity • Checksums • Internet • Cyclic Redundancy Checks (CRCs) • They are all linear systematic block code

  43. Error-Detecting Codes • Parity bit • Added to data so that number of 1 bits in codeword is • Even (even parity) • Odd (odd parity) • E.g., ASCII of ‘H’ is 1011010, its codeword is • ________ if even parity is used • ________ if odd parity is used 10110100 10110101

  44. Use Parity to Detect Burst Errors • Organize a block into (k x n) matrix • One parity for each column  one row of parities at the bottom • Transmit one row at a time • Can detect burst errors of length n

  45. Example • Interleaving of parity bits to detect a burst error

  46. Error-Detecting Code - CRC • Bit stream is treated as polynomial w/ coefficients 0 and 1 • Example: • data: 10100111 polynomial: degree = 7 • Modulo 2 arithmetic is used • Example: 10011011 11110000 +11001010 -10100110 01010001 01010110 • XOR

  47. CRC generator and checker

  48. Error-Detecting Code - CRC • Use generator polynomial G(x) to calculate checksumR(x) • Frame: P(x) generator: G(x) degree of G(x) = d • Transmitted: checksummedframeP(x)·xd + R(x) • It’s guaranteed that P(x)·xd + R(x) is divisible by G(x)!!

More Related