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

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

Transcript of COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Page 1: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

COEN 180

Erasure Correcting,Error Detecting, andError Correcting Codes

Page 2: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Basics

Use encoding to protect data for storage for transmission.

Encode in order to Discover errors

Example: CRC code tagged onto IP packets. Example: ISBN number check digit

Correct errors Example: Disk Drives, Communications Protocols

Correct erasures Redundant storage of data (e.g. in Disk Arrays)

Page 3: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Basics

Rich Mathematical TheoryBlock codes, burst codes, …Uses heavily Galois fields

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,

Page 4: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Detection

Basic Principle:Calculate a small “signature” from a data

object and store it with the data object.For verification, recalculate the signature.

Example: CRC codesCyclic Redundancy CodesFast calculation

Page 5: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Detection

Parity code Block code of l bits Adds parity bit to block code. Example:

Message: 1011 1000 0100

Encoded message: 1011 1000 0100 1

Encoded message after one error: 1111 1000 0100 1 Parity is Off

Encoded message after two errors: 1111 1100 0100 1 Parity is correct, error undetected

Page 6: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Detection: CRC

Example:Need 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 1000101001001000100100010 Whenever most significant bit is 1, XOR CRC

polynomial.

Page 7: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Detection: CRC

Example:

1000101001001000100100010

1000

Page 8: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Detection: CRC

Example:

1000101001001000100100010

10001

Most significant bit is 1: XOR 11011

01010Drop leading 0

1010

Page 9: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Detection: CRC

Example:

1000101001001000100100010

1010

Most significant bit is 0: Drop leading 0

0100

0

Shift contents of register to left, drop in next bit

Page 10: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Detection: CRC

Example:

1000101001001000100100010

0100

Most significant bit is 0: Drop leading 0

1001

1

Shift contents of register to left, drop in next bit

Page 11: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Detection: CRC

Example:

1000101001001000100100010

10100

Most significant bit is 1: XOR 11011

01111Drop leading 0

1111

Shift contents of register to left, drop in next bit

Page 12: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Detection: CRC

Add CRC of packet in TCP/IP

Page 13: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction

Transmission ChannelUsed for communications channelUsed for storage channel (travel in time)

Page 14: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction

Encode an object with additional parity bits. Use parity bits to detect and correct an error. Trivial Example: Replication Code

Encodes messages of length 1b 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.

000 0 100 0

001 0 101 1

010 0 110 1

011 1 111 1

Decoding Table

Page 15: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction

Hamming DistanceDefined to be the number of different bits in a

bit string of length l.Examples:

0011 1110 and 0101 1110 have distance 2 0011 1110 and 1100 0001 have distance 8

Page 16: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction

Code Word: a word that can be obtained by encoding a piece of datum.

There are many fewer code words than possible.

Maximum Likelihood Decoding:When receiving a message, decode it with the

code word closest in Hamming distance.

Page 17: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction

Maximum Likelihood Decoding

Page 18: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction

Example:Assume the following (bad) code:

00  -    0010001  -    0111010  -    1000111  -    11000

Assume we received 11111How do we decode?

Page 19: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction

Linear Codes Based on Reed Solomon. Encode symbols: bit-strings of length l. Generate an m by n matrix G such that

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 (x1, x2, …,xm) as (x1,x2,…,xm)G

Page 20: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction : Hamming Code

Hamming Code Systematic: Code word is data word + parity

m message bits and r parity bits

Linear Create matrix of size 2r-1 by r. Populate rows with binary encoding of all numbers

from 1 to 2r

If desired, arrange them so that the identity matrix is the lower part of the matrix.

Page 21: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction : Hamming Code

Hamming matrix for r = 3.

Page 22: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

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,0,0,0).

Page 23: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction: Hamming Code

Page 24: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction: Hamming Code

Example:Data is (0,1,0,1)What is the code word?

Page 25: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction: Hamming Code

Answer:(0,1,0,1,0,1,0).

Page 26: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction: Hamming Code

To correct an error, apply H to the received vector.

The result is the binary encoding of a row in H.

The corresponding coefficient in the vector is were the error most likely was.

Page 27: COEN 180 Erasure Correcting, Error Detecting, and Error Correcting Codes.

Error Correction: Hamming Code

Assume that we received (0100010). We apply H to this vector:

Therefore, the error is given by row (111).

That is, in the fourth row. Hence, error is in bit position 4.

(0100010)· H = (111).