LECTURE-7B
Error Detection Error Detection
and Correction
Introduction
Networks must be able to transfer data from one device to another with complete accuracy
another with complete accuracy.
Data can be corrupted during transmission.
An error occurs when a bit is altered between transmission and reception (1 is transmitted and 0 is received, and visa versa)
For reliable communication, errors must be detected and corrected
corrected.
Error detection and correction are implemented either at the data link layer or the transport layer of the OSI model.y p y
Types of Errors
The term single‐bit error means that only 1 bit of a given data
Single‐Bit Error
g y g
unit (such as a byte, character, or packet) is changed from 1 to 0 or from 0 to 1.
Single bit errors are the least likely type of errors in serial data
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.
H thi ki d f h i ll l
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.
of only 1 μs, which is very rare.
Burst Error
A burst error means that 2 or more bits in the data unit have changed
A burst error does not necessarily mean that the errors occur in consecutive bits.
The length of the burst is measured from the first corrupted bit to the last corrupted bit.
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:Example: If data is sent at rate = 1Kbps then a noise of 1/100 secIf data is sent at rate 1Kbps then a noise of 1/100 sec can affect 10 bits.(1/100*1000)
If same data is sent at rate = 1Mbps then a noise of 1/100 sec can affect 10 000 bits (1/100*106)
affect 10,000 bits.(1/100 10 )
Multiple‐bit Error and Burst Error
Error Detection
Error detection means to decide whether the received data is
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 meansError detection uses the concept of redundancy, which means adding extra bits for detecting errors at the destination.
These redundant bits are added by the sender and removed by the receiver.
Their presence allows the receiver to detect or correct corrupted bits
bits.
Error Detection Methods
Vertical Redundancy Check (VRC)
It can detect single bit error
It can detect single bit error
It can detect burst errors only if the total number of errors is odd.
a parity bit (extra bit) is added to every data unit so that the total number of 1s is even or odd (for odd‐parity).
Performance of Simple Parity Check
Example:p
We have an even‐parity data unit where the total number of 1s, including the parity bit, is 6: 1000111011.
If any 3 bits changed, the resulting parity will be odd and the errorIf any 3 bits changed, the resulting parity will be odd and the error will be detected:
1111111011: “ 9 ones”
0110111011: “7 ones”
0110111011: 7 ones 1100010011: “ 5 ones”
The same holds true for any odd number of errors
b h d
Suppose 2 bits are changed:
1110111011: ”8 ones”
1100011011: ”6 ones”
The number of 1s in the data unit is still even
The same holds true for any even number of errors The parity checker cannot detect errors when number of bits changed is even.
checker cannot detect errors when number of bits changed is even.
The change cancel each other and the data unit will pass a parity check even though the data unit is damaged
Longitudinal Redundancy Check (LRC)
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 checker will not detect an error.
Two‐dimensional Parity
Calculate the parity bit for each data unit, then organize them into table (rows and columns)
Calculate the parity bit for each column and create a new row
Calculate the parity bit for each column and create a new row (column parity)
A redundant row of bits is added to the whole block.
Example
• Suppose the following block is sent: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 t d
are corrupted.
10100011 10001001 11011101 11100111 10101010
• When the receiver checks the parity bits, some of the bits dop y , not follow the even‐parity rule and the whole block is discarded.( see next slide)
Two‐dimensional Parity Performance
Increases the likelihood of detecting burst errors.
The two‐dimensional parity check can detect up to three errors that occur anywhere in the table.
However errors affecting 4 bits may not be detectedHowever, errors affecting 4 bits may not be detected.
If 2 bits in one data unit are damaged and two bits in exactly the same position in anther data unite are also damaged.
The error will not be detected.
Cyclic Redundancy Check (CRC)
Gi k bit f th t itt t
Given a k‐bit frame or message, the transmitter generates an n‐
bit sequence, known as a frame check sequence (FCS), so that the resulting frame, consisting of (k+n) bits, is exactly divisible by
d i d b
some predetermined number.
The receiver then divides the incoming frame by the same number and, if there is no remainder, assumes that there was no number and, if there is no remainder, assumes that there was no error.
Division in the CRC Sender and Receiver
0 0 1
CRC
A polynomial
The divisor in CRC generator is most often represented not as string of 1s and 0s, but as an algebraic polynomial.
The polynomial is used for two reasons: it is Short and Can be used to prove the concept mathematically.
A polynomial should be selected to have the following :
¾ It should not be divisible by x.( i.e the )
coefficient of term X0 should be 1)
¾ It should be divisible by x+1.
¾ The first condition : guarantees that all the
¾ The first condition : guarantees that all the burst errors of a length equal to the degree of the polynomial are detected.
¾ The Second condition : guarantees that all
¾ The Second condition : guarantees that all the burst errors affecting an odd number of bits are detected.
CRC Performance
CRC is very effective error detection method:
CRC Can detect all burst errors that affect an odd number of
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 the polynomial
CRC can detect, with very high probability, burst errors of length greater than the degree of the polynomial
length greater than the degree of the polynomial.
Checksum
Like parity checks and CRC, the checksum based on redundancy.
The checksum is used in the Internet by several protocols notThe checksum is used in the Internet by several protocols not at the data link layer (Checksum used for example in network layer ).
Checksum
At the Sender
Th i i di id d i k
At the Receiver
Th i i di id d i k
The unit is divided into k sections, each of n bits.
All sections are added
The unit is divided into k sections, each of n bits.
All sections are added All sections are added
together using one’s complement to get the sum.
Th i l d
All sections are added together using one’s complement to get the sum.
Th i l d
The sum is complemented and becomes the checksum.
The checksum is sent with
The sum is complemented.
If the result is zero, the data are accepted: otherwise, they The checksum is sent with
the data
are accepted: otherwise, they are rejected.
Example
At the Sender At the Receiver
Example
Performance
The checksum detects all errors involving an odd number of bit
bits.
It detects most errors involving an even number of bits.
If one or more bits of a segment are damaged and theIf one or more bits of a segment are damaged and the corresponding bit or bits of opposite value in a second segment are also damaged, the sums of those columns will not change
d th i ill t d t t bl
and the receiver will not detect a problem.
Error Correction
¾ Retransmission: when error is discovered, the, receiver can have the sender retransmit the data unit.
¾ F d E C ti
¾ Forward Error Correction
¾ Burst Error Correction
Forward Error Correction
A receiver can use an error‐correcting code, whichg , automatically corrects certain errors.
Error‐correcting codes are more sophisticated than error
d t ti d d i d d bit
detection codes and require more redundancy bits.
Example for a single bit error:
Error Detection: one bit (error or no error)Error Detection: one bit (error or no error)
Error Correction: must know which bit is in error ( need more than one bit).
Forward Error Correction
Example
To correct a single‐bit error in an ASCII character (7‐bit) the errorTo correct a single bit error in an ASCII character (7 bit), the error correction must distinguish between: no error, error in position1 …., error in position 7( 8 states)
It require more redundancy bits to show the 8 states
It require more redundancy bits to show the 8 states.
3‐bit redundancy code: can indicate the location of 8 different possibilities.
B t t k if i th d d bit Additi l
But can not know if an error occur in the redundancy bits. Additional bits are required to cover all possible error location( including redundancy bits).
N b f d d bi d d
Number of redundancy bits needed Let data bits = m
Redundancy bits =y r
∴Total message sent = m+r
The value of r must satisfy the relation: 2r ≥ m+r+1
Hamming code
Positions of redundancy bits:
The key to the Hamming Code is the use of extra parity bits to
ll th id tifi ti f i l C t th d d
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.p p p y (positions 1, 2, 4, 8, 16, 32, 64, etc.)
All other bit positions are for the data to be encoded.
( i i 3 5 6 7 9 10 11 12 13 14 15 17 ) (positions 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, etc.)
The key to the Hamming Code is the use of extra parity bits to allow the identification of a single error Positions of allow the identification of a single error Positions of redundancy bits:
Redundancy bit Calculation
Each parity bit calculates the even parity for some of the bits inp y p y the code word. The position of the parity bit determines the sequence of bits that it alternately checks and skips.
Position 1( r1): check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc.Position 1( r1): check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc.
(1, 3, 5, 7, 9, 11, 13, 15,...)
Position 2 (r2): check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, etc.
(2, 3, 6, 7, 10, 11, 14, 15,...) ( , , , , , , , , )
Position 4 (r4): check 4 bits, skip 4 bits, etc (4, 5, 6, 7, 12, 13, 14, 15,...)
Position 8(r8): 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.
Redundancy bit Calculation
Example of Hamming Code
Error Detection and Correction Using Hamming
Code
Burst Error Correction
Hamming code cannot correct a burst error directly, it isg y, possible to rearrange the data and then apply the code.
Organize N units in a column and then send the first bit for
h f ll d b th d bit f h d
each, followed by the second bit of each , and so on.
If a burst error of M bits occurs (M<N) then the error dose not corrupt M bits of one single unit, its corrupts only 1 bit of ap g , p y unit.
With Hamming, we can then correct the corrupted bit in each i
unit.