Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture Focus: Data Communications and Networking  Data Link Layer  Error Control Lecture 19 CSCS 311.

Similar presentations


Presentation on theme: "Lecture Focus: Data Communications and Networking  Data Link Layer  Error Control Lecture 19 CSCS 311."— Presentation transcript:

1 Lecture Focus: Data Communications and Networking  Data Link Layer  Error Control Lecture 19 CSCS 311

2 Error Control

3 Error Detection and Correction  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.  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.

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 unit is changed.  A 0 is changed to a 1 OR a 1 to a 0. 0 11 00 11 0 TransmitterReceiver Data unit = A byte, character, or packet 01 TransmitterReceiver 10 Medium

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 Data unit = A byte, character, or packet  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.

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

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 Message Generator Message and redundancy Sender Receiver Decoder Message Checker Received data Accept, Correct or Discard Unreliable Transmission

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. DatawordRedundant bitsCodeword + = r bitsk bitsn 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 2 k datawords.  With n bits, we can create a combination of 2 n 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 2 n - 2 k codewords that are not used.  We call these codewords invalid or illegal.

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

16 Error Detection and Correction Coding Block Coding Example:  4B/5B block coding:  In this coding scheme, k =4 and n =5.  We have:  2 k = 2 4 = 16 datawords  2 n = 2 5 = 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: 1.The receiver has (or can find) a list of valid codewords. 2.The original codeword has changed to an invalid one.

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

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: 1.The receiver receives 011. It is a valid codeword. The receiver extracts the dataword 01 from it. 2.The codeword is corrupted during transmission, and 111 is received (the leftmost bit is corrupted). This is not a valid codeword and is discarded. 3.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 (a 0, a 1, a 2, and a 3 ) and generates a parity bit r 0.  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 Encoder Generator Codeword Sender Parity bit Dataword a3a3 a2a2 a1a1 a0a0 a3a3 a2a2 a1a1 a0a0 r0r0 Receiver Decoder Checker Codeword Syndrome Dataword a3a3 a2a2 a1a1 a0a0 b3b3 b2b2 b1b1 b0b0 q0q0 Unreliable Transmission Decision Logic Discard Accept s0s0

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 world 1110111 1101111111001011011001100100  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  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. Example:

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 (r 2 r 1 r 0 ) 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: Encoder Generator Codeword Sender Remainder Dataword a3a3 a2a2 a1a1 a0a0 a3a3 a2a2 a1a1 a0a0 r2r2 Receiver Decoder Checker Codeword Syndrome Dataword a3a3 a2a2 a1a1 a0a0 b3b3 b2b2 b1b1 b0b0 Unreliable Transmission Decision Logic Discard Accept 000 r1r1 r0r0 Divisor d 3 d 2 d 1 d 0 q2q2 q1q1 q0q0 s2s2 s1s1 s0s0

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 x 1 by x and x 0 by 1.

41 Error Detection Error Detection Methods Polynomial: 1000011 1x61x6 0x50x5 0x40x4 0x30x3 0x20x2 1x11x1 1x01x0 1000011 1x61x6 1x11x1 1x01x0 = x 6 + x + 1

42 Error Detection Error Detection Methods Polynomial: 1000011 1x61x6 1x11x1 1x01x0 = x 6 + 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 x 23 + X 3 + 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 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 x n, where n is the number of shifted bits;  Shifting to the right is accomplished by dividing each term of the polynomial by x n.  We do not have negative powers in the polynomial representation.  Shifting left 3 bits:  10011 becomes 10011000x 4 + x + 1 becomes x 7 + x 4 + x 3  Shifting right 3 bits:  10011 becomes 10x 4 + x + 1 becomes x  When we augment the dataword in the encoder, we actually shift the bits to the left. Error Detection Methods

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

46 Error Detection Error Detection Methods 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 Error Detection Methods 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 2 n - 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 2 n - 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).

51 Error Detection Error Detection Methods Checksum Example: Let us redo previous exercise (7, 11, 12, 0, 6) using one's complement arithmetic. Figure below shows the process at the sender and at the receiver. The sender initializes the checksum to 0 and adds all data items and the checksum (the checksum is considered as one data item). The result is 36. However, 36 can’t be expressed in 4 bits. The extra two bits are wrapped and added with the sum to create the wrapped sum value 6. The sum is then complemented, resulting in the checksum value 9 (15 - 6 = 9). The sender now sends six data items to the receiver including the checksum 9. (Continued)

52 Error Detection Error Detection Methods Checksum Example: The receiver follows the same procedure as the sender. It adds all data items (including the checksum); the result is 45. The sum is wrapped and becomes 15. The wrapped sum is complemented and becomes 0. Since the value of the checksum is 0, this means that the data is not corrupted. The receiver drops the checksum and keeps the other data items. If the checksum is not zero, the entire packet is dropped.

53 Error Detection Error Detection Methods Checksum

54 Error Detection Error Detection Methods Checksum The sender follows these steps: The unit is divided into k sections, each of n bits. All sections are added using one’s complement to get the sum. The sum is complemented and becomes the checksum. The checksum is sent with the data. The receiver follows these steps: The unit is divided into k sections, each of n bits. All sections are added using one’s complement to get the sum. The sum is complemented. If the result is zero, the data are accepted: otherwise, rejected.

55 Error Detection Error Detection Methods Checksum Suppose the following block of 16 bits is to be sent using a checksum of 8 bits. 10101001 00111001 The numbers are added using one’s complement 10101001 00111001 ---------------- Sum = 11100010 Checksum =00011101 The pattern sent is 10101001 00111001 00011101

56 Error Detection Error Detection Methods Checksum Now suppose the receiver receives the pattern sent and there is no error. 10101001 00111001 00011101 When the receiver adds the three sections, it will get all 1s, which, after complementing, is all 0s and shows that there is no error. 10101001 00111001 00011101 ---------------- Sum =11111111 Complement = 00000000 It means that the pattern is OK.

57 Error Detection Error Detection Methods Checksum Now suppose there is a burst error of length 5 that affects 4 bits. 10101111 11111001 00011101 When the receiver adds the three sections, it gets 10101111 11111001 00011101 Partial Sum 1 11000101 Carry 1 Sum11000110 Complement 00111001 It means the pattern is corrupted. 10101001 00111001 00011101


Download ppt "Lecture Focus: Data Communications and Networking  Data Link Layer  Error Control Lecture 19 CSCS 311."

Similar presentations


Ads by Google