1 / 57

Lecture Focus:

Lecture Focus:. Data Link Layer Error Control. CSCS 311. Data Communications and Networking. Lecture 19. Error Control. Error Control. Error Detection and Correction. Data can be corrupted during transmission. Many factors can alter one or more bits of a message.

Télécharger la présentation

Lecture Focus:

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. Lecture Focus: Data Link Layer Error Control CSCS 311 Data Communications and Networking Lecture 19

  2. Error Control

  3. Error Control Error Detection and Correction • Data can be corrupted during transmission. • Many factors can alter one or more bits of a message. • For reliable communication, errors must be detected and corrected. • Some applications can tolerate a small level of error. • e.g. errors in audio or video transmissions may be tolerable. • When we transfer text, we expect a very high level of accuracy.

  4. Error Control Types of Errors • Single-Bit Error • Burst Error

  5. Error Control Types of Errors Single-Bit Error • Only one bit in the given data unitis changed. • A 0 is changed to a 1OR a 1 to a 0. 0  1 1  0 Transmitter Receiver Transmitter Receiver 0 1 Medium 1 0 Data unit = A byte, character, or packet

  6. Error Control Types of Errors Single-Bit Error Single-bit errors are the least likely type of error in serial data transmission.

  7. Types of Errors Burst Error • When 2 or more bits in the data unit are changed. • A burst error does not necessarily mean that the errors occur in consecutive bits. • Length of the burst is measured from the first corrupted bit to the last corrupted bit. • Some bits in between may not have been corrupted. • A burst error is more likely to occur than a single-bit error. Data unit = A byte, character, or packet

  8. Error Detection Error Detection: We look only to see if any error has occurred. • Redundancy • Parity Check • Cyclic Redundancy Check (CRC) • Checksum

  9. Error Detection and Correction Redundancy Redundancy = Adding extra bits • The central concept in detecting or correcting errors is redundancy. • To be able to detect or correct errors, we need to send some extra bits with our data. • These redundant bits are added by the sender with the original data. • Their presence allows the receiver to detect or correct corrupted bits. • The receiver uses these bits to detect the error(s). • If the received message is error free, these redundant bits are removed and the remaining data is accepted. • If the received message is not error free, the whole message is discarded by the receiver.

  10. Error Detection and Correction Redundancy

  11. Error Detection and Correction Coding • Redundancy is achieved through various coding schemes. • The sender adds redundant bits through a process that creates a relationship between the redundant bits and the actual data bits. • The receiver checks the relationships between the two sets of bits to detect or correct the errors. • The ratio of redundant bits to the data bits and the robustness of the process are important factors in any coding scheme. • We can divide coding schemes into two broad categories: • Block coding • Convolution coding (Not to be studied)

  12. Error Detection and Correction Coding Structure of Encoder and Decoder Encoder Decoder Message Message Accept, Correct or Discard Generator Checker Unreliable Transmission Message and redundancy Received data Receiver Sender

  13. Error Detection and Correction Coding Block Coding • We divide our message into blocks, each of k bits, called datawords. • We add r redundant bits to each block to make the length n = k + r. • The resulting n-bit blocks are called codewords. + = Dataword Redundant bits Codeword k bits r bits n bits Size n = k + r

  14. Error Detection and Correction Coding Block Coding • We have a set of datawords, each of size k, and a set of codewords, each of size of n. • With k bits, we can create a combination of 2k datawords. • With n bits, we can create a combination of 2n codewords. • Since n > k, the number of possible codewords is larger than the number of possible datawords. • The block coding process is one-to-one; the same dataword is always encoded as the same codeword. • This means that we have 2n - 2k codewords that are not used. • We call these codewords invalid or illegal.

  15. Error Detection and Correction Coding Block Coding .… k bits k bits k bits k bits k bits 2k Datawords, each of k bits .… n bits n bits n bits n bits n bits 2n Codewords, each of n bits (only 2k of these are valid)

  16. Error Detection and Correction Coding Block Coding Example: • 4B/5B block coding: • In this coding scheme, k =4 and n =5. • We have: • 2k = 24 = 16 datawords • 2n = 25 = 32 codewords • 16 out of 32 codewords are used for message transfer. • The rest are either used for control purposes or unused.

  17. Error Detection Error Detection in Block Coding • If the following two conditions are met, the receiver can detect a change in the original codeword: • The receiver has (or can find) a list of valid codewords. • The original codeword has changed to an invalid one.

  18. Error Detection Error Detection in Block Coding Process Encoder Decoder k bits k bits Dataword Dataword Extract Discard Generator Checker Unreliable Transmission n bits n bits Codeword Codeword Receiver Sender

  19. Error Detection Error Detection in Block Coding Process • The sender creates codewords out of datawords by using a generator that applies the rules and procedures of encoding. • Each codeword sent to the receiver may change during transmission. • If the received codeword is the same as one of the valid codewords, the word is accepted; the corresponding dataword is extracted for use. • If the received codeword is not valid, it is discarded. • If the codeword is corrupted during transmission but the received word still matches a valid codeword, the error remains undetected. • This type of coding can detect only single errors. • Two or more errors may remain undetected.

  20. Error Detection Error Detection in Block Coding Process Example: • Assume that k =2 and n =3. • Table below shows the list of datawords and codewords.

  21. Error Detection Error Detection in Block Coding Example: • Assume the sender encodes the dataword 01 as 011 and sends it to the receiver. • Consider the following cases: • The receiver receives 011. It is a valid codeword. The receiver extracts the dataword 01 from it. • The codeword is corrupted during transmission, and 111 is received (the leftmost bit is corrupted). This is not a valid codeword and is discarded. • The codeword is corrupted during transmission, and 000 is received (the right two bits are corrupted). This is a valid codeword. The receiver incorrectly extracts the dataword 00. Two corrupted bits have made the error undetectable.

  22. Error Detection Error Detection Methods

  23. Error Detection Error Detection Methods Simple Parity-Check Code • The most familiar error-detecting code. • In this code, a k-bit dataword is changed to an n-bit codeword where n = k + 1. • The extra bit, called the parity bit, is selected to make the total number of 1s in the codeword even. • Some implementations specify an odd number of 1s. • The code is a single-bit error-detecting code. • It cannot correct any error. In parity check, a parity bit is added to every data unit so that the total number of 1s is even (or odd for odd-parity).

  24. Error Detection Error Detection Methods Simple Parity-Check Code Possible structure of an encoder and a decoder • The encoder uses a generator that takes a copy of a 4-bit dataword (a0, a1, a2, and a3) and generates a parity bit r0. • The dataword bits and the parity bit create the 5-bit codeword. • The parity bit that is added makes the number of 1s in the codeword even. • This is normally done by adding the 4 bits of the dataword (modulo-2); the result is the parity bit. • If the number of 1s is even, the result is 0; if the number of 1s is odd, the result is 1. • In both cases, the total number of 1s in the codeword is even.

  25. Error Detection Error Detection Methods Simple Parity-Check Code: Encoder and Decoder Sender Receiver Encoder Decoder Dataword Dataword a3 a2 a1 a0 a3 a2 a1 a0 Accept Decision Logic Discard Syndrome s0 Generator Checker Parity bit a3 a2 a1 a0 r0 b3 b2 b1 b0 q0 Unreliable Transmission Codeword Codeword

  26. Error Detection Error Detection Methods Simple Parity-Check Code: Encoder and a decoder • The sender sends the codeword which may be corrupted during transmission. • The receiver receives a 5-bit word. • The checker at the receiver does the same thing as the generator in the sender with one exception: • The addition is done over all 5 bits. • The result, which is called the syndrome, is just 1 bit. • The syndrome is 0 when the number of 1s in the received codeword is even; otherwise, it is 1. • The syndrome is passed to the decision logic analyzer. • If the syndrome is 0, there is no error in the received codeword; the data portion of the received codeword is accepted as the dataword; if the syndrome is 1, the data portion of the received codeword is discarded. The dataword is not created.

  27. Error Detection Error Detection Methods Simple Parity-Check Code: Encoder and a decoder Even-parity concept

  28. Error Detection Error Detection Methods Simple Parity-Check Code: Encoder and a decoder Even-parity concept • Suppose the sender wants to send the word world. • In ASCII the five characters are coded as w o r l d 1110111 1101111 1110010 1101100 1100100 • The following shows the actual bits sent 11101110 11011110 11100100 11011000 11001001

  29. Error Detection Error Detection Methods Simple Parity-Check Code: Encoder and a decoder Even-parity concept Example: • Now suppose the word world is received by the receiver without being corrupted in transmission. 11101110 11011110 11100100 11011000 11001001 • The receiver counts the 1s in each character and comes up with even numbers (6, 6, 4, 4, 4). • The data are accepted.

  30. Error Detection Error Detection Methods Simple Parity-Check Code: Encoder and a decoder Even-parity concept Example: • Now suppose the word world in Example 1 is corrupted during transmission. 11111110 11011110 11101100 11011000 11001001 • The receiver counts the 1s in each character and comes up with even and odd numbers (7, 6, 5, 4, 4). • The receiver knows that the data are corrupted, discards them, and asks for retransmission.

  31. Error Detection Error Detection Methods Simple Parity-Check Code: Encoder and a decoder Even-parity concept • Simple parity check can detect all single-bit errors. • It can detect burst errors only if the total number of errors in each data unit is odd.

  32. Error Detection Error Detection Methods Two-Dimensional Parity-Check: • In this method, the dataword is organized in a table (rows and columns). • For each row and each column, 1 parity-check bit is calculated. • The whole table is then sent to the receiver, which finds the syndrome for each row and each column. • The two-dimensional parity check can detect up to three errors that occur anywhere in the table. • However, errors affecting 4 bits may not be detected. • In two-dimensional parity check, a block of bits is divided into rows and redundant bits are added to the whole block.

  33. Error Detection Error Detection Methods Two-Dimensional Parity-Check:

  34. Error Detection Error Detection Methods Cyclic Redundancy Check (CRC): • In the encoder, the dataword has k bits; the codeword has n bits. • The size of the dataword is augmented by adding n – k (generally) 0s to the right-hand side of the word. • The n-bit result is fed into the generator. • The generator uses a divisor of size n - k + I (generally ), predefined and agreed upon. • The generator divides the augmented dataword by the divisor (modulo-2 division). • The quotient of the division is discarded; the remainder (r2r1r0) is appended to the dataword to create the codeword.

  35. Error Detection Error Detection Methods Cyclic Redundancy Check: • The decoder receives the possibly corrupted codeword. • A copy of all n bits is fed to the checker which is a replica of the generator. • The remainder produced by the checker is a syndrome of n - k bits, which is fed to the decision logic analyzer. • The analyzer has a simple function. • If the syndrome bits are all 0s, the 4 leftmost bits of the codeword are accepted as the dataword (interpreted as no error); otherwise, the 4 bits are discarded (error).

  36. Error Detection Error Detection Methods Cyclic Redundancy Check: Sender Receiver Encoder Decoder Dataword Dataword a3 a2 a1 a0 a3 a2 a1 a0 Syndrome Accept 0 0 0 Decision Logic Discard s2 s1 s0 Generator Checker Divisor d3d2d1d0 Remainder a3 a2 a1 a0 r2 r1 r0 b3 b2 b1 b0 q2 q1 q0 Unreliable Transmission Codeword Codeword

  37. Error Detection Error Detection Methods Cyclic Redundancy Check: CRC generator and checker

  38. Error Detection Error Detection Methods Cyclic Redundancy Check: CRC generator

  39. Error Detection Error Detection Methods Cyclic Redundancy Check: CRC checker

  40. Error Detection Error Detection Methods Polynomial: • A better way to understand cyclic codes and how they can be analyzed is to represent them as polynomials. • A pattern of 0s and 1s can be represented as a polynomial with coefficients of 0 and 1. • The power of each term shows the position of the bit; the coefficient shows the value of the bit. • Figure below shows a binary pattern and its polynomial representation. • Figure also shows how the polynomial can be shortened by removing all terms with zero coefficients and replacing x1 by x and x0 by 1.

  41. 1 0 0 0 0 1 1 1x6 0x5 0x4 0x3 0x2 1x1 1x0 1 0 0 0 0 1 1 1x6 1x1 1x0 = x6 + x+ 1 Error Detection Error Detection Methods Polynomial:

  42. Error Detection Error Detection Methods Polynomial: 1 0 0 0 0 1 1 1x6 1x1 1x0 = x6 + x+ 1 • Figure shows one immediate benefit; a 7-bit pattern can be replaced by three terms. • The benefit is even more conspicuous when we have a polynomial such as x23 + X3 + 1. • Here the bit pattern is 24 bits in length (three Is and twenty-one 0s) while the polynomial is just three terms.

  43. Error Detection Error Detection Methods Polynomial: Degree of a Polynomial: • The degree of a polynomial is the highest power in the polynomial. • For example, the degree of the polynomial x6 + x + 1 is 6. • Note that the degree of a polynomial is 1 less that the number of bits in the pattern. The bit pattern in this case has 7 bits.

  44. Error Detection Methods Error Detection Polynomials Shifting: • Shifting to the left means adding extra 0s as rightmost bits; shifting to the right means deleting some rightmost bits. • Shifting to the left is accomplished by multiplying each term of the polynomial by xn, where n is the number of shifted bits; • Shifting to the right is accomplished by dividing each term of the polynomial by xn. • We do not have negative powers in the polynomial representation. • Shifting left 3 bits: • 10011 becomes 10011000 x4 + x + 1 becomes x7 + x4 + x3 • Shifting right 3 bits: • 10011 becomes 10 x4 + x + 1 becomes x • When we augment the dataword in the encoder, we actually shift the bits to the left.

  45. Error Detection Methods Error Detection Cyclic Code Encoder Using Polynomials Creation of a codeword from a dataword: • The dataword 1001 is represented as x3 + 1. • The divisor 1011 is represented as x3 + x + 1. • To find the augmented dataword, we left-shift the dataword 3 bits (multiplying by x3). The result is x6 + x3 The divisor in a cyclic code is normally called the generator polynomial or simply the generator.

  46. Error Detection Methods Error Detection Cyclic Code Encoder and Decoder Using Polynomials Cyclic Code Analysis We can analyze a cyclic code to find its capabilities by using polynomials. We define the following, where f(x) is a polynomial with binary coefficients. Dataword: d(x) Codeword: c(x) Generator: g(x) Syndrome: s(x) Error: e(x) If s(x) is not zero, then one or more bits is corrupted. If s(x) is zero, either no bit is corrupted or the decoder failed to detect any errors. Algorithm: In a cyclic code, 1. If s(x)  0, one or more bits is corrupted. 2. If s(x) =0, either a. No bit is corrupted. or b. Some bits are corrupted, but the decoder failed to detect them.

  47. Error Detection Methods Error Detection Cyclic Code Using Polynomials

  48. Error Detection Error Detection Methods Checksum • The checksum is used in the Internet by several protocols. • Like block and cyclic codes, the checksum is based on the concept of redundancy. • Suppose our data is a list of five 4-bit numbers that we want to send to a destination. • In addition to sending these numbers, we send the sum of the numbers. • For example, if the set of numbers is (7, 11, 12, 0, 6), we send (7, 11, 12,0,6,36), where 36 is the sum of the original numbers. • The receiver adds the five numbers and compares the result with the sum. If the two are the same, the receiver assumes no error, accepts the five numbers, and discards the sum. • Otherwise, there is an error somewhere and the data are not accepted.

  49. Error Detection Error Detection Methods Checksum • We can make the job of the receiver easier if we send the negative (complement) of the sum, called the checksum. • In this case, we send (7, 11, 12, 0, 6, -36). • Receiver can add all the numbers received (including the checksum). • If the result is 0, it assumes no error; otherwise, there is an error. One's Complement • The previous example has one major drawback. • All of our data can be written as a 4-bit word (they are less than 15) except for the checksum. • One solution is to use one's complement arithmetic. • In this arithmetic, we can represent unsigned numbers between 0 and 2n - 1 using only n bits. • If the number has more than n bits, the extra leftmost bits need to be added to the n rightmost bits (wrapping). In one's complement arithmetic, a negative number can be represented by inverting all bits (changing a 0 to a 1 and a 1 to a 0). This is the same as subtracting the number from 2n - 1.

  50. Error Detection Error Detection Methods Checksum Example: How can we represent the number 21 in one's complement arithmetic using only four bits? Solution: The number 21 in binary is 10101 (it needs five bits). We can wrap the leftmost bit and add it to the four rightmost bits. We have (0101 + 1) = 0110 or 6. Example: How can we represent the number -6 in one's complement arithmetic using only four bits? Solution: In one's complement arithmetic, the negative or complement of a number is found by inverting all bits. Positive 6 is 0110; negative 6 is 100I. If we consider only unsigned numbers, this is 9. In other words, the complement of 6 is 9. Another way to find the complement of a number in one's complement arithmetic is to subtract the number from 2n - I (16 - 1 in this case).

More Related