0% found this document useful (0 votes)
12 views

Week 4

The document provides information about a computer networks course taught by Mr. Attique Ur Rehman at Lahore Garrison University. It includes details about the instructor, credit hours for the course, textbook recommendations, and topics that will be covered such as error detection techniques, error correction, Hamming distance, and digital error detection.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Week 4

The document provides information about a computer networks course taught by Mr. Attique Ur Rehman at Lahore Garrison University. It includes details about the instructor, credit hours for the course, textbook recommendations, and topics that will be covered such as error detection techniques, error correction, Hamming distance, and digital error detection.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 44

1

CSC- 362 Computer Networks


Week-4 Lecture- 7-8
2
Instructor Contact Details

 Name: Mr. Attique Ur Rehman


 Course Instructor: CSC362- Computer Networks
 Credit Hours: (3+1)=4
 Office Location: 2nd Floor Computer Science Faculty Office:
41-C
 Email: [email protected]
 Visiting Hours: Wednesday (11:30 am -1:00 pm)

Lahore Garrison University


3
Course Material

 Reference books
 Many textbooks on Networking may be consulted
 Research papers!
 RFCs and Internet drafts
 Related to TCP/IP suite and other protocols
 Web resources
 Tutorials, white papers, reports, etc.

Lahore Garrison University


4
Text Book

 Computer Networks: A Systems Approach by Larry L. Peterson and Bruce S. Davies.


 Third Edition [2003], Morgan Kaufmann Publishers, San Mateo, California, USA
 Computer Networks by Andrew S. Tanenbaum
 Fifth Edition
 Data Communication and Computer Networks, by Behrouz A. Forouzan
 5th Edition
 Data and Computer Communications by William Stallings
 10th Edition
 Computer Networking: A Top-Down Approach Featuring the Internet by James F. Kurose and Keith W. Ross
 6th edition

Lahore Garrison University


5
Error Detection or Correction ?

 Data can corrupted during transmission


 Some applications require that errors be detected and corrected.
 Detection implies discarding message and waiting for retransmission
 uses bandwidth
 introduces latency
 Error correction requires more redundant bits to send all the time : error-
correcting code (FEC)
 Error correction is useful when:
 errors are quite probable (wireless links)
 retransmission cost is too high (latency in satellite link, multicast)
6
Types of Error

 Single bit error


 only 1 bit in the data unit has changed.

 Burst Error
 2 or more bits in data units have changed
Error Detection or Correction: Structure of7
Sender and Receiver

To detect or correct errors, we need to send extra (redundant) bits with


data.
8

Error Detection

 Why we need it ?
 To avoid retransmission of whole packet or message
 What to do if error detected ?
 Discard, and request a new copy of the frame:
 explicitly or implicitly
 Try to correct error, if possible
9

Error Detection

 Validates correctness of each frame


 Errors checked at many levels
 Demodulation of signals into symbols (analog)
 Bit error detection/correction (digital)—our main focus
 Within network adapter (CRC check)
 Within IP layer (IP checksum)
 Possibly within application as well
10

Error Detection: How ?

 How to detect error ?


 Add redundant information to a frame to determine errors
 Transmit two complete copies of data
 n redundant bits for n-bit message
 Error at the same position in two copies go undetected
11

Error Detection: How ?

 We want only k redundant bits for an n-bit message, where k < < n
 In Ethernet, 32-bit CRC for 12,000 bits (1500 bytes)
 k bits are derived from the original message
 Both the sender and receiver know the algorithm
12

Error Correction

 Error-correcting codes try to add enough redundant information so that the


receiver can still figure out the data if the frame is damaged. This is
sometimes referred to as forward error correction.
 The overhead is high but it reduces the need to resend frames.
 These redundant codes are best suited for networks with high error (wireless).
13

Hamming Distance

 The Hamming distance between two words is the number of differences


between corresponding bits.
 To find hamming distance between two words just XOR them and then count
the number of 1 bits in the result.
 The Hamming distance d(000, 011) is 2 because

 The Hamming distance d(10101, 11110) is 3 because


14

Hamming Distance

 110011000011001
 010111001011001
 -------------------------
 100100001000000
 The Hamming Distance is 3.
 This means 3 bits would have to “flip” before we would be unable to detect an
error.
 The minimum Hamming distance is the smallest Hamming distance between
all possible pairs in a set of words.
15

Codewords

 We do not make use of all of the possible codewords due to the use of check
bits.
 This means we can compute all of the legal codewords and determine the
minimum Hamming distance for the set.
 In order to detect d errors, we need a distance of d+1.
 In order to correct d errors, we need a distance of 2d+1.
16

The Parity Bit

 Consider the parity bit that tells us if the parity of the data is even or odd.
 The Hamming Distance would equal 2.
 Since it is only one bit, then it is able to identify single errors (if one bit has
flipped).
 If two bits have flipped, then the parity bit will report the correct parity for the
data.
17

1-bit Error Detection with Parity

 Every code has even number of 1’s


011 111
01 11
010
110
00 10
000
Valid 100
codes 001 101
Parity encoding:
if only 1 bit flips, gray dots are invalid
it can be detected and indicate errors
18

1-bit Error Correction with Voting

 Every code is copied three times


011 111
0 1
010
110
Valid
codes 000
100
- if only 1 bit flips, it 001 101
can be corrected
- even with 2 erasures, gray dots correct to “1”
bit can be recovered blue dots correct to “0”
19
Error Bits or Error Burst

 Common model of errors


 Probability of error per bit
 Error in each bit independent of others
 Value of incorrect bit independent of others
 Burst model
 Probability of back-to-back bit errors
 Error probability dependent on adjacent bits
 Value of errors may have structure
 Why assume bursts?
 Appropriate for some media (e.g., Radio)
 Faster signaling rate enhances such phenomena
20

Digital Error Detection Techniques

• Two-dimensional parity
– Detects up to 3-bit errors
– Good for burst errors

• Cyclic redundancy check (CRC)


– Powerful mathematics
– Tricky in software, simple in hardware
– Used in network adapter
21

Two-Dimensional Parity
Parity
 Adding one extra bit to a 7- bits
bit code to balance 1s 0101001 1
 extra parity byte for the 1101001 0
entire frame
 Catches all 1-, 2- and 3-bit 1011110 1
errors and most 4-bit errors Data
0001110 1
 14 redundant bits for a 42-
bit message, in the example 0110100 1

1011111 0

Parity
1111011 0
byte
22
Two-Dimensional Parity

0 1 0 0 0 1 1 1
0 1 1 0 0 0 1 1
0 1 1 0 1 1 1 1
0 1 1 0 0 0 0 0
1 0 0 1 0 0 1 1
0 1 1 0 1 1 0 0

1 1 0 1 0 1 0 0
23

Cyclic Redundancy Check

Theory
 based on finite-field (binary-valued) arithmetic
 bit string represented as polynomial
 coefficients are binary-valued
 divide bit string polynomial by generator polynomial to generate CRC

Practice
 bitwise XOR’s
24

Cyclic Redundancy Check

 Add k bits of redundant data to an n-bit message


 want k << n
 e.g., k = 32 and n = 12,000 (1500 bytes)
 Represent n-bit message as n-1 degree polynomial
 e.g., MSG=10011010 as M(x) = x7 + x4 + x3 + x1
 Sender and receiver exchange polynomials
 Let k be the degree of some agreed-upon divisor/ generator polynomial
 e.g., C(x) = x3 + x2 + 1
25

Cyclic Redundancy Check

 Transmit polynomial P(x) that is evenly divisible by C(x)


 shift left k bits, i.e., M(x)xk
 add remainder of M(x)xk / C(x) into M(x)xk
 Receiver receives polynomial P(x) + E(x)
 E(x) = 0 implies no errors
 Receiver divides (P(x) + E(x)) by C(x); remainder will be zero ONLY if:
 E(x) was zero (no error), or
 E(x) is exactly divisible by C(x)
26

CRC Example - Sender

 C(x) = x3+x2+1 = 1101  generator


 M(x) = x8 + x6 + x5 + x4+1 = 101110001  message

1101 ) 101110001000 k bits


1101
1101
1101
00001000
1101
101 remainder
27

CRC Example - Receiver

 C(x) = x3+x2+1 = 1101  generator


 M(x) = x11+x9+x8+x7+x3+x2+1 = 101110001101  message

1101 ) 101110001101
1101
remainder bits
1101
1101
00001101
1101
0 correct !
28

CRC Example - Receiver

 C(x) = x3+x2+1 = 1101  generator


 M(x) = x11+x9+x8+x7+x3+x2+1 = 101110001101  message

1101 ) 101101001101
1101
Two bits
1100
1101
are flipped
1100
1101
1110
1101
111 incorrect !
29

CRC Example - Receiver

 C(x) = x3+x2+1 = 1101  generator


 M(x) = x11+x9+x8+x7+x3+x2+1 = 101110001101  message

1101 ) 101101011101
1101
Three bits
1100
1101
are flipped
1101
1101
1101
1101
0 incorrectly correct !!!
30

Hamming Distance (1950 Paper)

 Minimum number of bit flips between code words


 2 flips for parity
 3 flips for voting
 n-bit error detection
 No code word changed into another code word
 Requires Hamming distance of n+1
 n-bit error correction
 N-bit neighborhood: all code words within n bit flips
 No overlap between n-bit neighborhoods
 Requires Hamming distance of 2n+1
31

Hamming Codes (1950 Paper)

 The following general algorithm generates a single-error


correcting (SEC) code for any number of bits.
 Number the bits starting from 1: bit 1, 2, 3, 4, 5, etc.
 Write the bit numbers in binary. 1, 10, 11, 100, 101, etc.
 All bit positions that are powers of two (have only one 1 bit in
the binary form of their position) are parity bits.
 All other bit positions, with two or more 1 bits in the binary
form of their position, are data bits.
 Each data bit is included in a unique set of 2 or more parity bits,
as determined by the binary form of its bit position.
32

Hamming Codes (1950 Paper)

 Parity bit 1 covers all bit positions which have the least significant
bit set: bit 1 (the parity bit itself), 3, 5, 7, 9, etc.
 Parity bit 2 covers all bit positions which have the second least
significant bit set: bit 2 (the parity bit itself), 3, 6, 7, 10, 11, etc.
 Parity bit 4 covers all bit positions which have the third least
significant bit set: bits 4–7, 12–15, 20–23, etc.
 Parity bit 8 covers all bit positions which have the fourth least
significant bit set: bits 8–15, 24–31, 40–47, etc.
 In general each parity bit covers all bits where the binary AND of
the parity position and the bit position is non-zero.
Hamming Codes (1950 Paper) 33
34

Bit position of the data and parity bits

2 6 4
010 110 100
7
3 111 5
011 101

1
001
35
Graphical depiction of the 4 data bits and 3 parity bits and
which parity bits apply to which data bits
36

Error Detection and Correction


1 2 3 4 5 6 7

p1 p2 D1 p4 D2 D3 D5

p1 p2 D1 p3 D2 D3 D4
p1 p2 D1 p4 D2 D3 D4
p1 p2 D1 p3 D2 D3 D4
P1 = D1 XOR D2 XOR D4
P2 = D1 XOR D3 XOR D4
P4 = D2 XOR D3 XOR D4
37
Graphical depiction of the 7 data bits and 4 parity bits and
which parity bits apply to which data bits
38

Bit position of the data and parity bits


39

Example of (11,7)

 7-bit data word "0110101“


 Data word with parity “10001100101”
 If last bit of data word flip “10001100100”
 Checking of parity bit
 Correction of Error “10001100101”
 7-bit data word "0110101“
40

Calculation of Hamming code parity bits


Hamming(11,7) code 41

7-bit data word "0110101"


Checking of parity bits 42

(switched bit highlighted)


Checking of parity bits 43

(switched bit highlighted)


44

Correction of Error

You might also like