Error Detection 3
Error Detection 3
5-2
Error Detection
Data is encoded to satisfy certain pattern. At the output of
the link, if received stream does not satisfy the pattern, an
error has occurred.
EDC= Error Detection and Correction bits (redundancy)
D = Data protected by error checking, may include header
fields
5-3
Error Detection
Additional bits added by transmitter for error detection
Single Parity Check Code:
Takes k information bits (b1,…,bk), add one bit (bk+1) to form
a “codeword".
Value of “parity bit” is such that the codeword has even
(even parity) number of 1s.
bk+1= bk + bk-1 + bk-2 + … + b1 Mod 2
Codeword is robust against single error during transmission
• Single error will be detected since the codeword will contain an odd
number of 1s
• Codeword is also robust against all odd number of errors
Even number of bit errors goes undetected
5-4
Error Detection
Recalculate
check bits
Link
Calculate
check bits Compare
Check Received Information
bits check bits accepted if
check bits
match
5-5
Error Detection
Observation
Error detection requires redundancy in that the
amount of information that is transmitted is over
and above the required minimum information bits
(single parity, the fraction 1/(k+1) is redundant).
Every error-detection technique will fail to
detect some errors
5-6
Two dimensional parity checks
A simple method to improve the error-detection
capability of a single parity check code is to
arrange the information bits in columns of k bits
1 0 0 1 0 0
Last column consists of
0 1 0 0 0 1 check bits for each row
1 0 0 1 0 0
1 1 0 1 1 0
1 0 0 1 1 1
5-14
Two dimensional parity checks
If one, two, or three errors occur anywhere in
the matrix of bits during transmission, then at
least one row or parity check will fail.
Some patterns with four errors are not
detectable. As shown in next slide.
5-15
Two dimensional parity checks
1 0 0 1 0 0 1 0 0 1 0 0
0 0 0 0 0 1 0 0 0 0 0 1
One Two
1 0 0 1 0 0 1 0 0 1 0 0
error errors
1 1 0 1 1 0 1 0 0 1 1 0
1 0 0 1 1 1 1 0 0 1 1 1
1 0 0 1 0 0 1 0 0 1 0 0
0 0 0 1 0 1 0 0 0 1 0 1
Three Four
1 0 0 1 0 0 errors 1 0 0 1 0 0 errors
1 0 0 1 1 0 1 0 0 0 1 0
1 0 0 1 1 1 1 0 0 1 1 1
Arrows indicate failed check bits 5-16
Internet checksum
Several internet protocols (e.g., IP, TCP, UDP)
use check bits to detect errors.
With IP checksum is calculated for the content
of the header and included in a special field.
Because checksum must be recalculated at every
router, the algorithm for checksum is
implemented in software (ease of
implementation).
5-17
Internet checksum
The algorithm assumes that the header consists
of a certain number, say L, of 16-bit words.
b0 , b1 , b2 ,..., bL 1
Plus a checksum bL .
These L words corresponds to the information
or data and the bL corresponds to the parity
bits and is calculated as follows.
5-18
Internet checksum
Each 16-bit word is treated as an integer, and
the L words are added modulo 216 – 1
x b0 b1 ... bL 1 mod 2 1
16
5-19
Internet checksum
Example:
Consider two-bit words and L = 2.
b0 = xx (x = 0 or 1)
b1 = xx (x = 0 or 1)
Checksum is b2
Arithmetic is done modulo 22 - 1 = 3
If b0 = 00 and b1 = 01, then:
x = b0 + b1 modulo 3 = 0+1 mod3 = 1
Checksum b2 = -x mod3 = -1 mod3 = 2
Header satisfies: b0 + b1 + b2 mod3 = 0+1+2mod3 = 0.
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
5-22
Polynomial Codes (Cyclic
redundancy code CRC)
In polynomial codes the information symbols, the
codeword, and the error vectors are
represented by polynomials with binary
coefficients.
5-23
Polynomial Codes (Cyclic
redundancy code CRC)
Addition: (x 7 x 6 1) (x 6 x 5 ) x 7 (1 1)x 6 x 5 1
x7 x5 1
2 3 2 2 3
Multiplication: (x 1)(x x 1) x x x x x 1 x 1
x3 + x2 + x = q(x) quotient
Division: x3 + x + 1 ) x6 + x5
x6 + x4 + x3 dividend
divisor
x5 + x4 + x3
3 x5 + x3 + x2
35 ) 122 x4 + x2
105
x4 + x2 + x
17
x = r(x) remainder
5-24
Cyclic redundancy code CRC
A polynomial code is specified by its generator
polynomial g(x).
5-26
Generator polynomial: g(x)= x3 + x + 1 (7,4) code
Information: (1,1,0,0) i(x) = x3 + x2
Encoding: x3i(x) = x6 + x5
x3 + x2 + x 1110
x3 + x + 1 ) x 6 + x5 1011 ) 1100000
x6 + x4 + x 3 1011
x5 + x4 + x3 1110
x5 + x3 + x 2 1011
x4 + x2 1010
x4 + x2 + x 1011
x 010
Transmitted codeword:
b(x) = x6 + x5 + x
b = (1,1,0,0,0,1,0)
5-27
Cyclic redundancy code CRC
Note:
5-28
Error Detecting Capability
+
Transmitter: b(x) R(x) (Receiver)
R( x) b( x) e( x)
transmitted codeword error polynomial
5-29
Error Detecting Capability
At the receiver:
R(x) is divided by g(x) to obtain the remainder
that is defined as the Syndrome polynomial S(x)
If S(x) = 0, then R(x) is a valid codeword.
If S(x) 0, then Error has been detected.
+
Transmitter: b(x) R(x) (Receiver)
5-31
Error Detecting Capability
5-32
Error Detecting Capability
Example:
Let g(x)=x3+x+1. Consider the information sequence 1001.
a. Find the codeword corresponding to the preceding
information sequence.
5-33
Error Detecting Capability
b. Suppose that the codeword has a transmission
error in the 1st bit. What does the receiver obtain
when it does its error checking?
5-34
Error Detecting Capability
Example:
Let g1(x) = x + 1 and let g2(x) = x3 + x2 + 1. Consider the
information bits (1,1,0,1,1,0).
a. Find the codeword corresponding to these
information bits if g1(x) is used as the generating
polynomial.
5-35
Error Detecting Capability
b. Find the codeword corresponding to these
information bits if g2(x) is used as the generating
polynomial.
5-36
Error Detecting Capability
c. Can g2(x) detect single errors? double errors? If
not, give an example of an error pattern that
cannot be detected.
Single errors can be detected since g2(x) has
more than one term.
Double errors cannot be ALL detected even
though g2(x) is primitive because the codeword
length exceeds 2n-k-1=7. An example of such
undetectable error is 100000010.
Error Detecting Capability
Error Detecting Capability
Error Detecting Capability
d. Find the codeword corresponding to these
information bits if g(x) = g1(x)g2(x) is used as the
generating polynomial.
5-40
Error Detecting Capability
The new code can detect “all single” and “all odd
errors”.
It cannot detect double errors.
It can also detect all bursts of length n – k = 4 or
less. All bursts of length 5 are detected except
for the burst that equals g(x). The fraction 1/2n-k
= 1/16 of all bursts of length greater than 5 are
detectable.
5-41