Practical Session 10

19
Practical Session 10 Error Detecting and Correcting Codes

description

Practical Session 10. Error Detecting and Correcting Codes. Error detection and correction. communication channels are subject to channel noise , and thus errors may be introduced during data transmission - PowerPoint PPT Presentation

Transcript of Practical Session 10

Page 1: Practical Session 10

Practical Session 10

Error Detecting and Correcting Codes

Page 2: Practical Session 10

Error detection and correctionError detection and correction

• communication channels are subject to channel channel noisenoise, and thus errors may be introduced during data transmission

• we need techniques that enable reliable techniques that enable reliable delivery of digital data over unreliable delivery of digital data over unreliable communication channelscommunication channels

• detecting errors• reconstructing the original data

Page 3: Practical Session 10

Error detection and correctionError detection and correction

• General idea: add some redundancyredundancy (i.e. some extra dataextra data) to a message

• This extra data is used– to check consistency of the delivered messageto check consistency of the delivered message– to recover data determined to be corruptedto recover data determined to be corrupted

Page 4: Practical Session 10

Hamming DistanceHamming Distance• Hamming distance (d) Hamming distance (d) between two code words of equal length

is an amount of 1-bit changes amount of 1-bit changes required to reach from one word to the other

• number of 1’s in the XOR between the words

000 011 d(000, 011) = 210101 11110 d(10101, 11110) = 3

Page 5: Practical Session 10

Hamming DistanceHamming Distance

• Minimum Hamming distance Minimum Hamming distance is the smallest smallest Hamming distance Hamming distance between all possible pairs all possible pairs in a set of words.

Example

Given the following coding scheme, let’s find the minimum Hamming distance.

00000010111010111110

d(00000,01011)=3d(00000,10101)=3d(00000,11110)=4d(01011,10101)=4d(01011,11110)=3d(10101,11110)=3

minimum Hamming distance is d=3

Page 6: Practical Session 10

Hamming Distance - Hamming Distance - Error DetectionError Detection

Minimum Hamming Distance: d

Can detect (at least) d-1 errors

00000 01000 01010

Example

00000010111010111110d=3

3 errors can take us from one legal code word to another

01011 01011

Page 7: Practical Session 10

Hamming Distance - Hamming Distance - Erasures FixingErasures Fixing

Minimum Hamming Distance: d

Can fix (at least) d-1 erasures

00000 0_000 0_0_0 01011

Example

00000010111010111110d=3

3 erasures can take us from one legal code word to another

0_0__

Page 8: Practical Session 10

Hamming Distance - Hamming Distance - Error CorrectionError Correction

Minimum Hamming Distance: d

Can correct (at least) errors

00000 01000

Example

00000010111010111110d=3

2 errors can take us from two different legal code words to the same illegal word

2

1d

11110 01110

01010

Page 9: Practical Session 10

Hamming Distance - Hamming Distance - ExampleExample• Given four data words, can we use 5-bit code words

for fixing 1 error?• Answer: yes. We need a hamming distance d=3 to fix 1

error. We can create code words with independent graphs of independent graphs of a single error code wordsa single error code words.

d(00000,11100)=3 d(11100, 10111)=3 d(10111, 01011)=3 d(00000,10111)=4 d(11100, 01011)=4 d(00000,01011)=3

Page 10: Practical Session 10

Parity CheckParity Check

0001 1

0011 1

• Given a data word, a code word is created by adding a parity bit parity bit to the end of the data word

• d=2 d=2 (why?)

• Can detect odd number of errors Can detect odd number of errors (1,3,5,…)(1,3,5,…)

send: or

receive:

1 or 3 errors occur

Data wordData word Code wordCode word

0000 0000000001 0001110010 0010110011 001100

1101 1

Page 11: Practical Session 10

Longitudinal Redundancy Checking (LRC)Longitudinal Redundancy Checking (LRC)Adds an additional character called Block Check Block Check Character (BCC) Character (BCC) to a data word.1. determine vertical and horizontal parity bits

• Even parity calculated for each row (1 if number of ‘1’ bits is 1,3,5,7,…)• Odd parity calculated for each column (1 if number of ‘1’ bits is 0,2,4,6,…)

2. calculate BCC character• 1st bit of BCC number of 1’s in the 1st bit of characters• 2nd bit of BCC number of 1’s in the 2ndt bit of characters …• 8’th bit of BCC number of 1’s in the parity bits column

Example

suppose a data data word word “DATA”

ASCII100010010000011010100100000111011111101111

LetterDATA

BCCBCC

Parity bit001000

a code word code word is “DATA”11011111

Page 12: Practical Session 10

2 errors

occurred

Longitudinal Redundancy Checking (LRC)Longitudinal Redundancy Checking (LRC)Adds an additional character called Block Check Block Check Character (BCC) Character (BCC) to a data word.

• d=2 d=2 (why?)

ASCII100010010000011010100100000111011111101111

LetterDATA

BCCBCC

Parity bit001000

ASCII100010110000011010101100000111011111101111

LetterDATA

BCCBCC

Parity bit100000

These two errors would not change BCC character

Page 13: Practical Session 10

Cyclic Redundancy CheckCyclic Redundancy Check

• CRC is an error-detecting code• Given a data, its non trivial (cryptographic)

challenge to find another data with the same CRC code.

CRC can protect data (even from deliberate damage)

Page 14: Practical Session 10

Binary Pattern as PolynomialBinary Pattern as Polynomial

Page 15: Practical Session 10

CRC Polynomials (common)CRC Polynomials (common)

CRC-8-ATM x8 + x2 + x + 1

CRC-16-IBM x16 + x15 + x2 + 1

CRC-16-CCITT x16 + x12 + x5 + 1

CRC-32-IEEE 802.3 x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1

Page 16: Practical Session 10

Sending – Calculation StepsSending – Calculation Steps

1.1. GeneratorGenerator is chosen– sequence of bits, of which the first and last are 1

2.2. CRC check sequence is computed CRC check sequence is computed by long-division of message by generator– check sequence has 1 fewer bits than generator

3. Check sequence is appendedappended to the original message

Page 17: Practical Session 10

Sending – Calculation StepsSending – Calculation Steps

Compute 8-bit CRC a message ‘W’ (0x57).

1.Select Generator: CRC-8-ATM1.1. xx88 + x + x22 + x + 1 + x + 1 = = 100000111100000111

2.‘W’ is 01010111= x6 + x4 + x2 + x + 13.Extend ‘W’ with 8 bits: 01010111000000004.Perform XOR of the word get in step (3) by

generator– CRC code is the remainder

5.Append CRC code to ‘W’

Page 18: Practical Session 10

Generating CRC CodeGenerating CRC Code long-division of message by generator

0101011100000000 100000111

CRC Code: 1010001010100010

100000111

001011011000000

100000111

0011010110000

100000111

01010101100

100000111

0010100010

xor

xor

xor

xor

Each time apply XOR on the extended message, when place a generator from the left-most ‘1’ bit of the extended message

Stop when CRC code has 1 fewer bits than generator

Page 19: Practical Session 10

Receiving – Calculation StepsReceiving – Calculation Steps

• Append CRC code to the message: 0101011110100010

• Perform long division by the generator• If the reminder is not 0reminder is not 0: an error occurred

0101011110100010 100000111

result: 00000000

100000111xor

There is no errors in received message.