cn 3rd unnit

Upload: vrkatevarapu

Post on 02-Jun-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Cn 3rd Unnit

    1/29

    11/04/33

    1

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB1

    Data Link LayerData Link Layer

    P RT IIIRT III

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 2

    Data link layer duties

  • 8/10/2019 Cn 3rd Unnit

    2/29

    11/04/33

    2

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB3

    Chapters

    Chapter 10Error Detection and Correction

    Chapter 11 Data Link Control and Protocols

    Chapter 12Multiple Access

    Chapter 13Wired LANs: Ethernet

    Chapter 15Connecting LANs, Backbone networks

    and virtual LANs

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 4

    Chapter 10

    Error Detection

    and

    Correction

  • 8/10/2019 Cn 3rd Unnit

    3/29

    11/04/33

    3

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB5

    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.

    NoteNote::

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 6

    Types of ErrorTypes of Error

    Single-Bit Error

    Burst Error

  • 8/10/2019 Cn 3rd Unnit

    4/29

    11/04/33

    4

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB7

    Single-bit error

    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)

    STX (Start of text)LF (Line feed)

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 8

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

  • 8/10/2019 Cn 3rd Unnit

    5/29

    11/04/33

    5

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB9

    ERROR DETECTION

    Error detection uses the concept of redundancy, whichmeans adding extra bitsfor detecting errors at thedestination.

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 10

    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.

  • 8/10/2019 Cn 3rd Unnit

    6/29

    11/04/33

    6

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB11

    Error Detection methods

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 12

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

  • 8/10/2019 Cn 3rd Unnit

    7/29

    11/04/33

    7

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB13

    1.Parity Check

    1.1 simple parity check

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 14

    ExampleExample 11

    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

    w O r l d

  • 8/10/2019 Cn 3rd Unnit

    8/29

    11/04/33

    8

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB15

    ExampleExample 22

    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.

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 16

    ExampleExample 33

    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.

  • 8/10/2019 Cn 3rd Unnit

    9/29

    11/04/33

    9

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB17

    Performance of Simple Parity Check

    Example:

    We have an even-parity data unit where the total number of 1s, includingthe 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 errorsSuppose 2 bits are changed:

    1110111011: 8 ones

    1100011011: 6 ones

    The number of 1s in the data unit is still evenThe 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.

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 18

    Simple parity check can detect allSimple parity check can detect all

    singlesingle--bit errorsbit errors. It can detect. It can detect burstburst

    errors only if the total number oferrors only if the total number of

    errors in each data unit iserrors in each data unit is odd.odd.

    NoteNote::

  • 8/10/2019 Cn 3rd Unnit

    10/29

    11/04/33

    10

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 19

    1.2 Two-dimensional parityCalculate 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.

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 20

    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.

    NoteNote::

  • 8/10/2019 Cn 3rd Unnit

    11/29

    11/04/33

    11

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB21

    ExampleExample 44

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

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 22

    ExampleExample 44

    At Sender: At receiver:

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

    1 0 1 0 1 0 0

    0 0 1 1 1 0 0

    1 1 0 1 1 1 0

    1 1 1 0 0 1 1

    1

    1

    1

    1

    1 0 1 0 1 0 1 0

    1 0 1 0 00 1

    10 0 01 0 01 1 0 1 1 1 0

    1 1 1 0 0 1 1

    1

    11

    1

    1 0 1 0 1 0 1 0

    1 0 1 1 1 0 1 0

  • 8/10/2019 Cn 3rd Unnit

    12/29

    11/04/33

    12

    Behrouz A. Forouzan Data communication and Networking23

    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 24

    Two-dimensional Performance

    Dr. Gihan NAGUIB

  • 8/10/2019 Cn 3rd Unnit

    13/29

    11/04/33

    13

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB25

    2. Cyclic Redundancy Check CRC

    Uses Module-2 Binary division

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 26

    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:

    oThere is no carry when you add or subtract two digits in a

    column

    oAddition 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 0sat the end of the data

    unit.

    Appending CRC to the end of the data must make resulting bit

    sequence divisible by the divisor

  • 8/10/2019 Cn 3rd Unnit

    14/29

    11/04/33

    14

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB27

    Binary division in a CRC generator

    The leading zero of the

    remainder is dropped

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 28

    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 0sthe 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)

  • 8/10/2019 Cn 3rd Unnit

    15/29

    11/04/33

    15

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB29

    Binary division in CRC checker

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 30

    Example

  • 8/10/2019 Cn 3rd Unnit

    16/29

    11/04/33

    16

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB31

    Example: Division in the CRC decoder for two cases

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 32

    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 ofterm X0should 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.

  • 8/10/2019 Cn 3rd Unnit

    17/29

    11/04/33

    17

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB33

    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

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 34

    A polynomial representing a divisor

  • 8/10/2019 Cn 3rd Unnit

    18/29

    11/04/33

    18

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB35

    ExampleExample 55

    We cannot choose:

    X (binary 10) or

    X2+ X(binary 110) becauseboth are divisible by x.

    We can choose

    X + 1(binary 11) because it is not divisible by x, but is divisible

    byx + 1.

    X2+ 1(binary 101) becauseit is divisible by x + 1 (binary

    division).

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 36

    Standard polynomialsStandard polynomials

    Name Polynomial Application

    CRCCRC--88 x8 +x2 +x+1 ATM header

    CRCCRC--1010 x10+x9 +x5 +x4 +x2+1 ATM AAL

    ITUITU--1616 x16+x12+x5 + 1 HDLC

    ITUITU--3232x32+x26 +x23+x22+x16+x12+x11+x10

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

  • 8/10/2019 Cn 3rd Unnit

    19/29

    11/04/33

    19

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB37

    CRC PerformanceCRC 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, bursterrors of length greater than the degree of the

    polynomial.

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 38

    ExampleExample 66

    The CRC-12

    x12+ x11+ x3+ x + 1

    which has a degree of 12, will detect1. 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.

  • 8/10/2019 Cn 3rd Unnit

    20/29

    11/04/33

    20

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB39

    3. 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 networkat the data link layer (Checksum used for example in network

    layer ).layer ).

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 40

    Data unit and checksum

    The receiver follows these steps:The receiver follows these steps:

    1.1. The unit is divided into k sections,The unit is divided into k sections,

    each of n bits.each of n bits.

    2.2. All sections are added using onesAll sections are added using ones

    complement to get the sum.complement to get the sum.

    3.3. The sum is complemented.The sum is complemented.

    4.4. If the result is zero, the data areIf the result is zero, the data are

    accepted: otherwise, rejected.accepted: otherwise, rejected.

    The sender follows these steps:The sender follows these steps:

    1.1. The unit is divided into k sections,The unit is divided into k sections,

    each of n bits.each of n bits.

    2.2. All sections are added using onesAll sections are added using ones

    complement to get the sum.complement to get the sum.

    3.3. The sum isThe sum is complementedcomplementedandand

    becomes thebecomes the checksum.checksum.

    4.4. The checksum is sent with the data.The checksum is sent with the data.

  • 8/10/2019 Cn 3rd Unnit

    21/29

    11/04/33

    21

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB41

    ExampleExample 77

    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

    ------------

    Sum 11100010Checksum 00011101

    The pattern sent is 10101001 00111001 00011101

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 42

    ExampleExample 88

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

    Complement 00000000 means that the pattern is OK.

  • 8/10/2019 Cn 3rd Unnit

    22/29

    11/04/33

    22

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB43

    ExampleExample 99

    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 111000101

    Carry 1

    Sum 11000110

    Complement 00111001 the pattern is corrupted.

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 44

    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 asecond segment are also damaged,

    then the sum of columns will not change. Receiver

    will not be able to detect the error

    Performance of checksum

  • 8/10/2019 Cn 3rd Unnit

    23/29

    11/04/33

    23

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB45

    1. Retransmission:

    when error is discovered, the receiver can have the

    sender retransmit the data unit

    2. Forward Error Correction

    3. Burst Error Correction

    Error Correction

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 46

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

  • 8/10/2019 Cn 3rd Unnit

    24/29

    11/04/33

    24

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB47

    Forward Error Correction

    ExampleTo 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 theredundancy bits. Additional bits are required to

    cover all possible error location( including

    redundancy bits)

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 48

    Forward Error Correction

    The number of redundancy bits rto correct agiven number of data bitsm 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

  • 8/10/2019 Cn 3rd Unnit

    25/29

    11/04/33

    25

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB49

    Data and redundancy bitsData and redundancy bits

    Number of

    data bits

    m

    Number of

    redundancy bits

    r

    Total

    bits

    m + r

    11 2 3

    22 3 5

    33 3 6

    44 3 7

    55 4 9

    66 4 10

    77 4 11

    2r > = m + r + 1

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 50

    Hamming code

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

    The key to the Hamming Code is the use of extra parity bits to

    allow the identification of a single error

    Positions of redundancy bits:

  • 8/10/2019 Cn 3rd Unnit

    26/29

    11/04/33

    26

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB51

    Redundancy bit Calculation

    Binary(data) Decimal no

    00113

    01015

    01106

    01117

    10019

    101010

    101111

    Data ward =7 bits , r =4

    Codeward =7+4=11

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

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

    Bit r4: 5,6,7

    Bit r8: 9, 10,11

    Redundancy bit Calculation

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 52

    Each parity bit calculates the even parity for someof the bits in thecode 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 1if the total number of ones in the positions it

    checks isodd. Set a parity bit to 0if the total number of ones in the

    positions it checks is even.

    Redundancy bit Calculation

  • 8/10/2019 Cn 3rd Unnit

    27/29

    11/04/33

    27

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB53

    Redundancy bits calculation

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 54

    Example of redundancy bit calculation

    Using even parity

  • 8/10/2019 Cn 3rd Unnit

    28/29

    11/04/33

    28

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB55

    Error detection and correction using Hamming code

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB 56

    Burst error correction

    Hamming code cannot correct a burst error

    directly, it is possible to rearrange the data and

    then apply the code.

    Organize Nunits in a column and then send thefirst bit for each, followed by the second bit of

    each , and so on.

    If a burst error of Mbits occurs (M

  • 8/10/2019 Cn 3rd Unnit

    29/29

    11/04/33

    Behrouz A. Forouzan Data communication and NetworkingDr. Gihan NAGUIB57

    Burst error correction example