1 / 74

The Data Link Layer

The Data Link Layer. Sending Data Over a Communications Link. Schemes for Doing This --- Protocol. Need For Data Link Control: Frame Synchronization Use of a variety of Line Configuration Flow Control Error Control Addressing Control and Data on Same Link Link Management.

Download Presentation

The 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. The Data Link Layer Sending Data Over a Communications Link. Schemes for Doing This --- Protocol. Need For Data Link Control: • Frame Synchronization • Use of a variety of Line Configuration • Flow Control • Error Control • Addressing • Control and Data on Same Link • Link Management

  2. The Data Link Layer (cont.) Format of a Frame: KIND SEQ ACK Information Control Info.

  3. The Data Link Layer (cont.) Request Confirm Response Indication Request Network layer Indication Data link layer Response Confirm Service provider data link layer Physical layer Service user (network layer) Service user (network layer) A B A B (a) (b) Two different representations of the service primitives

  4. Data Link Layer (cont.) Services Provided to Network Layer: • Unacknowledged connectionless service. • Acknowledged connectionless service. • Connection-oriented service.

  5. Data Link Layer (cont.) • Note: Data are Transmitted One Char At a Time and Timing or Synchronization Must Be Maintained Within Each Char. Overhead 2-3 Bits/Char, Not Good.

  6. Data Link Layer (cont.) ··· SYN SYN One or more SYN character Control character Data character Control character (a) Character-oriented frame ··· F 8-bit flag 8-bit flag Control fields Data field Control field (b) Bit-oriented frame

  7. Data Link Layer (cont.) • Note: Blocks of Chars or Bits are Transmitted Without Start and Stop Codes. Clocks Must be Synchronized. Preamble Bit Patterns and Postamble Used.

  8. Framing Beginning and End? • Character count • Starting and ending characters, with character stuffing • Starting and ending flags, with bit stuffing • Physical layer coding violations.

  9. One character Character count (a) 5 1 2 3 4 5 6 7 8 9 8 0 1 2 3 4 5 6 9 7 8 9 0 1 2 3 4 Frame 1 5 character Frame 2 5 character Frame 3 8 character Frame 4 9 character Error (b) 5 1 2 3 4 7 6 7 8 9 8 0 1 2 3 4 5 6 9 7 8 9 0 1 2 3 4 Now a Character count Frame 1 Frame 2 (Wrong) A character stream (a) Without error (b) With one error Framing (cont.)

  10. DLE STX A DLE B DLE ETX (A) DLE STX A DLE DLE B DLE ETX (B) Stuffed DLE DLE STX A DLE B DLE ETX (C) (a) Data sent by the network layer (b) Data after being character stuffed by the data link layer (c) Data passed to the network layer on the receiving side Framing (cont.)

  11. (a) 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 (b) 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 0 Stuffed bits (c) 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 Framing (cont.) Bit stuffing. (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in the receiver's memory after destuffing.

  12. Error Detection/Correction • Include enough redundant information along with data to use: • Error correcting codes • Error Detecting Codes • Parity checks (error detecting)

  13. Error Detection/Correction (cont.) • Example: 7-bit ASCII character -- If 1110001 is transmitted using odd parity, then 1 is appended. è11100011 If an odd number of bits is erroneously inverted during transmission, then the receiver will detect an error. However, if an even number of bits is inverted, an undetected error occurs. • Note: Even parity may also be used. Problem with parity: noise impulses maybe long enough to destroy more than 1 bit, particularly at high data rates. (eg 1200bps)

  14. Parity Checks (cont.) • Use 2 sets of parity bits for blocks of characters arranged in 2 dimensions. Parity bits are obtained by performing exclusiveORoperation on row and column bits (even parity). • Example: Char1 1 0 1 1 0 1 1 1 Char2 1 1 0 1 0 1 1 1 Char3 0 0 1 1 1 0 1 0 Char4 1 1 1 1 0 0 0 0 Char5 1 0 0 0 1 0 1 1 Char6 0 1 0 1 1 1 1 1 0 1 1 1 1 1 1 0 VRC VRC: Vertical Redundancy Checks LRC: Longitudinal Redundancy Checks LRC

  15. Parity Checks (cont.) Note: This scheme is 2-4 orders of magnitude better than simple VRC. Also, some patterns of even number of errors remain undetected (e.g., bits 1 and 3 of Char1 and bits 1 and 3 of Char5)

  16. Parity Checks (cont.) Consider: Message with m message bits and r redundant bits, then the total length n = m + r. Referred to as an n-bit codeword. Given 2 codewords say, 110100 and 110111, we can tell how many corresponding bits differ by performing an exclusive OR on the 2 codewords. In this case, 2 bits differ, so, the Hamming distance = 2. Error-detection/error correction of a code depends on its Hamming distance of the complete code.

  17. Parity Checks (cont.) Note: from the complete list of the legal codewords, the 2 whose Hamming distance is minimum defines the Hamming distance of the complete code. Example: 1001 1000 1100 1011 This code has a distance = 1

  18. Format of a Frame • To detect d errors, you need a distance of d+1. • To correct d errors, you need a distance of 2d+1. Example: 111100 010111 100011 000000 • Can detect 2-single bit errors, since its Hamming distance = 3. Suppose the code 000011 arrives, then an error occurs. • Can correct 2d+1 = 3 or d = 1 error. Suppose the code 000011 arrives, then the code is corrected to 100011. Could this corrected code still be an error?

  19. 011 111 001 101 010 110 100 000 Format of a Frame • Picture code space as vertices of a hypercube. Use majority rule: • 1. If 0 or 1 one bit decide 000 • 2. If 2 or 3 one bits decide 111 So, we can overcome single errors, but not double errors.

  20. Error Code Correcting • Example: (4 codewords) 0000000000, 0000011111, 1111100000, 1111111111 Hamming distance = 5 Õ 2d+ 1=5 or d =2 Suppose 0000000111 arrives, the receiver knows that the original must have been 0000011111. • Note: if triple error changes 0000000000 into 0000000111, the error will not be corrected properly.

  21. Error Code Correcting (cont.) Design a code with m message bits and r check bits that will allow all single bit errors to be corrected. Each of the 2m legal messages has n (n = m + r) illegal codewords a distance 1 from it. So, each of the 2m messages requires n+1 bit patterns dedicated to it. Thus we have 2m(n+1) £ 2n ==> 2m(1+m+r) £ 2m+r , note n = m + r ==> 1+m+r£ 2r

  22. Error Code Correcting(cont.) Example: Given m = 4, find the smallest r satisfying the above ineq. Solution: start with r=1, substitute the values for r+m. 1 + 4 + 1 £ 21(r = 1) 6 £ 21False 1 + 4 + 2 £ 22(r = 2) 7 £ 22False 1 + 4 + 3 £ 23(r = 3) 8 £ 23TRUE So, at least 3 check bits are needed to correct a single bit error.

  23. Error Code Correcting (cont.) Char ASCII Check bits H a m m i n g c o d e 1001000 1100001 1101101 1101101 1101001 1101110 1100111 0100000 1100011 1101111 1100100 1100101 00110010000 10111001001 11101010101 11101010101 01101011001 01101010110 11111001111 10011000000 11111000011 00101011111 11111001100 00111000101 Order of bit trans- mission Use of a Hamming code to correct burst error

  24. Cyclic Redundancy Checks (CRC) Given a m-bit frame or message, the transmitter generates an r-bit sequence, knows as frame check sequence (FCS), so the resulting frame consists of m+r bits, exactly divisible by some predetermined number. The receiver then divides the incoming frame by the same number, and if there is no remainder, assume that no error occurred. Ways of presenting this procedure: • Module arithmetic • Polynomials • Shift registers and exclusive OR

  25. Cyclic Redundancy Checks (CRC) (cont.) We will use polynomials. Consider the Following Message: 10011 Õ x4 + x + 1, 01001 Õ x3 + 1 Note: Addition and subtraction -- mod2 Example: 1 0 0 1 1 « x4 + x + 1 0 1 0 0 1 « x3 + 1 1 1 0 1 0 « x4 + x3 + x

  26. Polynomial Method Sender and receiver must agree on a generator polynomial, G(x). Both the high-order and low- order bits of the polynomial must be 1. Let M(x): polynomial of degree m-1, (m bit message) G(x): polynomial of degree r, (r+1 bit), where m > r

  27. Polynomial Method (cont.) Step 1. Form xr M(x) Step 2. Compute {xr M(x)}/{G(x)} = Q(x) + {R(x)}/{G(x)}, where R(x) is the remainder or xr M(x) = Q(x)G(x) + R(x). Step 3. Create the r-bit string (ck-bits) corresponding to R(x), and append it to the message string. T(x) = xr M(x) + R(x). This is the message transmitted. Note: degree R(x)< degree G(x)

  28. Polynomial Method (cont.) Example: Let G(x) = x3 + x2 + 1; r = 3 Õ 1101 M(x) = x5 + x2 + x + 1; m = 6 Õ 100111 Find check bits: 1. x3M(x) = x8 + x5 + x4 + x3Õ 100111000 2. Find Q(x), R(x)

  29. 111111 x3 + x2+1 x8 + x5+ x4 + x3 1101 100111000 1101 1001 1101 1001 1101 1000 1101 1010 1101 1110 1101 011 ····· x + 1 CK-Bit Polynomial Method (cont.)

  30. Polynomial Method (cont.) Example: (cont.) 3. Transmitted message: 100111011 Ö x8+x5+x4+x3+x+1 In general: T(x) = xr M(x) + R(x) However, xr M(x) = G(x) Q(x) + R(x), Õ T(x) = G(x) Q(x) + R(x) + R(x) = G(x) Q(x)

  31. Polynomial Method (cont.) Example: 1. Given message M = 110011 (6 bits) generator G = 11001 (5 bits) FCS R = To be calculated (4 bits) 2. The message is multiplied by 24, yielding 1100110000.

  32. Q 100001 1100110000 11001 10000 11001 1001 11001 2M G R Polynomial Method (cont.) 3. The product is divide by G: 4. The remainder is added to 2n M to give T = 1100111001, which is transmitted.

  33. Polynomial Method (cont.) Example(cont.): 5. If there are no errors, the receiver receives T intact. The received frame is divided by G. Note: Since the remainder = 0, it is assumed that there have been no errors. 100001 1100111001 11001 11001 11001 0 11001

  34. Polynomial Method (cont.) T(x) = G(x)Q(x) Õ T(x) is divisible by G(x). Received Message: T(x) + E(x), where E(x) is error polynomial. {T(x) + E(x)} / {G(x)} must test for divisibility. If remainder = 0, decide no error was made, otherwise error.

  35. Polynomial Method (cont.) Suppose the error pattern is 100100000 (2 errors), the received message is 000011011 (x4 + x3 + x + 1). So, an error was made (non-zero) x x4 + x3 + x + 1 x3 + x2 + 1 x4 + x3 + x 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1

  36. Error Analysis How to choose G(x) to detect as many errors as possible? Must consider several cases.

  37. Case 1: Single Errors Suppose E(x) = xi (i.e. 1 bit flipped). How can G(x) be selected to detect a single bit error? Ans: Choose G(x) with at least 2 terms Õ We will get a remainder from {Xi} / {G(x)} Õ Error will be detected Example: n=6, error pattern = 001000 (E(x) = x3) If G(x) = x + 1, then {E(x)} / {G(x)} has a remainder.

  38. Case 2: Double Errors Note: (xk+1) = (x+1)(x{k-1} + x{k-2} + ××××× + 1) e.g.,: (x4+1) = (x+1)(x3 + x2 + x1 + 1) Suppose G(x) = x3 + x2 + x + 1 and E(x) = x4 + 1, then {E(x)} / {G(x)} = x + 1, (no remainder) So, error is not detected unless G(x) does not divide xk + 1, 1 £ k £ n

  39. Case 3: Odd Number of Errors Suppose the error pattern has either 1 or 3 or 5, etc. Then E(x) is not divisible by (x+1). Proof: contradiction If E(x) has an odd number of terms, and is divisible by x+1, we can write E(x) = (x+1) E1(x) Þ E(1) = (1+1) E1 (1) = 0

  40. Case 3: Odd Number of Errors(cont.) However, E(1)=0 Þ E(x) has an even number of terms (contradiction). Therefore, if G(x) has the factor (x+1), all error patterns of odd weight will be detected. Example: E(x) = x6 + x3 + 1, G(x) = (x+1)(x2+1) = x3 + x2 + x + 1 So, the error pattern is detected.

  41. Case 4: Burst Errors Burst errors -- string of bits in an error pattern delimited by 1's. Example: 000110100100 To analyze burst errors; let bit i be the degree of the lowest bit in the burst (2 above) and write E(x) = xi E1(x) , so E1 (x) has a 1 in the 0th position. Example: x8 + x7 + x5 + x2 = x2 (x6 + x5 + x3 + 1) E(x) = xi E1(x) Now, E(x) will not be detected iff E1(x) is divisible by G(x). burst of length 7

  42. Case 4: Burst Errors (cont.) We know that G(x) does not divide xi (from Case 1). Also, the degree of G(x) is r and contains (r+1) bits. If the burst contains r or fewer errors, E1(x) is of degree (r-1) or less. So, {E1(x)} / {G(x)} will have a remainder, E1(x), and the burst errors will be detected.

  43. Case 4: Burst Errors (cont.) Example: suppose r=7 and G(x) = (x5+1) (x2+1) = x7 + x5 + x2 + 1 Now, E(x) = x2 (x6+x5+x3+1) = x2 E1(x) so, {E1 (x)} / {G(x)} has remainder E1 (x) ¹ 0. Conclude: All burst of length r or less are detected if: 1. G(x) is of degree r (r+1 bits)

  44. Case 4: Burst Errors (cont.) If the length of the burst is r+1, then the burst polynomial, E1(x) must have a 1 in positions r and 0; so does G(x). The chance of not detecting this burst is the chance of a perfect match between E1 (x) and G(x) in the remaining (r-1) positions or (1/2)r-1.

  45. Three polynomial are international standards • CRC-12 = x12 + x11 + x3 + x2 + x + 1 (C.H. 6 bits) • CRC-16+ = x16 + x15 + x2 + 1 (C.H. 8 bits) • CRC-CCITT+ = x16 +x12 + x5 + 1 (C.H. 8 bits) +: catch all single and double errors, all errors with an odd number of bits, all burst errors of length 16 or less.

  46. Protocols Set of rules governing the exchange of data between 2 entities. • Elements of a Protocol • Syntax -- Include such things as data format, coding, and signal levels. • Semantics -- Includes control information for coordination and error handling. • Timing -- Includes speed matching and sequencing.

  47. Protocols (cont.) • 2 major classes of protocols • Character oriented (old) Example: IBM's BISYNC • Bit oriented (newer) Example: IBM's SDLC, HDLC developed by ISO. Note: Transmission via Frames. • We will emphasize.

  48. Protocols (cont.) • Example: Unrestricted Simplex Protocol Sender: Go get something to send (buffer) Copy it into info. field for transmission Send information Do until doomsday Receiver: Frame arrival Get the inbound frame Pass data to host Do until doomsday

  49. Protocols (cont.) Note: Simplest possible situation • Send information in one direction only • No control fields • Channel assumed to be perfect • Receiver can process information infinitely fast

More Related