_Ch6_Error_Detection_
_Ch6_Error_Detection_
and
Correction
CH10
.Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display
Note
2
10
10--1 INTRODUCTION
3
Figure 10.1 Single-bit error
4
Figure 10.2 Burst error of length 8
5
Figure 10.3 The structure of encoder and decoder
7
10
10--2 BLOCK CODING
In block coding,
coding we divide our message into blocks,
blocks
each of k bits, called datawords
datawords.. We add r redundant
bits to each block to make the length n = k + r. The
resulting n-bit blocks are called codewords.
codewords.
8
Figure 10.5 Datawords and codewords in block coding
9
Example 10.1
10
Figure 10.6 Process of error detection in block coding
11
Example 10.2
Assume the
A h sender
d encodesd the
h dataword
d d 01 as 011 andd
sends it to the receiver. Consider the following cases:
12
Example 10.2 (continued)
13
Table 10.1 A code for error detection (Example 10.2)
14
Figure 10.7 Structure of encoder and decoder in error correction
15
Example 10.3
16
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.
18
Note
19
Example 10.4
1. The
h Hamming
i di
distance d(
d(000, 011)) is
i 2 because
b
2 The
2. Th Hamming
H i distance
di d(10101 11110) is
d(10101, i 3 because
b
20
Note
21
Example 10.5
22
Example 10.6
Solution
We first find all the Hamming distances.
23
Note
24
Example 10.7
25
Example 10.8
26
Note
27
Example 10.9
Solution
This code guarantees the detection of up to three errors
(s = 3),
3) but it can correct up to one error.
error In other words,
words
if this code is used for error correction, part of its capability
is wasted.
wasted Error correction codes need to have an odd
minimum distance (3, 5, 7, . . . ).
28
10
10--3 LINEAR BLOCK CODES
29
Note
30
Table 10.3 Simple parity-check code C(5, 4)
31
Figure 10.10 Encoder and decoder for simple parity-check code
32
Example 10.12
33
Example 10.12 (continued)
34
10
10--4 CYCLIC CODES
35
10 6 A CRC
T bl 10.6
Table C C code
d with
i h C(7,
C( 4)
36
Figure 10.14 CRC encoder and decoder
37
Figure 10.15 Division in CRC encoder
38
Figure 10.16 Division in the CRC decoder for two cases
39
10
10--5 CHECKSUM
Th last
The l t error detection
d t ti method
th d we discuss
di here
h i
is
called the checksum
checksum.. The checksum is used in the
Internet
I t t by
b severall protocols
t l although
lth h nott att the
th data
d t
link layer
layer.. However, we briefly discuss it here to
complete
l t our discussion
di i on error checking
h ki
40
Example 10.18
41
Example 10.19
42
Example 10.20
Solution
The number 21 in binary is 10101 (it needs five bits). We
can wrap the leftmost bit and add it to the four rightmost
bits. We have (0101 + 1) = 0110 or 6.
43
Example 10.21
Solution
In one’s complement arithmetic, the negative or
complement of a number is found by inverting all bits. bits
Positive 6 is 0110; negative 6 is 1001. If we consider only
unsigned numbers,
numbers this is 9. 9 In other words,
words the
complement of 6 is 9. Another way to find the
complement of a number in one one’ss complement arithmetic
is to subtract the number from 2n − 1 (16 − 1 in this case).
44
Example 10.22
45
Example 10.22 (continued)
46
Figure 10.24 Example 10.22
47
Note
Sender site:
1. The
1 Th message is i divided
di id d into
i t 16-bit
16 bit words.
d
2. The value of the checksum word is set to 0.
3 All words
3. d including
i l di theth checksum
h k are
added using one’s complement addition.
4 The
4. Th sum isi complemented
l t d and d becomes
b the
th
checksum.
5 The checksum
5. checks m is sent with
ith the data.
data
48
Note
Receiver site:
1 The
1. Th message (including
(i l di checksum)
h k ) is
i
divided into 16-bit words.
2 All words
2. d are added
dd d using
i one’s ’
complement addition.
3 The
3. Th sum is i complemented
l t d and d becomes
b the
th
new checksum.
4 If the
4. th value
l off checksum
h k is
i 0,
0 the
th message
is accepted; otherwise, it is rejected.
49
Example 10.23
51