You are on page 1of 98

Module3

Error Detection and Correction


Dr. Pramod T.C
Assistant Professor,
Dept. of CSE
SIT, Tumkur
pramodtc@sit.ac.in
Introduction
• For most applications, a system must guarantee that the data received are
identical to the data transmitted.

• Many factors (Attenuation - loss of energy, distortion - changes its form or


shape, noise, and interference-unwanted signals) can alter one or more bits
of a message. Some applications require a mechanism for detecting and
correcting errors.

• Some applications can tolerate a small level of error. For example, random
errors in audio or video transmissions may be tolerable, but when we
transfer text, we expect a very high level of accuracy.

• Data link layer – error detection and correction functionality


Types of Errors

• Whenever bits flow from one point to another, they are subject to
unpredictable changes because of interference (change the shape of the
signal).

• Single-bit error: changed from 1 to 0 or from 0 to 1.


• Burst error: Two or more bits in the data unit have changed from 1 to 0 or
from 0 to 1
Redundancy

• The central concept in detecting or correcting errors is redundancy.

• To be able to detect or correct errors, we need to send some extra bits with
our data.

• These redundant bits are added by the sender and removed by the receiver.
Their presence allows the receiver to detect or correct corrupted bits.

example

Data Bits Redundant Bits


Sending same data two times.
110110101010101111 110110101010101111 Problem: Delay
110110101010101111 110111
Figure 10.3 The structure of encoder and decoder

10.5
Redundancy
• Redundancy is achieved through various coding schemes.

Block coding convolution coding.

• Parity check

• Cyclic redundancy check (CRC)

• Checksum
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.

K=3 bit Data words - 2^3 =8 Datawords are possible


n=5 bit code word – 2^5 = 32-8=14 code words are wasted

Since n > k, the number of possible codewords is larger than the number of possible
datawords
Question
1) For each of the following sets of codewords, please give the appropriate (n,k)
designation where n is number of bits in each codeword and k is the number of
message bits transmitted by each code word.
{111, 100, 001, 010}

• n=3, k=2 (there are 4 codewords)

2^k =2^2=4

2) {00000, 01111, 10100, 11011}

• n=5 k=2

2^k =2^2=4
BLOCK CODING

Error Detection
• Enough redundancy is added to detect an error.
• The receiver knows an error occurred but does not know which bit(s) is(are) in error.
• Has less overhead than error correction.

Error Correction
Detection versus Correction

• In error detection, we are only looking to see if any error has occurred.
• We are not even interested in the number of corrupted bits.

• In error correction, we need to know the exact number of bits that are
corrupted and, more importantly, their location in the message.
Error Detection
How can errors be detected by using block coding? If the following two conditions
are met, the receiver can detect a change in the original codeword.

1.The receiver has (or can find) a list of valid codewords.

2. The original codeword has changed to an invalid one.


Error Detection

Codeword (011)
Sender Receiver

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 (the leftmost bit
is corrupted). This is not a valid codeword and is discarded.

3. The codeword is corrupted during transmission, and 000 is received (the right two
bits are corrupted). This is a valid codeword. The receiver incorrectly extracts the
dataword 00. Two corrupted bits have made the error undetectable.
Error Detection
Let us add more redundant bits to Example 10.1 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. Table 10.2 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. The receiver, assuming that there is only 1 bit corrupted, uses the following
strategy to guess the correct dataword.

Table 10.2
Error Detection

Codeword (01011)
Sender Receiver
01001

1. Comparing the received codeword (01001) 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.

10.14
Hamming Distance
• The Hamming distance between two words (of the same size) is the number
of differences between the corresponding bits

• The Hamming distance between the received codeword and the sent codeword
is the number of bits that are corrupted during transmission

• The Hamming distance between two words x and y as d(x, y).

• The Hamming distance can easily be found if we apply the XOR operation
(⊕) on the two words and count the number of 1s in the result.

• If the codeword 00000 is sent and 01101 is received, 3 bits are in error and the
Hamming distance between the two is d(00000, 01101) = 3.
(00000 ⊕ 01101 =01101) =3 (three one’s)
Note
• “If the Hamming distance between the sent and the received
codeword is zero”, the codeword is not corrupted during
transmission.

• “If the Hamming distance between the sent and the received
codeword is not zero”, the codeword has been corrupted
during transmission.

• The Hamming distance is a value greater than or equal to zero.


Example 10.4

Let us find the Hamming distance between two pairs of


words.

1. The Hamming distance d(000, 011) is 2 because

2. The Hamming distance d(10101, 11110) is

3. The Hamming distance d(10101, 10101) is

10.
Minimum Hamming Distance for Error Detection
The minimum Hamming distance is the smallest Hamming distance between
all possible pairs of codewords

Find the minimum Hamming distance of the coding scheme

Solution: We first find all Hamming distances

The dmin in this case is 2.


Minimum Hamming Distance for Error Detection

Find the minimum Hamming distance of the coding scheme

The dmin in this case is 3.


Question
1) For each of the following sets of codewords, please give the appropriate (n,k,d)
designation where n is number of bits in each codeword, k is the number of message bits
transmitted by each code word and d is the minimum Hamming distance between
codewords.

{111, 100, 001, 010}

n=3, k=2 (there are 4 codewords), d = 2.

2){11111, 11110, 01011, 00100}

11111 ⊕ 11110 = 1 11111 ⊕ 01011 = 2 11111 ⊕ 00100 =4


11110 ⊕ 01011 = 2 11110 ⊕ 00100 = 3 01011 ⊕ 00100 = 4

n=5 , k=2 , d =1
Question
1) For each of the following sets of codewords, please give the appropriate (n,k,d)
designation where n is number of bits in each codeword, k is the number of message bits
transmitted by each code word and d is the minimum Hamming distance between
codewords.

{111, 100, 001, 010}

n=3, k=2 (there are 4 codewords), d = 2.

2){11111, 11110, 01011, 00100}


Minimum Hamming Distance for Error Detection
• If s errors occur during transmission, the Hamming distance between the
sent codeword and received codeword is s.

Example: If the codeword 00000 is sent and 01101 is received, S=3 bits are
in error and the Hamming distance between the two is d(00000, 01101) = S=3
(00000 ⊕ 01101 =01101) =3 (three one’s)
Minimum Hamming Distance for Error Detection
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.
The minimum Hamming distance for our first code scheme 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 2.


dmin = s + 1=1+1=2

If our system is to detect up to s errors, the minimum distance between the valid
codes must be (s + 1), so that the received codeword does not match a valid
codeword.
Minimum Hamming Distance for Error Detection
• Our second block code scheme has dmin = 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. The
receiver cannot be fooled.

The dmin in this case is 3.


dmin = s + 1=2+1=3

For example, if the second codeword (01011) is sent and one error occurs, the
received codeword does not match any valid codeword. If two errors occur, the
received codeword does not match any valid codeword. If three errors occur the
received codeword may match a valid codeword (01011 – 00000, instead of 01
the data 00 will be considered) and the errors are not detected.
Figure 10.8 Geometric concept for finding dmin in error detection

Let us assume that the sent codeword x is at the center of a circle with radius s.
All received codewords that are created by 0 to s errors are points inside the circle or
on the perimeter of the circle.

All other valid codewords must be outside the circle. This means that dmin must be an
integer greater than s or dmin = s + 1.
Question
• A code scheme has a Hamming distance dmin = 10. What is the
error detection capability of this scheme?

dmin = s + 1 =9+1=10
Question
• A code scheme has a Hamming distance dmin = 4. What is the
error detection capability of this scheme?
Question
• A code scheme has a Hamming distance dmin = 4. What is the
error detection capability of this scheme?

• This code guarantees the detection of up to three errors


(s = 3),

dmin = s + 1
LINEAR BLOCK CODES

Almost all block codes used today belong to a subset called linear
block codes. A linear block code is a code in which the exclusive
OR (addition modulo-2) of two valid codewords creates another
valid codeword.

In a linear block code, the exclusive OR (XOR)


of any two valid codewords creates another
valid codeword.
LINEAR BLOCK CODES
Let us see if the two codes we defined in Table 10.1 and Table
10.2 belong to the class of linear block codes.

1. The scheme in Table 10.1 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.

2. The scheme in Table 10.2 is also a linear block code.


We can create all four codewords by XORing two
other codewords.
Minimum Distance for Linear Block Codes
• It is simple to find the minimum Hamming distance for a linear block code.
The minimum Hamming distance is the number of 1s in the nonzero valid
codeword with the smallest number of 1s.

The numbers of 1s in the nonzero codewords are 2, 2, and 2. So the minimum


Hamming distance is dmin = 2.

The numbers of 1s in the nonzero codewords are 3, 3, and 4. So in this code we have dmin = 3.
Parity-Check Code
• This code is a linear block code.
• In this code, a k-bit dataword is changed to an n-bit codeword where n = k + 1.
• The extra bit, called the parity bit, is selected to make the total number of 1s in
the codeword even.
Table 10.3 Simple parity-check code C(n=5, k=4)

If the number of 1s is even in the dataword, the parity bit result is 0;


If the number of 1s is odd in the dataword, the parity bit result is 1
Encoder and decoder for simple parity-check code

r0 = a3 + a2 + a1 + a0 (modulo-2)

s0 = b3 + b2 + b1 + b0 + q0 (modulo-2)

• If the syndrome is 0, there is no detectable error in the received codeword; the data
portion of the received codeword is accepted as the dataword;

• If the syndrome is 1, the data portion of the received codeword is discarded. The
dataword is not created.
Encoder and decoder for simple parity-check code
Let us look at some transmission scenarios.
Codeword: 10111
Sender Receiver
Dataword: 1011

1.No error occurs; the received codeword is 10111. The syndrome is 0. The
dataword 1011 is created.

2. One single-bit error changes a1. The received codeword is 10011. The
syndrome is 1. No dataword is created.

3. One single-bit error changes r0. The received codeword is 10110. The
syndrome is 1. No dataword is created. Note that although none of the dataword
bits are corrupted, no dataword is created because the code is not sophisticated
enough to show the position of the corrupted bit.
Encoder and decoder for simple parity-check code
Let us look at some transmission scenarios.

Codeword: 10111
Sender Receiver
Dataword: 1011

4. An error changes r0 and a second error changes a3. The received codeword is
00110. The syndrome is 0. The dataword 0011 is created at the receiver. Note
that here the dataword is wrongly created due to the syndrome value. The
simple parity-check decoder cannot detect an even number of errors.

5. Three bits—a3, a2, and a1—are changed by errors. The received codeword is
01011. The syndrome is 1. The dataword is not created. This shows that the
simple parity check, guaranteed to detect one single error, can also find any
odd number of errors. But cannot detect an even number of errors
Note

A simple parity-check code can detect an odd


number of errors.
CYCLIC CODES
Properties of cyclic codes:
Linearity:
If two codeword are added, it resulting into another codeword
{0000, 0101, 1010, 1111} – codewords

0101 1111
1010 1010
1111 0101

Cyclic shifting:
• In a cyclic code, if a codeword is cyclically shifted (rotated), the
result is another codeword.

• For example, if 1010 is a codeword and we cyclically left-shift, then


0101 is also a codeword.
Cyclic Redundancy Check (CRC)
• Cyclic Redundancy Check (CRC) is an error detection method.
• It is based on binary division.
• The communicating parties agrees upon the size of message block and the
CRC divisor.
• For example, the block chosen may be CRC (7, 4), where 7 is the total
length of the block and 4 is the number of bits in the data segment. The
divisor chosen may be 1011.
• Used in networks such as LANs and WANs
Figure 10.15 Division in CRC encoder

Dataword:1001000
Divisor: 1011

Modulo 2 (XOR)

10.
Figure 10.16 Division in the CRC decoder for two cases

10.
Assume the data to be transmitted is
Data: 100100
Divisor:1101
Sender 100100 000 (one number less than the divisor)
111101
1101 100100000
1101
1000
1101 Sender sends the codeword to receiver:
1010 100100001
1101
1110
1101
0110
0000
1100
1101
001
Assume the data to be transmitted is
Data: 100100
Divisor:1101
Receiver received 100100001

111101
1101 100100001
1101
1000
1101
1010
1101
1110
1101
0110
0000
1101
1101
Syndrome=0 ---- no errors
0000
CRC encoder and decoder

• The dataword has k bits (4 here); the codeword has n bits (7 here).
• The size of the dataword is augmented by adding n − k (3 here) 0s to the right hand side
of the word. The n-bit result is fed into the generator.
• The generator uses a divisor of size n − k + 1 (4 here), predefined and agreed upon.
• The generator divides the augmented dataword by the divisor (modulo-2 division).
• The quotient of the division is discarded; the remainder (r2r1r0) is appended to the
dataword to create the codeword.
Question
A bit stream 10011101 is transmitted using the standard CRC
method. The divisor is 1001.
• What is the actual bit string transmitted?
Polynomials
• We can use a polynomial to represent a binary word.

Note
• The degree of a polynomial is the highest power in the polynomial. For example, the
degree of the polynomial x^6 + x + 1 is 6. Note that the degree of a polynomial is 1 less
than the number of bits in the pattern.

Addition: x5 + x4 + x2 Multiplication: x3 × x4 is x7
x6 + x4 + x2
x6 + x5 Division: x6/x3, or x3
Polynomials
1. The information sequence (x) =100100000. Write the corresponding polynomial
equation.

100100000 = 1. x^8+0.x^7+0.x^6+1.x^5+0.x^4+0.x^3+0.x^2+0.x^1+0.x^0 = x^8 + x^5

2. What is the corresponding polynomial of i) 100 ii) 1101 iii) 1 0 1 0 1 0


100 – x^2
1101 – x^3+X^2+1
101010 - X^5 +X^3 +X
1101101 - X6+x5+x3+x2+1

The divisor in a cyclic code is normally called the generator polynomial g(x) or
simply the generator.
Let Divisor / g(x)=x^3 + x+1. Consider the information sequence:1001000
1001000=x^6 +X^3

Sender
X^3+x

x^3 + x+1 x^6 +x^3


x^6+x^4+x^3
x^4
x^4+x^2+x Sender sends the codeword to receiver:
x^2+x x^6 +x^3+x^2+x

Note: we continue to divide until the degree of the remainder is less than the degree of
the divisor.
Let g(x)=x^3 + x+1. Consider the information sequence:1001011
1001011=x^6 +X^3

Receiver
X^3+x^1

x^3 + x+1 x^6 +x^3+x^2+x


X^6+x^4+x^3
X^4+X^2+X
X^4+X2+X Sender sends the codeword to receiver:
000
Question
• Generator: x^3 +X^2+1 Data :x^8 +x^5 Find the codeword
X5+X4
x^3 +X^2+1 x^8 +x^5
X^8+X^7+X5
X^7
X^7+x^5+x4
x^5+x4

x^3 +X^2+1 x^8 +x^5+1

0
Does CRC detect all errors (1 bit, 2bits and burst errors) ?
Divisor: 1 0 0
Message received = 1 0 1 0 1 1 0 0
Message received = message transmitted + error polynomial, i.e.,
1 0 1 0 1 1 0 0= 1 0 1 0 1 0 0 0 + 0 0 0 0 0 1 0 0

100 ) 1 0 1 0 1 1 0 0

000
• Clearly both are divisible by the divisor 1 0 0. In general, if the error polynomial is
divisible by the divisor, then such errors are undetected by the receiver. The receiver
wrongly concludes that there is no error in transmission

If the divisor is 1 0 1, then both errors are detected by the receiver. Thus,
choosing an appropriate divisor is crucial in detecting errors at the
receiver if any during the transmission.
Cyclic Code Analysis
• We can analyze a cyclic code to find its capabilities by using polynomials.
We define the following, where f(x) is a polynomial with binary
coefficients.

Dataword: d(x) Codeword: c(x) Generator: g(x) Syndrome: s(x) Error: e(x)

In a cyclic code,
If s(x) ≠ 0, one or more bits is corrupted.
If s(x) = 0, either

a. No bit is corrupted. or
b. Some bits are corrupted, but the decoder failed to detect them.
Cyclic Code Analysis
In our analysis we want to find the criteria that must be imposed on the
generator, g(x) to detect the type of error we especially want to be detected.

The received codeword is the sum of the sent codeword and the error.
Received codeword = c(x) + e(x)

The receiver divides the received codeword by g(x) to get the syndrome.

In a cyclic code, those e(x) errors that are divisible by g(x) are not caught.

Hence choosing an appropriate divisor (generator) is very important


to detect the errors
Cyclic Code Analysis
Let us show some specific errors and see how they can be caught by a well
designed g(x).

• Single-Bit Error
• Two Isolated Single-Bit Errors
• Odd Numbers of Errors
• Burst Errors
Note on Polynomials
• If a polynomial has no factors other than 1 and itself, it is a prime
polynomial or an Irreducible Polynomial.

• x2 + 1 (= 101) is not prime. because it has factors.

• Note any bitstring ending in 0 represents a polynomial that is not prime


since it has x as a factor.

• All primes look like 1....1

https://www.ece.unb.ca/tervo/ee4253/polytable.shtml

http://www.ee.unb.ca/cgi-bin/tervo/factor.pl?binary=11000001
Cyclic Code Analysis

What should the structure of G(x) be to guarantee the detection of a single-bit


error?

If the generator has more than one term and the coefficient of x0 is 1,
all single errors can be caught.

Example: x+1 , x^3+x+1, x^3+x^2+1


Cyclic Code Analysis
Which of the following g(x) values guarantees that a single-bit error is caught? For
each case, what is the error that cannot be caught?
a. x + 1 b. 1 c. x3

Solution
a. No xi can be divisible by x + 1. In other words, xi/(x + 1) always has a
remainder. Any single-bit error can be caught. Also, (x + 1) is irreducible.

b. xi/1
All values of i make xi divisible by g(x). No single-bit error can be caught. This
g(x) is useless.

c. If i is equal to or greater than 3, xi is divisible by g(x). The remainder of xi/x3 is


zero, and the receiver is fooled into believing that there is no error, although there
might be one.

All single-bit errors in positions 1 to 3 are caught


Odd Numbers of Errors
• A generator with a factor of x + 1 can catch all odd numbers of errors.
This means that we need to make x + 1 a factor of any generator.

• For example, x4 + x2 + x + 1 can catch all odd-numbered errors since it


can be written as a product of the two polynomials x + 1 and x3 + x2 + 1.

In another way,

If we make G(x) not prime but a multiple of (x+1), then E(x) can't be divided by G(x). can
detect all odd no. of errors.

G(x) =x8+x2+x+1 which is not prime. Factors are (x+1) (x7+x6+x5+x4+x3+x2+1)


Two Isolated Single-Bit Errors
• Now imagine there are two single-bit isolated errors. Under what
conditions can this type of error be caught?

• We can show this type of error as e(x) = x^j + x^i. The values of i and j
define the positions of the errors, and the difference j − i defines the
distance between the two errors,

e(x) = x^j + x^i.


We can write e(x) = x^i(x^j–i + 1).
Two Isolated Single-Bit Errors

We can write e(x) = x^i(x^j–i + 1).

If g(x) has more than one term and one term is x^0, it cannot divide x^i, as we saw in
the previous section. g(x) = more than one term +1 xi / (more than one term + 1)

g(x) must not divide x^t + 1, where t is between 0 and n − 1.

If a generator cannot divide xt + 1


(t between 0 and n – 1),
then all isolated double errors
can be detected.
Find the status of the following generators related to two isolated,
single-bit errors.
a. x4 + 1 b. x6 + 1 b. x7 + x6 + 1 c. x15 + x14 + 1

Solution
a. This generator cannot detect two errors that are four
positions apart. The two errors can be anywhere, but if their distance is 4,
they remain undetected.

b. This generator cannot detect two errors that are six


positions apart. The two errors can be anywhere, but if their distance is 6,
they remain undetected.

c. This is a good choice for this purpose. (Irreducible polynomial)

d. This polynomial cannot divide xt + 1 if t is less than


32,768. A codeword with two isolated errors up to
32,768 bits apart can be detected by this generator. (Irreducible polynomial)
10.
Note on polynomial generator selection
Burst Errors

• where L is the length of the error. All burst errors with length
smaller than or equal to the number of check bits r will be
detected
Burst Errors
Standard polynomials
The divisor polynomials are such that it detects almost all odd bit errors and a few even
bit errors. The commonly used polynomials in the literature are

Note
• Asynchronous Transfer Mode and refers to a communication protocol which can be used to
transfer data, videos and speech.

• ATM adoption layer is basically a software layer that accepts user data, which may be digitized
voice, video or computer data, and makes them suitable for transmission over an ATM network.

• HDLC is a group of data link (Layer 2) protocols used to transmit synchronous data packets
between point-to-point nodes.
Note: Ethernet Header
Advantages of Cyclic Codes
• Cyclic codes have a very good performance in detecting
single-bit errors, double errors, an odd number of errors, and
burst errors.

• They can easily be implemented in hardware and software.

• They are especially fast when implemented in hardware. This


has made cyclic codes a good candidate for many networks.
Other Cyclic Codes

• More powerful polynomials that are based on abstract algebra


involving Galois fields.

• One of the most interesting of these codes is the Reed


Solomon code used today for both detection and correction.
CHECKSUM

• Checksum is an error-detecting technique that can be applied


to a message of any length.
• Checksum= check +sum
• Sender side → Checksum creation
• Receiver side → Checksum validation
• Checksum technique is mostly used at the network and
transport layer rather than the data-link layer.
Traditional Checksum

• Sender wants to send a Message: (7, 11, 12, 0, 6)


• Sum of the numbers: 7+11+12+0+6 =36
• Message sent to receiver: (7, 11, 12, 0, 6, 36)
• 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 message is not
accepted.
One’s Complement Addition
• Each number (7,11,12,0,6) can be written as a 4-bit word (each is less than
15) except for the sum.
• If the number has more than m bits, the extra leftmost bits need to be added
to the m rightmost bits (wrapping).
• In this example, the decimal number 36 in binary is (100100)2. To change it
to a 4-bit number we add the extra leftmost bit to the right four bits as
shown below.

36 - 100100 45 – 101101

0100 1101
10 Binary addition 10
0110 =6 1111=15

Instead of sending 36 as the sum, we can send 6 as the sum (7, 11, 12, 0, 6, 6).
CHECKSUM

What is the reason for wrapping (the extra leftmost bits need to be added to the m
rightmost bits)?
CHECKSUM

• At the source, the message is first divided into m-bit units. The generator then creates an extra
m-bit unit called the checksum, which is sent with the message.

• At the destination, the checker creates a new checksum from the combination of the message
and sent checksum.

• If the new checksum is all 0s, the message is accepted; otherwise, the message is discarded
Internet Checksum

• Traditionally, the Internet has used a 16-bit checksum


Internet Checksum
Performance of Checksum error detection
• The traditional checksum uses a small number of bits (16) to detect errors in a
message of any size (sometimes thousands of bits). However, it is not as strong as
the CRC in error-checking capability.

Advantages:
– Fast checking
– Small number of bits required

Disadvantages:
For example, if the value of one word is incremented and the value of another word is
decremented by the same amount, the two errors cannot be detected because the sum
and checksum remain the same.

– Not robust
– Also, if the values of several words are incremented but the sum and the
checksum do not change, the errors are not detected.
Note
Other Approaches to the Checksum
• Fletcher and Adler have proposed some weighted checksums that eliminate the first
problem. However, the tendency in the Internet, particularly in designing new
protocols, is to replace the checksum with a CRC.

• Fletcher Checksum is a block code technique that was devised by John G. Fletcher
in 1970s at Lawrence Livermore Labs, USA.

• The error-detection capabilities of this method is nearly same as that of Cyclic


Redundancy Check (CRC) but requires much less computational effort.
Fletcher Checksum
• Fletcher has proposed two algorithms: 8-bit and 16-bit.
• The first, 8-bit Fletcher, calculates on 8-bit data items and creates a 16-bit
checksum.
• The second, 16-bit Fletcher, calculates on 16-bit data items and creates a 32-
bit checksum.
Basics
• 258 mod 256 =2
Note: A=10 B=11 C=12 D=13 E=14 F=15
• 300 mod 256 =44
• 121 mod 256 = 121

Convert Hexadecimal to Decimal


• 6A = (6 * 161) + (10 * 160) = 106
• 7DE = (7 * 162) + (13 * 161) + (14 * 160) = 2014
• AF = 175
• 69 = 105
Convert Decimal to Hexadecimal
• (45)10 = (2D)16 16 45

• (106)10 = (6A)16 2 -13

• (212)10 = D4
Simulate the Fletcher algorithm to calculate the checksum of the following
bytes: (2B)16 , (3F)16, (6A) (AF)16. Also show that the result is a weighted
16,

checksum
Di R=0 L=0
Step1 2B 2B 2B
Step2 3F 6A 95
Step3 6A D4 69
Step4 AF 83 EC
CHEKSUM = L R = EC 83
Checksum= (EC X 256) + 83
= 236 X 256 = 60416 = (3776 )16
3776+ 83 = (37F9) 16
Step2:
2B = 2x16^1 + Bx16^0 = 32+11=43
3F = 48 + 15 =63 Step3:
R= 43+63= 106 = (6A)16 R= 6A + 6A = 106 + 106 =212 = (D4)16
L= 2B+6A = 43+106 =149 =(95)16 L= 95 + D4 = 149 +212 = 361 mod 256 =105 = (69)

Step4:
R=AF+D4 = 175+212 =387 mod 256 = 131 = 83
L= 69 + 83 = 105 + 131 = 236 =EC
Simulate the 8-bit Fletcher algorithm to calculate the 16-bit checksum of the
following bytes: (2A)16 , (3B)16,

Di R=0 L=0
Step1
Step2
CHEKSUM = L R =
Simulate the Fletcher algorithm to calculate the checksum of the
following bytes: (2B)16 , (3F)16, (6A) (AF)16. Also show that the
16,

result is a weighted checksum

R= (D1+D2+D3+D4)=2B +3F+6A+AF =83


L= (4xD1+3xD2+2xD3+1xD4)= EC

L R EC 83
Fletcher Checksum (16 bit)
• The second, 16-bit Fletcher, calculates on 16-bit data items and creates a
32-bit checksum.

• The 16-bit Fletcher checksum is similar to the 8-bit Fletcher checksum, but
it is calculated over 16-bit data items and creates a 32-bit checksum. The
calculation is done modulo 65,536.
Adler Checksum
• The Adler checksum is a 32-bit checksum

If Di =(16FC, 3B2D, 49A6)16 Calculate the checksum using Adlers Algorithm


FORWARD ERROR CORRECTION (FEC)
• We discussed error detection and retransmission in the previous sections. However,
retransmission of corrupted and lost packets is not useful for real-time multimedia
because it creates an unacceptable delay in reproducing: we need to wait until the lost or
corrupted packet is resent.

• We need to correct the error or reproduce the packet immediately. Several schemes have
been designed and used in this case that are collectively referred to as forward error
correction (FEC) techniques.

• Forward error correction works by adding redundant bits to a bitstream to help the
decoder detect and correct some transmission errors without the need for retransmission.
The name forward stems from the fact that the flow of data is always in
the forward direction (i.e., from encoder to decoder).

• FEC using Hamming distance


• FEC using XOR
• FEC using chunk Interleaving
• FEC using compounding
Recap of Hamming Distance
• The Hamming distance between two words (of the same size) is the number of
differences between the corresponding bits

• If the codeword 00000 is sent and 01101 is received, 3 bits are in error and the
Hamming distance between the two is d(00000, 01101) = 3.
(00000 ⊕ 01101 =01101) =3 (three one’s)

The dmin in this case is 3.

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.
Forward Error Correction using Hamming Distance
Encoded bit sequence Corresponding Codeword
Min Hamming Distance
00 00000
10000 111 01010
01 11100 10

10 10011 1 4 2
11 01111 2 1 3
2 3 3
Data: 01 00 01 11 10 00 01
5 2 2

11100 00000 11100 01111 10011 00000 11100

11100 10000 11110 01010 10011 10011 10000

00 11
00
01 00 01 Resend 10 10

Undetectable error has transmitted. Three bit error is not possible to detect in this example.
We can make it robust by having longer codewords!
Forward Error Correction using Hamming Distance
• We said that to detect s errors, the minimum Hamming distance should be
dmin = s + 1

• For error detection, we definitely need more distance. It can be shown that
to detect t errors, we need to have dmin = 2t + 1

• If we want to correct 10 bits in a packet, we need to make the minimum


hamming distance 21 bits, which means a lot of redundant bits need to be
sent with the data.

• To give an example, consider the famous BCH code. In this code, if data is
99 bits, we need to send 255 bits (extra 156 bits) to correct just 23 possible
bit errors. Most of the time we cannot afford such a redundancy
Questions
(It can be shown that to detect t errors, we need to have dmin = 2t + 1)

• If we wish to detect 8 errors, what should be the minimum


hamming distance?
17

• The minimum hamming distance is 31, how many errors you


can detect?
15
Forward Error Correction using using XOR
R = P1 ⊕ P2 ⊕ … ⊕ Pi ⊕… ⊕ PN

Pi = P1 ⊕ P2 ⊕ … ⊕ R ⊕ … ⊕ PN

• If we apply the exclusive OR operation on N data items (P1 to PN), we can recreate
any of the data items by exclusive-ORing all of the items, replacing the one to be
created by the result of the previous operation (R).

• We can divide a packet into N chunks, create the exclusive OR of all the chunks and
send N + 1 chunks. If any chunk is lost or corrupted, it can be created at the receiver
site.
Data: 0011 0100 0000 0011 || 0100
0011 0011
⊕ 0100 0100
0111 0111
⊕ 0000 0100
0111 0011
⊕ 0011 0011
R=0100 0000
Forward Error Correction using chunk Interleaving
• we can divide each packet into 5 chunks (normally the number is much larger). We
can then create data chunk by chunk (horizontally), but combine the chunks into
packets vertically. In this case, each packet sent carries a chunk from several
original packets. If the packet is lost, we miss only one chunk in each packet, which
is normally acceptable in multimedia communication.

Assume checksum is added at the end.

5+4+3+2+1=15 15-1=14-2=12=12-4=8-5=3
Forward Error Correction using –
Combining Hamming Distance and Interleaving
• Hamming distance and interleaving can be combined.
• We can first create n-bit packets that can correct t-bit errors. Then we
interleave m rows and send the bits column by column.
• In this way, we can automatically correct burst errors up to m × t-bit errors.
Forward Error Correction using –
Compounding High- and Low-Resolution Packets

• Still another solution is to create a duplicate of each packet with a low-


resolution redundancy and combine the redundant version with the next
packet.
• For example, we can create four low-resolution packets out of five high-
resolution packets and send them as shown in Figure.
• If a packet is lost, we can use the low-resolution version from the next
packet. Note that the low-resolution section in the first packet is empty.
• In this method, if the last packet is lost, it cannot be recovered, but we use
the low-resolution version of a packet if the lost packet is not the last one.
• The audio and video reproduction does not have the same quality, but the
lack of quality is not recognized most of the time.
Forward Error Correction using-
Compounding High- and Low-Resolution Packets
References

• Forouzan, A. Behrouz. Data communications &


networking (sie). Tata McGraw-Hill Education,
5th Edition.

You might also like