You are on page 1of 35

Data Link Control

Error Detection and


Correction
Error Detection & Error
Control
 Most communication channels have some level of
noise and interference (e.g., wireless links have
BER of 10-3 or more, fiber optic links have BER of
10-9)  Transmission errors will always occur.
 Two approaches for error control both involve
error detection
 Automatic Retransmission Request (ARQ): assume a
return channel. Wastes bandwidth in retransmission
 Forward Error Correction (FEC): After detection,
attempt to correct; used when return channel may not be
available (used in satellite, deep space communication).
Requires redundancy in transmitted information.

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

Information bits Received information bits

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

Bottom row consists of


check bit for each column 5-13
Two dimensional parity checks
 The last bit of each column is the check bit for
the information bits in the column.
 Note the in effect the last column is a “check
codeword” over the m previous columns.
 The right most bit in each row is the check bit
of the other bits in the row.
 The resulting matrix of bits satisfies the
patterns that all rows have even parity and all
columns have even parity.

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

 The checksum bL is: bL = – x.


 The checksum is inserted in a dedicated field in
the header.
 The content of all headers, including the
checksum field must satisfies the following:

0  b0  b1  b2  ...  bL1  bL 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.

At the receiver, a checksum is computed. If the


condition (b0 + b1 + b2 mod3 = 0) is not satisfied, then
an error is detected. 5-20
Internet checksum
Suppose a header consists of four 16-bit words: (11111111
11111111, 11111111 00000000,
11110000 11110000, 11000000 11000000).
Find the internet checksum for this code.

b0 = 11111111 11111111 = 216 – 1 = 65535


b1 = 11111111 00000000 = 65280
b2 = 11110000 11110000 = 61680
b3 = 11000000 11000000 = 49344
x = b0 + b1 + b2 + b3 modulo 65535 = 241840 modulo 65535 =
45235
b4 = x modulo 65535 = 20300
So the internet checksum = 01001111 01001100
5-21
Internet checksum

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.

 The k information bits (ik 1 , ik  2 ,...., i0 )

are used to form a polynomial of degree k-1 :


k 1 k 2
i ( x )  ik 1 x  ik  2 x  ...  i1 x  i0
1

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

We assume codewords with n bits, of which k are


information and n-k are check bits. We refer to
such code as (n,k) code.

The generator polynomial of such code has


degree n-k and has the form of
g ( x)  x n  k  g n  k x n  k 1  .....  g1 x  1

Where g n k 1 , g n k 2 ,..., g1 are binary numbers.


5-25
Cyclic redundancy code CRC
Steps:
1) Multiply i(x) by xn-k (puts zeros in (n-k) low order
positions)
quotient
2) Divide xn-k i(x) by g(x) remainder

xn-ki(x) = g(x) q(x) + r(x)

3) Add remainder r(x) to xn-k i(x)


(puts check bits in the n-k low order positions):
b(x) = xn-ki(x) + r(x) transmitted codeword

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:

b(x) = xn-ki(x) + r(x)=g(x)q(x) +r(x) +r(x) =g(x)q(x)


Therefore, the codeword polynomial (b(x)) is
divisible by g(x). That is:
All codewords are multiple of the generator
polynomial g(x).
Thus, the receiver checks this patterns (b(x)
divisible by g(x)) to determine if an error has
occurred or not.

5-28
Error Detecting Capability

 At the receiver host, the link can be viewed as


adding, modulo 2, an error polynomial which has 1s
where errors occur to the input codeword to
produce the received polynomial R(x).

+
Transmitter: b(x) R(x) (Receiver)

e(x) Error Pattern

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)

e(x) Error Pattern


5-30
Error Detecting Capability

 Q: What kind of error patterns can we detect


using polynomial codes? Can we detect single
errors, double errors, or multiple error
patterns?
 Answer: the ability of detecting errors depends
on the choice of the generator polynomial, g(x).

5-31
Error Detecting Capability

 All single errors (that is when e(x) = xi) can be


detected since g(x) has more than one term
 e(x) = xi cannot be divided by g(x) since g(x) has at least
two terms

 Double errors ( when e(x) = xi + xj = xi (1 + xj-i) j >


i): 1 + xj-i should not be divisible by g(x).
 If g(x) is “primitive polynomial” with degree N = n –
k, all double errors are detected as long as length
of b(x) does not exceed 2n-k - 1

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

You might also like