9
Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) •Word parity •Block Parity

Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

Embed Size (px)

Citation preview

Page 1: Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

Error Detection and Correction

Parity Schemes: Modulo 2 addition (XOR)•Word parity•Block Parity

Page 2: Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

CRC Error Correction

CRC error correction schemes are mechanized using the binary symbol alphabet {0,1} and modulo 2 arithmetic. However the math behind it is applicable with any symbol alphabet and any legitimate algebra.

We will explore the method using normal, decimal arithmetic.

Consider a message: [mN-1,mN-2, m1,m0] where the mi are symbols selected from the symbol alphabet M = {0,1,2,3, ..,8,9}.

The number of symbols in the alphabet is x = 10, each symbol carries 3.32 bits of information. If we were to see the actual digits written out, we would intuitively associate a value with the message, represented by the polynomial:

M(x) = mN-1xN-1 + mN-2 xN-2 + .. + m1x1 + m0x0

We are going to append two check digits to the message, [c1,c0]. The polynomial representing the check digits is of order C = 2:

C(x) = c1x1 + c0x0

Page 3: Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

The Message digits must be shifted to the left to make room for the check digits, do the final data word will be represented by the polynomial:

D(x) = xcM(x) + C(x) =M’(x) + C(x)

Here’s the trick. We want to pick C(x) such that D(x) represents a number which is evenly divisible by some other number, G, called the generator, represented by the “generator polynomial” G(x). Stated mathematically:

0

0

D x R xQ x

G x G x Where R0(x) =0 is the remainder

polynomial after division.

Consider for a moment performing the division with the check digits set to zero:

1

1

M x R xQ x

G x G x

Where R1(x) is the remainder

polynomial after division.

If we set C(x) = G(x) – R1(x), then we can write . . .

Page 4: Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

1 11

1

01

D x M x C x M x C x R x G x R xQ x

G x G x G x G x G x G x

Q xG x

And we have zero remainder, as desired.

When the message is received at the destination, it is divided by the generator, and if the remainder is zero, we may be certain that a single digit error did not occur.

If the generator is judiciously chosen, when an error occurs, the remainder will uniquely identify which digit was corrupted.

Consideration of the number of check digitsThere must be a unique remainder for every possible error that can occur. In a binary code (x = 2), there is one possible error for each digit in D(x) .

Since the remainder must be less than G, it is clear that G > N + C.

Since the order of G must be equal to the order of C(x) i.e. C, the maximum value for G is xC-1. Thus

CN x C or,Cx G N C

Page 5: Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

ExampleWe’ll consider an example using decimal arithmetic. We will construct a message of 5 digits.

For simplicity, we will consider the only possible transmission errors to consist of increasing or decreasing each digit by one, so two possible errors per digit in the message (including check digits), so G > 2(N+C), and G < 10C . Thus, for this scheme:

2Cx G N C 2 10Cx C or,

So C = 2 digits will work, and G > 14.

Lets try G = 17 (prime numbers usually work well). We need to verify that each possible error creates a unique remainder, so lets pick a typical message, determine the check digits, introduce each possible error, and see if we get a unique remainder. If we don’t, we have to try another generator.

55555M 5555500M 1

5555500 2

17 17

MQ

G

1 17 2 15C G R ' 5555515D M C

Page 6: Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

VerificationThe remainders for each possible error are:

Corrupted Message Remainder

5555516 15555525 105555615 155556515 145565515 45655515 66555515 95555514 165555505 75555415 25554515 35545515 135455515 114555515 8

These are all unique, so we gave a good generator.

The sorted remainders, and their corresponding corrections are:

Remainder Correction

1 -12 1003 10004 -100006 -1000007 108 10000009 -100000010 -1011 10000013 1000014 -100015 -10016 1

Page 7: Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

+

1 0 0 1 0 1 1 0 1 1 0 1 0 1 0 1 1 01 0 0 1 0 1 0 0 0 0 0 0

1 0

0 1 0 0 0 0 1 0 1 1 0

10 0 1

0 0 0 0 0 0 0 0 0 0 0

1 0 0 1 0 1 0 0 0 00 0 1 0 0 0 1 1 00 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0

1 0 0 1 0 1 00 0 1 1 0 00 0 0 0 0 0

++ x0 00 01 01 11 x00 0 10 00 10 01 xx1 0 01 00 11 x0 xx0 0 10 01 01 xx xx0 1 10 00 x0 xx xx1 0 01 10 xx xx xx0 0 11 10 10 10 011

1 0 0 0 0 1 0 1 1 0

0 1 0 0 0 1 1 0

1 0 0 0 1 1 0

0 1 1 0 0

0 x1 01 xx xx xx0

Modulo 2 Division

Page 8: Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

++ 00 000

1 10 10 011 10 01 x

01 101

1 x0 xx xx1 10 10

01 010 Initial StateAfter 5 ShiftsFinal State

x xx xx xxx xx xx

Manipulate the Structure:+ +

01 010Data

Flip Again

+ +

0Data

Flip Over

0 1 1 0

1 0 0 1 0 (1)

Page 9: Error Detection and Correction Parity Schemes: Modulo 2 addition (XOR) Word parity Block Parity

Notes on Generator Choice

• Generator must have one more digit than Check Digits.• Generator must be of the form:

1 X X … X 1