Académique Documents
Professionnel Documents
Culture Documents
Module 5
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
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
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.
10.10
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
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
10.16
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
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
10.22
Example
Find the minimum Hamming distance of the coding scheme given in the above Table.
Example
Find the minimum Hamming distance of the coding scheme given in the shown Table.
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.
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
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
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
10.32
10.33
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.
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
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
10.38
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.
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 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
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
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
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
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
10.50
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
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
10.55
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.
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).
Standard polynomials
10.59
10.60
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.
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
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
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
IP Checksum (16 bits) covers only the header (not the data) and is recalculated by each router visited by the packet.
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.
FCS: the frame check sum is a 4-byte cyclical redundancy check (CRC) value used for error checking.
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
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
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, ).
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
10.83
10.84
General Logic r0 = a2 a1 a0 r1 = a3 a2 a1 r2 = a1 a0 a3
s0 = b2 b1 b0 q0 s1 = b3 b2 b1 q1 s2 = 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 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
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
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
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
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
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
10.94