You are on page 1of 4

 It is physically impossible for any data recording

or transmission medium to be 100% perfect


100% of the time over its entire expected useful
life.
 As more bits are packed onto a square
Error Detection and Correction centimeter of disk storage, as communications
transmission speeds increase, the likelihood of
error increases.
 Thus, error detection and correction is critical to
accurate data transmission, storage and retrieval.

Checksums and CRC


• Checksums and CRCs are examples of systematic
 Check digits, appended to the end of a long error detection.
number can provide some protection against data
• In systematic error detection a group of error control
input errors. bits is appended to the end of the block of
◦ The last character of barcodes and ISBNs transmitted data.
are check digits. – This group of bits is called a syndrome.

 Longer data streams require more economical • CRCs are polynomials over the modulo 2 arithmetic
field.
and sophisticated error detection mechanisms.
• In modulo 2 arithmetic if we add 1 to 1, we get 0.
 Cyclic redundancy checking (CRC) codes The addition rules couldn’t be simpler:
provide error detection for large blocks of data.
0+0=0 0+1=1
1+0=1 1+1=0
CRC CRC (2)

• Suppose we want to transmit the • If no bits are lost or


information string: 1111101. corrupted, dividing the
• The receiver and sender decide to received information string
use the (arbitrary) polynomial by the agreed upon pattern
pattern, 1101. will give a remainder of
• The information string is shifted zero.
left by one position less than the
number of positions in the divisor. • We see this is so in the
• The remainder is found through calculation at the right.
modulo 2 division (at right) and • Real applications use
added to the information string: longer polynomials to cover
1111101000 + 111 = 1111101111. larger information strings.

Error Correcting Code: Why? Error Correcting Code (2)

• Data transmission errors are easy to fix once an error • Hamming codes and Reed-Soloman codes are two
is detected. important error correcting codes.
– Just ask the sender to transmit the data again. • Reed-Soloman codes are particularly useful in
correcting burst errors that occur when a series of
• In computer memory and data storage, however, this
adjacent bits are damaged.
cannot be done.
– Because CD-ROMs are easily scratched, they employ a type
– Too often the only copy of something important is in of Reed-Soloman error correction.
memory or on disk.
• Because the mathematics of Hamming codes is
• Thus, to provide data integrity over the long term, much simpler than Reed-Soloman, we discuss
error correcting codes are required. Hamming codes in detail.
Hamming Codes Hamming Codes – Example (1)

• Hamming codes are code words formed by adding • With code words of length 12, we observe that each
redundant check bits, or parity bits, to a data word. of the digits, 1 though 12, can be expressed in
• The Hamming distance between two code words is powers of 2. Thus:
the number of bits in which two code words differ. 1 = 20 5 = 22 + 2 0 9 = 23 + 2 0
2 = 21 6 = 22 + 2 1 10 = 2 3 + 2 1
This pair of bytes has a 3 = 21+ 2 0 7 = 22 + 21 + 2 0 11 = 2 3 + 2 1 + 2 0
Hamming distance of 3: 4 = 22 8 = 23 12 = 2 3 + 2 2
– 1 (= 20) contributes to all of the odd-numbered digits.
• The minimum Hamming distance for a code is the – 2 (= 21) contributes to the digits, 2, 3, 6, 7, 10, and 11.
smallest Hamming distance between all pairs of – . . . And so forth . . .
words in the code. • We can use this idea in the creation of our check bits.

Hamming Codes – Example (2) Hamming Codes – Example (3)

• Using our code words of length 12, number each bit • Since 2 (= 21) contributes to the digits, 2, 3, 6, 7, 10,
position starting with 1 in the low-order bit. and 11. Position 2 will contain the parity for bits 3,
• Each bit position corresponding to an even power of 6, 7, 10, and 11.
2 will be occupied by a check bit. • When we use even parity, this is the modulo 2 sum
of the participating bit values.
• These check bits contain the parity of each bit • For the bit values shown, we have a parity value of
position for which it participates in the sum. 0 in the second bit position.

What are the values for the other parity bits?


Hamming Codes – Example (4) Hamming Codes – Example (5)

• The completed code word is shown above. • Suppose an error occurs in bit 5, as shown above.
– Bit 1checks the digits, 3, 5, 7, 9, and 11, so its value is Our parity bit values are:
1. – Bit 1 checks digits, 3, 5, 7, 9, and 11. Its value is 1, but
– Bit 4 checks the digits, 5, 6, 7, and 12, so its value is 1. should be zero.
– Bit 8 checks the digits, 9, 10, 11, and 12, so its value is – Bit 2 checks digits 2, 3, 6, 7, 10, and 11. The zero is
also 1. correct.
• Using the Hamming algorithm, we can not only – Bit 4 checks digits, 5, 6, 7, and 12. Its value is 1, but
detect single bit errors in this code word, but also should be zero.
correct them! – Bit 8 checks digits, 9, 10, 11, and 12. This bit is correct.

Hamming Codes – Example (6) Hamming Code - Exercises

1. Given the 8-bit data word 01011011, generate the


13-bit composite work for the Hamming code that
• We have erroneous bits in positions 1 and 4. corrects single errors and detects double errors.
• With two parity bits that don’t check, we know that 2. Obtain the 15-bit Hamming code word for the 11-bit
the error is in the data, and not in a parity bit. data work 11001001010.
• Which data bits are in error? We find out by 3. A 12-bit Hamming code word containing 8 bits of
adding the bit positions of the erroneous bits. data and 4 parity bits is read from memory. What
was the original 8-bit data word that was written
• Simply, 1 + 4 = 5. This tells us that the error is in
into memory if the 12-bit word read out is as
bit 5. If we change bit 5 to a 1, all parity bits check
follows: (a) 000011101010 (b) 101110000110 (c)
and our data is restored.
101111110100

You might also like