Chapter 10
Error Detection
and
Correction
10.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Note
Data can be corrupted
during transmission.
Some applications require that
errors be detected and corrected.
10.2
10-1 INTRODUCTION
Let us first discuss some issues related, directly or
indirectly, to error detection and correction.
Topics discussed in this section:
Types of Errors
Redundancy
Detection Versus Correction
Forward Error Correction Versus Retransmission
Coding
Modular Arithmetic
10.3
Note
In a single-bit error, only 1 bit in the data
unit has changed.
10.4
Figure 10.1 Single-bit error
10.5
Note
A burst error means that 2 or more bits
in the data unit have changed.
10.6
Figure 10.2 Burst error of length 8
10.7
Note
To detect or correct errors, we need to
send extra (redundant) bits with data.
10.8
Figure 10.3 The structure of encoder and decoder
10.9
10-2 BLOCK CODING
In block coding, we divide our message into blocks,
each of k bits, called datawords. We add r redundant
bits to each block to make the length n = k + r. The
resulting n-bit blocks are called codewords.
Topics discussed in this section:
Error Detection
Error Correction
Hamming Distance
Minimum Hamming Distance
10.10
Figure 10.5 Datawords and codewords in block coding
10.11
Error detection in block coding
10.12
Example 10.2
Let us assume that k = 2 and n = 3. Table below shows the list of
datawords and codewords.
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.
10.13
Example 10.2 (continued)
Dataword – 01
Codeword - 011
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.
10.14
Note
An error-detecting code can detect
only the types of errors for which it is
designed; other types of errors may
remain undetected.
10.15
Error correction
10.16
Error correction
• More redundant bits added to correct an error without knowing
what was actually sent.
• 3 redundant bits are added to the 2-bit dataword to make 5-bit
codewords. Table below 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.
• Receiver detects an error and assumes only 1 bit corrupted.
10.17
Example 10.3 (continued)
1. Comparing the received codeword (01001) with the first codeword
(00000) in the table, 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.
10.18
Note
The Hamming distance between two
words is the number of differences
between corresponding bits.
10.19
Example 10.4
Let us find the Hamming distance between two pairs of
words.
1. The Hamming distance d(000, 011) is 2 because
2. The Hamming distance d(10101, 11110) is 3 because
10.20
Note
The minimum Hamming distance is the
smallest Hamming distance between
all possible pairs in a set of words.
10.21
Example 10.5
Find the minimum Hamming distance of the coding scheme in
Table 10.1.
Solution
We first find all Hamming distances.
The dmin in this case is 2.
10.22
Example 10.6
Find the minimum Hamming distance of the coding scheme in Table
10.2.
Solution
We first find all the Hamming distances.
The dmin in this case is 3.
10.23
Note
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.
10.24
10-3 LINEAR BLOCK CODES
Almost all block codes used today belong to a subset
called linear block codes. A linear block code is a code
in which the exclusive OR (addition modulo-2) of two
valid codewords creates another valid codeword.
Topics discussed in this section:
Minimum Distance for Linear Block Codes
Some Linear Block Codes
10.25
Note
In a linear block code, the exclusive OR
(XOR) of any two valid codewords
creates another valid codeword.
10.26
Example 10.10
The scheme in the following table is a linear block code
because the result of XORing any codeword with any
other codeword is a valid codeword. For example, the
XORing of the second and third codewords creates the
fourth one.
10.27
Simple parity check code
• Dataword – k bits
• Codeword – n bits (n = k + 1), extra bit called the parity bit.
• Parity bit used to make the total number of 1’s in the
codeword even.
• Min. Hamming dist. (dmin) = 2, useful for detecting single bit
error.
10.28
Encoder and decoder for simple parity-check code
10.29
Working principle of simple parity-check code
• Calculation done in modular arithmetic.
Sender side
• Generator takes a copy of 4-bit dataword and generates parity bit (r 0)
r0 = a3 + a2 + a1 + a0 (modulo 2)
• Codeword (5 bits) – dataword (4 bits) + parity bit (1 bit)
• Parity bit makes the total number of 1’s is the codeword even.
10.30
Working principle of simple parity-check code
Receiver side
•Checker performs the same operation on 5-bit codeword to
generate the syndrome (s0)
s0 = b3 + b2 + b1 + b0 + q0 (modulo 2)
•If s0 is 0, there is no error, if 1 there is an error.
10.31
Example
Sender
Dataword – 1011 -------> Codeword - 10111
Five cases:
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.
3. One single-bit error changes r0 . The received codeword
is 10110. The syndrome is 1. No dataword is created.
10.32
Example 10.12 (continued)
Dataword – 1011 -------> Codeword - 10111
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.33
Note
A simple parity-check code can detect
an odd number of errors.
10.34
10-4 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.
1 0 1 1 0 0 0
Cyclic shift
0 1 1 0 0 0 1
10.35
Table 10.6 A CRC code with C(7, 4)
10.36
Cyclic Redundancy Check (CRC) encoder and decoder
• CRC used for error detection
10.37
Cyclic Redundancy Check (CRC)
Sender side
•Dataword – k bits Codeword – n bits
•To generate codeword
• (n – k) 0s are appended to the dataword.
• It is fed to a generator, which uses a divisor of size (n – k + 1),
which is agreed upon.
• Generator divides the augmented dataword (modulo 2 division) –
quotient discarded, remainder appended to the dataword
10.38
Cyclic Redundancy Check (CRC)
Receiver side
•Received codeword fed to the checker, which performs modulo 2
division on n bits.
•Output is called syndrome of (n – k) bits, this is fed to the decision
logic analyzer.
• If all bits are 0s, the first k bits are accepted as dataword.
• Otherwise, the k bits are discarded.
10.39
Sender side: Division in CRC encoder
10.40
Receiver side: Division in the CRC decoder for two cases
10.41