Sei sulla pagina 1di 26

Error Detection and Correction

Some applications require that errors be detected and corrected Types of Errors: Single-Bit Error,

Burst Error.

The structure of encoder and decoder

To detect or correct errors, we need to send extra (redundant) bits with data
1

Block Coding
The message is divided into blocks, each of k bits, called datawords. r redundant bits is added to each block to make the length n = k + r. The resulting n-bit blocks are called codewords.

The Block coding process is one to one (the same dataword is always encoded as the same codeword).
2

Block Coding
kB/nB coding: k-bit group replaced with an n-bit group. The 4B/5B block coding is a good example of this type of coding. 2 k 2 n codewords are not used.

2B/3B code

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

Block Coding
We add 3 redundant bits to the 2-bit dataword to make 5-bit 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. (error occurred). The receiver, assuming that there is only 1 bit corrupted, uses the following strategy to guess the correct dataword: Comparing the received codeword with the codewords in the table, 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.
4

Block Coding: Hamming distance


The Hamming distance between two words is the number of differences between corresponding bits. The Hamming distance d(000, 011) is 2: The Hamming distance d(10101, 11110) is 3:

Find the minimum Hamming distance of the coding scheme in Table in slide 3. Solution We first find all Hamming distances.

The dmin in this case is 2.


5

Block Coding: Hamming distance


Find the minimum Hamming distance of the coding scheme in Table in slide 4. Solution We first find all the Hamming distances.

The dmin in this case is 3. 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 dmin

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.

Block Coding: Hamming distance


The dmin in this case is 2. This code guarantees detection of only a single error. For example, if the third codeword (101) 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.

The dmin in this case is 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. 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.
7

Block Coding: Hamming distance

Geometric concept for finding dmin in error detection.

Geometric concept for finding dmin in error correction.

Block Coding: Hamming distance


To guarantee correction of up to t errors in all cases, the minimum Hamming distance in a block code must be dmin = 2t + 1.

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

Solution This code guarantees the detection of up to three errors (s = 3), but it can correct up to one error. In other words, if this code is used for error correction, part of its capability is wasted. Error correction codes need to have an odd minimum distance (3, 5, 7, . . . ).

Linear Block Codes


In a linear block code, the exclusive OR (XOR) of any two valid codewords creates another valid codeword.

Minimum Hamming distance: Is the numbers of 1s in the nonzero codewords. In our first code (Slide 3), 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 (Slide 4), are 3, 3, and 4. So in this code we have dmin = 3.

10

Linear Block Codes:

Simple Parity-Check Code

A simple parity-check code is a single-bit error-detecting code in which n = k + 1 with dmin = 2.

The extra bit, called the parity bit, is selected to make the total number of 1s in the code word even.

Simple parity-check code C(5, 4):

11

Linear Block Codes:

Simple Parity-Check Code

Encoder and decoder for simple parity-check code

r0 = a3 + a2 + a1 + a0

Modulo 2

A simple parity-check code can detect an odd number of errors.


12

Linear Block Codes:

Hamming Codes

dmin=3 in the example; (m) n-bit codeword; k-bit dataword


The relationship between m and n in these codes is n = 2 m 1 And k = n-m, the number of check bits r = m. If m = 3, then n = 7 and k = 4. This is a Hamming code C(7,4) with dmin=3

13

Linear Block Codes:

Hamming Codes

The structure of the encoder and decoder for a Hamming code

Generator:
r0 = a2 + a1 + a0 r1 = a3 + a2 + a1 r2 = a1 + a0 + a3 Modulo 2 Modulo 2 Modulo 2

Checker:
s0 = b2 + b1 + b0 + q0 s1 = b3 + b2 + b1 + q1 s2 = b1 + b0 + b3 + q2 Modulo 2 Modulo 2 Modulo 2
14

Linear Block Codes:

Hamming Codes

The 3-bit syndrome creates 8 different bit patterns. Logical decision made by the correction logic analyzer

Examples: 1. The dataword 0100 becomes the codeword 0100011. The codeword 0100011 is received. The syndrome is 000, the final dataword is 0100. 2. The dataword 0111 becomes the codeword 0111001. The codeword 0011001 is received. The syndrome is 011. After flipping b2 (changing the 1 to 0), the final dataword is 0111. 3. The dataword 1101 becomes the codeword 1101000. The codeword 0001000 is received. The syndrome is 101. After flipping b0, we get 0000, the wrong dataword.
15

Linear Block Codes:

Hamming Codes

Burst error correction using Hamming code

16

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. Cyclic Redundancy Check (CRC): A CRC code with C(7, 4)

17

Cyclic Codes
CRC encoder and decoder

The generator divides the augmented dataword by the divisor. The reminder (r2r1r0) is appended to the dataword to create the codeword.
18

Cyclic Redundancy Check


D = K_bits block of data to be transmitted T = n_bits frame to be transmitted F (FCS) = (n-k)_bits frame check sequence P = pattern of (n-k+1)_bits divisor

Transmitter calculates: F = D.2 n k / P Receiver calculates: T / P If no remainder, assume no error Addition and subtraction are done by modulo-2 arithmetic Example: Given Message D = 1010001101 (10bits) pattern P = 110101 (6 bits) FCS R = to be calculated (5 bits) Thus, n = 15, k = 10, and (n-k) = 5
19

1101010110 Q p 110101 101000110100000 2 n k D 110101 111011 110101 111010 110101 111110 110101 101100 110101 110010 110101 01110 R

20

Polynomials
A better way to understand cyclic codes is to represent them as polynomials. A polynomial to represent a binary word

Adding and subtracting polynomials is in modulo-2. The divisor in a cyclic code is normally called the generator polynomial.

21

22

Four versions of P(X) are widely used:

CRC 12 = X 12 + X 11 + X 3 + X 2 + X + 1 CRC 16 = X 16 + X 15 + X 2 + 1 CRC CCITT = X 16 + X 12 + X 5 + 1 CRC 32 = X 32 + X 26 + X 23 + X 22 + X 16 + X 12 + X 11 + X 10 + X 8 + X 7 + X 5 + X 4 + X 2 + X +1

23

CRC Implementation CRC process can be represented and implemented as a dividing circuit consisting of XOR gates and a shift register. The register contains n-k bits, equal to the length of FCS There are up to n-k XOR gates. The presence or absence of gates corresponds to the presence or absence of a term in the divisor polynomials, P(X), excluding the terms 1 and Xn-k The entire register is clocked simultaneously, causing a 1-bit shift along the entire register.

24

Divisor P = 110101 Data D = 1010001101

P( X ) = X 5 + X 4 + X 2 + 1 D( X ) = X 9 + X 7 + X 3 + X 2 + 1

+ + + + + + +

25

Advantages of Cyclic Codes

Choosing a good generator polynomial to: detect single-bit errors, detect double errors, detect burst errors.

They can easily be implemented in hardware. They are especially fast when implemented in hardware.

This has made cyclic codes a good candidate for many networks

26

Potrebbero piacerti anche