(2of3) - ECE3151 (B) (31.3.24) - 1
(2of3) - ECE3151 (B) (31.3.24) - 1
Error Detection
and
Correction
10.1
Note
10.2
10-1 INTRODUCTION
10.3
Note
10.4
Figure 10.1 Single-bit error
10.5
Note
10.6
Figure 10.2 Burst error of length 8
The number of bits affected depends on the data rate and duration of
noise. For example, if we are sending data at 1 kbps, a noise of 0.01 s
can affect 10 bits(=1000×0.01); if we are sending data at 1 Mbps, the
same noise can affect 10,000 bits(=1000000×0.01).
10.7
Detection Versus Correction
The correction of errors is more difficult than the detection.
In error detection, we are looking only to see if any error has
occurred. The answer is a simple yes or no. We are not even
interested in the number of errors. A single-bit error is the same
for us as a burst error.
In error correction, we need to know the exact number of bits
that are corrupted and more importantly, their location in the
message. The number of the errors and the size of the message
are important factors.
If we need to correct one single error in an 8-bit data unit, we
need to consider 8 possible error locations. (8C1)
If we need to correct two errors in a data unit of the same size, we
need to consider 28 possibilities. (8C2)
You can imagine the receiver's difficulty in finding 10 errors in a
data unit of 1000 bits.
(1000C10)=263409560461970212832400 possibilities
10.8
Redundancy
To detect or correct errors, we need to
send extra (redundant) bits with data.
10.9
Figure 10.3 The structure of encoder and decoder
10.10
Modular Arithmetic
In modulo-N arithmetic, we use only the
integers in the range 0 to N −1, inclusive.
Inclusive - Including the last number, Exclusive - Excluding the last number
e.g., [1,10]=1 2 3…10 is inclusive and [1,10)=1 2 3…9 is exclusive
For example, if the modulus is 12, we use only the integers 0 to
11, inclusive. An example of modulo arithmetic is our clock
system. It is based on modulo-12 arithmetic, substituting the
number 12 for 0.
In a modulo-N system, if a number is greater than N, it is
divided by N and the remainder is the result. If it is negative, as
many Ns as needed are added to make it positive.
10.12
10-2 BLOCK CODING
10.13
Figure 10.5 Datawords and codewords in block coding
10.14
Error Detection
How can errors be detected by using block coding?
If the following two conditions are met, the receiver can detect a
change in the original codeword.
1. The receiver has (or can find) a list of valid codewords.
2. The original codeword has changed to an invalid one.
10.16
Example 10.2
Table 10.1 A code for error detection (Example 10.2)
10.17
Example 10.2 (continued)
011111
2. The codeword is corrupted during transmission, and
111 is received. This is not a valid codeword and is
discarded.
011000
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.
10.18
Note
10.19
Error Correction
As we said before, error correction is much more difficult than
error detection.
10.20
Figure 10.7 Structure of encoder and decoder in error correction
10.21
Example 10.3
Let us add more redundant bits to Example 10.2 to see if the
receiver can correct an error without knowing what was actually
sent. We add 3 redundant bits to the 2-bit dataword to make 5-bit
codewords. Table 10.2 shows the datawords and 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. This means an error has occurred. The receiver,
assuming that there is only 1 bit corrupted, uses the following
strategy to guess the correct dataword.
Table 10.2 A code for error correction (Example 10.3)
10.22
Example 10.3 (continued)
1. Comparing the received codeword with the first codeword in
the table (01001 versus 00000), the receiver decides that the
first codeword is not the one that was sent because there are
two different bits.
2. By the same reasoning, the original codeword cannot be the
third or fourth one in the table.
3. 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.
01001
01001
01001
01001
10.23
Hamming Distance
10.25
Minimum Hamming Distance
The minimum Hamming distance is the
smallest Hamming distance between
all possible pairs in a set of words.
Although the concept of the Hamming distance is the
central point in dealing with error detection and correction
codes, the measurement that is used for designing a code
is the minimum Hamming distance.
We use dmin to define the minimum Hamming distance in
a coding scheme.
To find this value, we find the Hamming
distances between all words and select the smallest one.
10.26
Example 10.5
Solution
We first find all Hamming distances.
10.27
Example 10.6
Solution
We first find all the Hamming distances.
10.28
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 a separate
expression for dmin C(5, 2) with dmin = 3.
C(3, 2) with dmin =2
10.29
Note
10.30
Example 10.7
dmin = s +1=2
s=1
101111
101000
Only single error detected
10.31
Example 10.8
Our second block code scheme (Table 10.2) has dmin = 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. The receiver cannot be fooled.
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.
dmin = s +1=3
s=2
0101101010
0101101000
0101100000
Only single and double error detected
10.32
Minimum Distance for Error Correction
Note
10.33
Example 10.9
10.34
10-3 LINEAR BLOCK CODES
10.35
Note
10.36
Example 10.10
Let us see if the two codes we defined in Table 10.1 and Table 10.2 belong to the
class of linear block codes.
011⊕101=110 01011⊕10101=11110
10.37
Error-detecting code: Simple Parity-Check Code
Perhaps the most familiar error-detecting code is the simple parity-check code.
In this code, a k-bit dataword is changed to an n-bit codeword where n = k + 1.
The extra bit, called the parity bit, is selected to make the total number of 1s in
the codeword even.
Although some implementations specify an odd number of 1s, we discuss the
even case.
Note
10.38
Table 10.3 Simple parity-check code C(5, 4) with dmin=2
5th bit in the codewords is chosen such that total number of 1 is even.
10.39
Figure 10.10 Encoder and decoder for simple parity-check code
10.41
Example 10.12 codeword
a3a2a1a01011
r0=1⊕0⊕1 ⊕1=1
a3a2a1a0r010111
Let us look at some transmission scenarios. Assume the
sender sends the dataword 1011. The codeword created
from this dataword is 10111, which is sent to the receiver.
We examine five cases:
so=1 ⊕0 ⊕1 ⊕1 ⊕1=0
1. No error occurs; the received codeword is 10111. The
syndrome is 0. The dataword 1011 is created.
2. One single-bit error changes a1 . The received
codeword is 10011. The syndrome is 1. No dataword
is created. so=1 ⊕0 ⊕0 ⊕1 ⊕1=1
3. One single-bit error changes r0 . The received codeword
is 10110. The syndrome is 1. No dataword is created.
so=1 ⊕0 ⊕1 ⊕1 ⊕0=1
10.42
Example 10.12 (continued)
codeword
a3a2a1a0r010111
4. An error changes r0 and a second error changes a3 .
The received codeword is 00110. The syndrome is 0.
The dataword 0011 is created at the receiver. Note that
here the dataword is wrongly created due to the
syndrome value.
5. Three bits—a3, a2, and a1—are changed by errors.
The received codeword is 01011. The syndrome is 1.
The dataword is not created. This shows that the simple
parity check, guaranteed to detect one single error, can
also find any odd number of errors.
10.43
Note
10.44
Figure 10.11 Two-dimensional parity-check code
A better approach is the two-dimensional parity check. In this method,
the dataword is organized in a table (rows and columns).
The whole table is sent to the receiver, which finds the syndrome
for each row and each column.
10.45
Figure 10.11 Two-dimensional parity-check code
10.46
Figure 10.11 Two-dimensional parity-check code
10.47
Richard Hamming, the inventor of Hamming
codes, worked at Bell Labs in the late 1940s
on the Bell Model V computer, an
electromechanical relay-based machine.
During weekdays, when errors in the relays
were detected, the machine would stop and
flash lights so that the operators could
correct the problem. During after-hours
periods and on weekends, when there were
no operators, the machine simply moved on
to the next job. In a taped interview,
Hamming said, "And so I said, 'Damn it, if the
machine can detect an error, why can't it
locate the position of the error and correct
it?'". Over the next few years, he worked on
the problem of error-correction, developing
an increasingly powerful array of algorithms.
In 1950, he published what is now known as
Hamming code.
[Ref.] https://en.wikipedia.org/wiki/Hamming_code
10.48
Error correcting code:
Note Hamming codes
All Hamming codes discussed in this book have dmin = 3, which
means that they can detect up to two errors or correct one single
error.
We need to choose an integer m >= 3.
r0 ⊕r1 = a2 ⊕ a1 ⊕ a0 ⊕ a3 ⊕ a2 ⊕ a1=a0 ⊕ a3
r2= a1 ⊕ a0 ⊕ a3 So, r0 ⊕ r1≠ r2
10.51
Figure 10.12 The structure of the encoder and decoder for a Hamming code
s2= b1 ⊕ b0 ⊕ b3 ⊕ q2
s1= b3 ⊕ b2 ⊕ b1 ⊕ q1
s0= b2 ⊕ b1 ⊕ b0 ⊕ q0
r2= a1 ⊕ a0 ⊕ a3
r1= a3 ⊕ a2 ⊕ a1
r0= a2 ⊕ a1 ⊕ a0
The equations used by the checker are the same as those used by the
generator with the parity-check bits added to the right-hand side of the
10.52 equation.
Table 10.5 Logical decision made by the correction logic analyzer
s2= b1 ⊕ b0 ⊕ b3 ⊕ q2 (1)
s1= b3 ⊕ b2 ⊕ b1 ⊕ q1 (2) s2 s1 s0
(3)
s0= b2 ⊕ b1 ⊕ b0 ⊕ q0 q0 0 0 1
Syndrome bit 0 means no error.
Now look closely at each of the above q1 0 1 0
equations (1,2,3) and carefully watch the
following scenario: q2 1 0 0
q0 bit is in error => s0 is affected
q1 bit is in error => s1 is affected b3 1 1 0
q2 bit is in error => s2 is affected
b3 bit is in error => both s2 and s1 are affected b2 0 1 1
b2 bit is in error => both s1 and s0 are affected
b1 bit is in error => s2, s1 and s0 are all affected b1 1 1 1
b0 bit is in error => both s2 and s0 are affected
10.53 b0 1 0 1
Table 10.5 Logical decision made by the correction logic analyzer
The 3-bit syndrome creates eight different bit patterns (000 to 111) that
can represent eight different conditions.
These conditions define a lack of error or an error in 1 of the 7 bits of
the received codeword, as shown in Table 10.5
The generator is not concerned with the four cases shaded in Table
10.5 because there is either no error or an error in the parity bit. In the
other four cases, 1 of the bits must be flipped (changed from 0 to 1 or 1 to
0) to find the correct dataword.
The syndrome values in Table 10.5 are based on the syndrome bit
calculations.
For example, if qo is in error, s0 is the only bit affected; the syndrome,
therefore, is 001.
If b2 is in error, s0 and s1 are the bits affected; the syndrome, therefore
is 011.
Similarly, if b1 is in error, all 3 syndrome bits are affected and the
syndrome is 111
10.54
Example 10.13 b3 b2 b1 b0 q2 q1 q0
0 1 0 0 0 1 1
Let us trace the path of three datawords from the sender to the
destination:
1.The dataword 0100 becomes the codeword 0100011. The
codeword 0100011 is received. The syndrome is 000, the final
dataword is 0100.
s2= b1 ⊕ b0 ⊕ b3 ⊕ q2 =0 ⊕0 ⊕0 ⊕0=0, s1= b3 ⊕ b2 ⊕ b1 ⊕ q1 =0 ⊕1 ⊕0
⊕1=0, s0= b2 ⊕ b1 ⊕ b0 ⊕ q0= 1 ⊕ 0 ⊕ 0 ⊕ 1=0
10.57
Burst error correction using Hamming code
The key is to split a burst error between several codewords,
one error for each codeword.
In data communications, we normally send a packet or a frame
of data.
To make the Hamming code respond to a burst error of size N,
we need to make N codewords out of our frame.
Then, instead of sending one codeword at a time, we arrange
the codewords in a table and send the bits in the table a column
at a time.
In Figure 10.13, the bits are sent column by column (from the
left). In each column, the bits are sent from the bottom to the top.
In this way, a frame is made out of the four codewords and
sent to the receiver.
In Figure 10.13, when a burst error of size 4 corrupts the
frame, only 1 bit from each codeword is corrupted. The corrupted
bit in each codeword can then easily be corrected at the receiver.
10.58
10-4 CYCLIC CODES
10.59
Table 10.6 A CRC code with C(7, 4)
10.61
1011 1100 0111 Linear
1011000 ⊕1100010 = 0111010 proper
ty
1011
1 0 1 1 0 0 0
checke
0 1 0 1 1 0 0 d
0101
10.64
Figure 10.14 CRC encoder and decoder
k=4, n=7
n-k=7-4=3
n-k=3
n-k+1=3+1=4
10.65
Figure 10.15 Division in CRC encoder
10.66
Figure 10.16 Division in the CRC decoder for two cases
10.67
Figure 10.21 A polynomial to represent a binary word
10.68
Figure 10.22 CRC division using polynomials
1001=x3+0x2+0x1+1x0=x3+1
1001000=x6+0x5+0x4+1x3+0x2+0x1+0x0
1011=x +0x +1x +1x =x +x+1
3 2 1 0 3
=x6+x3
110
1001110
10.69
The divisor in a cyclic code is normally called the
generator polynomial or simply the generator.
Name Uses Generator Polynomials
CRC-6-GSM mobile networks x6+x5+x3+x2+x+1
CRC-8-Bluetooth wireless connectivity x8+x7+x5+x2+x+1
10.70
CRC can detect a burst error
❏ All burst errors with L ≤ r will be detected.
❏ All burst errors with L = r + 1 will be detected with probability 1 – (1/2) r–1.
❏ All burst errors with L > r + 1 will be detected with probability 1 – (1/2) r.
10.71
Home Work
Problem 1: A bit stream 1101011011 is transmitted using the standard
CRC method. The generator polynomial is x4+x+1. What is the actual bit
string transmitted?
Ans: 11010110111110.
10.72