Lesson 3.1 Error Detection Correction

Download as pdf or txt
Download as pdf or txt
You are on page 1of 67

Chapter 3 – Data Link layer

3.1 Error Detection and Correction

10.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Outline

◼ Overview of data link layer


◼ Error detection and correction
Overview of Data Link layer

◼ Role: transform the physical layer (a raw transmission


facility) to a link responsible for node-to-node
communications.
◼ Responsibilities:
◼ Framing: divides the bit stream received from the network
layer to manageable data units (frames).
◼ Addressing: adds a header to a frame to define the address
of sender and receiver.
◼ Flow control: to avoid overwhelming (choáng ngợp)
receiver when receiving rate is smaller than sending rate.
◼ Error control: adds mechanisms to detect and retransmit
damaged, duplicate and lost frames.
◼ Media access control: determines which devices get access
to a shared link at a given time the when more than 2
devices are connected with the same link
Note

Data can be corrupted


during transmission.

Some applications require that


errors be detected and corrected.

10.4
3-1 INTRODUCTION

Let us first discuss some issues related, directly or


indirectly, to error detection and correction.

Topics discussed in this section:


Types of Errors
Redundancy
Detection Versus Correction
Forward Error Correction Versus Retransmission
Coding
Modular Arithmetic

10.5
Note

In a single-bit error, only 1 bit in the data


unit has changed.

10.6
Figure 10.1 Single-bit error

10.7
Note

A burst error means that 2 or more bits


in the data unit have changed.

10.8
Figure 10.2 Burst error of length 8

10.9
Note

To detect or correct errors, we need to


send extra (redundant) bits with data.

10.10
Figure 10.3 The structure of encoder and decoder

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.

10.11
Detection Versus Correction

o The correction of errors is more difficult than the detection.


o In error detection, we are only looking to see if any error has
occurred. The answer is a simple yes or no. We are not even
interested in the number of corrupted bits. A single-bit error is the same
for us as a burst error.
o In error correction, we need to know the exact number of bits that are
corrupted and, more importantly, their location in the message. The
number of errors and the size of the message are important factors.
o If we need to correct a single error in an 8-bit data unit, we need to
consider eight possible error locations.
o if we need to correct two errors in a data unit of the same size, we
need to consider 28 (permutation of 8 by 2) possibilities. You can
imagine the receiver’s difficulty in finding 10 errors in a data unit of
1000 bits.

10.12
Coding

o Redundancy is achieved through various coding schemes. The sender


adds redundant bits through a process that creates a relationship
between the redundant bits and the actual data bits.
o The receiver checks the relationships between the two sets of bits to
detect errors. The ratio of redundant bits to data bits and the
robustness of the process are important factors in any coding scheme.

10.13
Note

In this book, we concentrate on block


codes; we leave convolution codes
to advanced texts.

10.14
Figure 10.4 XORing of two single bits or two words (Modulo-2)

10.15
3-2 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.

Topics discussed in this section:


Error Detection
Error Correction
Hamming Distance
Minimum Hamming Distance

10.16
Figure 10.5 Datawords and codewords in block coding

10.17
Example 10.1

The 4B/5B block coding discussed in Chapter 4 is a good


example of this type of coding. In this coding scheme,
k = 4 and n = 5. As we saw, we have 2k = 16 datawords
and 2n = 32 codewords. We saw that 16 out of 32
codewords are used for message transfer and the rest are
either used for other purposes or unused.

10.18
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 a list of valid codewords.
2. The original codeword has changed to an invalid one

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

10.19
Figure 10.6 Process of error detection in block coding

10.20
Example 10.2

10.21
Note

An error-detecting code can detect


only the types of errors for which it is
designed; other types of errors may
remain undetected.

10.22
Figure 10.7 Structure of encoder and decoder in error correction

10.23
Example 10.3

Let us add more redundant bits to Example 10.2 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 (đoán) the correct dataword.

10.24
Example 10.3 (continued)
1. 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 (lý luận), 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 (tham khảo) the table
to find the dataword 01.
10.25
Table 10.2 A code for error correction (Example 10.3)

10.26
Note

The Hamming distance between two


words is the number of differences
between corresponding bits.

10.
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 because

10.
Note

The minimum Hamming distance is the


smallest Hamming distance between
all possible pairs in a set of words.

10.
Example 10.5

Find the minimum Hamming distance of the coding


scheme in Table 10.1.
Solution
We first find all Hamming distances.

The dmin in this case is 2.

10.
Example 10.6

Find the minimum Hamming distance of the coding


scheme in Table 10.2.

Solution
We first find all the Hamming distances.

The dmin in this case is 3.

10.
Note

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.

10.
Geometric concept explaining dmin in error detection

We can look at this criteria geometrically. 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.

10.
Example 10.7

The minimum Hamming distance for our first code


scheme (Table 10.1) 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.

10.
Note

To guarantee correction of up to t errors


in all cases, the minimum Hamming
distance in a block code
must be dmin = 2t + 1.

10.
Geometric concept for finding dmin in error correction

10.
Example 10.9

A code scheme has a Hamming distance dmin = 4. What is


the error detection and correction capability of this
scheme?

Solution
This code guarantees the detection of up to three errors (s =
3), but it can correct up to one error. In other words, if this
code is used for error correction, part of its capability is
wasted. Error correction codes need to have an odd
minimum distance (3, 5, 7, . . . ).

10.
10-3 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.

10.
Note

In a linear block code, the exclusive OR


(XOR) of any two valid codewords
creates another valid codeword.

10.
Note

A simple parity-check code is a


single-bit error-detecting code in which
n = k + 1 with dmin = 2.
Even parity (ensures that a codeword
has an even number of 1’s) and odd
parity (ensures that there are an odd
number of 1’s in the codeword).

10.
Table 10.3 Simple parity-check code C(5, 4)

10.
Figure 10.10 Encoder and decoder for simple parity-check code

10.
Example 10.12

Let us look at some transmission scenarios. Assume the


sender sends the dataword 1011. The codeword created
from this dataword is 10111, which is sent to the receiver.
We examine five cases:

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.
10.
Example 10.12 (continued)

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

10.
Note

A simple parity-check code can detect an


odd number of errors.

10.
Figure 10.11 Two-dimensional parity-check code

10.
Figure 10.11 Two-dimensional parity-check code

10.
Figure 10.11 Two-dimensional parity-check code

10.
Note

All Hamming codes have dmin = 3 (2 bit


error detection and single bit error
correction).
A codeword consists of n bits of which k
are data bits and r are check bits.
Let m = r, then we have: n = 2m -1
and k = n-m

10.
Figure 10.12 The structure of the encoder and decoder for a Hamming code

10.
Figure 10.11 Two-dimensional parity-check code

Create r: Calculate s:
r0=a2⊕a1 ⊕a0 s0=b2⊕b1 ⊕b0 ⊕q0
r1=a3⊕a2 ⊕a1 s1=b3⊕b2 ⊕b1 ⊕q1
r2=a1⊕a0 ⊕a3 s2=b1⊕b0 ⊕b3 ⊕q2

Sydrome 000 001 010 011 100 101 110 111


Error None q0 q1 b2 q2 b0 b3 b1

10.
Example 10.13

10.
Example 10.14

10.
Burst Errors
◼ Burst errors are very common, in particular in
wireless environments where a fade will
affect a group of bits in transit. The length of
the burst is dependent on the duration of the
fade.
◼ One way to counter burst errors, is to break
up a transmission into shorter words and
create a block (one word per row), then have
a parity check per word.
◼ The words are then sent column by column.
When a burst error occurs, it will affect 1 bit
in several words as the transmission is read
back into the block format and each word is
checked individually.
Figure 10.13 Burst error correction using Hamming code

10.
10-4 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.

10.
Table 10.6 A CRC code with C(7, 4)

10.
Figure 10.14 CRC encoder and decoder

10.
Figure 10.15 Division in CRC encoder

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

10.
10-5 CHECKSUM

The last error detection method is called the checksum.


The checksum is used in the Internet by several
protocols although not at the data link layer.

10.
Example 10.18

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.
Example 10.19

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.

10.
Example 10.20

How can we represent the number 21 in one’s


complement arithmetic using only four bits?

Solution
The number 21 in binary is 10101 (it needs five bits). We
can wrap the leftmost bit and add it to the four rightmost
bits. We have (0101 + 1) = 0110 or 6.

10.
Example 10.21

How can we represent the number −6 in one’s


complement arithmetic using only four bits?

Solution
In one’s complement arithmetic, the negative or
complement of a number is found by inverting all bits.
Positive 6 is 0110; negative 6 is 1001. If we consider only
unsigned numbers, this is 9. In other words, the
complement of 6 is 9. Another way to find the complement
of a number in one’s complement arithmetic is to subtract
the number from 2n − 1 (16 − 1 in this case).

10.
Note

Sender site:
1. The message is divided into 16-bit words.
2. The value of the checksum word is set to 0.
3. All words including the checksum are
added using one’s complement addition.
4. The sum is complemented and becomes the
checksum.
5. The checksum is sent with the data.

10.
Note

Receiver site:
1. The message (including checksum) is
divided into 16-bit words.
2. All words are added using one’s
complement addition.
3. The 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.

You might also like