4 Error Detection and Correction
4 Error Detection and Correction
4 Error Detection and Correction
Some applications require that errors be detected and corrected Types of Errors: Single-Bit Error,
Burst Error.
To detect or correct errors, we need to send extra (redundant) bits with data
1
Block Coding
The message is divided into blocks, each of k bits, called datawords. r redundant bits is added to each block to make the length n = k + r. The resulting n-bit blocks are called codewords.
The Block coding process is one to one (the same dataword is always encoded as the same codeword).
2
Block Coding
kB/nB coding: k-bit group replaced with an n-bit group. The 4B/5B block coding is a good example of this type of coding. 2 k 2 n codewords are not used.
2B/3B code
Assume the sender encodes the dataword 01 as 011 and sends it to the receiver. Consider the following cases: 1. The receiver receives 011. It is a valid codeword. The receiver extracts the dataword 01 from it. 2. The codeword is corrupted during transmission, and 111 is received. This is not a valid codeword and is discarded. 3. The codeword is corrupted during transmission, and 000 is received. This is a valid codeword. The receiver incorrectly extracts the dataword 00. Two corrupted bits have made the error undetectable. 3
Block Coding
We add 3 redundant bits to the 2-bit dataword to make 5-bit codewords.
Assume the dataword is 01. The sender creates the codeword 01011. The codeword is corrupted during transmission, and 01001 is received. First, the receiver finds that the received codeword is not in the table. (error occurred). The receiver, assuming that there is only 1 bit corrupted, uses the following strategy to guess the correct dataword: Comparing the received codeword with the codewords in the table, The original codeword must be the second one in the table because this is the only one that differs from the received codeword by 1 bit, The receiver replaces 01001 with 01011 and consults the table to find the dataword 01.
4
Find the minimum Hamming distance of the coding scheme in Table in slide 3. Solution We first find all Hamming distances.
The dmin in this case is 3. Any coding scheme needs to have at least three parameters: The codeword size n, the dataword size k, and the minimum Hamming distance dmin
To guarantee the detection of up to s errors in all cases, the minimum Hamming distance in a block code must be dmin = s + 1.
The dmin in this case is 3. This code can detect up to two errors. Again, we see that when any of the valid codewords is sent, two errors create a codeword which is not in the table of valid codewords. However, some combinations of three errors change a valid codeword to another valid codeword. The receiver accepts the received codeword and the errors are undetected.
7
A code scheme has a Hamming distance dmin = 4. What is the error detection and correction capability of this scheme?
Solution This code guarantees the detection of up to three errors (s = 3), but it can correct up to one error. In other words, if this code is used for error correction, part of its capability is wasted. Error correction codes need to have an odd minimum distance (3, 5, 7, . . . ).
Minimum Hamming distance: Is the numbers of 1s in the nonzero codewords. In our first code (Slide 3), the numbers of 1s in the nonzero codewords are 2, 2, and 2. So the minimum Hamming distance is dmin = 2. In our second code (Slide 4), are 3, 3, and 4. So in this code we have dmin = 3.
10
The extra bit, called the parity bit, is selected to make the total number of 1s in the code word even.
11
r0 = a3 + a2 + a1 + a0
Modulo 2
Hamming Codes
13
Hamming Codes
Generator:
r0 = a2 + a1 + a0 r1 = a3 + a2 + a1 r2 = a1 + a0 + a3 Modulo 2 Modulo 2 Modulo 2
Checker:
s0 = b2 + b1 + b0 + q0 s1 = b3 + b2 + b1 + q1 s2 = b1 + b0 + b3 + q2 Modulo 2 Modulo 2 Modulo 2
14
Hamming Codes
The 3-bit syndrome creates 8 different bit patterns. Logical decision made by the correction logic analyzer
Examples: 1. The dataword 0100 becomes the codeword 0100011. The codeword 0100011 is received. The syndrome is 000, the final dataword is 0100. 2. The dataword 0111 becomes the codeword 0111001. The codeword 0011001 is received. The syndrome is 011. After flipping b2 (changing the 1 to 0), the final dataword is 0111. 3. The dataword 1101 becomes the codeword 1101000. The codeword 0001000 is received. The syndrome is 101. After flipping b0, we get 0000, the wrong dataword.
15
Hamming Codes
16
Cyclic Codes
Cyclic codes are special linear block codes with one extra property. In a cyclic code, if a codeword is cyclically shifted (rotated), the result is another codeword. Cyclic Redundancy Check (CRC): A CRC code with C(7, 4)
17
Cyclic Codes
CRC encoder and decoder
The generator divides the augmented dataword by the divisor. The reminder (r2r1r0) is appended to the dataword to create the codeword.
18
D = K_bits block of data to be transmitted T = n_bits frame to be transmitted F (FCS) = (n-k)_bits frame check sequence P = pattern of (n-k+1)_bits divisor
Transmitter calculates: F = D.2 n k / P Receiver calculates: T / P If no remainder, assume no error Addition and subtraction are done by modulo-2 arithmetic Example: Given Message D = 1010001101 (10bits) pattern P = 110101 (6 bits) FCS R = to be calculated (5 bits) Thus, n = 15, k = 10, and (n-k) = 5
19
1101010110 Q p 110101 101000110100000 2 n k D 110101 111011 110101 111010 110101 111110 110101 101100 110101 110010 110101 01110 R
20
Polynomials
A better way to understand cyclic codes is to represent them as polynomials. A polynomial to represent a binary word
Adding and subtracting polynomials is in modulo-2. The divisor in a cyclic code is normally called the generator polynomial.
21
22
23
CRC Implementation CRC process can be represented and implemented as a dividing circuit consisting of XOR gates and a shift register. The register contains n-k bits, equal to the length of FCS There are up to n-k XOR gates. The presence or absence of gates corresponds to the presence or absence of a term in the divisor polynomials, P(X), excluding the terms 1 and Xn-k The entire register is clocked simultaneously, causing a 1-bit shift along the entire register.
24
P( X ) = X 5 + X 4 + X 2 + 1 D( X ) = X 9 + X 7 + X 3 + X 2 + 1
+ + + + + + +
25
Choosing a good generator polynomial to: detect single-bit errors, detect double errors, detect burst errors.
They can easily be implemented in hardware. They are especially fast when implemented in hardware.
This has made cyclic codes a good candidate for many networks
26