Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 37

Data Link Layer Topics to Cover

Error Detection and Correction


Data Link Control and Protocols
Multiple Access
Local Area Networks
Wireless LANs
Error Detection
• Why we need it ?
– To avoid retransmission of whole packet or
message
• What to do if error detected ?
– Discard, and request a new copy of the
frame:
• explicitly or implicitly
– Try to correct error, if possible
Types of Errors
• Single Bit Error  Burst Error
– In a single-bit
 A burst error
means that 2 or
error, only 1 bit
more bits in the
in the data unit
data unit have
has changed. changed.
Redundancy
• To detect or correct errors, we need to send
extra (redundant) bits with data.
Error Detection
Simple Parity Check
• A simple parity-check code is a single-bit error-
detecting code in which n = k + 1.
Example
• 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 dataword 1011
is created.
2. One single-bit error changes a1 . The received
codeword is 10011. No dataword is created.
3. One single-bit error changes r0 . The received codeword is 10110. The
syndrome is 1. No dataword is created.
Example (contd.)
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.
Performance
• A Simple parity check can detect all single-bit
errors. It can detect burst errors only if the
total number of errors in each data unit is odd.
Two-dimensional Parity-check Code
Simple parity can detect burst errors only if the total number of errors
in each data unit is odd.
In two-dimensional parity check, a block of bits is divided into rows and
a redundant row of bits is added to the whole block.
Example
• Suppose the following block is sent:
10101001 00111001 11011101 11100111 10101010

• However, it is hit by a burst noise of length 8, and some bits are


corrupted.
10100011 10001001 11011101 11100111 10101010

• When the receiver checks the parity bits, some of the bits do not
follow the even-parity rule and the whole block is discarded.
10100011 10001001 11011101 11100111 10101010
Performance
• 2D parity check increases the likelihood of
detecting burst errors. As we have seen in the
example given in the previous slide, a
redundancy of n bits can easily detect a burst
error of n bits. There is, however, one pattern
of errors that remains un-detectable. If 2 bits
in one data unit are damaged and 2 bits in
exactly in the same positions in another data
unit are also damaged, the checker will not
detect an error.
Cyclic Redundancy Check
•Cyclic Redundancy Check (also called polynomial code)
•Based on binary division
• No carries
• Subtraction is equivalent to XOR
Binary division in a CRC generator
In the encoder,
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 dataword by the
divisor .
The quotient of the division is discarded;
the remainder (r2r1r0) is appended to the dataword to create the codeword.
There is one important point we need to remember in this type of division. If the leftmost
bit of the dividend (or the part used in each step) is 0, the step cannot use the regular
divisor; we need to use an all-0s divisor.
When there are no bits left to pull down
Binary division in a CRC checker
A polynomial to represent a binary word
• A pattern of 0s and 1s can be represented as a polynomial
with coefficients of 0 and 1. The power of each term shows
the position of the bit; the coefficient shows the value of the
bit.
CRC division using polynomials

Some standard polynomials used by popular
protocols for CRC generation

Summary
• CRC can detect all burst errors that affect an
odd number of bits.
• CRC can detect all burst errors of length less
than or equal to the degree of polynomial.
• CRC can detect, with a very high propability,
burst errors of length greater than the degree
of polynomial.
Checksum
• The sender follows these steps:
i. The unit is divided into k sections, each of n bits.
ii. All sections are added using one’s complement to get the sum.
iii. The sum is complemented and becomes the checksum.
iv. The checksum is sent with the data.

• The receiver follows these steps:


i. The unit is divided into k sections, each of n bits.
ii. All sections are added using one’s complement to get the sum.
iii. The sum is complemented.
iv. If the result is zero, the data are accepted: otherwise, rejected.
• Suppose the message 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
message is not accepted.

Checksum: Sending
Suppose the following block of 16 bits is to be sent using a
checksum of 8 bits.
10101001 00111001
The numbers are added using one’s complement
10101001
00111001
------------
Sum 11100010
• Checksum 00011101 (Take 1’s complement of Sum)
• The pattern sent is 10101001 00111001 00011101
Checksum: Receiving
Now suppose the receiver receives the pattern sent and
there is no error.
10101001 00111001 00011101
• When the receiver adds the three sections, it will get all
1s, which, after complementing, is all 0s and shows that
there is no error.
10101001
00111001
00011101
Sum 11111111
Complement 00000000 means that the pattern is OK.
Checksum: Error
A burst error of length 5 that affects 4 bits.
10101111 11111001 00011101
• When the receiver adds the three sections, it gets
10101111
11111001
00011101
Partial Sum 1 11000101
Carry 1
Sum 11000110 => Complement
00111001 !!!??
ERROR CORRECTION

• Retransmission
• flow and error control protocols
• Forward Error Correction
– require more redundancy bits
– should locate the invalid bit or bits
– n-bit code word contains m data bits + r
redundancy bits ,n=m+r
i. Hamming code
ii. Burst Error Correction
Data and redundancy bits
Number of Number of Total
data bits redundancy bits bits
m r m+r
1 2 3
2 3 5
3 3 6
4 3 7
5 4 9
6 4 10
7 4 11
Hamming Code
• Hamming codes provide for FEC using a “Block
Parity”
– i.e, instead of one parity bit send a block of parity
bits
• Allows correction of single bit errors
• This is accomplished by using more than one
parity bit
Positions of Redundancy Bits
Redundancy Bits Calculation
Example
Calculating the Hamming Code
• The key to the Hamming Code is the use of extra parity bits to allow the
identification of a single error. Create the code word as follows:
• Mark all bit positions that are powers of two as parity bits. (positions 1, 2, 4, 8, 16,
32, 64, etc.)
• All other bit positions are for the data to be encoded. (positions 3, 5, 6, 7, 9,10, 11,
12, 13, 14, 15, 17, etc.)
• Each parity bit calculates the parity for some of the bits in the code word. The
position of the parity bit determines the sequence of bits that it alternately checks
and skips.
• Position 1: check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc. (1,3,5,7,9,11,13,15,...)
• Position 2: check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, etc.
(2,3,6,7,10,11,14,15,...)
• Position 4: check 4 bits, skip 4 bits, etc. (4,5,6,7,12,13,14,15,...)
• Position 8: check 8 bits, skip 8 bits, etc. (8-15,24-31,40-47,...)
• Set a parity bit to 1 if the total number of ones in the positions it checks is odd.
• Set a parity bit to 0 if the total number of ones in the positions it checks is even.
Error Correction using Hamming Code
Burst Error Correction
Burst error correction
• Although the Hamming code cannot correct a burst error directly, it is possible
to rearrange the data and then apply the code.
• Instead of sending all the bits in a data unit together, we can organize N units
in a column and then send the first bit of each, followed by the second bit of
each, and so on.
• In this way, if a burst error of M bits occurs (M<N), then the error does not
corrupt M bit of one single unit; it corrupts only 1 bit of a unit.
• Organize the six data units into columns and rows. We send the first column,
then the second column, and so on. The bits that are corrupted by a burst error
are shown in squares. Five consecutive bits are corrupted during the actual
transmission.
• However, when these bits arrive at the destination and are reorganized into
data units, each corrupted bit belongs to one unit and is automatically
corrected. The trick here is to let the burst error corrupt only 1 bit of each unit.
• Errors can be categorized as a single-bit error or a burst error. A single-bit error has one bit error
per data unit. A burst error has two or more bit errors per data unit.
• Redundancy is the concept of sending extra bits for use in error detection.
• Three common redundancy methods are parity check, cyclic redundancy check (CRC), and
checksum.
• An extra bit (parity bit) is added to the data unit in the parity check.
• The parity check can detect only an odd number of errors; it cannot detect an even number
oferrors.
• In the two-dimensional parity check, a redundant data unit follows n data units.
• CRC, a powerful redundancy checking technique, appends a sequence of redundant bits derived
from binary division to the data unit.
• The divisor in the CRC generator is often represented as an algebraic poly-nomial.
• Errors are corrected through retransmission and by forward error correction.
• The Hamming code is an error correction method using redundant bits. The number of bits is a
function of the length of the data bits.
• In the Hamming code, for a data unit of m bits, use the formula 2 r >= m +r +1 to determine r,
the number of redundant bits needed.
• By rearranging the order of bit transmission of the data units, the Hamming code can correct
burst errors.

You might also like