MSWord

advertisement
Yeditepe University ICS 471 Notes on Error Detection and Correction (Parity, Checksum, LRC, CRC) Spring 2002
Basic Idea
How do we check to see if a message is transmitted correctly?
One way is to try it out. If the message makes sense, we assume it is correct. -- certainly not the way we want.
Have the sender send the message twice, if they are the same, we assume it is correct. -- too expensive; which
one is correct if the two messages are different?
Have some extra information attatched to the message. These extra information can be used to check to see if
the message being received is correct.
This last method is the most effective and popular way.
How and What Do We Attach To Messages ?
One simplest way is to use parity check. Add an extra bit so that the number of 1s in a message is even (or odd).
Whether it is even or odd is pre-determined, known as even parity check, or odd parity check.
For example, if we decide to use even parity check, the message being sent is 1001100 which is 7 bits. We would add
an 1 to the end so that the number of 1s are even. The actual message being sent will be 10011001, last bit being a
partiy check bit.
This actually is a special case of a class of error-correcting code based on what is called Hamming distance. At this
point, we concentrate on LRC and CRC.
Longitudinal Redundancy Checking (LRC)
This method applies the parity idea across all the bytes in the transmission and increases the error detection
performance.
LRC process is:
oA parity bit is calculated for each character in the transmission.
oA Block Check Character (BCC) byte is added to the end of the transmission.
oThe parity bit process is applied to the bits the BCC.
oGiven Odd Parity, the first bit of the BCC is a 0 or 1 to make the total of the 1st bits in all the bytes an
odd number.
oThe second bit makes the total of the second bits an odd number, etc.
At the destination the computer checks to see if the total of the bits in each character is odd and that the total
of the bits in the first bit position, the second bit position, etc. including the BCC is odd. If they do not check
out then an error has occurred.
Cyclic Redundancy Check (CRC)
An error-detection technique used widely in today's computer networks is based on cyclic redundancy check
(CRC) codes. CRC codes are also known as polynomial codes, since it is possible to view the bit string to be sent
as a polynomial whose coefficients are the 0 and 1 values in the bit string, with operations on the bit string interpreted
as polynomial arithmetic.
CRC codes operate as follows. Consider the d-bit piece of data, D, that the sending node wants to send to the
receiving node. The sender and receiver must first agree on an r + 1 bit pattern, known as a generator, that we will
Page 1 of 3
Mesut Ali Ergin
Yeditepe University ICS 471 Notes on Error Detection and Correction (Parity, Checksum, LRC, CRC) Spring 2002
denote as G. We will require that the most significant (leftmost) bit of G be a 1. The key idea behind CRC codes is
shown in Figure 1. For a given piece of data, D, the sender will choose r additional bits, R, and append them to D
such that the resulting d + r bit pattern (interpreted as a binary number) is exactly divisible by G using modulo 2
arithmetic. The process of error checking with CRCs is thus simple: The receiver divides the d + r received bits by G.
If the remainder is nonzero, the receiver knows that an error has occurred; otherwise the data is accepted as being
correct.
Figure 1: CRC codes
All CRC calculations are done in modulo 2 arithmetic without carries in addition or borrows in subtraction. This
means that addition and subtraction are identical, and both are equivalent to the bit-wise exclusive-or [  ] of the
operands. Thus, for example,
1011
1001
0101 = 1110
1101 = 0100
Also, we similarly have
1011 - 0101 = 1110
1001 - 1101 = 0100
Multiplication and division are the same as in base-2 arithmetic, except that any required addition or subtraction is
done without carries or borrows. As in regular binary arithmetic, multiplication by 2k left shifts a bit pattern by k
places. Thus, given D and R, the quantity
D • 2r  R
yields the d + r bit pattern shown in Figure 1. We'll use this algebraic characterization of the d + r bit pattern from
Figure 1 in our discussion below.
Let us now turn to the crucial question of how the sender computes R. Recall that we want to find R such that there
is an n such that
D • 2r  R = nG
That is, we want to choose R such that G divides into D • 2r  R without remainder. If we exclusive-or (that is, add
modulo 2, without carry) R to both sides of the above equation, we get
D • 2r = nG  R
This equation tells us that if we divide D • 2r by G, the value of the remainder is precisely R. In other words, we can
calculate R as
R = remainder = ( D . 2r ) / G
Figure 2. illustrates this calculation for the case of D = 101110, d = 6 and G = 1001, r = 3. The nine bits transmitted
in this case are 101110 011. You should check these calculations for yourself and also check that indeed
D • 2r = 101011 • G  R.
Page 2 of 3
Mesut Ali Ergin
Yeditepe University ICS 471 Notes on Error Detection and Correction (Parity, Checksum, LRC, CRC) Spring 2002
Figure 2: An example CRC calculation
International standards have been defined for 8-, 12-, 16- and 32-bit generators, G. An 8-bit CRC is used to protect
the 5-byte header in ATM cells. The CRC-32 32-bit standard, which has been adopted in a number of link-level IEEE
protocols, uses a generator of
GCRC-32 = 100000100110000010001110110110111
Each of the CRC standards can detect burst errors of less than r + 1 bits and any odd number of bit errors.
Furthermore, under appropriate assumptions, a burst of length greater than r + 1 bits is detected with probability 1 0.5r. The theory behind CRC codes and even more powerful codes is beyond the scope of this text.
Page 3 of 3
Mesut Ali Ergin
Download