L08 Error Control
L08 Error Control
L08 Error Control
Diffraction
Reflection
2
Today
1. Error control codes
– Encoding and decoding fundamentals
– Measuring a code’s error correcting power
– Measuring a code’s overhead
– Practical error control codes
• Parity check, Hamming block code
3
Where is error control coding used?
• The techniques we’ll discuss today are
pervasive throughout the internetworking stack
Application
• Based on theory, but broadly applicable in
practice, in other areas: Transport
– Hard disk drives Network
– Optical media (CD, DVD, & c.) Link
– Satellite, mobile communications
Physical
4
Error control in the Internet stack
• Transport layer
– Internet Checksum (IC)
over TCP/UDP header, data IC TCP payload
TCP header
5
Error control in the Internet stack
• Transport layer
– Internet Checksum (IC)
over TCP/UDP header, data IC TCP payload
TCP header
• Network layer (L3)
– IC over IP header only IC IP payload
IP header
6
Error control in the Internet stack
• Transport layer
– Internet Checksum (IC)
over TCP/UDP header, data IC TCP payload
TCP header
• Network layer (L3)
– IC over IP header only IC IP payload
IP header
• Link layer (L2)
– Cyclic Redundancy Check (CRC) LL header LL payload LL CRC
7
Error control in the Internet stack
• Transport layer
– Internet Checksum (IC)
over TCP/UDP header, data IC TCP payload
TCP header
• Network layer (L3)
– IC over IP header only IC IP payload
IP header
• Link layer (L2)
– Cyclic Redundancy Check (CRC) LL header LL payload LL CRC
8
Today
1. Error control codes
– Encoding and decoding fundamentals
– Measuring a code’s error correcting power
– Measuring a code’s overhead
– Practical error control codes
• Parity check, Hamming block code
9
Error control: Motivation
00 Network 00
01 01
10 10
11 message 11
Sender Receiver
“Allowed”
messages
10
Error control: Key Ideas
• Reduce the set of “allowed” messages
– Not every string of bits is an “allowed” message
– Receipt of a disallowed string of bits means that the
message was garbled in transit over the network
11
Encoding and decoding
• Problem: Not every string of bits is “allowed”
– But we want to be able to send any message!
– How can we send a “disallowed” message?
12
A simple error-detecting code
• Let’s start simple: suppose messages are one bit long
Sender:
0 ➜ 00
01
10
1 ➜ 11
13
Receiving the two-repetition code
• Suppose the network causes no bit error
16
Hamming distance
• Measures the number of bit flips to change one
codeword into another
00 01 11
17
How many bit errors can we detect?
• Suppose the minimum Hamming distance between any
pair of codewords is dmin
dmin = 3
– Receiver will flag message as “Error detected”
18
Decoding error detecting codes
• The receiver decodes in a two-step process:
19
A simple error-correcting code
• Let’s look at a three-repetition code
0 ➜ 000 000 ➜ 0
001 001
010 010
100 100
011 011
101 101
110 110
1 ➜ 111 111 ➜ 1
20
Correcting one bit error
• Receiver chooses the closest codeword (measured by
Hamming distance) to the received bits
0 ➜ 000 000 ➜ 0
001 001
Fix error
010 010
100 100
Decision boundary
011 011
101 101
Fix error
110 110
1 ➜ 111 111 ➜ 1
21
Decoding error correcting codes
• The receiver decodes in a two-step process:
22
How many bit errors can we correct?
• Suppose there is at least dmin Hamming distance between
any two codewords Round
down
dmin = 5
Decision boundary
23
Code rate
• Suppose codewords of length n, messages length k (k < n)
24
Today
1. Error control codes
– Encoding and decoding fundamentals
– Measuring a code’s error correcting power
– Measuring a code’s overhead
– Practical error control codes
• Parity check, Hamming block code
25
Parity bit
• Given a message of k data bits D1, D2, …, Dk, append a
parity bit P to make a codeword of length n = k + 1
011100 1
26
Checking the parity bit
• Receiver: counts number of 1s in received message
– Even: received message is a codeword
27
Two-dimensional parity
28
Two-dimensional parity: Properties
• Flip 1 data bit, 3 parity bits flip d1,1 d1,2 d1,3 d1,4 p1
• Flip 2 data bits, ≥ 2 parity bits flip
• Flip 3 data bits, ≥ 3 parity bits flip d2,1 d2,2 d2,3 d2,4 p2
29
Block codes
• Let’s fully generalize the parity bit for even more error
detecting/correcting power
• Split message into k-bit blocks, and add n−k parity bits
to the end of each block:
codeword: n bits
30
A higher rate error correcting code?
• What if we repeat the parity bit 3 ? D1D2D3D4 PPP
– P = D1 ⊕ D2 ⊕ D3 ⊕ D4; R = 4/7
31
Hamming (7, 4) code
k = 4 bits n − k = 3 bits D1 D4
P1
D1D2D3D4 P1P2P3
P1 = D 1 ⊕ D3 ⊕ D4 P2 P3
P2 = D 1 ⊕ D 2 ⊕ D 3
P3 = ⊕ D2 ⊕ D3 ⊕ D4 D2
D3:all
32
Hamming (7, 4) code: dmin
• Change one data bit, either: D1 D4
– Two Pi change, or
P1
– Three Pi change
33
Hamming (7, 4): Correcting One Bit Error
• Infer which corrupt bit from D1 D4
which parity checks fail:
P1
• P1 and P2 fail ⇒ Error in D1
• P2 and P3 fail ⇒ Error in D2 P2 P3
• P1, P2, & P3 fail ⇒ Error in D3 D2
• P1 and P3 fail ⇒ Error in D4 D3:all
34
Today
1. Error control codes
35
Cyclic redundancy check (CRC)
• Most popular method error detecting code at L2
– Found in Ethernet, Wi-Fi, token ring, many many others
1 0 1 1 1 0
36
Modulo-2 Arithmetic
• Addition and subtraction are both exclusive-or without
carry or borrow
37
CRC at the sender
• M(x) is our message of length k
– e.g.: M(x) = x5 + x3 + x2 + x (k = 6) 101110
38
CRC at the sender
2. Divide padded message T(x) by generator G(x)
– The remainder R(x) is the CRC:
101 011
1001 101110 000
1001
0101
0000
1010
1001
011 0
000 0
11 00
10 01
1 010
1 001
011 R(x) = x + 1
39
CRC at the sender
3. The sender transmits codeword C(x) = T(x) + R(x)
– i.e., the sender transmits the original message with the
CRC bits appended to the end
40
Properties of CRC codewords
• Remember: Remainder [ T(x)/G(x) ] = R(x)
• What happens when we divide C(x) / G(x)?
• C(x) = T(x) + R(x) so remainder is
– Remainder [ T(x)/G(x) ] = R(x), plus
– Remainder [ R(x)/G(x) ] = R(x)
– Recall, addition is exclusive-or operation, so:
• Remainder [ C(x)/G(x) ] = R(x) + R(x) = 0
41
Detecting errors at the receiver
• Divide received message C′(x) by generator G(x)
– If no errors occur, remainder will be zero
1 0 1 0 1 1
43
Detecting errors at the receiver
• Divide received message C′(x) by generator G(x)
– If errors occur, remainder may be non-zero
101 011
1001 101111 010
1001
How0many
1 0 1errors can the CRC detect?
0000
☟
1
How do
0 1 1
1 0we0 choose
1 generator G(x)?
010 0
000 0
10 01
10 01
0 0 0 0 à undetected error!
44
Detecting errors with the CRC
• The error polynomial E(x) = C(x) + C′(x) is the difference
between the transmitted and received codeword
– E(x) tells us which bits the channel flipped
45
Detecting single-bit errors w/CRC
• Suppose a single-bit error in bit-position i: E(x) = xi
46
Error detecting properties of the CRC
• The CRC will detect:
All single-bit errors
• Provided G(x) has two non-zero terms
– All burst errors of length ≤ g − 1
• Provided G(x) begins with xg−1 and ends with 1
• Similar argument to previous property
– All double-bit errors
• With conditions on the frame length and choice of
G(x)
– Any odd number of errors
• Provided G(x) contains an even number of non-zero
coefficients
47
Error detecting code: CRC
• Far less overhead than error correcting codes
– Typically 16 to 32 bits on a 1,500 byte (12 Kbit) frame
48
Friday Precept:
Work on Lab 2
Tuesday Topic:
Convolutional Codes
49