1 / 31

Lecture Focus:

Lecture Focus:. Data Link Layer Error Control Error Correction. CSCS 311. Data Communications and Networking. Lecture 20. Error Correction. We need to know the exact number of bits that are corrupted and more importantly, their location in the message.

kellybryant
Download Presentation

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 Error Correction CSCS 311 Data Communications and Networking Lecture 20

  2. Error Correction • We need to know the exact number of bits that are corrupted and more importantly, their location in the message. • The number of the errors and the size of the message are important factors. • If we need to correct one single error in an 8-bit data unit, we need to consider 8 possible error locations. • If we need to correct two errors in a data unit of the same size, we need to consider 28 possibilities. • Imagine the receiver's difficulty in finding 10 errors in a data unit of 1000 bits. 8! = 8 *7 * 6! ---- 2! * 6! The correction of errors is more difficult than the detection.

  3. Error Correction Error Correction Techniques • Retransmission • Forward Error Correction • Burst Error Correction

  4. Error Correction Error Correction Techniques Forward Error Correction (FEC) • In this process, the receiver tries to guess the message by using redundant bits. • This is possible, if the number of errors is small. Retransmission • A technique in which the receiver detects the occurrence of an error and asks the sender to resend the message. • Resending is repeated until a message arrives that the receiver believes is error-free (usually, not all errors can be detected).

  5. Error Correction Encoder and Decoder Encoder Decoder k bits k bits Dataword Dataword Correct Generator Checker Unreliable Transmission n bits n bits Codeword Codeword Receiver Sender

  6. Error Correction Example: • Let us add 3 redundant bits to the 2-bit dataword to make 5-bit codewords. • Table below shows the datawords and codewords. • Assume the dataword is 01. • The sender consults the table (or uses an algorithm) to create the • codeword 01011. • The codeword is corrupted during transmission, and 01001 is received (error in the second bit from the right). • First, the receiver finds that the received codeword is not in the table. • This means an error has occurred. (Detection must come before correction.) The receiver, assuming that there is only 1 bit corrupted, uses the following strategy to guess the correct dataword. 01001

  7. Error Correction • Comparing the received codeword with the first codeword in the table (01001 versus 00000), the receiver decides that the first codeword is not the one that was sent because there are two different bits. • By the same reasoning, the original codeword cannot be the third or fourth one in the table. • The original codeword must be the second one in the table because this is the only one that differs from the received codeword by 1 bit. The receiver replaces 01001 with 01011 and consults the table to find the dataword 01. X 01001 X X

  8. Error Correction Hamming Distance • The Hamming distance between two words (of the same size) is the number of differences between the corresponding bits. • We show the Hamming distance between two words x and y as d(x, y). • The Hamming distance can easily be found if we apply the XOR operation ( ) on the two words and count the number of 1s in the result. • Note that the Hamming distance is a value greater than zero. d(x, y) > 0 Example: The Hamming distance d(000, 011) is 2. 000  011 is 011 (two 1s). The Hamming distance d(10101, 11110) is 3. 10101  11110 is 01011 (three 1s).

  9. Error Correction Hamming Distance Minimum Hamming Distance • The concept of the Hamming distance is the central point in dealing with error detection and correction codes. • The measurement that is used for designing a code is the minimum Hamming distance. • In a set of words, the minimum Hamming distance is the smallest Hamming distance between all possible pairs. • We use dmin to define the minimum Hamming distance in a coding scheme. • To find this value, we find the Hamming distances between all words and select the smallest one.

  10. Error Correction Hamming Distance Minimum Hamming Distance Example: Find the minimum Hamming distance of the coding scheme in below table. Solution: We first find all Hamming distances. d(000, 011) =2 d(000, 101) =2 d(000, 110) =2 d(011, 101) =2 d(011, 110) =2 d(101,110)=2 The dmin in this case is 2.

  11. Error Correction Hamming Distance Minimum Hamming Distance Example: Find the minimum Hamming distance of the coding scheme in below table. Solution: We first find all the Hamming distances. d(00000, 01011) = 3 d(01011, 10101) = 4 d(00000, 10101) = 3 d(01011, 11110) = 3 d(00000, 11110) = 4 d(10101, 11110) = 3 The dmin in this case is 3.

  12. Error Correction Hamming Distance Minimum Hamming Distance Three Parameters Any coding scheme needs to have at least three parameters: • The codeword size n, • The dataword size k, and • The minimum Hamming distance dmin. • A coding scheme C is written as C(n, k) with a separate expression for dmin. • We can call our first coding scheme C(3, 2) with dmin =2 and our second coding scheme C(5, 2) with dmin = 3.

  13. Error Correction Hamming Distance Hamming Distance and Error • When a codeword is corrupted during transmission, the Hamming distance between the sent and received codewords is the number of bits affected by the error. • In other words, the Hamming distance between the received codeword and the sent codeword is the number of bits that are corrupted during transmission. • If the codeword 00000 is sent and 01101 is received, 3 bits are in error and the Hamming distance between the two is d(00000, 01101) =3.

  14. Error Correction Hamming Distance Minimum Distance for Error Detection • If s errors occur during transmission, the Hamming distance between the sent codeword and received codeword is s. • If our code is to detect up to s errors, the minimum distance between the valid codes must be s + 1, so that the received codeword does not match a valid codeword. • In other words, if the minimum distance between all valid codewords is s + 1, the received codeword can’t be erroneously mistaken for another codeword. • The distances are not enough (s + 1) for the receiver to accept it as valid. The error will be detected.

  15. Error Correction Hamming Distance Minimum Distance for Error Detection Example: • The minimum Hamming distance for (table below) is 2. • This code guarantees detection of only a single error. • For example, if the third codeword (101) is sent and one error occurs, the received codeword does not match any valid codeword. • If two errors occur, however, the received codeword may match a valid codeword and the errors are not detected.

  16. Error Correction Hamming Distance Minimum Distance for Error Detection Example: • The minimum Hamming distance for (table below) is 3. • This code can detect up to two errors. • We see that when any of the valid codewords is sent, two errors create a codeword which is not in the table of valid codewords. The receiver cannot be fooled. • However, some combinations of three errors change a valid codeword to another valid codeword. The receiver accepts the received codeword and the errors are undetected.

  17. Error Correction Hamming Distance Minimum Distance for Error Correction dmin = 2*t + 1 where t is the number of errors that can be corrected. • If the minimum Hamming distance is 3, code can detect up to two errors and correct up to 1 error.

  18. Error Correction Hamming Code • A category of error-correcting codes. • These codes were originally designed with dmin = 3, which means that they can detect up to two errors or correct one single error. • Although there are some Hamming codes that can correct more than one error, our discussion focuses on the single-bit error-correcting code. • First let us find the relationship between n and k in a Hamming code. • We need to choose an integer m >= 3. (why?) • The values of n and k are calculated from m as n = 2m – 1 and k = n - m. • The number of check bits r = m.

  19. Error Correction Hamming Code • For example, if m =3, then n = 7 and k = 4. • This is a Hamming code C(7, 4) with dmin =3. • Table below shows the datawords and codewords for this code.

  20. Error Correction Hamming Code The structure of the encoder and decoder for a Hamming code Encoder Decoder Dataword Dataword a3 a2 a1 a0 a3 a2 a1 a0 Syndrome Correction Logic s2 s1 s0 Generator Checker a3 a2 a1 a0 r2 r1 r0 b3 b2 b1 b0 q2 q1 q0 Unreliable Transmission Codeword Codeword

  21. Error Correction Hamming Code The structure of the encoder and decoder for a Hamming code • A copy of a 4-bit dataword is fed into the generator that creates three parity checks r0, r1 and r2 as shown below: r0 = a2 + a1 + a0(Modulo-2) r1 = a3 + a2 + a1(Modulo-2) r2 = a1 + a0 + a3(Modulo-2) • Each of the parity-check bits handles 3 out of the 4 bits of the dataword. • The total number of 1s in each 4-bit combination (3 dataword bits and 1 parity bit) must be even.

  22. Error Correction Hamming Code The structure of the encoder and decoder for a Hamming code • The checker in the decoder creates a 3-bit syndrome (s2s1s0) in which each bit is the parity check for 4 out of the 7 bits in the received codeword: s0 = b2 + b1 + b0 + q0 (Modulo-2) s1 = b3 + b2 + b1 + q1(Modulo-2) s2 = b1 + b0 + b3 + q2(Modulo-2) • The 3-bit syndrome creates eight different bit patterns (000 to 111) that can represent eight different conditions. • These conditions define a lack of error or an error in 1 of the 7 bits of the received codeword, as shown in below table.

  23. Error Correction Hamming Code The structure of the encoder and decoder for a Hamming code • The syndrome values in above table are based on the syndrome bit calculations. • For example, if q0 is in error, s0 is the only bit affected; the syndrome, therefore, is 001. • If b2 is in error, s0 and s1 are the bits affected; the syndrome, therefore is 011. • If b1 is in error, all 3 syndrome bits are affected and the syndrome is 111. s0 = b2 + b1 + b0 + q0 s1 = b3 + b2 + b1 + q1 s2 = b1 + b0 + b3 + q2

  24. Error Correction Hamming Code Example The dataword 0100 is to be sent. a0= 0 a1= 0 a2= 1 a3= 0 r0= a2 + a1 + a0= 0+0+1 = 1 r1= a3 + a2 + a1= 0+1+0 = 1 r2= a1 + a0 + a3 = 0+0+0 = 0 So, the dataword 0100 becomes the codeword 0 1 0 0 0 1 1. The codeword 01 00011 is received. The syndrome is: s0= b2 + b1 + b0 + q0 =1 + 0 + 0 + 1 = 0 s1= b3 + b2 + b1 + q1 =0 + 1 + 0 + 1 = 0 s2= b1 + b0 + b3 + q2= 0 + 0 + 0 + 0 = 0 s2s1s0 = 0 0 0 As the syndrome is 000 (no error), the final dataword is 0100. b3b2b1b0q2q1q0

  25. Error Correction Hamming Code Example The dataword 0111 is to be sent. a0 = 0 a1 = 1 a2 = 1 a3 = 1 r0 = a2 + a1 + a0 = 1+1+1 = 1 r1 = a3 + a2 + a1 = 0+1+1 = 0 r2 = a1 + a0 + a3 = 1+1+0 = 0 So, the dataword 0111 becomes the codeword 0 1 1 1 0 0 1. The codeword 0011001 is received. The syndrome is: s0 = b2 + b1 + b0 + q0 = 0 + 1 + 1 + 1 = 1 s1 = b3 + b2 + b1 + q1 = 0 + 0 + 1 + 0 = 1 s2 = b1 + b0 + b3 + q2 = 1 + 1 + 0 + 0 = 0 s2s1s0 = 0 1 1 Syndrome is 011. According to the below table, b2 is in error. After flipping b2 (changing the 1 to 0), the final dataword is 0111. b3b2b1b0q2q1q0

  26. Error Correction Hamming Code The structure of the encoder and decoder for a Hamming code Example The dataword 1101 becomes the codeword 1101000. The codeword 0001000 is received (two errors). The syndrome is 101, which means that b0 is in error. After flipping b0, we get 0000, the wrong dataword. This shows that our code cannot correct two errors.

  27. Error Correction Hamming Code Data and redundancy bits • m = the number of check bits ( m >= 3) • n = 2m – 1 • k = n - m.

  28. Error Correction Hamming Code Data and redundancy bits Positions of redundancy bits in Hamming code

  29. Error Correction Hamming Code Redundancy bits calculation 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011

  30. Error Correction Hamming Code Example of redundancy bit calculation

  31. Error Correction Hamming Code Error detection using Hamming code 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011

More Related