51
Data Link Layer: Data Link Layer: Error Detection and Error Detection and Correction Correction 01204325: Data 01204325: Data Communication and Communication and Computer Networks Computer Networks Asst. Prof. Chaiporn Jaikaeo, Ph.D. Asst. Prof. Chaiporn Jaikaeo, Ph.D. [email protected] [email protected] http://www.cpe.ku.ac.th/~cpj http://www.cpe.ku.ac.th/~cpj Computer Engineering Department Computer Engineering Department Kasetsart University, Bangkok, Thailand Kasetsart University, Bangkok, Thailand Adapted from lecture slides by Behrouz A. Forouzan © The McGraw-Hill Companies, Inc. All rights reserved

Data Link Layer: Error Detection and Correction 01204325: Data Communication and Computer Networks Asst. Prof. Chaiporn Jaikaeo, Ph.D. [email protected]

Embed Size (px)

Citation preview

Data Link Layer:Data Link Layer:Error Detection and Error Detection and

CorrectionCorrection

01204325: Data 01204325: Data Communication and Communication and Computer NetworksComputer Networks

Asst. Prof. Chaiporn Jaikaeo, Ph.D.Asst. Prof. Chaiporn Jaikaeo, [email protected]@ku.ac.th

http://www.cpe.ku.ac.th/~cpjhttp://www.cpe.ku.ac.th/~cpjComputer Engineering DepartmentComputer Engineering Department

Kasetsart University, Bangkok, ThailandKasetsart University, Bangkok, ThailandAdapted from lecture slides by Behrouz A. Forouzan© The McGraw-Hill Companies, Inc. All rights reserved

22

OutlineOutline Overview of Data Link LayerOverview of Data Link Layer Types of errorsTypes of errors RedundancyRedundancy Correction vs. detectionCorrection vs. detection CodingCoding

33

Data Link LayerData Link Layer

44

Error ControlError Control Detecting errorsDetecting errors Correcting errorsCorrecting errors

Forward error correctionForward error correction Automatic repeat requestAutomatic repeat request

55

Types of ErrorsTypes of Errors Single-bit errorsSingle-bit errors

Burst errorsBurst errors

66

RedundancyRedundancy To detect or correct errors, To detect or correct errors,

redundant bits of data must be redundant bits of data must be addedadded

77

CodingCoding Process of adding redundancy for error Process of adding redundancy for error

detection or correctiondetection or correction Two types:Two types:

Block codesBlock codes Divides the data to be sent into a set of blocksDivides the data to be sent into a set of blocks Extra information attached to each blockExtra information attached to each block MemorylessMemoryless

Convolutional codesConvolutional codes Treats data as a series of bits, and computes a code Treats data as a series of bits, and computes a code

over a continuous seriesover a continuous series The code computed for a set of bits depends on the The code computed for a set of bits depends on the

current and previous inputcurrent and previous input

88

XOR OperationXOR Operation Main operation for computing error Main operation for computing error

detection/correction codesdetection/correction codes Similar to modulo-2 additionSimilar to modulo-2 addition

99

Block CodingBlock Coding Message is divided into Message is divided into kk-bit blocks-bit blocks

Known as Known as datawordsdatawords rr redundant bits are added redundant bits are added

Blocks become Blocks become nn==kk++rr bits bits Known as Known as codewordscodewords

1010

Example: Example: 4B/5B Block 4B/5B Block CodingCoding

DataData CodeCode DataData CodeCode

00000000 1111011110 1000 1000 1001010010

00010001 0100101001 10011001 1001110011

00100010 1010010100 10101010 1011010110

00110011 1010110101 10111011 1011110111

01000100 0101001010 11001100 1101011010

01010101 0101101011 11011101 1101111011

01100110 0111001110 11101110 1110011100

01110111 0111101111 11111111 1110111101

k = ?r = ?n = ?

1111

Error Detection in Block Error Detection in Block CodingCoding

1212

NotesNotes An error-detecting code can detect An error-detecting code can detect

only the types of errors for which it is only the types of errors for which it is designeddesigned Other types of errors may remain Other types of errors may remain

undetected.undetected. There is no way to detect every There is no way to detect every

possible errorpossible error

1313

Error CorrectionError Correction

1414

Example: Example: Error Correction Error Correction CodeCode

The receiver receives 01001, what is the original dataword?

k, r, n = ?

1515

Hamming DistanceHamming Distance

d(01, 00) = ?d(01, 00) = ? d(11, 00) = ?d(11, 00) = ? d(010, 100) = ?d(010, 100) = ? d(0011, 1000) = ?d(0011, 1000) = ? How many 8-bit words are How many 8-bit words are nn bits bits

away from 10000111?away from 10000111?

Hamming Distance between two words is the number of differences between corresponding

bits.

Hamming Distance between two words is the number of differences between corresponding

bits.

1616

Minimum Hamming Minimum Hamming DistanceDistance

Find the minimum Hamming Find the minimum Hamming Distance of the following codebookDistance of the following codebook

The minimum Hamming distance is the smallest Hamming distance between all possible pairs in a set of words.

The minimum Hamming distance is the smallest Hamming distance between all possible pairs in a set of words.

0000000000

0101010111

1010101011

1111111100

1717

Detection Capability of Detection Capability of CodeCode To guarantee the To guarantee the detectiondetection of up to of up to

ss-bit errors, the minimum Hamming -bit errors, the minimum Hamming distance in a block code must bedistance in a block code must be

ddminmin = = ss + 1 + 1ddminmin = = ss + 1 + 1

1818

Correction Capability of Correction Capability of CodeCode To guarantee the To guarantee the correctioncorrection of up to of up to

tt-bit errors, the minimum Hamming -bit errors, the minimum Hamming distance in a block code must bedistance in a block code must be

ddminmin = 2 = 2tt + 1 + 1ddminmin = 2 = 2tt + 1 + 1

1919

Example: Example: Hamming Hamming DistanceDistance A code scheme has a Hamming A code scheme has a Hamming

distance ddistance dminmin = 4. What is the error = 4. What is the error detection and correction capability of detection and correction capability of this scheme?this scheme?

2020

Common Detection Common Detection MethodsMethods Parity checkParity check Cyclic Redundancy CheckCyclic Redundancy Check ChecksumChecksum

2121

Parity CheckParity Check Most common, least complexMost common, least complex Single bit is added to a blockSingle bit is added to a block Two schemes:Two schemes:

Even parity – Maintain even number of Even parity – Maintain even number of 1s1s

E.g., 1011 E.g., 1011 1011 101111 Odd parity – Maintain odd number of 1sOdd parity – Maintain odd number of 1s

E.g., 1011 E.g., 1011 1011 101100

2222

Example: Example: Parity CheckParity Check

Suppose the sender wants to send the word world. In ASCII the five characters are coded (with even parity) as

1110111 1101111 1110010 1101100 1100100

The following shows the actual bits sent

11101110 11011110 11100100 11011000 11001001

Suppose the sender wants to send the word world. In ASCII the five characters are coded (with even parity) as

1110111 1101111 1110010 1101100 1100100

The following shows the actual bits sent

11101110 11011110 11100100 11011000 11001001

2323

Example: Example: Parity CheckParity Check

Receiver receives this sequence of words:

11111110 11011110 11101100 11011000 11001001

Which blocks are accepted? Which are rejected?

2424

Parity-Check: Parity-Check: Encoding/DecodingEncoding/Decoding

2525

Performance of Parity Performance of Parity CheckCheck Can 1-bit errors be detected?Can 1-bit errors be detected? Can 2-bit errors be detected?Can 2-bit errors be detected? ::

2626

2D Parity Check2D Parity Check

What is its performance?

2727

2D Parity Check: 2D Parity Check: PerformancePerformance

2828

2D Parity Check: 2D Parity Check: PerformancePerformance

2929

Cyclic Redundancy CheckCyclic Redundancy Check In a cyclic code, rotating a codeword In a cyclic code, rotating a codeword

always results in another codewordalways results in another codeword Example:Example:

3030

CRC Encoder/DecoderCRC Encoder/Decoder

3131

CRC GeneratorCRC Generator

3232

Checking CRCChecking CRC

3333

Polynomial Polynomial RepresentationRepresentation More common representation than binary More common representation than binary

formform Easy to analyzeEasy to analyze Divisor is commonly called Divisor is commonly called generator generator

polynomialpolynomial

3434

Division Using Division Using PolynomialPolynomial

3535

Strength of CRCStrength of CRC Can be analyzed using polynomialCan be analyzed using polynomial

MM((xx)) – Original message – Original message GG((xx)) – Generator polynomial of degree n – Generator polynomial of degree n RR((xx)) – Generated CRC – Generated CRC

Transmitted message isTransmitted message isMM((xx))xxnn – – RR((xx) )

which is divisible bywhich is divisible by GG((xx))

M(x)xn = Q(x)G(x) + R(x)

3636

Strength of CRCStrength of CRC Received message isReceived message is

MM((xx))xxnn – – RR((xx) + ) + EE((xx))

where where EE((xx)) represents bit errors represents bit errors Receiver does not detect any error Receiver does not detect any error

when when EE((xx)) is divisible by is divisible by GG((xx)), which , which means either:means either: EE((xx)) 0 0 No error No error EE((xx)) 0 0 Undetectable error Undetectable error

3737

Strength of CRCStrength of CRC If If GG((xx)) contains at least two terms, then contains at least two terms, then

all single-bit errors can be detectedall single-bit errors can be detected If If GG((xx)) cannot divide cannot divide xxtt + 1 + 1 ( (00 tt < < nn), ),

then all isolated double errors can be then all isolated double errors can be detecteddetected

If If GG((xx)) contains a factor of contains a factor of ((xx+1)+1), all odd-, all odd-numbered errors can be detectednumbered errors can be detected

3838

Properties of Good Properties of Good PolynomialPolynomial It should have at least two termsIt should have at least two terms The coefficient of the term The coefficient of the term xx00 should should

be 1be 1 It should not divide It should not divide xxtt + 1 + 1, for , for tt

between 2 and between 2 and nn − 1 − 1 It should have the factor It should have the factor xx + 1 + 1

3939

CRC's Strength SummaryCRC's Strength Summary All burst errors with L ≤ n will be All burst errors with L ≤ n will be

detecteddetected All burst errors with L = n + 1 will be All burst errors with L = n + 1 will be

detected with probability 1 – (1/2)detected with probability 1 – (1/2)n–1n–1

All burst errors with L > n + 1 will be All burst errors with L > n + 1 will be detected with probability 1 – (1/2)detected with probability 1 – (1/2)nn

4040

Example: CRC Example: CRC GeneratorsGenerators Which of the following polynomials Which of the following polynomials

guarantees that a single-bit error can guarantees that a single-bit error can be detectedbe detected(a) x+1(a) x+1

(b) x(b) x33

(c) 1(c) 1

4141

Example: CRC Example: CRC GeneratorsGenerators Criticize the following CRC Criticize the following CRC

generatorsgenerators xx33

xx1010 + x + x99 + x + x55

xx66+1+1

4242

Standard PolynomialsStandard Polynomials

4343

Error CorrectionError Correction Two methodsTwo methods

Retransmission after detecting errorRetransmission after detecting error Forward error correction (FEC)Forward error correction (FEC)

4444

Forward Error CorrectionForward Error Correction Consider only a single-bit error in Consider only a single-bit error in kk bits of bits of

datadata kk possibilities for an error possibilities for an error One possibility for no errorOne possibility for no error #possibilities = #possibilities = kk + 1 + 1

Add r redundant bits to distinguish these Add r redundant bits to distinguish these possibilities; we needpossibilities; we need

22rr kk+1+1 But the r bits are also transmitted along with But the r bits are also transmitted along with

data; hencedata; hence

22rr kk++rr+1+1

4545

Number of Redundant Number of Redundant BitsBits

Number ofNumber ofdata bitsdata bits

kk

Number of Number of redundancy bitsredundancy bits

rr

Total Total bitsbits

kk + + rr

11 22 33

22 33 55

33 33 66

44 33 77

55 44 99

66 44 1010

77 44 1111

4646

Hamming CodeHamming Code Simple, powerful FECSimple, powerful FEC Widely used in computer memoryWidely used in computer memory

Known as ECC memoryKnown as ECC memory

error-correcting bits

4747

Redundant Bit Redundant Bit CalculationCalculation

4848

Example: Example: Hamming CodeHamming Code

4949

Example: Example: Correcting Correcting ErrorError Receiver receives 1001Receiver receives 100100100101100101

5050

Strength of Hamming Strength of Hamming CodeCode Minimum Hamming Distance is 3Minimum Hamming Distance is 3

It can correct at most 1 bit errorIt can correct at most 1 bit error It can detect at most 2 bit errorIt can detect at most 2 bit error But… not both!!! (Why?)But… not both!!! (Why?)

SECDED – Extended Hamming code SECDED – Extended Hamming code with one extra parity bitwith one extra parity bit Achieves minimum Hamming distance of Achieves minimum Hamming distance of

44 Can distinguish between one bit and two Can distinguish between one bit and two

bit errorsbit errors

5151

Burst Error CorrectionBurst Error Correction