Lecture Error

Embed Size (px)

Citation preview

  • 7/31/2019 Lecture Error

    1/36

    1

    Error Detection and Correction

  • 7/31/2019 Lecture Error

    2/36

    2

    Handling Errors (1): Ignore Them!

    data in

    data out

    Tx -DATA

    frame

    Rx

    Some errors are not significant

    audio

    video

  • 7/31/2019 Lecture Error

    3/36

    3

    Handling Errors (2): Do something

    data in

    data out

    Lets meet at1pm tomorrow Tx

    -DATAframe

    RxLets meet at

    3pm tomorrow

    Most errors are significant must be detected

    If only detect errors Reverse Error Correction (REC)

    must ask for retransmission ARQ protocol

    unsuited to real-time applications

    unsuited to simplex communication

    If detect and correct errors Forward Error Correction (FEC)

  • 7/31/2019 Lecture Error

    4/36

    4

    A Simple REC System

    data in

    Lets meet at1pm tomorrow Tx

    -

    -

    Lets meet at

    3pm tomorrow

    Lets meet at1pm tomorrow

    NAK

    Rx

    Send data twice

    Rx delivers data if two copies identical and generates ACK-frame

    Rx sends NAK-frame if two copies differ

  • 7/31/2019 Lecture Error

    5/36

    5

    A Simple FEC System

    data in data out

    Lets meet at1pm tomorrow Tx

    -

    -

    -

    Lets meet at

    3pm tomorrow

    Lets meet at1pm tomorrow

    Lets meet at1pm tomorrow

    RxLets meet at

    1pm tomorrow

    Send data thrice

    Rx delivers the majority

  • 7/31/2019 Lecture Error

    6/36

    6

    Defeating Error Correction

    data in data out

    Lets meet at1pm tomorrow Tx

    -

    -

    -

    Lets meet at

    3pm tomorrow

    Lets meet at3pm tomorrow

    Lets meet at1pm tomorrow

    RxLets meet at

    3pm tomorrow

    More severe errors may not be detected

  • 7/31/2019 Lecture Error

    7/36

    7

    The Basis for Error Handling

    add redundancy to data to form codewords

    handle two types of errors:

    random errors bit error rate (BER)

    error bursts up to B bits in error

    Codewords should have enough redundancy to detect probable errors

  • 7/31/2019 Lecture Error

    8/36

  • 7/31/2019 Lecture Error

    9/36

    9

    Coordination Failure with Communication Failure

    H1

    m1 -H2

    ...

    H1mn1 H2

    H1mn - H2

  • 7/31/2019 Lecture Error

    10/36

    10

    Hamming Distance

    - b00 1

    - b0

    6

    b1

    00 01

    10 11

    -b0

    6b1

    >b2

    000 001

    010 011

    100 101

    110 111

    HD is number of bits between codewords

    e.g. 0002 is HD of two from 0112, 1012, and 1102

    Error detection/correction based on HD between valid codewords

  • 7/31/2019 Lecture Error

    11/36

    11

    Hamming Distance of Two

    000 001

    010 011

    100 101

    110 111

    000 001

    010 011

    100 101

    110 111

    One bit error will change valid codeword to invalid codeword

    Two bit error will change valid codeword into different valid codeword

  • 7/31/2019 Lecture Error

    12/36

    12

    Hamming Distance of Three

    000 001

    010 011

    100 101

    110 111

    One bit error will change valid codeword to invalid codeword

    invalid code HD of one from only one valid codeword

    Two bit error will change valid codeword to invalid codeword

  • 7/31/2019 Lecture Error

    13/36

  • 7/31/2019 Lecture Error

    14/36

    14

    Using Hamming Distance

    To reliably detect up to e bits in error

    bits in error must be less than HD

    e = HD 1

    HD = e + 1

    To reliably detect and correct up to e bits in error

    bits in error must be less than halfway of HD

    e = HD 1

    2

    HD = 2e + 1

    5

  • 7/31/2019 Lecture Error

    15/36

    15

    Parity Bits

    codeword

    r m6 m5 m4 m3 m2 m1 m0

    r = m0 +2 . . . +2 m6

    ASCII X (10110002)

    1 1 0 1 1 0 0 0

    modulo arithmetic

    no carry

    0 +2 0 = 0

    1 +2 0 = 1

    0 +2 1 = 1

    1 +2 1 = 0

    this defines even parity

    16

  • 7/31/2019 Lecture Error

    16/36

    16

    Parity Bits

    codeword

    r m6 m5 m4 m3 m2 m1 m0

    r = m0 +2 . . . +2 m6

    ASCII X (10110002)

    1 1 0 1 1 0 0 0

    1 1 0 0 1 0 0 0

    17

  • 7/31/2019 Lecture Error

    17/36

    17

    Parity Bits

    codeword

    r m6 m5 m4 m3 m2 m1 m0

    r = m0 +2 . . . +2 m6

    ASCII X (10110002)

    1 1 0 1 1 0 0 0

    1 1 0 1 1 0 1 0

    18

  • 7/31/2019 Lecture Error

    18/36

    18

    Parity Bits

    codeword

    r m6 m5 m4 m3 m2 m1 m0

    r = m0 +2 . . . +2 m6

    ASCII X (10110002)

    1 1 0 1 1 0 0 0

    0 1 0 1 1 0 0 0

    19

  • 7/31/2019 Lecture Error

    19/36

    19

    Odd and Even Parity

    000 001

    010 011

    100 101

    110 111 even parity

    r = m0 +2 . . . +2 mn

    hardware: XOR returns 0

    by eye: even number of one bits

    000 001

    010 011

    100 101

    110 111 odd parityr = m0 +2 . . . +2 mn + 1

    hardware: XOR returns 1

    by eye: odd number of one bits

    Dont need to know which bit is redundant bit

    Implements HD=2 reliably detects one bit errors

    20

  • 7/31/2019 Lecture Error

    20/36

    20

    Worksheet: Hamming Distance and Parity

    1. Draw arcs between the codewords HD=1

    1011 1100 1001

    1111 1010 1000

    0111 0000

    2. If1000 is to be a valid codeword, shade codewords which maintain HD=2.

    3. What type of parity do codewords have?

    4. If1010 was received, with single bit, what codewords might have been sent?

    5. How bit errors can parity check detect, and how many can it correct?

  • 7/31/2019 Lecture Error

    21/36

  • 7/31/2019 Lecture Error

    22/36

  • 7/31/2019 Lecture Error

    23/36

    24

  • 7/31/2019 Lecture Error

    24/36

    24

    Hamming Code

    b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1

    20

    21

    22

    23

    m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1

    X 0 1 0 1 ? 1 0 0 ? 0 ? ?

    Each bit position bn where n = 2x used for redundancy bit

    Parity generated on all bits bm where m has x bit set

    25

  • 7/31/2019 Lecture Error

    25/36

    25

    Numbering bits means each has unique identifier

    b12 1 1 0 0

    b11 1 0 1 1

    b10 1 0 1 0

    b9 1 0 0 1

    b8 1 0 0 0

    b7 0 1 1 1

    b6 0 1 1 0

    b5 0 1 0 1

    b4 0 1 0 0

    b3 0 0 1 1

    b2 0 0 1 0

    b1 0 0 0 1

    26

  • 7/31/2019 Lecture Error

    26/36

    26

    Hamming Code: Compute 20 Value

    b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1

    20 1 1 1 0 0 ?

    21

    22

    23

    m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1

    X 0 1 0 1 ? 1 0 0 ? 0 ? ?

    The value ofr1

    is the even parity for all bn

    where n has b1 = 1

    Thus r1 = 1

    27

  • 7/31/2019 Lecture Error

    27/36

    27

    Hamming Code: Compute 21 Value

    b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1

    20

    21 1 0 1 0 0 ?

    22

    23

    m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1

    X 0 1 0 1 ? 1 0 0 ? 0 ? 1

    The value ofr2

    is the even parity for allbn

    wheren

    hasb2 = 1

    Thus r2 = 0

    28

  • 7/31/2019 Lecture Error

    28/36

    8

    Hamming Code: Compute 22 Value

    b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1

    20

    21

    22 0 1 0 0 ?

    23

    m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1

    X 0 1 0 1 ? 1 0 0 ? 0 0 1

    The value ofr3

    is the even parity for allbn

    wheren

    hasb3 = 1

    Thus r3 = 1

  • 7/31/2019 Lecture Error

    29/36

  • 7/31/2019 Lecture Error

    30/36

    31

  • 7/31/2019 Lecture Error

    31/36

    Worksheet: Hamming Code

    m8 m7 m6 m5 r4 m4 m3 m2 r3 m1 r2 r1

    1. Write message 11101110 into the message bit boxes above.

    2. Compute using even parity the bits r4r3r2r1

    3. Invert message bit m6, and write down in the order r4r3r2r1 a 1 ifrn parity is

    now incorrect, or a 0 if correct.

    4. Invert the bit position in the codeword which the number represents.

    32

  • 7/31/2019 Lecture Error

    32/36

    Cyclic Redundancy Check

    If we take a number n and divide by divisor d, result is

    integer quotient q

    integer remainder r

    obeys the equation n = qd + r

    If we add an error e to n, then n+

    e=

    q

    d+

    r

    e < d r = r

    r = r e must be an integer multiple ofd

    CRC uses this idea (but using modulo 2 division)

    33

  • 7/31/2019 Lecture Error

    33/36

    Examples of CRC Checking

    n d q r e n + e r OK?

    245 161 1 84 0 245 84 Yes

    1 246 85 No

    2 247 86 No

    160 405 83 No

    161 406 84 Yes

    162 407 85 No

    321 566 83 No

    322 567 84 Yes

    323 568 85 No

    First error pattern not detected = 16110 = 101000012

    Second error pattern not detected = 32210 = 1010000102

    34

  • 7/31/2019 Lecture Error

    34/36

    Properties of 16 bit CRC

    name polynomial binary divisor application

    CRC-16 X16 + X15 + X2 + 1 11000000000000101 USB

    CRC-CCITT X16 + X12 + X5 + 1 10001000000100001 Bluetooth

    Choosing values for polynomials need care to achieve the best performance. Those

    above detect:

    error bursts of 16 bits

    all error bursts with an odd number of bits

    99.997% of 17 bit errors

    99.998% of 18 or longer bit errors

    35

  • 7/31/2019 Lecture Error

    35/36

    Properties of 32 bit CRC

    IEEE 802.3 CRC-32 is

    x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1

    As a shorthand write as a number representing polynomials (missing off the

    last +1). e.g. IEEE 802.3 0x82608EDB, iSCSI 0x8F6E37A0

    HD max no message bits

    0x82608EDB 0x8F6E37A0 0xBA0DC66B 0xD419CC15 0x80108400

    8 91 177 152 58 0

    7 171 (177) (152) 81 0

    6 268 5,243 16,360 1,060 0

    5 2,974 (5,243) (16,360) 65,505 65,5054 91,607 128K 114,663 (65,505) (65,505)

    3 128K unknown (114,663) (65,505) (65,505)

    36

  • 7/31/2019 Lecture Error

    36/36

    Error Bursts

    message1+redundant1 = n15 n14

    n13

    n12

    n11

    message2+redundant2 = n25 n24

    n23

    n22

    n21

    message3+redundant3 = n35 n34 n

    33 n

    32 n

    31

    message4+redundant4 = n45 n44

    n43

    n42

    n41

    - . . . n13 n42 n

    32 n

    22 n

    12 n

    41 n

    31 n

    21 n

    11

    transmitted data interleaves codewords

    If basic error checking can detect B bit bursts, interleaving N codewords

    allows N B bursts to be detected