Module-3.1 Error Detection and Correction

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

Module-3

Data Link Layer


Data link layer duties

Error Detection and Correction

• Data can be corrupted during transmission.


• For reliable communication, error must be detected and corrected.
• Error Detection and Correction are implemented either at the data link layer or the
transport layer of the OSI model.

Type of Errors
Single-Bit
~ is when only one bit in the data unit has changed.

Single bit errors are the least likely type of errors in serial data transmission
because the noise must have a very short duration which is very rare. However
this kind of errors can happen in parallel transmission.

Example:
 If data is sent at 1Mbps then each bit lasts only 1/1,000,000 sec. or 1 μs.
 For a single-bit error to occur, the noise must have a duration of only 1 μs,
which is very rare.
Burst Error

~ means that 2 or more consecutive bits in the data unit have


changed.

In Burst errors, the length of the burst is measured from the first corrupted bit to the
last corrupted bit. Some bits in between may not have been corrupted.
 Burst error is most likely to happen in serial transmission since the
duration of noise is normally longer than the duration of a bit.
 The number of bits affected depends on the data rate and duration of noise.
Example:
 If data is sent at rate = 1Kbps then a noise of 100 sec can affect 10
bits.(1/100*1000)

 If same data is sent at rate = 1Mbps then a noise of 100 sec can affect
10,000 bits.(1/100*106)
Error Detection
• Error detection means to decide whether the received data is
correct or not without having a copy of the original message.
• Error detection uses the concept of redundancy, which
means adding extra bits for detecting errors at the
destination.
Error Detection Methods
Vertical Redundancy Check (VRC)
– A parity bit is added to every data unit so that the total number of
1s (including the parity bit) becomes even for even-parity check or
odd for odd-parity check
– Simple parity check
Parity Calculation
Assuming even parity, find the parity bit for each of the
following data units.
a. 1001011
b. 0001100
c. 1000000
d. 1110111
Assuming odd parity, find the parity bit for each of the following data
units.
a. 1001011
b. 0001100
c. 1000000
d. 1110111
Example

Suppose the sender wants to send the word world. In ASCII


the five characters are coded as
1110111 1101111 1110010 1101100 1100100
The following shows the actual bits sent
11101110 11011110 11100100 11011000 11001001
Now suppose the word world is received by the receiver without being
corrupted in transmission.
11101110 11011110 11100100 11011000 11001001
The receiver counts the 1s in each character and comes up with even
numbers (6, 6, 4, 4, 4). The data are accepted.
Contd..

Now suppose the word world is corrupted during transmission.


Sent: 11101110 11011110 11100100 11011000 11001001
Received:11111110 11011110 11101100 11011000 11001001
The receiver counts the 1s in each data block and comes up with even
and odd numbers (7, 6, 5, 4, 4).
So, the receiver knows that the data are corrupted, discards them,
and asks for retransmission.
Performance
 It can detect single bit error.
 It can detect burst errors only if the total number of errors is odd.
Sent Received (Single-bit) Received (Burst)
11100001 0100001 (first bit is 0101001 (1st bit and 4th
changed) bit changed)
1000001 1000011
1110001 0110001
1101001 Conclusion: Receiver
1100101 accepts the data
1100011 0001001
1100000 1010011

Conclusion: The receiver discards the data. Conclusion: Receiver


discards
Longitudinal Redundancy Check (or)
Two –Dimensional Parity Check
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 10001000 11011101 11100111 00110001

Performance

LCR increases the likelihood of detecting burst errors.

If two bits in one data units are damaged and two bits in exactly the same
positions in another data unit are also damaged, the LRC will not detect an error.
CRC (Cyclic Redundancy Check)
~ is based on binary division.
(cont’d)

• Polynomials
– CRC generator(divisor) is most often represented not as a string of 1s and 0s,
but as an algebraic polynomial.

- A polynomial representing a divisor


Standard polynomials
Sender Calculation
~ uses modular-2 division.

Binary Division
in a
CRC Generator
Receiver Calculation

Binary Division
in a
CRC Checker
Checksum @ Sender Side by binary arithmetic

• To create the checksum the sender does the following:


1. In checksum error detection scheme, the data is divided
into k segments each of m bits.
2. In the sender’s end the segments are added to get the
sum.
3. The sum is complemented to get the checksum.
4. The checksum segment is sent along with the data
segments.
5. At the receiver’s end, all received segments are added to
get the sum. The sum is complemented.
6. If the result is zero, the received data is accepted;
otherwise discarded.
• Checksum Generator
Example
• Sender Calculation • Receiver calculation
Original data : 10101001 Received data : 10101001
00111001 00111001 00011101
10101001 10101001
00111001 00111001
--------------
--------------
11100010 Sum
11100010 Sum
00011101  3rd Section
00011101 Checksum ---------------
(1’s Complement) 11111111  Sum
10101001 00111001 00011101 00000000  Checksum (1’s
Complement of sum
@receiver end)
Example
Internet Checksum by Hexadecimal
A sender needs to send the four data items 3456, ABCC, 02BC, and
EEEE (Data are in Hex).
Answer the following:
i. Find the checksum at the sender site.
ii. Find the checksum at the receiver site if there is no error.
ii. Find the checksum at the receiver site if the second data item is
changed to ABCE.
iv Find the checksum at the receiver site if the second data item is
changed to ABCE and the third data item is changed to 02BA.
Conclusion
Practice Problems
1. Given the data word 101001111 and the divisor 10111, show the generation of
the CRC code word at the sender site (using binary division).
2. The sender transmits 1011 data word and uses 1001 as a divisor. Perform CRC
calculation @both side and provide receiver conclusion. CRC-010
3. The source is transmitting the following sequence of data bits to the receiver.
10110010010010111011001001001011
4. Perform checksum at the sender side by making 8 bit data word. Assume that the
leftmost bit in each segment is inverted due to noise on the transmission link. How the
receiver identifies that there is an error in the received data word?
5. A sender needs to send the four data items 7891, CCAB, D0BC, and
3FA1 (Data are in Hex).
Answer the following:
i. Find the checksum at the sender site.
ii. Find the checksum at the receiver site if there is no error.
ii. Find the checksum at the receiver site if the first data item is changed to ABCE.
iv Find the checksum at the receiver site if the second data item is changed to ABCE
and the third data item is changed to 02BA.
Error Correction
~ can be handled in two ways.
 when an error is discovered, the receiver can ask the sender retransmit
the entire data unit.

 a receiver can use an error-correcting code, which automatically corrects


certain errors.
Hamming Code

• Hamming code is a block code that is capable of detecting up to two


simultaneous bit errors and correcting single-bit errors. It was developed
by R.W. Hamming for error correction.
• In this coding method, the source encodes the message by inserting
redundant bits within the message. These redundant bits are extra bits
that are generated and inserted at specific positions in the message itself
to enable error detection and correction. When the destination receives
this message, it performs recalculations to detect errors and find the bit
position that has error.
1. Calculation of redundant bit
2r  m + r + 1
2. Arranging data bit and parity bit – Parity bit occupies the bit positions that
are power of two (1,2,4,8,16,…).
Step-3: Calculating the values of each redundant bit
Parity Bit Calculation-Rules

• Each redundancy parity bit is the VRC bit for one combination
of data bits
r1 = bits @ 1, 3, 5, 7, 9, 11
r2 = bits @ 2, 3, 6, 7, 10, 11
r4 = bits @ 4, 5, 6, 7
r8 = bits @ 8, 9, 10, 11
Example –Sender side Calculation

• Calculating the r values

Calculating Even Parity


Receiver Side Calculation
Hamming Distance

• Hamming distance is a metric for comparing two binary data strings.


While comparing two binary strings of equal length, Hamming distance is
the number of bit positions in which the two bits are different.
• The Hamming distance between two strings, a and b is denoted as d(a,b).
• It is used for error detection or error correction when data is transmitted
over computer networks. It is also using in coding theory for comparing
equal length data words.
Calculation of Hamming Distance
• In order to calculate the Hamming distance between two strings, and , we
perform their XOR operation, (a⊕ b), and then count the total number of
1s in the resultant string.
Example
• Suppose there are two strings 1101 1001 and 1001 1101.
• 11011001 ⊕ 10011101 = 01000100. Since, this contains two 1s, the
Hamming distance, d(11011001, 10011101) = 2.
Minimum Hamming Distance

• In a set of strings of equal lengths, the minimum Hamming


distance is the smallest Hamming distance between all
possible pairs of strings in that set.
Example
Suppose there are four strings 010, 011, 101 and 111.
• 010 ⊕ 011 = 001, d(010, 011) = 1.
• 010 ⊕ 101 = 111, d(010, 101) = 3.
• 010 ⊕ 111 = 101, d(010, 111) = 2.
• 011 ⊕ 101 = 110, d(011, 101) = 2.
• 011 ⊕ 111 = 100, d(011, 111) = 1.
• 101 ⊕ 111 = 010, d(011, 111) = 1.
Hence, the Minimum Hamming Distance, dmin = 1.
DIY
1. A 7-bit hamming code is received as 1011011. Assume even parity and state
whether the received code is correct or not. If wrong, locate the bit in error.
2. Test if these code words are correct, assuming they were created using an even
parity Hamming Code. If one is incorrect, indicate what the correct code word should
have been. Also, indicate what the original data was.
a) 010101100011
b) 111110001100
c) 110010001010

You might also like