Sie sind auf Seite 1von 29

11/04/33

PART III

Data Link Layer

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

Data link layer duties

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

11/04/33

Chapters
Chapter 10 Error Detection and Correction
Chapter 11 Data Link Control and Protocols
Chapter 12 Multiple Access
Chapter 13 Wired LANs: Ethernet
Chapter 15 Connecting LANs, Backbone networks
and virtual LANs
Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

Chapter 10

Error Detection
and
Correction
Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

11/04/33

Note::
Note
Network must be able to transfer data from
one device to another with acceptable
accuracy.
Data can be corrupted during transmission.

For reliable communication, errors must be


detected and corrected.

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

Types of Error

Single-Bit Error
Burst Error

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

11/04/33

Single-bit error
STX (Start of text)

LF (Line feed)

In a single-bit error, only one bit in the data


unit has changed. (0 1 or 1 0)
Does the Single-bit error happen in parallel or
serial transmission ? Why ?
Single-bit error most likely to occur in parallel
transmission (eg. between CPU and memory)
Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

Burst error

A burst error means that 2 or more bits in the data unit have changed
Burst error does not necessarily mean that the errors occur in consecutive
bits
Most

likely to happen in a serial transmission

Number of bits affected depends on the data rate and noise duration
If the data is sent at 1 kbps, a noise of 1/100 s can affect 10 bits.
If the data is sent at 1 Mbps, a noise of 1/100 s can affect 10000
Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

bits.
8

11/04/33

ERROR DETECTION
Error detection uses the concept of redundancy, which
means adding extra bits for detecting errors at the
destination.

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

ERROR DETECTION
Error can be detected by using block coding:
Dived the message into blocks, each of k bits, called datawords.
Add r redundant bits to each block to make the length
n = k + r.
The resulting n bits blocks are called codewords

Pages 274 until the end of section 10.2 are excluded.


Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

10

11/04/33

Error Detection methods

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

11

1. Parity Check
The most common and least expensive
Simple or Two Dimensional

1.1 simple parity check

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).

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

12

11/04/33

1. Parity Check
1.1 simple parity check

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

13

Example 1
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

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

14

11/04/33

Example 2
Now suppose the word world in Example 1 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.

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

15

Example 3
Now suppose the word world in Example 1 is corrupted
during transmission.

11111110 11011110 11101100 11011000 11001001


The receiver counts the 1s in each character and comes up
with even and odd numbers:
(7, 6, 5, 4, 4).
The receiver knows that the data are corrupted, discards
them, and asks for retransmission.

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

16

11/04/33

Performance of Simple Parity Check


Example:
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 error
will be detected:
1111111011: 9 ones
0110111011: 7 ones
1100010011: 5 ones

The same holds true for any odd number of errors


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. The change cancel each other and the data unit will pass a
parity check even though the data unit is damaged.
Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

17

Note::
Note

Simple parity check can detect all


single--bit errors.
single
errors. It can detect burst
errors only if the total number of
errors in each data unit is odd.

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

18

11/04/33

1.2 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 (column parity)
A redundant row of bits is added to the whole block.

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

19

Note::
Note

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.

Dr. Gihan NAGUIB

10

Behrouz A. Forouzan Data communication and Networking

20

11/04/33

Example 4
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.( see next slide)

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

21

Example 4
At Sender:
1
0
1
1

0
0
1
1

1
1
0
1

0
1
1
0

1
1
1
0

0
0
1
1

At receiver:
0
0
0
1

1
1
1
1
1 0 1010 1 0

1
1
1
1

0
0
1
1

1
0
0
1

0
0
1
0

0
1
1
0

0
0
1
1

1
0
0
1

1
1
1
1

1010101 0
1 0 1110 1 0

Error in colum positions: 2, 4, 5 ,6 and 8


Dr. Gihan NAGUIB

11

Behrouz A. Forouzan Data communication and Networking

22

11/04/33

Two-dimensional Performance
Increases the likelihood of detecting burst errors.
A redundancy of n-bits can detect a burst error of n bits
A burst error of more than n bits is also detected with a
very high probability
One pattern of errors still elusive:
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.

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

23

Two-dimensional Performance

Dr. Gihan NAGUIB

12

Behrouz A. Forouzan Data communication and Networking

24

11/04/33

2. Cyclic Redundancy Check CRC


Uses Module-2 Binary division

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

25

Cyclic Redundancy Check CRC


In CRC generator (At sender)
A string of n 0s is appended to the data unit
The number n is 1 less than the number of bits in the divisor
Divide the data word plus appended zeros by the divisor
Use module-2 binary division:
o There is no carry when you add or subtract two digits in a
column
o Addition and subtraction gives the same results
o This means: you can use XOR operation for both Addition
and subtraction
The remainder resulting from the division is the CRC
The CRC of n bits replaces the appended 0s at the end of the data
unit.
Appending CRC to the end of the data must make resulting bit
sequence divisible by the divisor
Dr. Gihan NAGUIB

13

Behrouz A. Forouzan Data communication and Networking

26

11/04/33

Binary division in a CRC generator

The leading zero of the


remainder is dropped

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

27

Cyclic Redundancy Check CRC


In CRC Checker (At receiver):
After receiving the data appended with the

CRC, it does the same module -2 division


If the remainder is all 0s the CRC dropped and
the data are accepted ( the data is correct)
If the remainder is not equal zero, the received
stream of bits is discarded and data must be resent
( the data is corrupted)
Dr. Gihan NAGUIB

14

Behrouz A. Forouzan Data communication and Networking

28

11/04/33

Binary division in CRC checker

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

29

Behrouz A. Forouzan Data communication and Networking

30

Example

Dr. Gihan NAGUIB

15

11/04/33

Example: Division in the CRC decoder for two cases

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

31

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 :
1. It should not be divisible by x.( i.e the coefficient of
term X0 should be 1)

2. It should be divisible by x+1.


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 burst errors
affecting an odd number of bits are detected.
Dr. Gihan NAGUIB

16

Behrouz A. Forouzan Data communication and Networking

32

11/04/33

A polynomial representing a divisor

Note that:
the degree of a polynomial is 1 less that the number of bits in the pattern.
The bit pattern in this case has 7 bit
Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

33

A polynomial representing a divisor

Dr. Gihan NAGUIB

17

Behrouz A. Forouzan Data communication and Networking

34

11/04/33

Example 5
We cannot choose:
X (binary 10) or
X2 + X (binary 110) because both are divisible by x.
We can choose
X + 1 (binary 11) because it is not divisible by x, but is divisible
by x + 1.
X2 + 1 (binary 101) because it is divisible by x + 1 (binary
division).

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

35

Standard polynomials
Name

Polynomial

Application

CRC--8
CRC

x8 + x2 + x + 1

ATM header

CRC--10
CRC

x10 + x9 + x5 + x4 + x 2 + 1

ATM AAL

ITU--16
ITU

x16 + x12 + x5 + 1

HDLC

ITU--32
ITU

x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10


+ x8 + x7 + x5 + x4 + x2 + x + 1

LANs

Dr. Gihan NAGUIB

18

Behrouz A. Forouzan Data communication and Networking

36

11/04/33

CRC Performance
CRC is very effective error detection method:
1. CRC Can detect all burst errors that affect an odd
number of bits.
2.

CRC Can detect all burst errors of length less than


or equal to the degree of the polynomial

3. CRC can detect, with very high probability, burst


errors of length greater than the degree of the
polynomial.

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

37

Example 6
The CRC-12
x12 + x11 + x3 + x + 1
which has a degree of 12, will detect
1. all burst errors affecting an odd number of bits,
2. will detect all burst errors with a length less
than or equal to 12, and
3. will detect, 99.97 percent of the time, burst
errors with a length of 12 or more.
Dr. Gihan NAGUIB

19

Behrouz A. Forouzan Data communication and Networking

38

11/04/33

3. Checksum
Like parity checks and CRC, the checksum based on redundancy

The checksum is used in the Internet by several protocols not


at the data link layer (Checksum used for example in network
layer ).

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

39

Data unit and checksum


The sender follows these steps:

The receiver follows these steps:

1.

The unit is divided into k sections,


each of n bits.

1. The unit is divided into k sections,


each of n bits.

2.

All sections are added using ones


complement to get the sum.

2. All sections are added using ones


complement to get the sum.

3.

The sum is complemented and


becomes the checksum.

3. The sum is complemented.

4.

The checksum is sent with the data.

4. If the result is zero, the data are


accepted: otherwise, rejected.

Dr. Gihan NAGUIB

20

Behrouz A. Forouzan Data communication and Networking

40

11/04/33

Example 7
Suppose the following block of 16 bits is to be sent using a checksum
of 8 bits.
10101001 00111001
The numbers are added using ones complement
10101001
00111001
-----------11100010

Sum
Checksum

00011101

The pattern sent is


Dr. Gihan NAGUIB

10101001 00111001 00011101


Behrouz A. Forouzan Data communication and Networking

41

Example 8
Now suppose the receiver receives the pattern sent in Example 7 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
Complement
Dr. Gihan NAGUIB

21

1111111 1
00000000 means that the pattern is OK.
Behrouz A. Forouzan Data communication and Networking

42

11/04/33

Example 9
Now suppose there is 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

Sum

11000110

Complement

00111001

Dr. Gihan NAGUIB

the pattern is corrupted.

Behrouz A. Forouzan Data communication and Networking

43

Performance of checksum
Almost detects all errors involving odd
numbers of bits or even.
if 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,
then the sum of columns will not change. Receiver

will not be able to detect the error

Dr. Gihan NAGUIB

22

Behrouz A. Forouzan Data communication and Networking

44

11/04/33

Error Correction

1. Retransmission:
when error is discovered, the receiver can have the
sender retransmit the data unit

2. Forward Error Correction


3. Burst Error Correction
Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

45

Forward Error Correction


A receiver can use an error-correcting code, which
automatically corrects certain errors.
Error-correcting codes are more sophisticated
than error detection codes and require more
redundancy bits.
Example for a single bit error:
Error Detection: one bit (error or no error)
Error Correction: must know which bit is in
error ( need more than one bit).

Dr. Gihan NAGUIB

23

Behrouz A. Forouzan Data communication and Networking

46

11/04/33

Forward Error Correction


Example
To 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
3-bit redundancy code: can indicate the location of 8
different possibilities.
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)

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

47

Forward Error Correction

The number of redundancy bits r to correct a


given number of data bits m is :

2r >= m + r + 1
2r = number of states
m + r indicates the location of an error in
each m + r positions
1 indicates no error
The value of r can be determined by plugging in
the value of m
Eg. m=7 , the smallest r that can satisfy this is 4

Dr. Gihan NAGUIB

24

Behrouz A. Forouzan Data communication and Networking

48

11/04/33

Data and redundancy bits


2r > = m + r + 1
Number of
data bits
m

Number of
redundancy bits
r

Total
bits
m+r

10

11

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

49

Hamming code
Positions of redundancy bits:
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.)

Dr. Gihan NAGUIB

25

Behrouz A. Forouzan Data communication and Networking

50

11/04/33

Redundancy bit Calculation


Data ward =7 bits , r =4
Codeward =7+4=11

(data) Decimal no

Binary

0011

0101

0110

Bit r1: bits 3, 5, 7, 9,11

0111

1001

Bit r2: bits 3,6,7,10,11

10

1010

Bit r4: 5,6,7

11

1011

Bit r8: 9, 10,11

Dr. Gihan NAGUIB

Redundancy bit Calculation

Behrouz A. Forouzan Data communication and Networking

51

Redundancy bit Calculation


Each parity bit calculates the even 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( 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.
Dr. Gihan NAGUIB

26

Behrouz A. Forouzan Data communication and Networking

52

11/04/33

Redundancy bits calculation

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

53

Example of redundancy bit calculation


Using even parity

Dr. Gihan NAGUIB

27

Behrouz A. Forouzan Data communication and Networking

54

11/04/33

Error detection and correction using Hamming code

Dr. Gihan NAGUIB

Behrouz A. Forouzan Data communication and Networking

55

Burst error correction


Hamming code cannot correct a burst error
directly, it is possible to rearrange the data and
then apply the code.
Organize N units in a column and then send the
first bit for 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 a unit.
With Hamming, we can then correct the
corrupted bit in each unit.
Dr. Gihan NAGUIB

28

Behrouz A. Forouzan Data communication and Networking

56

11/04/33

Burst error correction example

Dr. Gihan NAGUIB

29

Behrouz A. Forouzan Data communication and Networking

57

Das könnte Ihnen auch gefallen