Error Detection and Correction
Error Detection and Correction
7
Error Detection and
Correction
2.7 Error Detection and Correction
• 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 centimeter of disk storage,
as communications transmission speeds increase, the likelihood of
error inevitably increases.
• Thus, error detection and correction is critical to accurate data
transmission, storage and retrieval.
• Check digits, appended to the end of a long number, can provide
some protection against data input errors.
– The last characters of ISBNs and UP student numbers are check digits.
3
2.7 Parity
I
• Sent string is: 1111 0101
– Observe that the number of 1’s are now even.
what
mould odd d
do if
agro
aol.ua wanna i
paries
Ol t
wer od
4
2.7 Parity
5
2.7.1 Cyclic Redundancy Check
once
again doesn't say
where just
that
• A cyclic redundancy check (CRC) is a type of checksum that is used
in error detection for large blocks of data.
• Checksums and CRCs are examples of systematic error detection.
• In systematic error detection a group of error control bits is
appended to the end of the block of transmitted data.
– This group of bits is called a syndrome.
– Original information is unchanged by the addition of the error-checking
bits.
• CRCs use polynomials over the modulo 2 arithmetic field.
6
2.7.1 Cyclic Redundancy Check
• Modulo 2 arithmetic works like clock arithmetic. wrap aroad
• In clock arithmetic, if we add 2 hours to 11:00, we get 1:00. 12 D l
• In modulo 2 arithmetic if we add 1 to 1, we get 0. The addition
rules couldn’t be simpler:
0+0=0 0+1=1 t
f
1+0=1 1+1=0
8
2.7.1 Cyclic Redundancy Check
9
2.7.1 Cyclic Redundancy Check
10
2.7.1 Cyclic Redundancy Check
O
Note: The divisor in this example corresponds T ede
to a modulo 2 polynomial: X 3 + X 2 + 1. Renninger
ht
11 ie
2.7.1 Cyclic Redundancy Check
• How do we use this to perform error detection? no
• Both parties decide on a CRC-Polynomial ( ) sonar ur
• The algorithm is then as follows for sender: enodbi n
– 1) Given a information block , Left shift | | 1 bits.
– 2) Perform modulo 2 division of by
string
• Find the remainder,
– 3) Set = + (normal binary addition)
• The algorithm is the as follows for a receiver
– 1) Receive
– 2) Perform modulo 2 division of by
– 3) If = 0 then transmission was successful
– 4) Else there was an error.
Is T.EE
bragiii
12
2.7.1 Cyclic Redundancy Check
(example) ffYidnpa
infostrinos
• = 1001011 and = 1011
i
cigar.cat wow
bits
• = 3 = 1001011000 IN I shift
• Module 2 divide by
– = 1010100 and = 100 (check at home)
• = + R= 1001011100
• Transmit.
– Then if Module 2 divide by results in =
0, transmission successful.
– If 0 at least 1 bit error occurred.
13
2.7.1 Cyclic Redundancy Check
14
2.7 Error Detection and Correction
e correction
• Data transmission errors are easy to fix once an error is detected.
– Just ask the sender to transmit the data again.
• In computer memory and data storage, however, this cannot be done.
– Too often the only copy of something important is in memory or on disk.
• Thus, to provide data integrity over the long term, error correcting
codes are required.
– We want to be able to detect and correct.
15
2.7.2 Hamming Codes
• Hamming codes are code words formed by adding redundant check
bits, or parity bits, to a data word.
• The memory word itself consists of m bits, but r redundant bits are
added to allow for error detection and/or correction.
• The Hamming distance between two code words is the number of bits
in which two code words differ (3 in example). only diff nodes
vectors Inmon
– Answer: D(min) = 3 it is
invalid
because
• How many single-bit errors can be detected? minimal
– Answer: up to 2 single-bit errors DCmin 1 distanceis
20
2.8 Error Detection and Correction
• For example, say we have data words of length 8. What is the
minimum number of check bits needed for correcting single-bit
errors?
(8 + r + 1) 2 r 8 41 1 13 E 29 Elf
r must be greater than or equal to 4.
• How long will the resulting code words be?
Answer: 12
• So how do we assign values to check bits so that we can
achieve detection and correction?
21
The Hamming Algorithm
1. Determine the number of check bits, r, necessary for the code
and then number the n bits, right to left, starting with 1 (not 0).
2. Each bit whose bit number is a power of 2 is a parity bit
(positions 1,2,4,8,etc) and the others are data bits (positions
3,5,7,9,10,etc).
3. Each parity bit calculates the parity of some of the bits in the
code word. The position of the parity bit determines the
sequence of bits that it alternately checks and skips:
Position 1: check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc. (1, 3, 5, 7, 9, …)
Position 2: check 2 bits, skip 2 bits, check 2 bits, etc. (2,3,6,7,10,11,…)
Position 4: check 4 bits, skip 4 bits, check 4 bits, etc. (4,5,6,7,12,13,14,15,20,...)
…and so on.
4. Set each parity bit to 1 if the number of 1’s in the positions it
checks is odd, or to 0 if the number of 1’s in the position it
checks is even (even parity).
22
2.7.2 Hamming Codes
• Consider the example with words of length 4, with 3 check bits.
• Code words will be of length 7 (white cells are data and green cells
are parity bits):
7 6 5 4 3 2 1
– The set of bits using parity bit 1: 1, 3, 5, 7 (check 1, skip 1, …)
– The set of bits using parity bit 2: 2, 3, 6, 7 (check 2, skip 2, …)
– The set of bits using parity bit 4: 4, 5, 6, 7 (check 4)
25
2.7.2 Hamming Codes Akel bit 5
7
we art even
WAS
the
r
• There is an error in the code word above. Correct it.
– Bit 1 checks 1, 3, 5, 7, 9, and 11. (1,0,0,0,1,1)
• This is incorrect as we have a total of 3 ones (which is not even parity). correct
S – The common elements in the two sets are 5 and 7, but 7 is part
of bit 2 check, so cannot be the problem.
can
also – Therefore, the bit that changed was 5, so flip the bit in position 5.
do 26 – Alternatively, simply add 1 + 4 = 5, and flip bit 5.
does
e
where we cannot make a correction