30
EEC-484/584 EEC-484/584 Computer Networks Computer Networks Lecture 7 Lecture 7 Wenbing Zhao Wenbing Zhao [email protected] [email protected]

EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao [email protected]

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

Page 1: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

EEC-484/584EEC-484/584Computer NetworksComputer Networks

Lecture 7Lecture 7

Wenbing ZhaoWenbing Zhao

[email protected]@ieee.org

Page 2: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

22

OutlineOutline

• Error Detection – CRC

• Exercises for Framing and Error Detection

• Medium Access Control

Page 3: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

33

Error-Detecting Codes: CRCError-Detecting Codes: CRC

• Polynomial code, also known as CRC (Cyclic Redundant Code)

• Treat bit string as polynomial with 0 and 1 coefficients

• m-bit frame: M(x) = bm-1xm-1 + … + b0

• E.g.: 11011010 => M(x) = x7 + x6 + x4 + x3 + x1

• Use modulo 2 arithmetic– No carries or borrows: XOR

• The degree of a polynomial is the maximum of the degrees of all terms in the polynomial

Page 4: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

44

Cyclic Redundant CodeCyclic Redundant Code• Sender and receiver agree on generator

polynomial G(x) (High & low order bits must be 1)• For a frame with m bits corresponding to M(x),m > deg G(x) = r

• Append checksum to end of frame so polynomial T(x) corresponding to checksummed frame is divisible by G(x)

• When receiver gets checksummed frame, divides T(x) by G(x)

• If remainder R(x) != 0, then transmission error

Page 5: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

55

Algorithm to Compute CRC ChecksumAlgorithm to Compute CRC Checksum

• Let m = deg M(x), r = deg G(x)• Append r 0 bits to lower-order end of frame: xrM(x)• Divide bit string corresponding to xrM(x) by bit string

corresponding to G(x)• Subtract remainder R(x) from bit string corresponding

to xrM(x), result is checksummed frame. Let T(x) be its polynomial– xrM(x) = Q(x)G(x) + R(x)– xrM(x) – R(x) = Q(x)G(x) = T(x)

Page 6: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

66

Compute CRC Compute CRC ChecksumChecksum

XOR

Page 7: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

77

International Standard PolynomialsInternational Standard Polynomials

• CRC-12 G(x) = x12 + x11 + x3 + x2 + x1 + 1– Used for 6-bit characters

• CRC-16 G(x) = x16 + x15 + x2 + 1CRC-CCITT G(x) = x16 + x12 + x5 + 1– Used for 8-bit characters

• CRC-32 G(x) = x32 + x26 + x23 + x22 + x16 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x1 + 1– Used in IEEE 802– Detects all bursts of length 32 or less and all bursts

affecting an odd number of bits

Page 8: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

88

ExerciseExercise

• Q1. The following character encoding is used in a data link protocol: A: 01000111; B: 11100011; FLAG: 01111110; ESC: 11100000 Show the bit sequence transmitted (in binary) for the four-character frame: A B ESC FLAG when each of the following framing methods are used:(a) Character count.

(b) Flag bytes with byte stuffing.

(c) Starting and ending flag bytes, with bit stuffing

Page 9: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

99

ExerciseExercise

• Q4. One of your classmates, Scrooge, has pointed out that it is wasteful to end each frame with a flag byte and then begin the next one with a second flag byte. One flag byte could do the job as well, and a byte saved is a byte earned. Do you agree?

Page 10: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1010

ExerciseExercise

• Q5. To provide more reliability than a single parity bit can give, an error-detecting coding scheme uses one parity bit for checking all the odd-numbered bits and a second parity bit for all the even-numbered bits. What is the Hamming distance of this code?

Page 11: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1111

ExerciseExercise

• Q6. A bit stream 10011101 is transmitted using the standard CRC method described in the text. The generator polynomial is x3 + 1. Show the actual bit string transmitted. Suppose the third bit from the left is inverted during transmission. Show that this error is detected at the receiver's end.

Page 12: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1212

Medium Access Control SublayerMedium Access Control Sublayer

• Broadcast channels often used on DLL– multiaccess or random access

• The channel allocation problem: Who gets to use the channel?– Static Channel Allocation– Dynamic Channel Allocation

Page 13: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1313

Static Channel AllocationStatic Channel Allocation

• FDM – Frequency Division Multiplexing– Frequency spectrum divided into logical channel– Each user has exclusive use of own frequency band

• TDM – Time Division Multiplexing– Time divided into slots each user has time slot– Users take turns in round robin fashion

• Problem: wasted bandwidth if user does not use his/her frequency band or timeslot

Page 14: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1414

Frequency Division MultiplexingFrequency Division Multiplexing

Page 15: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1515

Time Division MultiplexingTime Division Multiplexing

T1 Carrier (1.544 Mbps)

Page 16: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1616Model for Model for Dynamic Channel AllocationDynamic Channel Allocation

• N independent stations (also called terminals)

• Probability of a frame being generated in an interval t is t (arrival rate constant)

• Once a frame has been generated, the station is blocked until the frame is transmitted successfully

Page 17: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1717

Model for Model for Dynamic Channel AllocationDynamic Channel Allocation

• Single Channel shared by all stations

• Collision – event when two frames transmitted simultaneously and the resulting signal is garbled– All stations can detect collisions

Page 18: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1818

Model for Model for Dynamic Channel AllocationDynamic Channel Allocation

• Frame transmission time– Continuous Time – can begin at any instant– Slotted Time – always begin at the start of a

slot

• Carrier sense or not– Carrier sense – stations can tell if the channel

is busy. Do not send if channel is busy– No carrier sense – just go ahead and send

Page 19: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

1919

Multiple Access ProtocolsMultiple Access Protocols

• ALOHA

• Carrier Sense Multiple Access Protocols

Page 20: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2020

Pure ALOHAPure ALOHA

• Let users transmit whenever they have data to send

• If frame destroyed (due to collision), sender waits random amount of time, sends again

• User does not listen before transmitting

Page 21: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2121

Pure ALOHA: Vulnerable PeriodPure ALOHA: Vulnerable Period• Vulnerable period for a frame: A collision will

happen if another frame is sent during this period

2 frame time

Page 22: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2222

Pure ALOHAPure ALOHA

• Throughput for ALOHA systems

Page 23: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2323

Slotted ALOHASlotted ALOHA

• Idea: divide time into intervals, each interval corresponds to one frame– Station is permitted to send only at the

beginning of next slot

• Vulnerable period is halved (1 frame time)– Probability of no collision in time slot = e-G

– Throughput S = G e-G

– Max occurs when G = 1, S = 2*0.184

Page 24: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2424

Carrier Sense Multiple AccessCarrier Sense Multiple Access

• When station has data to send, listens to channel to see if anyone else is transmitting

• If channel is idle, station transmits a frame• Else station waits for it to become idle• If collisions occurs, station waits random amount

of time, tries again• Also called 1-persistent CSMA

– With probability 1 station will transmit if channel is idle

Page 25: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2525

• After a station starts sending, it takes a while before 2nd station receives 1st station’s signal– 2nd station might start sending before it knows that

another station has already been transmitting

• If two stations become ready while third station transmitting– Both wait until transmission ends and start

transmitting, collision results

Carrier Sense Multiple Access:Carrier Sense Multiple Access:Collision Still PossibleCollision Still Possible

Page 26: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2626

pp-persistent CSMA:-persistent CSMA:Reduce the Probability of CollisionReduce the Probability of Collision

• Sense continuously, but does not always send when channel is idle– Applicable for slotted channels

• When ready to send, station senses the channel– If channel idle, station transmits with probability p,

defers to next slot with probability q = 1-p– Else (if channel is busy) station waits until next slot tries

again– If next slot idle, station transmits with probability p,

defers with probability q = 1-p– …

Page 27: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2727

Non-Persistent CSMANon-Persistent CSMA

• Does not sense continuously, send if it senses the channel is idle

• Before sending, station senses the channel– If channel is idle, station begins sending– Else station does not continuously sense, waits

random amount of time, tries again

Page 28: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2828

Persistent and Nonpersistent CSMAPersistent and Nonpersistent CSMA

• Improves over ALOHA because they ensure no station to transmit when it senses channel is busy

Page 29: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

2929

CSMA with Collision DetectionCSMA with Collision Detection

• If two stations start transmitting simultaneously, both detect collision and stop transmitting

• Minimum time to detect collision = time for signal to propagate

Page 30: EEC-484/584 Computer Networks Lecture 7 Wenbing Zhao wenbing@ieee.org

Fall Semester 2007Fall Semester 2007 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao

3030Contention Period:Contention Period:Minimum Time to Detect CollisionMinimum Time to Detect Collision

• Let the time for a signal to propagate between the two farthest stations be

• For station to be sure it has channel and other stations will not interfere, it must wait 2 without hearing a collision (not as you might expect)– At t0, station A begins transmitting– At t0+-, B begins transmitting, just before A’s signal

arrives– B detects collision and stops– At t0+-+ (t0+2-), A detects collision

A B