Top Banner
CS352- Link Layer Dept. of Computer Science Rutgers University
49

CS352- Link Layer Dept. of Computer Science Rutgers University.

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352- Link Layer

Dept. of Computer Science

Rutgers University

Page 2: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 2

Content

Error detection and correction MAC sub-layer Ethernet Token Ring

Page 3: CS352- Link Layer Dept. of Computer Science Rutgers University.

Error Detection and Correction

Page 4: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 4

Error Detection and Correction

Used on many link types Can be used anytime you don’t trust the media

Caches ,memories, disks

Major Algorithmic Strategies: Parity

1 and 2 dimensional Hamming codes (Interleaved Parity Codes) Checksums Cyclic Redundancy Codes (CRC)

Page 5: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 5

Parity Codes

Single Bit Parity:Detect single bit errors

Two Dimensional Bit Parity:Detect and correct single bit errors

0 0

Page 6: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 6

Hamming Codes

Want to be able to correct error with less overhead than 2D parity

Hamming codes correct all single bit errors with only log(M) extra bits and detect double bit errors

Uses an interleaved parity scheme

Page 7: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 7

Calculating a Hamming Code

Procedure: Place message bits in their non-power-of-two

Hamming positions Build a table listing the binary representation each

each of the message bit positions Calculate the check bits

Page 8: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 8

Hamming Code Example

Message to be sent: 1 0 1 1

1 0 1 11 2 3 4 5 6 7

20 21 222n: check bits

Position

Page 9: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 9

Hamming Code Example

Calculate check bits:

3 = 21 + 20 = 0 1 15 = 22 + 20 = 1 0 16 = 22 + 21 + = 1 1 07 = 22 + 21 + 20 = 1 1 1

Message to be sent: 1 0 1 1

1 0 1 11 2 3 4 5 6 7

20 21 222n: check bits

Position

Page 10: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 10

1Starting with the 20 position:

Look at positions with 1’s in them

Count the number of 1’s in thecorresponding message bits

If even, place a 1 in the 20

check bit, i.e., use odd parity

Otherwise, place a 0

Calculate check bits:

3 = 21 + 20 = 0 1 15 = 22 + 20 = 1 0 16 = 22 + 21 + = 1 1 07 = 22 + 21 + 20 = 1 1 1

Message to be sent: 1 0 1 1

1 0 1 11 2 3 4 5 6 7

20 21 222n: check bits

Position

Hamming Code Example

Page 11: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 11

Repeat with the 21 position:

Look at positions those positions with 1’s in them

Count the number of 1’s in thecorresponding message bits

If even, place a 1 in the 21

check bit

Otherwise, place a 0

1 0

Calculate check bits:

3 = 21 + 20 = 0 1 15 = 22 + 20 = 1 0 16 = 22 + 21 + = 1 1 07 = 22 + 21 + 20 = 1 1 1

Message to be sent: 1 0 1 1

1 0 1 11 2 3 4 5 6 7

20 21 222n: check bits

Position

Hamming Code Example

Page 12: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 12

1 0Repeat with the 22 position:

Look at positions those positions with 1’s in them

Count the number of 1’s in thecorresponding message bits

If even, place a 1 in the 22

check bit

Otherwise, place a 0

1

Calculate check bits:

3 = 21 + 20 = 0 1 15 = 22 + 20 = 1 0 16 = 22 + 21 + = 1 1 07 = 22 + 21 + 20 = 1 1 1

Message to be sent: 1 0 1 1

1 0 1 11 2 3 4 5 6 7

20 21 222n: check bits

Position

Hamming Code Example

Page 13: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 13

Hamming Code Example

Original message = 1011

Sent message = 1011011

Now, how do we check for a single-bit error in the sent message using the Hamming code?

Page 14: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 14

Using Hamming Codes to Correct Single-Bit Errors

Received message: 1 0 1 1 0 0 1

2n: check bits

Calculate check bits:

3 = 21 + 20 = 0 1 15 = 22 + 20 = 1 0 16 = 22 + 21 = 1 1 07 = 22 + 21 + 20 = 1 1 1

1 0 1 1 0 0 11 2 3 4 5 6 7

20 21 22

Position

Page 15: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 15

Starting with the 20 position:

Look at positions with 1’s in them

Count the number of 1’s in both the corresponding message bits and the 20 check bit and compute the parity.

If even parity, there is an errorin one of the four bits that werechecked. Odd parity: No error in bits 1, 3, 5, 7

Received message: 1 0 1 1 0 0 1

2n: check bits

Calculate check bits:

3 = 21 + 20 = 0 1 15 = 22 + 20 = 1 0 16 = 22 + 21 = 1 1 07 = 22 + 21 + 20 = 1 1 1

1 0 1 1 0 0 11 2 3 4 5 6 7

20 21 22

Position

Using Hamming Codes to Correct Single-Bit Errors

Page 16: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 16

Repeat with the 21 position:

Look at positions with 1’s in them

Count the number of 1’s in both the corresponding message bits and the 21 check bit and compute the parity.

If even parity, there is an errorin one of the four bits that werechecked. Even parity: ERROR in bit 2, 3, 6 or 7!

Received message: 1 0 1 1 0 0 1

2n: check bits

Calculate check bits:

3 = 21 + 20 = 0 1 15 = 22 + 20 = 1 0 16 = 22 + 21 = 1 1 07 = 22 + 21 + 20 = 1 1 1

1 0 1 1 0 0 11 2 3 4 5 6 7

20 21 22

Position

Using Hamming Codes to Correct Single-Bit Errors

Page 17: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 17

Repeat with the 22 position:

Look at positions with 1’s in them

Count the number of 1’s in both the corresponding message bits and the 22 check bit and compute the parity.

If even parity, there is an errorin one of the four bits that werechecked. Even parity: ERROR in bit 4, 5, 6 or 7!

Received message: 1 0 1 1 0 0 1

2n: check bits

Calculate check bits:

3 = 21 + 20 = 0 1 15 = 22 + 20 = 1 0 16 = 22 + 21 = 1 1 07 = 22 + 21 + 20 = 1 1 1

1 0 1 1 0 0 11 2 3 4 5 6 7

20 21 22

Position

Using Hamming Codes to Correct Single-Bit Errors

Page 18: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 18

1 0 1 1 0 0 11 2 3 4 5 6 7Position

Finding the error’s location

Page 19: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 19

No error in bits 1, 3, 5, 7

1 0 1 1 0 0 11 2 3 4 5 6 7Position

Finding the error’s location

Page 20: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 20

ERROR in bit 2, 3, 6 or 7

ERROR in bit 4, 5, 6 or 7

Error must be in bit 6because bits 3, 5, 7are correct, and all theremaining informationagrees on bit 6

erroneous bit, change to 1

1 0 1 1 0 0 11 2 3 4 5 6 7Position

Finding the error’s location

Page 21: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 21

Finding the error’s locationAn Easier Alternative to the Last Slide

3 = 21 + 20 = 0 1 15 = 22 + 20 = 1 0 16 = 22 + 21 = 1 1 07 = 22 + 21 + 20 = 1 1 1

E E NE

1 1 0 = 6 E = error in columnNE = no error in column

Page 22: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 22

Hamming Codes

Hamming codes can be used to locate and correct a single-bit error

If more than one bit is in error, then a Hamming code cannot correct it

Hamming codes, like parity bits, are only useful on short messages

Page 23: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 23

CRC Polynomial Codes

Can detect errors on large chunks of data Has low overhead More robust than parity bit Requires the use of a “code polynomial”

Example: x2 + 1

Page 24: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 24

Cyclic Redundancy Check

Procedure:

1. Let r be the degree of the code polynomial. Append r zero bits to the end of the transmitted bit string. Call the entire bit string S(x)

2. Divide S(x) by the code polynomial using modulo 2 division.

3. Subtract the remainder from S(x) using modulo 2 subtraction.

The result is the checksummed message

Page 25: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 25

Generating a CRCExample

Message: 1011 1 x x3 + 0 x x2 + 1 x x + 1 = x3 + x + 1

Code Polynomial: x2 + 1 (101)

Step 1: Compute S(x)

r = 2

S(x) = 101100

Page 26: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 26

Generating a CRCExample (cont’d)

Step 2: Modulo 2 divide

101100101101

001 000 010 000 100 101 01

1001

Remainder

Page 27: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 27

Generating a CRCExample (cont’d)

Step 3: Modulo 2 subtract the remainder from S(x)

101100- 01101101

Checksummed Message

Page 28: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 28

Decoding a CRC

Procedure

1. Let n be the length of the checksummed message in bits

2. Divide the checksummed message by the code polynomial using modulo 2 division. If the remainer is zero, there is no error detected.

Page 29: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 29

Decoding a CRCExample

101101 Checksummed message (n = 6)

1011 Original message (if there are no errors)

101101101101

001 000 010 000 101 101 00

1001

Remainder = 0(No error detected)

Page 30: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 30

Decoding a CRCAnother Example

When a bit error occurs, there is a large probability that it will produce a polynomial that is not an even multiple of the code polynomial, and thus errors can usually be detected.

101001101101

000 000 000 000 001 000 01

1000

Remainder = 1(Error detected)

Page 31: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 31

Choosing a CRC polynomial

The longer the polynomial, the smaller the probability of undetected error

Common standard polynomials:(1) CRC-12: x12 + x11 + x3 + x2 + x1 + 1

(2) CRC-16: x16 + x15 + x2 + 1

(3) CRC-CCITT: x16 + x12 + x5 + 1

Page 32: CS352- Link Layer Dept. of Computer Science Rutgers University.

MAC sub-layer

Page 33: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 33

What is “Media”

Radio Ring Shared Wire

Page 34: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 34

Medium Access Sub-layer

Network Layer

Data Link Layer

Physical Layer

Medium Access Sub-layer

Page 35: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 35

Medium Access Sublayer (cont’d)

Medium access (MAC) sub-layer is not important on point-to-point links

The MAC sub-layer is only used in broadcast or shared channel networks

Examples: Satellite, Ethernet, Cellular

Page 36: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 36

Access Protocols

Who gets to use the channel next? Fixed/Static assignment Demand assignment Contention Turn-Based

Page 37: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 37

Fixed Assignment Protocols

Static and predetermined allocation of channel access: independent of user activity

Idle users may be assigned to the channel, in which case channel capacity is wasted

Examples: TDMA, FDMA

Page 38: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 38

Channel Partitioning MAC protocols: TDMA

TDMA: time division multiple access access to channel in "rounds" each station gets fixed length slot (length = pkt

trans time) in each round unused slots go idle example: 6-station LAN, 1,3,4 have pkt, slots

2,5,6 idle

Page 39: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 39

Channel Partitioning MAC protocols: FDMA

FDMA: frequency division multiple access channel spectrum divided into frequency bands each station assigned fixed frequency band unused transmission time in frequency bands go idle example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6

idle

frequ

ency

bands time

Page 40: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 40

Demand Assignment Protocols

Allocate channel capacity to hosts on a demand basis (i.e., only to active users)

Requires methods for measuring the demand for the channel Polling Reservation schemes

Page 41: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 41

Polling

A central controller interrogates each host and allocates channel capacity to those who need it

Good for systems with: Short propagation delay Small polling messages Non-bursty traffic

Page 42: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 42

Reservation Schemes

Hosts independently reserve the channel for period of time

Reservations are usually piggybacked on data messages passing along the channel

Good for systems with : short propagation delay no central controller node non-bursty traffic

Page 43: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 43

Reservation Protocols (cont’d)

Reservation protocol examples: Bit-Map Protocol Binary Countdown Protocol

Page 44: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 44

Bit-Map Protocol

Contention and data transmission periods alternate The contention period is divided into slots, with 1 bit-wide

slots for each host in the network. If a host wants to transmit a packet, it sets its contention slot

equal to 1. Otherwise, it sets it to 0. The slots pass all hosts in sequence, so every host is aware

of who will transmit

1 11 1 1 1 2 4 5 6

01234567 01234567

0 4

data frame

Page 45: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 45

Bit-Map Protocol (cont’d)

But what if there are a large number of hosts in the network?

The contention period will have to grow to include them all

With a large number of hosts, the contention period may be very long, leading to inefficiency

Page 46: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 46

Binary Countdown Protocol

During contention period, each host broadcasts its binary address one bit at a time,

starting with the most significant bit bits transmitted simultaneously are boolean OR’d together

Arbitration rule: If a host sent a zero bit but the boolean OR results in a one

bit, the host gives up and stops sending address bits Whichever host remains after the entire address has been

broadcast gets access to the medium

Page 47: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 47

Binary Countdown (cont’d)

0 0 1 0

0 1 0 1

1 0 0 1

1 0 1 0

0 - - -

0 - - -

1 0 0 -

1 0 1 0

0 1 2 3

Bit TimeHostAddresses

Page 48: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 48

Binary Countdown: Fairness

Stations with the highest addresses will always win. This is good if you want to implement priority, but

bad if you want to give all hosts fair access to the channel Used in CAN-bus networks (cars)

Solution: Change the address of a host after a successful

transmission

Page 49: CS352- Link Layer Dept. of Computer Science Rutgers University.

CS352 Fall,2005 49

Binary Countdown: Permuting Addresses

After host A successful transmission, all hosts with addresses less than host A add one to their address, improving their priority

Host A changes its address to zero, giving it the lowest priority