Download - 4 Error Detection and Correction
-
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
The structure of encoder and decoder
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.
codewords are not used.nk 22
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. 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
-
The Hamming distance between two words is the number of differences between
corresponding bits.
Block Coding: Hamming distance
The Hamming distance d(000, 011) is 2:
The Hamming distance d(10101, 11110) is 3:
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 2.
5
-
Find the minimum Hamming distance of the coding scheme in Table in slide 4.
Block Coding: Hamming distance
Solution
We first find all the Hamming distances.
The dmin in this case is 3.
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.
Any coding scheme needs to have at least three parameters:
The codeword size n, the dataword size k, and the minimum Hamming distance dmin
A coding scheme C is written as C(n,k) with dmin
6
-
Block Coding: Hamming distance
The dmin in this case is 2.This code guarantees detection of only a single error.
For example, if the third codeword (101) is sent and
one error occurs, the received codeword does not
match any valid codeword. If two errors occur,
however, the received codeword may match a valid
codeword and the errors are not detected.
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
-
Block Coding: Hamming distance
Geometric concept for finding
dmin in error detection.
Geometric concept for
finding dmin in error correction.
8
-
To guarantee correction of up to t errors in all cases, the minimum Hamming distance in a block code must be dmin = 2t + 1.
Block Coding: Hamming distance
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, . . . ).
9
-
Linear Block Codes
In a linear block code, the exclusive OR (XOR) of any two valid codewords creates
another valid codeword.
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.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
-
Linear Block Codes: Simple Parity-Check Code
A simple parity-check code is a single-bit error-detecting code in which
n = k + 1 with dmin = 2.
The extra bit, called the parity bit, is selected to make the total number of
1s in the code word even.
Simple parity-check code C(5, 4):Simple parity-check code C(5, 4):
11
-
Linear Block Codes: Simple Parity-Check Code
Encoder and decoder for simple parity-check code
201230 +++= Moduloaaaar
A simple parity-check code can detect an odd number of errors.12
-
Linear Block Codes: Hamming Codes
The relationship between m and n in these codes is And k = n-m, the number of check bits r = m.
12 = mn
dmin=3 in the example; (m)n-bit codeword;k-bit dataword
If m = 3, then n = 7 and k = 4. This is a Hamming code C(7,4) with dmin=3
13
-
Linear Block Codes: Hamming Codes
The structure of the encoder and decoder for a Hamming code
2
2
2
3012
1231
0120
++=
++=
++=
Moduloaaar
Moduloaaar
ModuloaaarGenerator: Checker:
2
2
2
23012
11231
00120
+++=
+++=
+++=
Moduloqbbbs
Moduloqbbbs
Moduloqbbbs
14
-
Linear Block Codes: Hamming Codes
Logical decision made by the correction logic analyzer
The 3-bit syndrome creates 8 different bit patterns.
Examples:
1. The dataword 0100 becomes the codeword 0100011.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
-
Burst error correction using Hamming code
Linear Block Codes: 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
-
Cyclic Redundancy Check
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:
Receiver calculates:
If no remainder, assume no error
P2DF kn /. =PT /
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
-
110101
111010
110101
111011
110101
2000001010001101 110101
Q1101010110
Dp kn
R 01110
110101
110010
110101
101100
110101
111110
110101
20
-
Polynomials
A polynomial to represent a binary word
A better way to understand cyclic codes is to represent them as polynomials.
Adding and subtracting polynomials is in modulo-2.
The divisor in a cyclic code is normally called the generator polynomial.
21
-
22
-
1XXXCCITTCRC
1XXX16CRC
1XXXXX12CRC
+++=
+++=
+++++=
51216
21516
231112
Four versions of P(X) are widely used:
1XXX
XXXXXXXXXXX32CRC
1XXXCCITTCRC
+++
+++++++++++=
+++=
24
5781011121622232632
51216
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
-
++
+
+
1XXXXXD1010001101DData
1XXXXP110101PDivisor
++++==
+++==
2379
245
)(
)(
+
25
+ + + + +
-
Advantages of Cyclic Codes
They can easily be implemented in hardware.
Choosing a good generator polynomial to:
detect single-bit errors,
detect double errors,
detect burst errors.
This has made cyclic codes a good candidate for many networks
They can easily be implemented in hardware.
They are especially fast when implemented in hardware.
26