Lecture 13
Lecture 13
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
1
(n,k) Block Codes
• Arrange the message into k-bit blocks
• Make each codeword n bits long, by adding (n-k) bits to each block.
k n-k
The entire block is called
a “codeword”
Message bits Extra bits
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
2
Error Detection vs Correction
• Error detection
– We try to detect errors, but don’t try to fix them.
• Error correction
– We try to correct errors.
• Note that we must choose between error detection and error
correction.
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
3
(n,1) repetition code
• Repetition codes are block codes, where
– The message is split to 1-bit blocks.
– Blocks are expanded to n bits by repeating the bit n times.
– The minimum Hamming distance between valid codewords is d=n.
• Example: (3,1) repetition code
– Two valid codewords
• Input bit 0 Codeword 000
• Input bit 1 Codeword 111
– Hamming distance d=3.
– We can EITHER
• Detect (d-1) = 2 or fewer bit errors
OR
• Correct (d-1)/2 = 1-bit errors
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT 4
ELEC1200: A System View of
Communications: from Signals to Packets
Lecture 13
• Review
– Channel Coding
– Error correction vs detection
– (n,1) repetition codes
• More complex block codes
– (k+1,k) parity bit code with d = 2
– (8,4) code with d = 3
– (9,4) code with d = 4
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
5
More complex block codes
• We can create more complex block codes than the repetition code by
adding multiple parity bits
– Different parity bits consider different subsets of the message block.
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
7
Error Detection
• It turns out that d=2 for this code.
• We can only detect (d-1) = 1-bit errors.
– Sum the received bits. If the sum is odd, there’s been an error.
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
8
ELEC1200: A System View of
Communications: from Signals to Packets
Lecture 13
• Review
– Channel Coding
– Error correction vs detection
– (n,1) repetition codes
• More complex block codes
– (k+1,k) parity bit code with d = 2
– (8,4) code with d = 3
– (9,4) code with d = 4
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
9
(8,4) block code D1 D2 D3 D4
D1 D2 D3 D4 P1 P2 P3 P4 P3 P4 P4 is parity bit
for column #2
• Example:
0 1 1
1 0
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
10
Performing Error Detection
• It turns out that d = 3 for this code.
D1 D2 D3 D4 P1 P2 P3 P4
– The proof is beyond the scope of this class.
(Step 1)
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
11
Examples of Error Detection
Received Rearranged Computed
Error?
Codeword Codeword Syndrome
0 1 1 0 1 1 0
no
1 1 0 0
01111010 1 1 0 1 0
1 0 0 0
0 1 1 0 1 1 0
yes
1 0 0 1
01101010 1 0 0 1 0
1 0 0 1
0 1 1 0 1 1 0
yes
1 0 1 0
01101110 1 0 1 1 0
1 0 0 1
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
12
Performing Error Correction
• We can correct (d-1)/2 = 1-bit errors.
D1 D2 D3 D4 P1 P2 P3 P4
1. Rearrange the codeword
2. Add syndrome bits to the rows and columns to (Step 1)
make them even parity
3. Check the syndrome bits. D1 D2 P1
S3 S4
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
13
Examples of Error Correction
Received Rearranged Computed Corrected
Codeword Codeword Syndrome Data
0 1 1 0 1 1 0
01111010 1 1 0 0 0111
1 1 0 1 0
no error
1 0 0 0
0 1 1 0 1 1 0
01101010 1 0 0 1 0111
1 0 0
1 0 D4 incorrect
1 0 0 1
0 1 1 0 1 1 0
01111110 1 1 1 1 1 1 1 0111
1 0
1 0 0 0 P2 incorrect
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
14
Error Correction Summary
• Take an input message stream: 011011101101
0110
• Break the message stream into k-bit blocks (e.g., k = 4).
1110
1101
01101111
• Add (n-k) parity bits to form n-bit codeword (e.g., n = 8). 11100101
11010110
01100111
• Transmit data through noisy channel and receive codewords with
some errors. 11110101
11000110
• Perform error correction.
• Extract the k=4 message bits from each corrected codeword. 0110 1110 1101
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
15
ELEC1200: A System View of
Communications: from Signals to Packets
Lecture 13
• Review
– Channel Coding
– Error correction vs detection
– (n,1) repetition codes
• More complex block codes
– (k+1,k) parity bit code with d = 2
– (8,4) code with d = 3
– (9,4) code with d = 4
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
16
(9,4) block code
• Add an extra parity bit, P5, to the (8,4) code.
– P5 chosen so the 9-bit codeword has even parity.
Message D1 D2 D3 D4
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
17
Creating (9,4) codewords
• Parity bits Message D1 D2 D3 D4
– P1: parity for D1,D2
– P2: parity for D3,D4
– P3: parity for D1,D3
– P4: parity for D2,D4 D1 D2 P1
– P5: parity for D1,D2,D3,D4,P1,P2,P3,P4 Add
parity D3 D4 P2
bits
• Examples P3 P4 P5
1 0 1
– Message Block: 1010 Codeword: 101011000
1 0 1
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
18
Performing Error Correction
• To correct errors, we assume at most 2 bits have errors.
• Procedure
1. Compute 5 syndrome bits by checking D1 D2 P1 S1
• First two rows for even parity (S1,S2)
D3 D4 P2 S2
• First two columns for even parity (S3,S4)
• Entire codeword for even parity (S5) P3 P4 P5
2. Check the syndrome bits.
3 4 S S S5
if all Si = 0 (i = 1,2,3,4 and 5)
no error
else
if S5 = 1, (1-bit error occurred)
Check the S1-S4 following the (8,4) code to find which bit to correct.
else a 2-bit error occurred
We can detect, but not correct, this.
• Alternatively, we can detect, but not correct, errors in 3 or fewer bits. How?
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
19
Examples of Error Correction
Received Rearranged Computed Corrected
Codeword Codeword Syndrome Data
0 1 1 0 1 1 0
011110101 1 1 0 0 0111
1 1 0 1 0 1
1 0 1 no errors
0 0 0
0 1 1 0 1 1 0
011010101 1 0 0 1 0111
1 0 0
1 0 1 D4 incorrect
1 0 1 0 1 1
0 1 1 0 1 1 0
1 1 1 1 0111
011111101 1 1 1 P2 incorrect
1 0 1
1 0 1 0 0 1
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
20
Examples of Error Correction
Received Rearranged Computed Corrected
Codeword Codeword Syndrome Data
0 1 1 0 1 1 0
011110101 1 1 0 0 0111
1 1 0 1 0 1
1 0 1 no errors
0 0 0
0 1 1 0 1 1 0
011111111 1 1 1 1 ????
1 1 1
1 1 1 2-bit error
1 1 1 0 1 0
The reason we cannot correct these 2-bit errors is that there is another
valid codeword that differs from the received codeword by 2-bit errors.
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
21
Inability to correct two-bit errors
Two valid codewords differ
from the received codeword
by 2 bits. Valid
codeword
Received
codeword
Valid
codeword
ELEC 1200 22
Summary
• We create more complex codes by adding parity bits for subsets of
the message block.
• The (8,4) code rearranges the 4 message bits into a 2x2 array and
adds a parity bit for each row/column.
• Since d=3, we can EITHER
– Detect errors in 2 or fewer bits, OR
– Correct 1-bit errors.
• The (9,4) code adds an overall parity bit to the (8,4) code.
• Since d=4, we can EITHER
– Detect errors in 3 or fewer bits, OR
– Correct 1-bit errors and detect, but not correct, 2-bit errors.
ELEC 1200 Some content taken with permission from material for the course EECS6.02 by C. Sodini, M. Perrot and H. Balakrishnan at MIT
23