Upload
others
View
10
Download
0
Embed Size (px)
Citation preview
1
Error Detection and Correction
2
Handling Errors (1): Ignore Them!
data in→
data out→
Tx -DATA
frame Rx
Some errors are not significant
audio
video
3
Handling Errors (2): Do something
data in→
data out→
Let’s meet at1pm tomorrow Tx -DATA
frame Rx Let’s meet at3pm tomorrow
Most errors are significant — must be detected
If only detect errors→ Reverse Error Correction (REC)
must ask for retransmission — ARQ protocol
unsuited to real-time applications
unsuited to simplex communication
If detect and correct errors→ Forward Error Correction (FEC)
4
A Simple REC System
data in→
Let’s meet at1pm tomorrow Tx
-
-
�
Let’s meet at3pm tomorrow
Let’s meet at1pm tomorrow
NAK
Rx
Send data twice
Rx delivers data if two copies identical and generates ACK-frame
Rx sends NAK-frame if two copies differ
5
A Simple FEC System
data in→
data out→
Let’s meet at1pm tomorrow Tx
-
-
-
Let’s meet at3pm tomorrow
Let’s meet at1pm tomorrow
Let’s meet at1pm tomorrow
Rx Let’s meet at1pm tomorrow
Send data thrice
Rx delivers the majority
6
Defeating Error Correction
data in→
data out→
Let’s meet at1pm tomorrow Tx
-
-
-
Let’s meet at3pm tomorrow
Let’s meet at3pm tomorrow
Let’s meet at1pm tomorrow
Rx Let’s meet at3pm tomorrow
More severe errors may not be detected
7
The Basis for Error Handling
addredundancy to data to formcodewords
handle two types of errors:
random errors→ bit error rate (BER)
error bursts → up toB bits in error
Codewords should have enough redundancy to detectprobableerrors
8
Example of valid codewords
binary decimalsymbolb2 b1 b0 d0 represented0 0 0 0 A0 0 1 1 Invalid0 1 0 2 Invalid0 1 1 3 Invalid1 0 0 4 Invalid1 0 1 5 Invalid1 1 0 6 Invalid1 1 1 7 B
?Send’A’ 0 0 0 - Tx Channel with
BER = 0.1Rx - ? ? ?
6
binary decimalp(if ’A’b2 b1 b0 d0 is sent)0 0 0 0 0.7290 0 1 1 0.0810 1 0 2 0.0810 1 1 3 0.0091 0 0 4 0.0811 0 1 5 0.0091 1 0 6 0.0091 1 1 7 0.001
9
Coordination Failure with Communication Failure
H1
m1 - H2
...
H1
mn−1� H2
H1
mn - H2
10
Hamming Distance
- b0
0 1- b0
6
b1
00 01
10 11
- b0
6
b1
>b2
000 001
010 011
100 101
110 111
HD is number of bits between codewords
e.g.0002 is HD of two from0112, 1012, and1102
Error detection/correction based on HD between valid codewords
11
Hamming Distance of Two
000 001
010 011
100 101
110 111
000 001
010 011
100 101
110 111
One bit error will change valid codeword to invalid codeword
Two bit error will change valid codeword into different valid codeword
12
Hamming Distance of Three
000 001
010 011
100 101
110 111
One bit error will change valid codeword to invalid codeword
invalid code HD of one from only one valid codeword
Two bit error will change valid codeword to invalid codeword
13
Examples of Hamming Distance
binary decimal symbol HD HD
b2 b1 b0 d0 representedfrom ’A’ from ’B’
0 0 0 0 A 0 3
0 0 1 1 Invalid 1 2
0 1 0 2 Invalid 1 2
0 1 1 3 Invalid 2 1
1 0 0 4 Invalid 1 2
1 0 1 5 Invalid 2 1
1 1 0 6 Invalid 2 1
1 1 1 7 B 3 0
14
Using Hamming Distance
To reliably detect up toe bits in error
bits in error must be less than HD
e = HD − 1
HD = e + 1
To reliably detect and correct up toe bits in error
bits in error must be less than halfway of HD
e = ⌊HD − 1
2⌋
HD = 2e + 1
15
Parity Bits
codewordr m6 m5 m4 m3 m2 m1 m0
r = m0 +2 . . . +2 m6
ASCII ‘X’ ( 10110002)
1 1 0 1 1 0 0 0
modulo arithmeticno carry
0 +2 0 = 0
1 +2 0 = 1
0 +2 1 = 1
1 +2 1 = 0
this defineseven parity
16
Parity Bits
codewordr m6 m5 m4 m3 m2 m1 m0
r = m0 +2 . . . +2 m6
ASCII ‘X’ ( 10110002)
1 1 0 1 1 0 0 0
1 1 0 0 1 0 0 0
17
Parity Bits
codewordr m6 m5 m4 m3 m2 m1 m0
r = m0 +2 . . . +2 m6
ASCII ‘X’ ( 10110002)
1 1 0 1 1 0 0 0
1 1 0 1 1 0 1 0
18
Parity Bits
codewordr m6 m5 m4 m3 m2 m1 m0
r = m0 +2 . . . +2 m6
ASCII ‘X’ ( 10110002)
1 1 0 1 1 0 0 0
0 1 0 1 1 0 0 0
19
Odd and Even Parity
000 001
010 011
100 101
110 111 even parityr = m0 +2 . . . +2 mn
hardware: XOR returns 0
by eye: even number of one bits
000 001
010 011
100 101
110 111 odd parityr = m0 +2 . . . +2 mn + 1
hardware: XOR returns 1
by eye: odd number of one bits
Don’t need to know which bit is redundant bit
Implements HD=2→ reliably detects one bit errors
20
Worksheet: Hamming Distance and Parity
1. Draw arcs between the codewords HD=1
1011 1100 1001
1111 1010 1000
0111 0000
2. If 1000 is to be a valid codeword, shade codewords which maintain HD=2.
3. What type of parity do codewords have?
4. If 1010 was received, with single bit, what codewords might have been sent?
5. How bit errors can parity check detect, and how many can it correct?
21
Block Sum Check
r m6 m5 m4 m3 m2 m1 m0
w0 0 1 0 0 1 0 0 0
w1 0 1 1 0 0 1 0 1
w2 0 1 1 0 1 1 0 0
w3 0 1 1 0 1 1 0 0
w4 0 1 1 0 1 1 1 1
BCC 0 1 0 0 0 0 1 0
Parity only detects one bit errors
Improve by adding BCC at end, doing column-wise parity
22
Block Sum Check: Random Errors
r m6 m5 m4 m3 m2 m1 m0
w0 0 1 0 0 1 0 0 0
w1 0 1 0 0 1 1 0 1
w2 0 1 1 0 1 1 0 0
w3 0 1 0 0 0 1 0 0
w4 0 1 1 0 1 1 1 1
BCC 0 1 0 0 0 0 1 0
BCC defeated by four bits in error
HD=4
detect three bit errors
detect and correct one bit errors
23
Block Sum Check: Burst Errors
r m6 m5 m4 m3 m2 m1 m0
w0 0 1 0 0 1 0 0 0
w1 0 1 1 0 0 1 0 1
w2 0 1 1 0 1 1 1 1
w3 0 1 1 0 1 1 1 1
w4 0 1 1 0 1 1 1 1
BCC 0 1 0 0 0 0 1 0
Smallest burst with four bit square is ten bits
remember, not all bits in a burst need be in error, just the first and last
BCC copes with 9 bit bursts
24
Hamming Code
b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1
20
21
22
23
m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1
‘X’ 0 1 0 1 ? 1 0 0 ? 0 ? ?
Each bit positionbn wheren = 2x used for redundancy bit
Parity generated on all bitsbm wherem hasx bit set
25
Numbering bits means each has unique identifier
b12 1 1 0 0
b11 1 0 1 1
b10 1 0 1 0
b9 1 0 0 1
b8 1 0 0 0
b7 0 1 1 1
b6 0 1 1 0
b5 0 1 0 1
b4 0 1 0 0
b3 0 0 1 1
b2 0 0 1 0
b1 0 0 0 1
26
Hamming Code: Compute20 Value
b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1
20 1 1 1 0 0 ?
21
22
23
m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1
‘X’ 0 1 0 1 ? 1 0 0 ? 0 ? ?
The value ofr1 is the even parity for allbn wheren hasb1 = 1
Thusr1 = 1
27
Hamming Code: Compute21 Value
b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1
20
21 1 0 1 0 0 ?
22
23
m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1
‘X’ 0 1 0 1 ? 1 0 0 ? 0 ? 1
The value ofr2 is the even parity for allbn wheren hasb2 = 1
Thusr2 = 0
28
Hamming Code: Compute22 Value
b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1
20
21
22 0 1 0 0 ?
23
m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1
‘X’ 0 1 0 1 ? 1 0 0 ? 0 0 1
The value ofr3 is the even parity for allbn wheren hasb3 = 1
Thusr3 = 1
29
Hamming Code
b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1
20 1 1 1 0 0 1
21 1 0 1 0 0 0
22 0 1 0 0 1
23 0 1 0 1 0
m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1
‘X’ 0 1 0 1 0 1 0 0 1 0 0 1
Each bit positionbn wheren = 2x use for redundancy bit
Parity generated on all bitsbm wherem hasx bit set
30
Hamming Code: Error Correction
b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1
20 1 1 1 0 0 1
21 1 0 1 1 0 0
22 0 1 1 0 1
23 0 1 0 1 0
m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1
‘X’ 0 1 0 1 0 1 1 0 1 0 0 1
Parity checks failing ‘points’ to error
HD=3→ detect and correct one bit errors
31
Worksheet: Hamming Code
m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1
1. Write message11101110 into the message bit boxes above.
2. Compute using even parity the bitsr4r3r2r1
3. Invert message bitm6, and write down in the orderr4r3r2r1 a1 if rn parity is
now incorrect, or a 0 if correct.
4. Invert the bit position in the codeword which the number represents.
32
Cyclic Redundancy Check
If we take a numbern and divide by divisord, result is
integer quotientq
integer remainderr
obeys the equationn = qd + r
If we add an errore to n, thenn + e = q′d + r′
e < d → r′ 6= r
r′ = r → e must be an integer multiple ofd
CRC uses this idea (but using modulo 2 division)
33
Examples of CRC Checking
n d q r e n + e r′ OK?
245 161 1 84 0 245 84 Yes
1 246 85 No
2 247 86 No
160 405 83 No
161 406 84 Yes
162 407 85 No
321 566 83 No
322 567 84 Yes
323 568 85 No
First error pattern not detected= 16110 = 101000012
Second error pattern not detected= 32210 = 1010000102
34
Properties of 16 bit CRC
name polynomial binary divisor application
CRC-16 X16 + X15 + X2 + 1 11000000000000101 USB
CRC-CCITT X16 + X12 + X5 + 1 10001000000100001Bluetooth
Choosing values for polynomials need care to achieve the best performance. Those
above detect:
error bursts of 16 bits
all error bursts with an odd number of bits
99.997% of 17 bit errors
99.998% of 18 or longer bit errors
35
Properties of 32 bit CRC
IEEE 802.3 CRC-32 is
x32 +x26 +x23 +x22 +x16 +x12 +x11 +x10 +x8 +x7 +x5 +x4 +x2 +x+1
As a shorthand write as a number representing polynomials (missing off the
last +1).e.g.IEEE 802.3 0x82608EDB, iSCSI 0x8F6E37A0
HD max no message bits
0x82608EDB 0x8F6E37A0 0xBA0DC66B 0xD419CC15 0x80108400
8 91 177 152 58 0
7 171 (177) (152) 81 0
6 268 5,243 16,360 1,060 0
5 2,974 (5,243) (16,360) 65,505 65,505
4 91,607 ≥ 128K 114,663 (65,505) (65,505)
3 ≥ 128K unknown (114,663) (65,505) (65,505)
36
Error Bursts
message1+redundant1 = n1
5n1
4n1
3n1
2n1
1
message2+redundant2 = n2
5n2
4n2
3n2
2n2
1
message3+redundant3 = n3
5n3
4n3
3n3
2n3
1
message4+redundant4 = n4
5n4
4n4
3n4
2n4
1
- . . . n1
3n4
2n3
2n2
2n1
2n4
1n3
1n2
1n1
1
transmitted data interleaves codewords
If basic error checking can detectB bit bursts, interleavingN codewords
allowsNB bursts to be detected