COEN 180 Erasure Correcting Error Detecting and Error

  • Slides: 27
Download presentation
COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes

COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes

Basics n Use encoding to protect data for storage ¨ for transmission. ¨ n

Basics n Use encoding to protect data for storage ¨ for transmission. ¨ n Encode in order to ¨ Discover errors n n ¨ Correct errors n ¨ Example: CRC code tagged onto IP packets. Example: ISBN number check digit Example: Disk Drives, Communications Protocols Correct erasures n Redundant storage of data (e. g. in Disk Arrays)

Basics n Rich Mathematical Theory ¨ Block codes, burst codes, … ¨ Uses heavily

Basics n Rich Mathematical Theory ¨ Block codes, burst codes, … ¨ Uses heavily Galois fields n Mathematical structure with addition, multiplication, … in which we manipulate objects according to the same rules as the more popular fields of real numbers, complex numbers, rational numbers,

Error Detection n Basic Principle: ¨ Calculate a small “signature” from a data object

Error Detection n Basic Principle: ¨ Calculate a small “signature” from a data object and store it with the data object. ¨ For verification, recalculate the signature. n Example: CRC codes ¨ Cyclic Redundancy Codes ¨ Fast calculation

Error Detection n Parity code ¨ Block code of l bits ¨ Adds parity

Error Detection n Parity code ¨ Block code of l bits ¨ Adds parity bit to block ¨ Example: n Message: ¨ n 1011 1000 0100 1 Encoded message after one error: ¨ n 1011 1000 0100 Encoded message: ¨ n code. 1111 1000 0100 1 Parity is Off Encoded message after two errors: ¨ 1111 1100 0100 1 Parity is correct, error undetected

Error Detection: CRC n Example: ¨ Need n a CRC polynomial (a bit string

Error Detection: CRC n Example: ¨ Need n a CRC polynomial (a bit string for us) Example 11011 (with leading 1) ¨ Cyclically shift through the message with a field the length of the CRC polynomial Example 100010100100100010 n Whenever most significant bit is 1, XOR CRC polynomial. n

Error Detection: CRC n Example: 100010100100100010 1000

Error Detection: CRC n Example: 100010100100100010 1000

Error Detection: CRC n Example: 100010100100100010 10001 Most significant bit is 1: XOR 11011

Error Detection: CRC n Example: 100010100100100010 10001 Most significant bit is 1: XOR 11011 01010 Drop leading 0 1010

Error Detection: CRC n Example: 100010100100100010 1010 0 Shift contents of register to left,

Error Detection: CRC n Example: 100010100100100010 1010 0 Shift contents of register to left, drop in next bit Most significant bit is 0: Drop leading 0 0100

Error Detection: CRC n Example: 100010100100100010 0100 1 Shift contents of register to left,

Error Detection: CRC n Example: 100010100100100010 0100 1 Shift contents of register to left, drop in next bit Most significant bit is 0: Drop leading 0 1001

Error Detection: CRC n Example: 100010100100100010 10100 Shift contents of register to left, drop

Error Detection: CRC n Example: 100010100100100010 10100 Shift contents of register to left, drop in next bit Most significant bit is 1: XOR 11011 01111 Drop leading 0 1111

Error Detection: CRC n Add CRC of packet in TCP/IP

Error Detection: CRC n Add CRC of packet in TCP/IP

Error Correction n Transmission Channel ¨ Used for communications channel ¨ Used for storage

Error Correction n Transmission Channel ¨ Used for communications channel ¨ Used for storage channel (travel in time)

Error Correction n Encode an object with additional parity bits. Use parity bits to

Error Correction n Encode an object with additional parity bits. Use parity bits to detect and correct an error. Trivial Example: Replication Code Encodes messages of length 1 b ¨ Add to bit two copies of the bit. ¨ When all three bits in the received message coincide, conclude that no error has occurred. ¨ Otherwise, use a majority rule to decide. ¨ Decoding Table 000 0 100 0 001 0 101 1 010 0 110 1 011 1 111 1

Error Correction n Hamming Distance ¨ Defined to be the number of different bits

Error Correction n Hamming Distance ¨ Defined to be the number of different bits in a bit string of length l. ¨ Examples: 0011 1110 and 0101 1110 have distance 2 n 0011 1110 and 1100 0001 have distance 8 n

Error Correction Code Word: a word that can be obtained by encoding a piece

Error Correction Code Word: a word that can be obtained by encoding a piece of datum. n There are many fewer code words than possible. n Maximum Likelihood Decoding: n ¨ When receiving a message, decode it with the code word closest in Hamming distance.

Error Correction Maximum Likelihood Decoding

Error Correction Maximum Likelihood Decoding

Error Correction n Example: ¨ Assume the following 00 - 00100 01 - 01110

Error Correction n Example: ¨ Assume the following 00 - 00100 01 - 01110 10 - 10001 11 - 11000 ¨ Assume we received 11111 How do we decode? (bad) code:

Error Correction n Linear Codes ¨ Based on Reed Solomon. ¨ Encode symbols: bit-strings

Error Correction n Linear Codes ¨ Based on Reed Solomon. ¨ Encode symbols: bit-strings of length l. ¨ Generate an m by n matrix G such that n n any m by m submatrix is invertible. such that G is of the form (1|P) ¨ ¨ where 1 is the m by m identity matrix P is the so-called parity matrix. ¨ Encode m symbol data (x 1, x 2, …, xm) as (x 1, x 2, …, xm)G

Error Correction : Hamming Code n Hamming Code ¨ Systematic: n Code word is

Error Correction : Hamming Code n Hamming Code ¨ Systematic: n Code word is data word + parity m message bits and r parity bits ¨ Linear ¨ Create matrix of size 2 r-1 by r. ¨ Populate rows with binary encoding of all numbers from 1 to 2 r ¨ If desired, arrange them so that the identity matrix is the lower part of the matrix.

Error Correction : Hamming Code Hamming matrix for r = 3.

Error Correction : Hamming Code Hamming matrix for r = 3.

Error Correction: Hamming Code If data word is (a, b, c, d), then code

Error Correction: Hamming Code If data word is (a, b, c, d), then code word is (a, b, c, d, x, y, z) where the parity bits are chosen such that (a, b, c, d)H=(0, 0, 0, 0). n

Error Correction: Hamming Code

Error Correction: Hamming Code

Error Correction: Hamming Code n Example: ¨ Data is (0, 1, 0, 1) ¨

Error Correction: Hamming Code n Example: ¨ Data is (0, 1, 0, 1) ¨ What is the code word?

Error Correction: Hamming Code n Answer: ¨ (0, 1, 0).

Error Correction: Hamming Code n Answer: ¨ (0, 1, 0).

Error Correction: Hamming Code To correct an error, apply H to the received vector.

Error Correction: Hamming Code To correct an error, apply H to the received vector. n The result is the binary encoding of a row in H. n The corresponding coefficient in the vector is were the error most likely was. n

Error Correction: Hamming Code n n Assume that we received (0100010). We apply H

Error Correction: Hamming Code n n Assume that we received (0100010). We apply H to this vector: (0100010)· H = (111). n n n Therefore, the error is given by row (111). That is, in the fourth row. Hence, error is in bit position 4.