The Data Link Layer - PowerPoint PPT Presentation

the data link layer n.
Skip this Video
Loading SlideShow in 5 Seconds..
The Data Link Layer PowerPoint Presentation
Download Presentation
The Data Link Layer

play fullscreen
1 / 74
The Data Link Layer
Download Presentation
Download Presentation

The Data Link Layer

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. The Data Link Layer Chapter 3

  2. Hybrid Reference Model - REMINDER Application Layer Transport Layer Network Layer Data Link Layer Physical Layer

  3. Data Link Layer • “Virtual communication” takes place in the data link layer (in additional to the other layers). • Provides services to the network layer • Framing (sending machine breaks input data into input frames). Need to recognize framing boundaries. • Error control - noise burst can ruin a transmission.

  4. Data Link Layer • Provides svcs to the network layer (contd) • Flow control - how to stop a fast transmitter from overwhelming a slow one.

  5. Data Link Layer • Services Provided to Network Layer • Transfer data from network layer on source machine to network layer on destination machine through “virtual communication.” • Actual path is through all lower layers. • Services are 1) Unacknowledged connectionless service 2) Acknowledged connectionless service 3) Ack. Connection-oriented service

  6. Data Link Layer

  7. Unacknowledged connectionless service • Source machine sends frames to destination machine. Destination machine does not ack. • No connection estd. before hand • Frame loss due to noise is not recovered in data link layer but maybe above. • Appropriate for • Low error rate systems • real time traffic (speech) - bad data is worse than late data.

  8. Acknowledged connectionless service • Each frame sent is acknowledged but no connections are set up. • If frame does not arrive, sender can wait and retransmit. • Can be used over unreliable channels.

  9. Acknowledged connection-oriented service • Connection estd. Before any data are transferred. • Each frame sent is numbered and the data link layer guarantees that each frame sent is indeed received. • Each frame is recd. Only once (guaranteed) and that order is maintained (guaranteed) (is frame receivable multiple times in connectionless service?)

  10. Connection-oriented service • Three phases to transfer: • Connection is established by initializing counters for received/unreceived frames • One or more frames are transmitted • Connection is released freeing up resources (variables, buffers) • Example - next slide

  11. Placement of data link protocol • WAN subnet consisting of routers connected by point-to-point leased tel. Lines. • Frame arrives at router - it is checksummed and is passed to data link layer software. • DLL soft. Checks to see if frame was expected. If so gives packet in payload field to routing software. • Routing software chooses appropriate outgoing line and passes the packet to DLL software which transmits it.

  12. Placement of data link protocol

  13. Routing Code (box 3, prev. slide) • Routing code wants reliable sequenced connections on each of the Pt-to-Pt lines. • Data link protocol must make unreliable lines look good (good for wireless links).

  14. Framing • In order to provide service to the network layer, DLL must use services provided by the physical layer. • Bit stream delivered by physical layer may not be error free. • DLL must correct for errors • DLL breaks bit stream into discrete frames and creates checksum for each frame.

  15. Framing (cont’d) • Transmission is tricky. One possibility is to insert gaps between frames but there is no guarantee about timing from the network. • Start and end of frame marked by • Character count • Starting and ending chars with char stuffing • Starting & ending flags with bit stuffing • Physical layer coding violations

  16. Character count Even if checksum is incorrect, the destination does not know where the bad frame starts.

  17. Starting and ending chars w/ character stuffing • Use ASCII chars DLE STX (Data Link Escape, Start TeXt) and DLE ETX (End TeXt). If receiver loses frame boundaries it should look for DLE STX and DLE ETX • Problem: Binary data. DLE STX/ETX could occur and ruin framing. • Stuffing: Add an ASCII DLE before each DLE in the binary data.

  18. Starting and ending chars w/ character stuffing Data from Network Layer Data after stuffing Data after de-stuffing that is passed to network layer on destination end DISADVANTAGE: Reliance on 8 bits per character

  19. Start & end flags w/ bit stuffing • Frame begins and ends with 01111110 called flag byte. • When senders DLL senses 5 consecutive 1’s it “stuffs” a 0 into the bit stream. • Receiver sees the 5 consecutive 1’s followed by a 0 and destuffs it (i.e., deletes the 0). • Bit stuffing unambiguously locates frame boundaries.

  20. Start & end flags w/ bit stuffing

  21. Physical Layer Coding Violations Read on your own

  22. Error Control • How to ensure that all frames are sent to network layer at dest. in proper order? • This is important for reliable connection-oriented service. • Receiver sends back responses (positive or negative) to incoming frames. Positive means frame OK, negative means retransmit.

  23. Error Control • Question: What happens when an error burst destroys a whole frame? • Answer: Receiver knows not that an error has occurred. It wouldn’t send and acknowledgement. Sender would hang forever in such a case. • To solve above, DLL’s have timers. On sending frame a timer is set off ….

  24. Error Control • … if acknowledgement is not received (or lost) before timer goes off, sender is alerted to retransmit frame. • Problem: What to do if frames are submitted multiple times? • Answer: Assign a sequence number to frame. Therefore receiver will be able to distinguish original and retransmitted frame.

  25. Flow control • Problem: What to do when sender sends frames faster than receiver can accept them? • Solution: Have rules as to when a sender can send the next frame. The rule could say “send n frames now but do not send any more after that until I ask for them.” • More on flow control later.

  26. Error detection and correction • Two strategies • Include enough redundant information to deduce what the error was - error correcting codes • Use redundant info. So that the receiver knows that an error occurred but not which error. In any case it can request a retransmission - error detecting codes

  27. Error correcting codes • Terminology: • Frame consists of m message bits + r redundant or checkbits. n = r + m • n bit unit consisting of data + checkbits is called a codeword • Hamming distance - 0010 XOR 1101 = 1111, i.e., the number of bit positions at which two codewords differ is called the Hamming distance. • If two codewords are a Hamming distance d apart, it takes d single bit errors to convert one to another.

  28. Error correcting codes • 2^m possible data messages are legal but 2^n possible codewords are not. This is because of how check bits are calculated. • Having an algo. to calculate legal codewords we can compute exhaustive list of them. From this list two codewords whose Hamming Distance is minimum can be calculated. • This distance is called the Hamming Distance of the Complete Code.

  29. Error correcting codes • To detectd bit errors we need a distance d+1 code because there is no way d single bit errors can change one valid code word into another valid code word. • To correctd errors we need a distance 2d+1 code because legal codewords are so far apart so that with even d changes - the original codeword and the modified codeword are still closest.

  30. Error correcting codes • Parity Bit: is appended to the data and is chosen so that the number of 1 bits in the code word is even (or odd). • Example (even parity): 10110101 -> 101101011 and 10110001 -> 101100010 • A code with a single parity bit has a distance 2 since any single bit error produces a word with the wrong parity. It is used to detect single errors.

  31. Error correcting codes • Example: Code consisting of 4 code words • 0000000000, 0000011111, 1111100000, 1111111111 • Code has distance 5. Therefore double errors can be corrected • If 0000000111 arrives, the receiver knows that the original must have been 0000011111. • If triple error changes 0000000000 into 0000000111 then by a minimum distance approach we will not correct the code word.

  32. Error correcting codes • Given m message bits and r checkbits. Design a code that will allow all single bit errors to be corrected. • Each of the 2^m legal messages has n illegal codewords at a distance 1 from it (just invert each of the n bits in the n-bit codeword) • Thus each 2^m legal messages requires (n+1) bit patterns dedicated to it • (n+1)2^m <= 2^n but n = m + r so (m+r+1) <= 2^r. Given m we get a lower limit on r (number of check bits) to correct single bit errors.

  33. Error correcting codes- Hamming • Bits of codeword are numbered from L-R starting with 1. • Bits that are powers of 2 (1, 2, 4, 8 etc) are check bits. The rest (3,5,6,7,9, etc) are filled with the m data bits. • Each check bit forces the parity of some collection of bits (including itself) to be even (or odd). • A bit may be included in several parity computations ...

  34. Error correcting codes- Hamming • To see which check bits the data bit in position k contributes to, rewrite k as a sum of powers of 2. k = 15 = 1 + 2 + 4 + 8 or k = 29 = 1 + 4 + 8 = 16. • A bit is checked by only those check bits occurring in its power of two expansion. • On codeword receipt, receiver initializes counter to 0. It checks each check bit (k = 1, 2, 4, 8, …) to see if it has the correct parity (even or odd). If not, it adds k to the counter.

  35. Error correcting codes- Hamming • If counter is non zero, it contains the number of the incorrect bit. E.g. if check bits 1, 2, 8 are in error, the bit in error is 11

  36. Error-Detecting Codes • Let the block size be 1000 bits. To provide error correction for such blocks 10 check bits are needed. • Why? (m+r+1) <= 2^r. • 1Mbit requires 10^4 checkbits. • To detect a block with a single bit error one parity bit per block will suffice. • Once every 1000 blocks an extra block is reqd.

  37. Error-Detecting Codes • With a single parity bit, if a block is garbled by a burst error, what is the probability that the error will be detected? • Solution:Take a block and break into an nxm matrix. Compute parity bit for each column and place at the bottom of matrix. Matrix is transmitted one row at a time. Receiver checks parity bits, if any one is wrong it requests transmission again.

  38. Error-Detecting Codes • Burst Error: In a number of bits of length l, at least the first bit and the last bit are wrong. • In the n (cols) x m (rows) matrix method a single burst of length n (in any row) can be fixed since the parity will be violated. • However if a burst of length of n+1 occurs (where the error is in the first bit and the n+1th bit) then the error will be undected. • Another way is Cyclic Redundancy Code

  39. Error-Detecting Codes (CRC) • Bit strings represented as polynomials • 110001 = 1x^5 + 1x^4 + 0x^3 + 0x^2 +0x^1 + 1x^0 • Highest order bit (of k bits) is the coefficient of x^(k-1). • The polynomial is said to be of degree k-1 • Polynomial addition and subtraction is done modulo 2 • 10011011 + 11001010 = 01010001 • Division is same as binary but subtraction is done modulo 2.

  40. Error-Detecting Codes (CRC) • Sender and receiver use an agreed upon generator polynomialG(x). The high and low order bits of G(x) are 1. • To compute a checksum for a frame with m bits (whose polynomial is M(x)), the frame must be longer than the generator poly. • Take the checksum and place it at the end of the frame so that the poly represented by the new frame (with checksums at the end of it) is divisible by G(x)

  41. Error-Detecting Codes (CRC) • When receiver gets checksummed frame, it divides by G(x). If remainder exists, then error occurred. • Algorithm • r = degree of G(x). Append r zero bits to the lower-end of frame. Now we have m+r bits and this corresponds to the polynomial x^rM(x). • Divide bit string corresponding to G(x) into the bit string corresponding to x^rM(x) using modulo 2 division.

  42. Error-Detecting Codes (CRC) • Algorithm (contd) • Subtract the remainder (always r or fewer bits) from the bit string corresponding to x^rM(x) using modulo 2 subtraction. • Result of above operation is the checksummed frame to be transmitted. Call its polynomial T(x). • T(x) is divisible by G(x).

  43. G(x) = x^4 +x + 1

  44. Error-Detecting Codes (CRC) • Suppose error occurs i.e., T(x) + E(x). Each 1 bit in E(x) is an error. • A single burst error is indicated by 1xxxxx1 where xxxx could be any combination of 0’s and 1’s. • Receiver does [T(x) + E(x)]/G(x). What is left is E(x)/G(x). • If E(x) = x^i, i shows which bit is in error then if G(x) has >= 2 terms it will never divide E(x) so single bit errors are detected.

  45. Error-Detecting Codes (CRC) • Two isolated single bit errors: E(x) = x^i + x^j = x^j(x^(i - j) + 1), i > j. • Assume that G(x) is not divisible by x, a sufficient condition for double errors to be detected is that G(x) does not divide x^k+1 upto the maximum of i-j. • Odd number of bits in error: Make x+1 a factor of G(x) & we can catch all errors consisting of an odd number of inverted bits. • READ PARA starting bottom of p189 on own.

  46. Error-Detecting Codes (CRC) • Burst errors of length <= r: r is the number of checkbits. • Burst error of length k < r represented by x^i (x^(k-1) + … + 1); i determines how far from the right hand of the frame the burst is located. • If G(x) has an x^0 term it will not have x^i as a factor so if degree of (x^(k-1) + … 1) is less than the degree of G(x), the remainder can never be 0. • Burst length of length = r+1: Pr(Accept) = 1/2^(r-1)

  47. Error-Detecting Codes (CRC) • Burst length of length > r+1 then then Pr(Accept) = 1/2^r • Example Polynomials • CRC-12: x^12 + x^11 + x^3 + x^2 + x^1 + 1 • CRC-16: x^16 + x^15 + x^2 + 1 • CRC-CCITT: x^16 + x^12 + x^5 + 1 • CRC 12 used for 6 bit chars. CRC-16 and CCITT used for 8 bit characters.

  48. Elementary data link protocols • Assumptions: • Physical, data link layer and network layer engage in “peer to peer” communication, i.e., each layer has physically independent proc. • Machine A sends data to machine B using a reliable connection oriented service. Also we will consider the case where B wants to send to A simultaneously. • A has ‘infinite bit bucket’, i.e., no waiting for data production by Network Layer - i.e., data is always available.

  49. Elementary data link protocols • Assumptions: • The DLL on source machine A assumes that data from Network layer (on A) is all data every bit of which is to be passed to the network layer on destination machine B. • When DLL accepts a packet it creates a frame by putting a data link header and trailer to it. SEE FIGURE ON NEXT SLIDE.

  50. Elementary data link protocols