MD05 Error Detection and Correction
-
Upload
blackhawkrey1981 -
Category
Documents
-
view
259 -
download
2
Transcript of MD05 Error Detection and Correction
-
8/12/2019 MD05 Error Detection and Correction
1/94
CNT 3004
Module 5
-
8/12/2019 MD05 Error Detection and Correction
2/94
Chapter 10
Error Detectionand
Correction
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
-
8/12/2019 MD05 Error Detection and Correction
3/94
Chapter 10
Error
Detection
And
Correction
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
-
8/12/2019 MD05 Error Detection and Correction
4/94
10.4
INTRODUCTION
Data can be corrupted during transmission.
Some applications require that errors be detected andcorrected.
In a single-bit error, only one bit in the data unit haschanged.
-
8/12/2019 MD05 Error Detection and Correction
5/94
10.5
Burst of errors
A burst of error means that two or more bits in the
data unit have changed.
-
8/12/2019 MD05 Error Detection and Correction
6/94
10.6
Detection versus Correction
The correction of errors is more difficult than the
detection.
In error detection, we are only looking to see if any
error has occurred. The answer is a simple yes or no.
We are not even interested in the number of corrupted
bits. A single-bit error is the same for us as a burst of
errors.
In error correction, we need to know the exact numberof bits that are corrupted and, more importantly, their
location in the message.
-
8/12/2019 MD05 Error Detection and Correction
7/94
10.7
To detect or correct errors, we need to send extra(redundant) bits with data.
Redundancy is achieved through various codingschemes. The sender uses an encoderand the
receiver uses a decoder.
The encoder at the sender site adds redundant bits
whose values are based on the actual data bits.The checker at the receiver site examines the
redundant and data bits to detect or correct errors.
Redundancy
-
8/12/2019 MD05 Error Detection and Correction
8/94
10.8
The structure of encoder and decoder
-
8/12/2019 MD05 Error Detection and Correction
9/94
10.9
In modulo-N arithmetic, we use only the
integers in the range 0 to N 1, inclusive.
In modulo-2 (binary) arithmetic, we use only
two integer values 0 and 1.
Modular arithmetic
-
8/12/2019 MD05 Error Detection and Correction
10/94
10.10
XOR of two single bits XOR of two binary strings
Exclusive OR (XOR)
XOR is used for both addition and subtraction in modulo-2
arithmetic. The result of XOR is 0 if the two bits are the same and 1
if they are different.
-
8/12/2019 MD05 Error Detection and Correction
11/94
10.11
There are two methods of error correction: Forward error correction
If there are errors, the receiver can instantaneously recoverthe correct data using the redundant bits. We will study thistype of error correction in this module.
Correction by retransmission
If there are errors, the sender must retransmit the data to thereceiver. We will study this type of error correction in thenext module.
In CNT 3004, we concentrate on block codes for errordetection and correction; we will not coverconvolution codes.
-
8/12/2019 MD05 Error Detection and Correction
12/94
10.12
BLOCK CODING
In block coding, we divide our message into blocks, each of k
bits, calleddatawords. We add r redundant bits to each block tomake the length n = k + r. The resulting n-bit blocks are called
codewords.
With k bits, we can create 2^k different datawords and with nbits we can create 2^n different codewords.
The encoder assigns a unique codeword for each dataword. The
same dataword is always encoded as the same codeword. This
means that we have 2^n - 2^k codewords that are not used and
are called invalid codeword.
-
8/12/2019 MD05 Error Detection and Correction
13/94
10.13
Datawords and codewords in block coding
-
8/12/2019 MD05 Error Detection and Correction
14/94
10.14
Process of error detection in block coding
Errors can be detected if
The receiver knows the list of valid codewords
The original valid codeword has changed to an invalid one.
-
8/12/2019 MD05 Error Detection and Correction
15/94
10.15
Let us assume that k = 2 and n = 3. The table below shows the list of datawordsand codewords. Since valid codewords have even number of 1s, an odd number
of 1s indicates that the codeword is invalid.
Assume the sender encodes the dataword 01 as 011 and sends it to the receiver.
Consider the followingthree cases:
1. The receiver receives 011. It is a valid codeword. The receiver correctly
extracts the dataword 01from it.
2. The first bit of the codeword is corrupted during transmission, and 111 is
received. This is not a valid codeword and is discarded.
3. The 2nd
and 3rd
bits of the codeword are corrupted during transmission, and000 is received. This is a valid codeword. The receiver incorrectly extracts the
dataword 00. Two corrupted bits have made the error undetectable.
Example
Three cases1. 011011
2. 011111
3. 011000
-
8/12/2019 MD05 Error Detection and Correction
16/94
10.16
An error-detecting code can detect only the types of errors forwhich it is designed; other types of errors may remain
undetected.
Error correction is much more difficult than error detection. Inaddition to detecting that the received codeword is invalid, the
receiver needs to find (determine) the value of the original
codeword.
More redundant bits are needed for error correction than forerror detection.
In the case of error correction, the encoder at the sender site
adds error-correcting redundant bits whose values are basedon the actual data bits. The checker at the receiver site
examines the redundant bits and the data bits to detect then
correct the errors.
Error detection vs. error correction
-
8/12/2019 MD05 Error Detection and Correction
17/94
10.17
Structure of encoder and decoder in error correction
-
8/12/2019 MD05 Error Detection and Correction
18/94
10.18
Let us add more redundant bits to see if the receiver can correct anerror without knowing what was actually sent. We add 3 redundant
bits to the 2-bit dataword to make 5-bit codewords. The Table below
shows the datawords and codewords. Assume the dataword is 01.
The sender creates the codeword 01011. The codeword is corruptedduring transmission, and 01001 is received. First, the receiver finds
that the received codeword is not in the table. This means an error
has occurred. Assuming that there is at most one bit corrupted, the
receiver, finds the correct codeword as shown on the next slide.
Example
-
8/12/2019 MD05 Error Detection and Correction
19/94
Assuming that there is at most one bit corrupted, the receiver usesthe following strategy to guess the correct dataword.
1.After 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 twodifferent 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.
Example (continued)
The above strategy is
further illustrated on the
next slide.
-
8/12/2019 MD05 Error Detection and Correction
20/94
The receiver received the codeword 01001
The receiver compares the received codeword with every valid codeword
in the table and count the number of different bits.
2 bits
01001
1 bit
3 bits
4 bits
Example (continued)
Action:codeword 01001 is corrected to codeword 01011because it gives the minimum bit difference of one bit.
The correct dataword is 01
Minimum
-
8/12/2019 MD05 Error Detection and Correction
21/94
Another Example
The valid codeword 01011 differs from the received codeword 00011 by
only in one bit. The valid codeword 01011 is selected and the dataword 01
is extracted.
The receiver received the codeword 00011
Remark
The two invalid codewords 01001 and 00011 differ from the valid codeword
01011 by only one bit but differ from any other valid codeword by more than
one bit.
-
8/12/2019 MD05 Error Detection and Correction
22/94
10.22
We can use XOR to find the Hamming distance between two pairs
of words.
1. The Hamming distance d(000, 011) is 2 because
Example
2. The Hamming distance d(10101, 11110) is 3 because
Hamming distance
The Hamming distance between two words of the same size
is the number of differences between the corresponding bits.
-
8/12/2019 MD05 Error Detection and Correction
23/94
10.23
Find the minimum Hamming distance of the coding scheme
given in the above Table.Solution
We first find all Hamming distances.
Example
The dmin in this case is 2.
The minimum Hamming distance
is the smallest Hamming distance
between all possible pairs in a set
of codewords.
Minimum Hamming Distance
-
8/12/2019 MD05 Error Detection and Correction
24/94
10.24
Find the minimum
Hamming distance of the
coding scheme given in
the shown Table.
SolutionWe first find all the Hamming distances.
The dmin in this case is 3.
Example
-
8/12/2019 MD05 Error Detection and Correction
25/94
10.25
There are three main parameters for a coding scheme:the codeword sizen, the dataword sizek, and the minimum
Hamming distancedmin. The Hamming distance between the sent codeword and the
received codeword is the number of bits that are corrupted
during transmission.
To guarantee the detection of up to s errors in all
cases, the minimum Hamming distance in a blockcode must be dmin = s + 1.
Minimum Hamming distance for error detection
Notation: the variables is used to denote the number of bit errors that
can be detected and the variablet is used to denote the number of bit
errors that can be corrected.
-
8/12/2019 MD05 Error Detection and Correction
26/94
-
8/12/2019 MD05 Error Detection and Correction
27/94
10.27
Example
The block code scheme given in the Table below has dmin = 3. This code can
detect up to two errors. Again, we see that when any of the valid codewords is
sent, two bit errors create a codeword which is not in the table of valid
codewords. The receiver cannot be fooled in this case and will be able to detect
the two bit errors.
However, some combinations of three bit errors change a valid codeword to
another valid codeword, for example, when 01011 is changed to 00000. The
receiver accepts the received codeword and the errors are undetected.
-
8/12/2019 MD05 Error Detection and Correction
28/94
10.28
Geometric concept for finding dmin in error detection
Let us assume the sent codeword is atthe center of a circle with radius s.
All other codewords created by s or
less bit errors are points inside thecircle or on its perimeter.
All other valid codewords (having atleast s+1 different bits) are outside
the circle.
-
8/12/2019 MD05 Error Detection and Correction
29/94
10.29
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 createsanother valid codeword.
-
8/12/2019 MD05 Error Detection and Correction
30/94
-
8/12/2019 MD05 Error Detection and Correction
31/94
-
8/12/2019 MD05 Error Detection and Correction
32/94
10.32
Note: In linear block codes, the minimum Hamming distance is the
number of 1s in the nonzero valid codeword with the smallest
number of 1s.
In our first code (Table A), 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 (Table B), the numbers of 1s in the
nonzero codewords are 3, 3, and 4. So in this code we have dmin = 3.
Minimum Hamming Distance in Linear
Block Codes
Table A Table B
-
8/12/2019 MD05 Error Detection and Correction
33/94
10.33
In a simple parity-check code, a k-bit dataword is changed to k+1
bit codeword. In this case, n=k+1. The extra bit is called the parity
bit and is selected to make the total number of 1s even. The
minimum Hamming distance for this type of block codes is 2.
Simple parity-check codes
A simple parity-check code is a single-bit error-detecting code
in which n = k+ 1 with dmin = 2.
The Table shows a parity-check
code with k=2 and n=3.
-
8/12/2019 MD05 Error Detection and Correction
34/94
Simple parity-check code C(5, 4)
Parity-check code with k=4 and n=5, denoted C(5,4)
The encoder uses a generator that takes a copy of the 4-bit dataworda3a2a1a0and generates a parity bit r0 using XOR. The parity bit makes the
number of 1s in the 5-bit codeworda3a2a1a0r0 even. The transmitted
codeworda3a2a1a0r0arrives at the receiver possibly with bit errors in the
formb3b2b1b0q0. The receiver constructs a one-bit syndromesto detect any
single bit error. Details are shown on the next slide.
-
8/12/2019 MD05 Error Detection and Correction
35/94
10.35
Encoder and decoder for simple parity-check code
r0 = a3 a2 a1 a0r0 makes total number of 1s even
s0 = b3 b2 b1 b0 q0s0is called the syndrome
s0 must be 0 to accept the codeword
k = 4 , n = 5
Simple parity check code C(5 4)
-
8/12/2019 MD05 Error Detection and Correction
36/94
10.36
Let us look at some transmission scenarios. Assume the sender sends the dataword 1011.
The codeword created from this dataword is a3a2a1a0r0=10111, which is sent to the
receiver. We examine five cases:
1. No error occurs; the received codeword is 10111. The syndrome is 0. The dataword
1011 is created.
2. One single-bit errorchanges a1. The received codeword is 10011. The syndrome is 1.
No dataword is created. The error is detected and the codeword is rejected.
3. One single-bit errorchanges r0. The received codeword is 10110. The syndrome is 1.
No dataword is created. The error is detected and the codeword is rejected.
4. Two bit errors: two errors change r0and 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 because the syndrome value s0 =0.
Simple parity-check code C(5, 4)
5. Three bits errorsa3, a2, and a1are
changed by errors. The received
codeword is 01011. The syndrome is 1.
The dataword is not created.This shows that the simple parity
check code, guaranteed to detect one
single bit error, can also detect any
odd number of errors.
-
8/12/2019 MD05 Error Detection and Correction
37/94
-
8/12/2019 MD05 Error Detection and Correction
38/94
10.38
Two-dimensional parity-check code
In the 4th Edition, this topic is covered in Section 10.3, pages 280-281.
In the 5th Edition, this topic is introduced in the Problem P10-11 on page 289 at the
end of Chapter 10.
-
8/12/2019 MD05 Error Detection and Correction
39/94
10.39
Two-dimensional parity-check code
In the two-dimensional parity-check code, the data is organized as a table. In theexample, below four 7-bit datawordsare organized as rows of the table. A parity bit is
computed for each dataword and stored in the 8thcolumn. The augmented 8-bit row
represents a codeword.A fifth row is created by computing a parity bit for each column.
In the diagram below, the boxes mark the position of bit errors and the arrows point to
the locations of nonzero syndromes when errors occur in the marked positions.
The two-dimensional parity-check code can detect up to three errors that
occur anywhere in the table. Errors affecting four bits may not be always
detected.
-
8/12/2019 MD05 Error Detection and Correction
40/94
10.40
Two-dimensional parity-check code
0 0 0
0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0
0
1
0
0
0
0
0
0
1
0
0
0
Action at the receiverThe receiver adds a parity bit (9th bit) for each received 8-bit codeword.
The receiver creates a 6th column by adding a parity bit for each column.
Parity bits with value 1 indicates the presence of an error in the
corresponding row or column.
-
8/12/2019 MD05 Error Detection and Correction
41/94
10.41
Two-dimensional parity-check code
Two-dimensional parity-check codes can detect up to three
errors that occur anywhere in the group of codewords.Notice that two bit errors within a codeword can always bedetected by a two-dimensional parity-check code butcannot be detected by a simple parity-check code.
-
8/12/2019 MD05 Error Detection and Correction
42/94
10.42
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.
In CNT 3004, we only cover a category of cyclic codes called
Cyclic Redundancy Check (CRC) codes which are used in LANs
and WANs. In CRC, the generation of the redundant bits is done
using modulo-2 division.
-
8/12/2019 MD05 Error Detection and Correction
43/94
-
8/12/2019 MD05 Error Detection and Correction
44/94
C C d
-
8/12/2019 MD05 Error Detection and Correction
45/94
10.45
CRC DecoderThe checker uses the same agreed upon divisord3d2d1d0 to generate the syndrome
bits. The received codeword b3b2b1b0q2q1q0 is divided by the divisor modulo 2. Theremainder of the modulo 2 division s2s1s0 is the syndrome. If there are no errors, thevalue of the syndrome is 000.
-
8/12/2019 MD05 Error Detection and Correction
46/94
Modulo 2 Division in the CRC decoder for two cases
-
8/12/2019 MD05 Error Detection and Correction
47/94
Modulo 2 Division in the CRC decoder for two cases
The checker uses the same agreed upon divisorto divide the received codeword
using modulo 2 arithmetic. The remainder of the modulo 2 division S2S1S0 is calledthe syndrome. The codeword is accepted if the syndrome is 0. A non-zerosyndrome indicates the presence of bit errors; in this case, the receiver discards
the dataword.
P l i l
-
8/12/2019 MD05 Error Detection and Correction
48/94
10.48
A better way to understand cyclic codes and how they can beanalyzed is to represent them as polynomials. A pattern (string) of 0s
and 1s can be represented as a polynomial with coefficients of 0 and
1. The power of each term indicates the position of the bit and the
coefficient shows the value of the bit.
Thedegreeof the polynomial is the highest power in the polynomial.
For example, the degree of the polynomial shown below is 6.
Polynomials
Addi d S bt ti P l i l
-
8/12/2019 MD05 Error Detection and Correction
49/94
Adding and Subtracting Polynomials
Operations are done in modulo-2 and coefficients areonly 0 and 1
Addition and subtraction give the same result
Adding (or subtracting) is done by combining terms
and deleting pairs of identical terms
Example: Add x^5 + x^4 + x^2 to x^6 + x^4 + x^2
Adding x^5 + x^4 + x^2
and x^6 + x^4 + x^2
gives x^6 + x^5
10.49
M lti l i d Di idi P l i l
-
8/12/2019 MD05 Error Detection and Correction
50/94
Multiplying and Dividing Polynomials
Multiplying a term by another term is done by adding
their powers.
For example x^5 * x^4 = x^9.
For the division operation, we subtract the power of
the second term from the power of the first term.For example, x^7 / x^3 = x^4.
10.50
Cyclic Code Encoder Using Polynomials
-
8/12/2019 MD05 Error Detection and Correction
51/94
Cyclic Code Encoder Using Polynomials
Example:The divisor 1011 is represented as x^3+x+1 and the dataword
1001 is represented as x^3+1. We first multiply the dataword by
x^3 to shift it to the left by three positions (i.e., store zeros in the
three redundant bit positions). This gives the dividend polynomial
x^6+x^3 that will be divided by the divisor x^3+x+1.
We divide the term x^6 by the first term of the divisor x^3. Thisgives the first term of the quotient = x^6/x^3 = x^3. Then we
multiply the term x^3 by the divisor and subtract the result from
the dividend. We continue the division operation until the degree
of the dividend is less than the degree of the divisor. Theremainder of the division is used as the three redundant bits r2r1r0.
10.51
The division using polynomials is shown on the next slide.
CRC di i i i l i l
-
8/12/2019 MD05 Error Detection and Correction
52/94
10.52
CRC division using polynomials
The divisor in a cycliccode is normally called
the generator polynomialor simply the generator.
divisor = 1011
codeword = 1001000
r2r1r0 = 110
Notations for Polynomials in Cyclic Codes
-
8/12/2019 MD05 Error Detection and Correction
53/94
Notations for Polynomials in Cyclic Codes
Dataword: d(x) degree < k
Codeword: c(x) degree < n
Generator: g(x) degree < n-k +1Syndrome: s(x) degree < n-k
Error: e(x) degree < n
Example: n=7
codeword= 0001100 c(x) = x^3+x^2
received as 1001000 two bits in error
error = 1000100 e(x) = x^6 + x^2
Example1:
-
8/12/2019 MD05 Error Detection and Correction
54/94
10.54
Example1:
Polynomials for some 5-bit codewords
0 1 1 0 1 x^3 + x^2 + 1
0 0 0 1 1 x + 1
1 0 0 0 0 x^40 0 0 0 1 1
1 1 1 1 0 x^4 + x^3 + x^2 + x
Example 2:The transmitted 5-bit codeword
1 1 1 1 0 x^4 + x^3 + x^2 + xwas received as
1 0 1 0 0 x^4 + x^2
The error polynomial is
The above error polynomial indicates two error bits.
The errorpolynomial is
obtained by
computing the
XOR of the
polynomial of
the transmittedcodeword and
the polynomial
of the received
codeword.
e(x) = x^3 + x
Cyclic Code Analysis
-
8/12/2019 MD05 Error Detection and Correction
55/94
10.55
In a cyclic code,
Ifs(x) 0, then at least one bit is corrupted.
Ifs(x) = 0, then no bit is corrupted assuming the number of
corrupted bits does not exceed the errordetection capability of the code.
s(x) = syndrome computed by the receiver
Cyclic Code Analysis
-
8/12/2019 MD05 Error Detection and Correction
56/94
10.56
Rule: if the generatorg(x) has more than one term and thecoefficient ofx0 is 1, then all single bit errors can be caught
because the remainder of e(x)/g(x) = x^i/g(x) is not zero.
For a single-bit error
e(x) = x^iwhere i is the position of the bit error.
In a cyclic code, errors represented by the error polynomial e(x) are notcaught if e(x) is divisible byg(x), i.e., if the remainder of e(x) / g(x) is zero.
To check if the generatorg(x) can detect errors of type e(x):
divide e(x) byg(x)If the remainder of e(x) / g(x) is zero, then the generatorg(x) cannot
guarantee the detection of errors of type e(x).
Example
-
8/12/2019 MD05 Error Detection and Correction
57/94
Which of the following divisor polynomials g(x) guarantees that a single-bit error
is caught? For each case, what is the error that cannot be caught?
a. x + 1 b.x3 c. 1
Solution
a. The generator polynomial x+1 can detect any single-bit error in any positionbecause the polynomial has two terms and the coefficient of x0 is 1. For any i,
xi is not divisible by x + 1 because xi/ (x+1) always has a remainder.
b.If i=0, 1, or 2 then xi/ x3 has a non zero remainder equal to xi. Sosingle bit
errors in positions 0, 1 and 2 can be detected. If i is equal to 3 or greater than3, xi is divisible by g(x)= x3, i.e., xi/ x3 does not have a remainder when i 3.
Sosingle bit errors in positions 3 or higher cannot be caughtas shown below.
c. The polynomial consists of a single term and cannot detect any single-biterror. All values of i make xidivisible by g(x)=1. No single-bit error can be
caught.
n-bit codewordcn-1c5c4c3c2c1c0cannot be caught can be caught
-
8/12/2019 MD05 Error Detection and Correction
58/94
-
8/12/2019 MD05 Error Detection and Correction
59/94
10.59
Standard polynomials
This slide is only for your info
Advantages of Cyclic Codes
-
8/12/2019 MD05 Error Detection and Correction
60/94
10.60
Cyclic codes have a very good performance indetecting single-bit errors, double errors, an odd
number of errors, and burst errors.
Cyclic codes can easily be implemented insoftware. They can also be implemented in
hardware by using a handful of electronic
devices. Cyclic codes are especially fast when
implemented in hardware. This has made cyclic
codes a good candidate for many networks.
-
8/12/2019 MD05 Error Detection and Correction
61/94
CHECKSUM
-
8/12/2019 MD05 Error Detection and Correction
62/94
10.62
CHECKSUM
The last error detection method we discuss here is called the
checksum. The checksum is used in the Internet by several
protocols.
Suppose our data is a list of five 4-bit numbers that we want to
send to a destination. In addition to sending these numbers, we
send the sum of the numbers. For example, if the set of numbers
is (7, 11, 12, 0, 6), we send (7, 11, 12, 0, 6,36), where 36 is the sum
of the original numbers. The receiver adds the five numbers and
compares the result with the sum. If the two are the same, thereceiver assumes no error, accepts the five numbers, and discards
the sum. Otherwise, there is an error somewhere and the data are
not accepted
Example
Example
-
8/12/2019 MD05 Error Detection and Correction
63/94
10.63
We can make the job of the receiver easier if we send the
negative (complement) of the sum, called the checksum.
In this case, we send (7, 11, 12, 0, 6, 36). The receiver
can add all the numbers received (including the
checksum). If the result is 0, it assumes no error;
otherwise, there is an error.
The diagram on the next slide shows the logic of the
checksum method.
Checksum
-
8/12/2019 MD05 Error Detection and Correction
64/94
10.64
The checksum must be represented using the same
number of bits (say m bits) used to represent each
data number.
-
8/12/2019 MD05 Error Detection and Correction
65/94
Example(7, 11, 12, 0, 6, 36)
checksum
-
8/12/2019 MD05 Error Detection and Correction
66/94
10.66
The Figure on the next slide shows the process at the sender and at the receiver.The sender initializes the checksum to 0 and adds all data items and the
checksum (the checksum is considered as one data item and is shown in red
color). The result is 36. However, 36 cannot be expressed in 4 bits. The extra
two bits are wrapped and added to the sum to create the wrapped sum value 6.Details of computing the wrapped sum are shown in binary. The wrapped sum
is then complemented, resulting in the checksum value 15 6=9. The sender
now sends six data items to the receiver including the 4-bitchecksum 9.
The receiver follows the same procedure as the sender. It adds all data items
(including the checksum); the result is the 6-bit value 45 which has two extra
bits over the length of a data item. The sum is wrapped with the two extra bits
and becomes 15. The wrapped sum is complemented and becomes 0. Since the
value of the checksum computed by the receiver is 0, this means that the data is
not corrupted. The receiver drops the checksum and keeps the other data items.
If the checksum is not zero, the entire packet is dropped.
( , , , , , )
Example
-
8/12/2019 MD05 Error Detection and Correction
67/94
10.67
1 1 1 1
0 0 0 0
0 1 1 0
1 0 0 1
Initialized checksum Received checksum
Example
-
8/12/2019 MD05 Error Detection and Correction
68/94
In the previous example, the decimal number 36 in binary is(100100)2. To change it to a 4-bit number we add the extra
two leftmost bits to the right four bits as shown below.
10.68
1 0 0 1 0 01 0
+
0 1 1 0 wrapped sum = 6
1 0 0 1 complemented wrapped sum =checksum = 9
Internet 16-bit Checksum
-
8/12/2019 MD05 Error Detection and Correction
69/94
10.69
Sender site:1. The message is divided into 16-bit words.2. The value of the checksum word is set to 0.3. All words including the checksum are
added using ones complement addition.
4. The wrapped sum is complemented and becomes thechecksum.
5. The checksum is sent with the data.
Receiver site:1. The message (including the checksum) isdivided into 16-bit words.
2. All words are added using onescomplement addition.
3. The wrapped sum is complemented and becomes thenew checksum.
4. If the value of checksum is 0, the messageis accepted; otherwise, it is rejected.
Other Approaches
-
8/12/2019 MD05 Error Detection and Correction
70/94
10.70
This illustrates one major problem with the traditional
checksum calculation. If two items are transposed in
transmission, the checksum cannot catch this error. The
reason is that the traditional checksum is not weighted: it
treats each data item equally. In other words, the order of
data items is immaterial to the calculation. Several
approaches have been used to prevent this problem. Two ofthem are the Fletcher Checksum and Adler Checksum.
They will not be covered in CNT 3004.
(7, 11, 12, 0, 6) (7, 12, 11, 0, 6) (7, 10, 10, 3, 6)
The following sets of four numbers produce the samechecksum
Error Detection Fields in Various Protocols
-
8/12/2019 MD05 Error Detection and Correction
71/94
TCP Header Format
This Slide is for Information Only
Error Detection Fields in Various Protocols
-
8/12/2019 MD05 Error Detection and Correction
72/94
UDP Header Format
This Slide is for Information Only
Error Detection Fields in Various Protocols
-
8/12/2019 MD05 Error Detection and Correction
73/94
This Slide is for Information Only
IPv4 Packet Format
IP Checksum (16 bits) covers only the header (not the data) and is recalculated by each
router visited by the packet.
Error Detection Fields in Various Protocols
-
8/12/2019 MD05 Error Detection and Correction
74/94
This Slide is for Information Only
ATM Cell Format
ATM Header Error Control or HEC (8 bits) covers only the 5-byte header (not the data)and is recalculated by each ATM switch visited by the cell.
ATM cell is a packet of fixed size (54 bytes) consisting of a header (5 bytes) and a
data payload (48 bytes).
Error Detection Fields in Various Protocols
-
8/12/2019 MD05 Error Detection and Correction
75/94
This Slide is for Information Only
FCS: the frame check sum is a 4-byte cyclical redundancy check (CRC) value
used for error checking.
Error Detection Fields in Various Protocols
-
8/12/2019 MD05 Error Detection and Correction
76/94
This Slide is for Information Only
802.11: is the Wireless WiFi MAC protocol.
FORWARD ERROR CORRECTION
-
8/12/2019 MD05 Error Detection and Correction
77/94
10.77
We discussed error detection and
retransmission in the previous sections.However, retransmission of corrupted and
lost packets is not useful for real-time
multimedia transmission. We need to correctthe error or reproduce the packet
immediately.
Using Hamming Distance
-
8/12/2019 MD05 Error Detection and Correction
78/94
10.78
We earlier discussed the Hamming distance for
error detection. For error correction, we definitely
need more distance. It can be shown that to correct
t errors, we need to have dmin = 2t + 1. Forexample, to correct 2 bit errors, we need dmin = 5.
Example: if we want to correct 10 bits in a packet,we need to make the minimum hamming distance
21 bits, which means a lot of redundant bits need
to be sent with the data. The geometricalrepresentation of this concept is shown on the next
slide.
Geometric concept for finding dmin in error correction
-
8/12/2019 MD05 Error Detection and Correction
79/94
10.79
Each valid codeword is at the center of a circular territory with radius t.
If a codeword is corrupted by t or less bit errors, the corrupted codeword is apoint inside the circle or on its perimeter.
If the receiver receives a codeword that belongs to a circular territory, it
decides that it is the codeword at the center of this circle under the assumption
that no more than t bit errors have occurred.
Concept of correcting t errors
Minimum Hamming distance for error correction
-
8/12/2019 MD05 Error Detection and Correction
80/94
To guarantee correction of up tot bit errors in allcases, the minimum Hamming distance in a block
code must be dmin = 2t + 1.
A code scheme has a minimum Hamming distance dmin = 4. What is the error
detection and correction capability of this scheme?
This code guarantees the detection of up to three bit errors
(s=3), but it can correct up to one bit error (t=1). In other words,
if this code is used for error correction, part of its capability is wasted because aminimum Hamming distance dmin = 3 is sufficient to correct any one bit error.
Efficient error correction codes need to have an odd minimum Hamming
distance (3, 5, 7, 9, 11, ).
Example
Solution dmin = 4=2t + 1 t = 1dmin = 4=s + 1 s = 3
Reminder:to guarantee the detection of up tosbit errors, we must have dmin = s + 1
Error-Correcting Hamming Codes
Source: 4thEdition Textbook only
-
8/12/2019 MD05 Error Detection and Correction
81/94
10.81
In CNT 3004, we only cover Hamming codes withminimum distance dmin = 3. These codes can
correct only a single bit error.
In these codes, we addrredundant (check) bits to
each dataword of length k bits to make the lengthof the codeword n=k+r bits.
The relationship between r and n in these codes isn = (2 ^ r ) 1.
Hamming code C(7, 4)
Source: 4thEdition Textbook only
-
8/12/2019 MD05 Error Detection and Correction
82/94
The notation C(7, 4) means that each dataword in the code is of length k=4
bits and the number of redundant bits is r=3 bits, making the length of the
codeword n=7 bits. Notice that 7 = 2^3 - 1
The structure of the encoder and decoder for a Hamming code
Source: 4thEdition Textbook only
-
8/12/2019 MD05 Error Detection and Correction
83/94
10.83
Generating the three parity check bits
Source: 4thEdition Textbook only
-
8/12/2019 MD05 Error Detection and Correction
84/94
r0 = a2 a1 a0
r1 = a3 a2 a1
r2 = a1 a0 a3
Note: the above three equations are not unique
Example:
Consider the dataword 0011 a3=0, a2=0, a1=1, a0=1.
We compute the redundant bits as follows
r0 = a2 a1 a0 = 0 1 1 = 0
r1 = a3 a2 a1 = 0 0 1 = 1r2 = a1 a0 a3 = 1 1 0 = 0
The 4-bit dataword 0011 is transmitted as the 7-bit codeword 0011010.
10.84
-
8/12/2019 MD05 Error Detection and Correction
85/94
General Logic
Source: 4thEdition Textbook only
-
8/12/2019 MD05 Error Detection and Correction
86/94
r0 = a2 a1 a0r1 = a3 a2 a1
r2 = a1 a0 a3
s0 = b2 b1 b0 q0s1 = b3 b2 b1 q1s2 = b1 b0 b3 q2
Example 1: error in bit a0, i.e., b0 is corrupted
This causes s0 and s2 to be 1. Syndrome value is 101
Syndrome is the 3-bit number S2 S1 S0. An error in bit aj causescertain syndrome bits to be 1 and results in a unique syndrome value.
Example 2: error in bit a1, i.e., b1 is corruptedThis causes all syndrome bits to be 1. Syndrome is 111
Example 3: error in bit a2, i.e., b2 is corruptedThis causes s0 and s1 to be 1. Syndrome value is 011
See next slide for all bit error positions
-
8/12/2019 MD05 Error Detection and Correction
87/94
-
8/12/2019 MD05 Error Detection and Correction
88/94
Let us trace the path of the following dataword from the sender to the
Example Hamming code C(7, 4) Source: 4thEdition only
-
8/12/2019 MD05 Error Detection and Correction
89/94
10.89
destination:
Case 1: No Errors
The dataword 0100becomes the codeword 0100011.
No errors occurred and the received codeword is 0100011 = b3b2b1b0q2q1q0Using the equations, we find the syndrome bits are s0 = s1= s2 = 0.
The syndrome is 000 implying no errors. The final dataword is 0100.
syndrome=s2s1s0s0 =b2 b1 b0 q0s1 =b3 b2 b1 q1s2 =b1 b0 b3 q2
Let us trace the path of the following dataword from the sender to the
destination:
Example Hamming code C(7, 4) Source: 4thEdition only
-
8/12/2019 MD05 Error Detection and Correction
90/94
destination:
Case 2: One bit Error
The dataword0111becomes the codeword 0111001.
One bit error occurred. The received codeword is 0011001 = b3b2b1b0q2q1q0
The computed syndrome is 011 which correctly indicates an error in bit b2.After flipping b2 (changing the 0 to 1), the final dataword is 0111.
syndrome=s2s1s0s0 =b2 b1 b0 q0s1 =b3 b2 b1 q1s2 =b1 b0 b3 q2
Let us trace the path of the following dataword from the sender to the
destination:
Example Hamming code C(7, 4) Source: 4thEdition only
-
8/12/2019 MD05 Error Detection and Correction
91/94
destination:
Case 2: Two bit Errors
The dataword 1101 is coded as 1101000.
Two bit errors occurred. The received codeword is 0001000 = b3b2b1b0q2q1q0
The computed syndrome is 101 indicating an error in b0.After flipping b0, we get 0000, the wrong dataword.
This shows that our code cannot correct two bit errors.
syndrome=s2s1s0s0 =b2 b1 b0 q0s1 =b3 b2 b1 q1
s2 =b1
b0
b3
q2
A Hamming code uses r = 4 redundant bits. Calculate the
maximum value of k (i e maximum length of the dataword) that
Example
-
8/12/2019 MD05 Error Detection and Correction
92/94
10.92
maximum value of k (i.e., maximum length of the dataword) thatsatisfies the Hamming code requirement for single bit error
correction.
SolutionThe number of redundant bits is r =4 and we know that n = 2^r-1
Thus we have
n = 2 ^ 4 1 = 15 and k = n - r = 15 - 4 = 11
This means that the maximum length of the dataword = k = 11 bits
The Hamming code is
C(15, 11)
Forward Error Correction Using XOR
-
8/12/2019 MD05 Error Detection and Correction
93/94
For real-time multimedia applications, the retransmission of
lost packets is not practical. A simple forward error
correction (FEC) scheme can be used by transmitting one
additional redundant packet for each N packets of multimedia traffic. The redundant packet is computed as the
XOR of the N data packets.
If one packet is lost out of the N+1 transmitted packets, thelost packet can be immediately reproduced by computing the
XOR of the N received packets. This is shown on the next
slide.
Forward Error Correction Using XOR
-
8/12/2019 MD05 Error Detection and Correction
94/94
10.94
The simple FEC method uses the property of the
exclusive OR (XOR) operation as shown below.
If packet Pi is lost, the receiver can compute it as
follows:
Redundant packet R