You are on page 1of 15

Fundamentals of Computer Networks

ECE 478/578
Lecture #4: Error Detection and Correction
Instructor: Loukas Lazos
Dept of Electrical and Computer Engineering
University of Arizona
Bit Errors in a Link
Types of errors
Isolated errors: Bit errors that do not affect other bits
Burst errors: A cluster of bits in which a number of errors occur


Burst errors increase with data rate
1s of impulse noise or fading effect will affect
At most 2 bits when data rate is 1Mbps
At most 101 bits when data rate is 100Mbps
2
How Often do Errors Occur?
Let two independent events have probability p, q
Probability of either event is:
1 - (1 - p)(1 - q) = p + q pq p + q, for p, q small
BER = 10
-7
, and a file is 10
4
long, then the probability of a single error
is 10
4
x 10
-7
= 10
-3
Probability of exactly two errors. For two bits i, j the probability of
error is 10
-7
x 10
-7

Total # of pairs:

Probability of two errors: 5 x 10
7
x 10
-14
= 5 x 10
-7

3
( )
7 4 4
4
10 5 2 / 1 10 10
2
10
~ =
|
|
.
|

\
|
Dealing with Errors
Receiver must be aware that an error occurred in a frame
Need to have an error detection mechanism

Receiver must receive the correct frame

Two possible strategies
Add information redundancy to correct errors (error correcting
codes)
Ask sender to re-send frame (retransmission strategies)

In practice both are employed
4
Error Detection
Single parity checks
Append a single parity bit at end of frame. Parity is 1 if # of ones is
odd, and zero otherwise

Example: 0 1 1 0 1 0 1 0 1 1 0 0 parity

Single parity check can detect any odd # of errors

Cannot tell where the error took place or how many occurred

Not useful for burst errors
5
Two-dimensional Parity
Arrange bits of a frame into a two dimensional array






Can detect all 1-, 2-, and 3-bit errors, and most 4-bit errors but not all
Can also correct 1-bit errors, if it is known that a one-bit error
occurred
Overhead: 13/35
6
1 0 0 1 0 1 0 1
0 1 1 1 0 1 0 0
1 1 1 0 0 0 1 0
1 0 0 0 1 1 1 0
0 0 1 1 0 0 1 1
1 0 1 1 1 1 1 0
(IP) Checksum
Treat data as 16-bit words
Add 16-bit words two at a time
Add carry to LSB
Once done, compute ones complement (i.e. invert result)
E.g. Assume the following header
1000 0110 0101 1110
1010 1100 0110 0000
0111 0001 0010 1010
1000 0001 1011 0101

What type of errors can remain undetected?
7
Cyclic Redundancy Check (CRC)
Add k redundant bits on a n-bit message
Design goal k<<n so that overhead is low
Example: 32-bit CRC adequate for 12,000 bits (1,500) bytes

Represent (n+1)-bit messages as n degree polynomials

Example: 10011010 maps to x
7
+ x
4
+ x
3
+ x
1

The bits of the message to be transmitted become the
coefficients of the polynomial
8
Polynomial Arithmetic
Any polynomial B(x) is divisible by a polynomial C(x) if deg(B) deg(C)
C(x) is called the divisor
If C(x) and B(x) are of the same degree, the remainder is obtained by
subtracting C(x) from B(x)
Modulo 2 arithmetic, subtraction is an XOR operation between
coefficients

Example B(x) = x
3
+ 1, C(x) = x
3
+ x
2
+ 1
Remainder: R(x) = x
2
B(x) = 1001, C(x) =1101, R(x) = 0100 (XOR of B(x), C(x))
9
CRC Calculation
Goal: For message M(x), and divisor C(x), construct polynomial P(x)
that is divisible by C(x)

C(x) known to both sender and receiver

Process:
Step 1: multiply M(x) by x
k
(add k zeros at the end of message) and obtain T(x) .
k is the degree of C(x).
Step 2: Divide T(x) by C(x)
Step 3: Subtract the remainder R(x) from T(x).
Step 4: Obtain P(x) = M(x)|R(x) divisible by C(x)
10
Example: CRC Calculation
M = 10011010, C(x) = x
3
+ x
2
+1




T(x) = 10011010 | 000
R(x) = 101
P(x) = 10011010 | 101
11
Selection of C(x)
Bit errors can be seen as a polynomial E(x) added to P(x)
Error remains undetected if E(x) is divisible by C(x)
Single-bit errors: E(x) = x
i
, x
k
, x
0
coefficients are nonzero, all single-bit
errors detected
Double-bit errors: C(x) has a factor with at least 3 terms
Odd number errors: C(x) contains the factor (x+1)
Any burst error of less than k bits and most burst errors of larger than
k bits
12
Commonly Used CRCs
CRC C(x)
CRC-8 x
8
+ x
2
+ x + 1
CRC-10 x
10
+ x
9
+ x
5
+ x
4
+ x + 1
CRC-12 x
12
+ x
11
+ x
3
+ x
2
+ 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
13
Fundamentals of Coding
Coding: Map an k-bit word to an n-bit word.
Notation: This code is usually referred to as (n,k)-code
Weight of a word: The number of ones in the word.
Ex.: W(100011101)= 5
Hamming distance between x, y: d(x,y) = W(xy)
Ex. x = 10011101, y = 11100110, d = 6
# words at a hamming distance d:

# words at a distance up to d:

Minimum distance: the minimum Hamming distance out of all
distances in a code
14
|
|
.
|

\
|
d
n

=
|
|
.
|

\
|
d
i
i
n
0
Detecting and Correcting Errors
An (n, k)-code can detect up to n-k-1 errors and correct up to n-k/2
errors

Example
Hamming (7,4)-code, can detect any single or two bit errors, and
correct any single bit error

Well known codes
Hamming codes
Reed-Solomon codes: used in DSL, WiMax, CD, DVD, Blue-Ray
Discs
15

You might also like