Vous êtes sur la page 1sur 94

CNT 3004

Module 5

Chapter 10 Error Detection and Correction


Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Chapter 10 Error Detection And Correction


Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

INTRODUCTION
Data can be corrupted during transmission. Some applications require that errors be detected and corrected. In a single-bit error, only one bit in the data unit has changed.

10.4

Burst of errors A burst of error means that two or more bits in the data unit have changed.

10.5

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 number of bits that are corrupted and, more importantly, their location in the message.
10.6

Redundancy
To detect or correct errors, we need to send extra (redundant) bits with data. Redundancy is achieved through various coding schemes. The sender uses an encoder and 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.
10.7

The structure of encoder and decoder

10.8

Modular arithmetic 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.

10.9

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.

XOR of two single bits

XOR of two binary strings

10.10

There are two methods of error correction:


Forward error correction
If there are errors, the receiver can instantaneously recover the correct data using the redundant bits. We will study this type of error correction in this module.

Correction by retransmission
If there are errors, the sender must retransmit the data to the receiver. We will study this type of error correction in the next module.

In CNT 3004, we concentrate on block codes for error detection and correction; we will not cover convolution codes.

10.11

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. With k bits, we can create 2^k different datawords and with n bits 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.
10.12

Datawords and codewords in block coding

10.13

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.

10.14

Example
Let us assume that k = 2 and n = 3. The table below shows the list of datawords and 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 following three cases: 1. The receiver receives 011. It is a valid codeword. The receiver correctly extracts the dataword 01 from 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, and 000 is received. This is a valid codeword. The receiver incorrectly extracts the dataword 00. Two corrupted bits have made the error undetectable. Three cases 1. 011 011 2. 011 111 3. 011 000 10.15

Error detection vs. error correction

An error-detecting code can detect only the types of errors for


which it is designed; other types of errors may remain undetected. Error correction is much more difficult than error detection. In addition 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 for error detection. In the case of error correction, the encoder at the sender site adds error-correcting redundant bits whose values are based on the actual data bits. The checker at the receiver site examines the redundant bits and the data bits to detect then correct the errors.

10.16

Structure of encoder and decoder in error correction

10.17

Example
Let us add more redundant bits 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. The 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. 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.

10.18

Example (continued)
Assuming that there is at most one bit corrupted, the receiver uses the 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 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. The above strategy is further illustrated on the next slide.

Example (continued)
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.

01001

2 bits 1 bit Minimum 3 bits 4 bits


Action: codeword 01001 is corrected to codeword 01011
because it gives the minimum bit difference of one bit. The correct dataword is 01

Another Example The receiver received the codeword

00011

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. 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.

Hamming distance
The Hamming distance between two words of the same size is the number of differences between the corresponding bits.

Example
We can use XOR to 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.22

Minimum Hamming Distance


The minimum Hamming distance is the smallest Hamming distance between all possible pairs in a set of codewords.

Example
Find the minimum Hamming distance of the coding scheme given in the above Table.

Solution We first find all Hamming distances.

The dmin in this case is 2.


10.23

Example
Find the minimum Hamming distance of the coding scheme given in the shown Table.

Solution We first find all the Hamming distances.

The dmin in this case is 3.


10.24

Minimum Hamming distance for error detection


There are three main parameters for a coding scheme: the codeword size n, the dataword size k, and the minimum Hamming distance dmin. 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 block code must be dmin = s + 1.
Notation: the variable s is used to denote the number of bit errors that can be detected and the variable t is used to denote the number of bit errors that can be corrected.

10.25

Example
The minimum Hamming distance for our first code scheme (shown in the Table below) is 2. This code guarantees detection of only a single error. For example, if the second codeword (011) 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.

Three cases 1. 011 011 2. 011 111 3. 011 000 10.26

minimum Hamming distance = dmin = 2

no bit error one bit error two bit errors

can be detected cannot be detected

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.

10.27

Geometric concept for finding dmin in error detection

Let us assume the sent codeword is at the center of a circle with radius s. All other codewords created by s or less bit errors are points inside the circle or on its perimeter. All other valid codewords (having at least s+1 different bits) are outside the circle.

10.28

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.

10.29

Example
Let us examine two codes that belong to the class of linear block codes. 1. The scheme in the Table below 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.
The minimum Hamming distance of this code is 2. Since dmin = s + 1 = 2, then s=1 and the code can detect a single bit error.

10.30

2. The scheme in the Table below is also a linear block code. We can create all four codewords by XORing two other codewords or by XORing one codeword with itself.

The minimum Hamming distance of this code is 3. Since dmin = s + 1 = 3, then s=2 and the code can detect two bit errors.

10.31

Minimum Hamming Distance in Linear Block Codes


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.
Table A Table B

10.32

Simple parity-check codes


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. 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.

10.33

Parity-check code with k=4 and n=5, denoted C(5,4)

Simple parity-check code C(5, 4)

The encoder uses a generator that takes a copy of the 4-bit dataword a3a2a1a0 and generates a parity bit r0 using XOR. The parity bit makes the number of 1s in the 5-bit codeword a3a2a1a0r0 even. The transmitted codeword a3a2a1a0r0 arrives at the receiver possibly with bit errors in the form b3b2b1b0q0. The receiver constructs a one-bit syndrome s to detect any single bit error. Details are shown on the next slide.

Encoder and decoder for simple parity-check code


k=4,n=5

r0 = a3 a2 a1 a0
r0 makes total number of 1s even

s0 = b3 b2 b1 b0 q0
s0 is called the syndrome
s0 must be 0 to accept the codeword

10.35

Simple parity-check code C(5, 4)


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 error changes 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 error changes 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 r0 and 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. 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. 10.36

A simple parity-check code can detect any odd number of bit errors but cannot detect even number of bit errors. Because the simple parity-check code cannot detect two bit errors, it is characterized as being able to guarantee the detection of up to one bit error.

10.37

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.

10.38

Two-dimensional parity-check code


In the two-dimensional parity-check code, the data is organized as a table. In the example, below four 7-bit datawords are organized as rows of the table. A parity bit is computed for each dataword and stored in the 8th column. 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.

10.39

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.

Two-dimensional parity-check code

Action at the receiver


The 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.
0 0

1 0 0 0

0 0 0 0 0

Parity bits with value 1 indicates the presence of an error in the corresponding row or column.
10.40

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 be detected by a two-dimensional parity-check code but cannot be detected by a simple parity-check code.
10.41

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.

10.42

A CRC code with C(n=7, k=4)

10.43

In the CRC code C(n,k), the generator uses an agreed upon divisor of n-k+1 bits (or 7 - 4+1 = 4 bits in the above example) to generate the parity bits. The quotient of the modulo-2 division is discarded and the remainder (3 bits in the above example) is appended to the dataword to create the codeword.

CRC Encoder
The generator uses an agreed upon divisor d3d2d1d0 (of n-k+1 = 7-4+1 = 4 bits in our example) to generate the parity bits. The dataword is expanded to a3a2a1a0000 and is divided by the divisor modulo 2. The remainder of the modulo 2 division r2r1r0 is used as the redundancy bits.

10.44

CRC Decoder
The checker uses the same agreed upon divisor d3d2d1d0 to generate the syndrome bits. The received codeword b3b2b1b0q2q1q0 is divided by the divisor modulo 2. The remainder of the modulo 2 division s2s1s0 is the syndrome. If there are no errors, the value of the syndrome is 000.

10.45

Modulo 2 Division in CRC encoder

Note: It may be easier for some students to do this type of division using the polynomial notation to be discussed shortly. If you are not familiar or do not feel comfortable with the modulo 2 division approach shown on this slide, you can use the alternative division approach using polynomials.

10.46

Modulo 2 Division in the CRC decoder for two cases


The checker uses the same agreed upon divisor to divide the received codeword using modulo 2 arithmetic. The remainder of the modulo 2 division S2S1S0 is called the syndrome. The codeword is accepted if the syndrome is 0. A non-zero syndrome indicates the presence of bit errors; in this case, the receiver discards the dataword.

Polynomials
A better way to understand cyclic codes and how they can be analyzed 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. The degree of the polynomial is the highest power in the polynomial. For example, the degree of the polynomial shown below is 6.

10.48

Adding and Subtracting Polynomials


Operations are done in modulo-2 and coefficients are only 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

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


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. This gives 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. The remainder of the division is used as the three redundant bits r2r1r0.
The division using polynomials is shown on the next slide. 10.51

CRC division using polynomials

divisor = 1011 codeword = 1001000

The divisor in a cyclic code is normally called the generator polynomial or simply the generator.

r2r1r0 = 110

10.52

Notations for Polynomials in Cyclic Codes Dataword: d(x) degree < k Codeword: c(x) degree < n Generator: g(x) degree < n-k +1 Syndrome: 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 1000100 e(x) = x^6 + x^2 error =

Example1:
Polynomials for some 5-bit codewords 0 0 1 0 1 1 0 0 0 1 1 0 0 0 1 0 1 0 0 1 1 1 0 1 0 x^3 + x^2 + 1 x+1 x^4 1 x^4 + x^3 + x^2 + x
The error polynomial is obtained by computing the XOR of the polynomial of the transmitted codeword and the polynomial of the received codeword.

Example 2:
The transmitted 5-bit codeword

1 1 1 1 0
was received as

x^4 + x^3 + x^2 + x

1 0 1 0 0

x^4

+ x^2

x^3 +x The error polynomial is e(x) = The above error polynomial indicates two error bits.
10.54

Cyclic Code Analysis


s(x) = syndrome computed by the receiver
In a cyclic code, If s(x) 0, then at least one bit is corrupted. If s(x) = 0, then no bit is corrupted assuming the number of corrupted bits does not exceed the error detection capability of the code.

10.55

Cyclic Code Analysis


In a cyclic code, errors represented by the error polynomial e(x) are not caught if e(x) is divisible by g(x), i.e., if the remainder of e(x) / g(x) is zero. To check if the generator g(x) can detect errors of type e(x): divide e(x) by g(x) If the remainder of e(x) / g(x) is zero, then the generator g(x) cannot guarantee the detection of errors of type e(x).

For a single-bit error e(x) = x^i where i is the position of the bit error. Rule: if the generator g(x) has more than one term and the coefficient of x0 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.
10.56

Example
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 position because 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. So single bit errors in positions 0, 1 and 2 can be detected. If i is equal to 3 or greater than 3, xi is divisible by g(x)= x3, i.e., xi / x3 does not have a remainder when i 3. So single bit errors in positions 3 or higher cannot be caught as shown below. n-bit codeword cn-1c5c4c3c2c1c0
cannot be caught can be caught

c. The polynomial consists of a single term and cannot detect any single-bit
error. All values of i make xi divisible by g(x)=1. No single-bit error can be caught.

Properties 3 and 4 on this slide are only for your info


(not required for CNT 3004)

A good polynomial generator needs to have the following properties: 1. It should have at least two terms. 2. The coefficient of the term x0 should be 1 (properties 1 and 2 guarantee detecting any
single bit error).

3. It should not divide xt + 1, for t between 2 and n 1 (to detect two isolated bit
errors spaced less than t bits apart).

4. It should have the factor x + 1 (to detect all


odd-numbered errors).
10.58

This slide is only for your info

Standard polynomials

10.59

Advantages of Cyclic Codes


Cyclic codes have a very good performance in detecting single-bit errors, double errors, an odd number of errors, and burst errors. Cyclic codes can easily be implemented in software. 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.

10.60

Other Cyclic Codes


The cyclic codes we have discussed in this section are very simple and are limited to error detection. There are, however, more powerful polynomials that are beyond the scope of CNT 3004. One of the most interesting of these cyclic codes is the ReedSolomon code used today for both error detection and error correction.

10.61

CHECKSUM
The last error detection method we discuss here is called the checksum. The checksum is used in the Internet by several protocols.

Example
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, the receiver assumes no error, accepts the five numbers, and discards the sum. Otherwise, there is an error somewhere and the data are not accepted
10.62

Example
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.

10.63

Checksum

10.64

The checksum must be represented using the same number of bits (say m bits) used to represent each data number.

Ones complement arithmetic


The checksum must be represented using the same number of bits used to represent each data number. Since this is not always possible, we use ones complement arithmetic.

Example
How can we represent the number 6 in ones complement arithmetic using only four bits?

Solution
In ones complement arithmetic, the negative or complement of a number is found by inverting all bits. Positive 6 is 0110 in binary; complement of 6 is 1001. If we consider only unsigned numbers, then 1001 is 9. So the complement of 6 is 9. Another way to find the complement of a number in ones complement arithmetic is to subtract the number from 2n 1 where n is the number of bits, i.e., 2n 1 =16 1 = 15 in this case. This gives 15 6 = 9.

Example

(7, 11, 12, 0, 6, 36)

checksum

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-bit checksum 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. 10.66

Example

Initialized checksum

Received checksum

0 1 1 0 1 0 0 1

1 1 1 1 0 0 0 0

10.67

Example
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.

100100 10
0110 1001
wrapped sum = 6 complemented wrapped sum = checksum = 9

10.68

Internet 16-bit Checksum


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 the checksum. 5. The checksum is sent with the data.

Receiver site:
1. The message (including the checksum) is divided into 16-bit words. 2. All words are added using ones complement addition. 3. The wrapped sum is complemented and becomes the new checksum. 4. If the value of checksum is 0, the message is accepted; otherwise, it is rejected. 10.69

Other Approaches
The following sets of four numbers produce the same checksum

(7, 11, 12, 0, 6) (7, 12, 11, 0, 6) (7, 10, 10, 3, 6)


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 of them are the Fletcher Checksum and Adler Checksum. They will not be covered in CNT 3004.
10.70

Error Detection Fields in Various Protocols

TCP Header Format

This Slide is for Information Only

Error Detection Fields in Various Protocols

UDP Header Format

This Slide is for Information Only

Error Detection Fields in Various Protocols

IPv4 Packet Format

IP Checksum (16 bits) covers only the header (not the data) and is recalculated by each router visited by the packet.

This Slide is for Information Only

Error Detection Fields in Various Protocols

ATM Cell Format

ATM cell is a packet of fixed size (54 bytes) consisting of a header (5 bytes) and a data payload (48 bytes).
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.

This Slide is for Information Only

Error Detection Fields in Various Protocols

FCS: the frame check sum is a 4-byte cyclical redundancy check (CRC) value used for error checking.

This Slide is for Information Only

Error Detection Fields in Various Protocols

802.11: is the Wireless WiFi MAC protocol.

This Slide is for Information Only

FORWARD ERROR CORRECTION 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 correct the error or reproduce the packet immediately.

10.77

Using Hamming Distance


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. For example, 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 geometrical representation of this concept is shown on the next slide.
10.78

Geometric concept for finding dmin in error correction

Concept of correcting t errors

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 a point 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.

10.79

Minimum Hamming distance for error correction

To guarantee correction of up to t bit errors in all cases, the minimum Hamming distance in a block code must be dmin = 2t + 1.
Reminder: to guarantee the detection of up to s bit errors, we must have dmin = s + 1

Example
A code scheme has a minimum Hamming distance dmin = 4. What is the error detection and correction capability of this scheme?

Solution

dmin = 4=s + 1 s = 3

dmin = 4=2t + 1 t = 1

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 a minimum 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, ).

Source: 4th Edition Textbook only

Error-Correcting Hamming Codes


In CNT 3004, we only cover Hamming codes with minimum distance dmin = 3. These codes can correct only a single bit error. In these codes, we add r redundant (check) bits to each dataword of length k bits to make the length of the codeword n=k+r bits.

The relationship between r and n in these codes is n = (2 ^ r ) 1.


10.81

Source: 4th Edition Textbook only


Hamming code C(7, 4)

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

Source: 4th Edition Textbook only


The structure of the encoder and decoder for a Hamming code

10.83

Source: 4th Edition Textbook only

Generating the three parity check bits 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 = 1 r2 = a1 a0 a3 = 1 1 0 = 0 The 4-bit dataword 0011 is transmitted as the 7-bit codeword 0011010.

10.84

Source: 4th Edition Textbook only

Generating the three parity check bits r0 = a2 a1 a0 r1 = a3 a2 a1 r2 = a1 a0 a3


Note: the above three equations are not unique
For CNT 3004, you are not required to remember these equations.

Creating the three syndrome bits s0 = b2 b1 b0 q0 s1 = b3 b2 b1 q1 s2 = b1 b0 b3 q2


10.85

General Logic r0 = a2 a1 a0 r1 = a3 a2 a1 r2 = a1 a0 a3

Source: 4th Edition Textbook only

s0 = b2 b1 b0 q0 s1 = b3 b2 b1 q1 s2 = b1 b0 b3 q2

Syndrome is the 3-bit number S2 S1 S0. An error in bit aj causes


certain syndrome bits to be 1 and results in a unique syndrome value.

Example 1: error in bit a0, i.e., b0 is corrupted This causes s0 and s2 to be 1. Syndrome value is 101 Example 2: error in bit a1, i.e., b1 is corrupted This causes all syndrome bits to be 1. Syndrome is 111 Example 3: error in bit a2, i.e., b2 is corrupted This causes s0 and s1 to be 1. Syndrome value is 011 See next slide for all bit error positions

General Logic Received codeword (7 bits):

b3 b2 b1 b0 q2 q1 q0 s0 = b2 b1 b0 q0 s1 = b3 b2 b1 q1 s2 = b1 b0 b3 q2
The values of the 3-bit syndrome for the different positions of a single bit error are shown in the table given below. For example, b1 appears in all three equations; therefore an error in b1 will make all three equations produce a value 1.
Bit error S2 S1 S0 b3 1 1 0 b2 0 1 1 b1 1 1 1 b0 1 0 1 q2 1 0 0 q1 0 1 0 q0 0 0 1
Syndrome bits

Source: 4th Edition Textbook only


Logical decision made by the correction logic analyzer

The three syndrome bits can represent 8 cases. One case represents lack of errors (000), another case represents an error in the b2 bit (011), a third case represent an error in the b3 bit (110), and so on.

10.88

Example

Hamming code C(7, 4)

Source: 4th Edition only

Let us trace the path of the following dataword from the sender to the destination: Case 1: No Errors The dataword 0100 becomes the codeword 0100011. No errors occurred and the received codeword is 0100011 = b3b2b1b0q2q1q0 Using 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= s2 s1 s0 s0 = b2 b1 b0 q0 s1 = b3 b2 b1 q1 s2 = b1 b0 b3 q2

10.89

Example

Hamming code C(7, 4)

Source: 4th Edition only

Let us trace the path of the following dataword from the sender to the destination: Case 2: One bit Error The dataword 0111 becomes 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= s2 s1 s0 s0 = b2 b1 b0 q0 s1 = b3 b2 b1 q1 s2 = b1 b0 b3 q2

Example

Hamming code C(7, 4)

Source: 4th Edition only

Let us trace the path of the following dataword from the sender to the 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= s2 s1 s0 s0 = b2 b1 b0 q0 s1 = b3 b2 b1 q1 s2 = b1 b0 b3 q2

Example
A Hamming code uses r = 4 redundant bits. Calculate the maximum value of k (i.e., maximum length of the dataword) that satisfies the Hamming code requirement for single bit error correction.

Solution
The 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)
10.92

Forward Error Correction Using XOR


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, the lost 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


The simple FEC method uses the property of the exclusive OR (XOR) operation as shown below.
Redundant packet R

If packet Pi is lost, the receiver can compute it as follows:

10.94

Vous aimerez peut-être aussi