Lec-7B Error Detection and correction

36
LECTURE-7B Error Detection Error Detection and Correction

Transcript of Lec-7B Error Detection and correction

LECTURE-7B

Error DetectionError Detectionand Correction

Introduction

Networks must be able to transfer data from one device toanother with complete accuracyanother with complete accuracy.Data can be corrupted during transmission.An error occurs when a bit is altered between transmission andreception (1 is transmitted and 0 is received, and visa versa)For reliable communication, errors must be detected andcorrectedcorrected.Error detection and correction are implemented either at thedata 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 Errorg y g

unit (such as a byte, character, or packet) is changed from 1 to0 or from 0 to 1.Single bit errors are the least likely type of errors in serial dataSingle bit errors are the least likely type of errors in serial datatransmission because the noise must have a very shortduration which is very rare.H thi ki d f h i ll lHowever this kind of errors can happen in paralleltransmission.Example: If data is sent at 1Mbps then each bit lasts only1/1,000,000 sec. or 1 μs.For a single‐bit error to occur, the noise must have a durationof only 1 μs, which is very rare.of only 1 μs, which is very rare.

Burst ErrorA burst error means that 2 or more bits in the data unit havechangedA burst error does not necessarily mean that the errors occur inconsecutive bits.The length of the burst is measured from the first corrupted bitto the last corrupted bit.Burst error is most likely to happen in serial transmission sincethe duration of noise is normally longer than the duration of abit.The number of bits affected depends on the data rate andduration of noise.Example: If data is sent at rate = 1Kbps then a noise of 1/100 secExample: If data is sent at rate 1Kbps then a noise of 1/100 seccan affect 10 bits.(1/100*1000)If same data is sent at rate = 1Mbps then a noise of 1/100 sec canaffect 10 000 bits (1/100*106)affect 10,000 bits.(1/100 10 )

Multiple‐bit Error and Burst Error

Error DetectionError detection means to decide whether the received data isError detection means to decide whether the received data iscorrect 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 meansadding extra bits for detecting errors at the destination.

These redundant bits are added by the sender and removed bythe receiver.

Their presence allows the receiver to detect or correct corruptedbitsbits.

Error Detection Methods

Vertical Redundancy Check (VRC) It can detect single bit errorIt can detect single bit errorIt can detect burst errors only if the total number of errors isodd.a parity bit (extra bit) is added to every data unit so that thetotal number of 1s is even or odd (for odd‐parity).

Performance of Simple Parity CheckExample: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 errorwill be detected:

1111111011: “ 9 ones”0110111011: “7 ones”0110111011: 7 ones1100010011: “ 5 ones”The same holds true for any odd number of errors

b h dSuppose 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 paritychecker 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 paritycheck 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 inexactly the same positions in another data unit are alsodamaged, the LRC checker will not detect an error.

Two‐dimensional Parity

Calculate the parity bit for each data unit, then organize theminto table (rows and columns)Calculate the parity bit for each column and create a new rowCalculate 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 dare 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 isdiscarded.( see next slide)

Two‐dimensional Parity Performance

Increases the likelihood of detecting burst errors.The two‐dimensional parity check can detect up to threeerrors 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 exactlythe 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 tGiven a k‐bit frame or message, the transmitter generates an n‐bit sequence, known as a frame check sequence (FCS), so thatthe resulting frame, consisting of (k+n) bits, is exactly divisible by

d i d bsome predetermined number.

The receiver then divides the incoming frame by the samenumber and, if there is no remainder, assumes that there was nonumber and, if there is no remainder, assumes that there was noerror.

Division in the CRC Sender and Receiver

0 0 1

CRC

A polynomialThe divisor in CRC generator is most oftenrepresented not as string of 1s and 0s, but asan algebraic polynomial.The polynomial is used for two reasons: it isShort and Can be used to prove the conceptmathematically.A polynomial should be selected to have thefollowing :

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 theThe first condition : guarantees that all the

burst errors of a length equal to the degree ofthe polynomial are detected.

The Second condition : guarantees that allThe Second condition : guarantees that allthe burst errors affecting an odd number ofbits are detected.

CRC Performance

CRC is very effective error detection method:CRC Can detect all burst errors that affect an odd number ofCRC Can detect all burst errors that affect an odd number ofbits.CRC Can detect all burst errors of length less than or equal tothe degree of the polynomialCRC can detect, with very high probability, burst errors oflength greater than the degree of the polynomiallength greater than the degree of the polynomial.

Checksum

Like parity checks and CRC, the checksum based onredundancy.The checksum is used in the Internet by several protocols notThe checksum is used in the Internet by several protocols notat the data link layer (Checksum used for example in networklayer ).

Checksum

At the Sender

Th i i di id d i k

At the Receiver

Th i i di id d i kThe unit is divided into ksections, each of n bits.

All sections are added

The unit is divided into ksections, each of n bits.

All sections are addedAll sections are addedtogether using one’scomplement to get the sum.

Th i l d

All sections are addedtogether using one’scomplement to get the sum.

Th i l dThe sum is complementedand becomes the checksum.

The checksum is sent with

The sum is complemented.

If the result is zero, the dataare accepted: otherwise, theyThe checksum is sent with

the dataare accepted: otherwise, theyare rejected.

Example

At the Sender At the Receiver

Example

Performance

The checksum detects all errors involving an odd number ofbitbits.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 thecorresponding bit or bits of opposite value in a second segmentare also damaged, the sums of those columns will not changed th i ill t d t t bland the receiver will not detect a problem.

Error Correction

Retransmission: when error is discovered, the,receiver can have the sender retransmit the dataunit.F d E C tiForward Error CorrectionBurst 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 errord t ti d d i d d bitdetection 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 ( needmore 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 errorcorrection must distinguish between: no error, error in position1 ….,error in position 7( 8 states)It require more redundancy bits to show the 8 statesIt require more redundancy bits to show the 8 states.3‐bit redundancy code: can indicate the location of 8 differentpossibilities.B t t k if i th d d bit Additi lBut can not know if an error occur in the redundancy bits. Additionalbits are required to cover all possible error location( includingredundancy bits).N b f d d bi d dNumber of redundancy bits needed

Let data bits =mRedundancy bits = ry∴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 toll th id tifi ti f i l C t th d dallow the identification of a single error Create the code wordas 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 toallow the identification of a single error Positions ofallow the identification of a single error Positions ofredundancy bits:

Redundancy bit CalculationEach parity bit calculates the even parity for some of the bits inp y p ythe code word. The position of the parity bit determines thesequence 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 itchecks is odd. Set a parity bit to 0 if the total number of ones inthe 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 deach, followed by the second bit of each , and so on.If a burst error of M bits occurs (M<N) then the error dose notcorrupt M bits of one single unit, its corrupts only 1 bit of ap g , p yunit.With Hamming, we can then correct the corrupted bit in each

iunit.

Burst Error Correction