medium access control tanenbaum (chapter 4) others references: walrand j., communication networks: a...

78
Medium Access Control Tanenbaum (Chapter 4) Others References: Walrand J., Communication Networks: A first Course Bertesekas and Gallager, Data Networks

Post on 21-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Medium Access Control

Tanenbaum (Chapter 4)

Others References:Walrand J., Communication Networks: A first Course

Bertesekas and Gallager, Data Networks

04/18/23 Medium Access Control 2

Where in the OSI Reference Model ?

Session

Transport

Network

Link Layer

Physical

Presentation

Application

Data Link Layer

Medium Access Control

04/18/23 Medium Access Control 3

Why Do We Need a MAC Layer ?

• Let us consider different topologies– Point-to-point channel

• full duplex

• half duplex

– Broadcast channel

04/18/23 Medium Access Control 4

Management of Broadcast Channels

• Contention free: allocating statically shares of the channel to all stations (by TDM, FDM, or other)

• Contention: let stations compete for the ALL channel

Servers

One server

04/18/23 Medium Access Control 5

Objectives of This Chapter:Establish A Key Result

• 1) Efficiency: with heavy load, contention free systems are better than contention systems.

• 2) For average delay: contention systems are better than contention free (Whatever is the protocol! ) Introduction to Queueing Theory

04/18/23 Medium Access Control 6

Objectives of This Chapter (cont’d):Establish some Properties

• Relationship between a MAC protocol and physical properties of network:– Upperbound on efficiency– Maximum length of medium– Bandwidth– Minimum packet size

04/18/23 Medium Access Control 7

Objectives of This Chapter (cont’d):Techniques of Analysis

• Initiate students to the techniques used to analyze the performance of MAC protocols:– Aloha protocol– Slotted Aloha– CSMA– CSMA/CD

Objective 1: Establish A Key Result on

Average Delay

Queueing Theory

Introduction to Analytical Modeling

L.Kleinrock, “Queueing Systems”

R.Jain, “The Art of Computer Systems Performance Analysis”

E. Modiano, MIT course on Communications

04/18/23 Medium Access Control 10

Packet Switched Networks

PS

PS

PS

PS

PS

PS

PS

PacketSwitch

Buffer

PS

04/18/23 Medium Access Control 11

Queues Everywhere

• Processes waiting for CPU

• I/O Disk requests

• Network interface card

• IP input (output) queues

• Events (mouse click, keyboard…)

• ………………………

04/18/23 Medium Access Control 12

Queueing Theory

• What creates queues?– Randomness!!!

• Used for analyzing network performance• In packet networks, randomness comes from:

– random packet arrival– Random packet length

• Information of interest:– Delay in buffer (queueing delay)– Buffer size

04/18/23 Medium Access Control 13

Queueing Theory

JobSources

Servers

jobs

Or customers

04/18/23 Medium Access Control 14

A Queueing System A/S/m/B/K/SD

• A : Interarrival time of jobs distribution• S : The service time distribution• m : Number of servers• B : Capacity of the system (max # of jobs allowed)• K : population size• SD : Service discipline

– Default values B = ∞; K=∞; and Z=FCFS– For A and B

• G : General distribution• M : Exponential Distribution (memoryless property)• D : Deterministic

04/18/23 Medium Access Control 15

Example

• M/D/2/15/20000/FCFS– Time between arrivals exponentially distributed

– Service time constant (no variation)

– 2 servers

– System capacity is 15 (2 places for currently served + 13 waiting)

– Population is 20000 (20000 customers will ever come to the system)

– Service discipline is first come first served

04/18/23 Medium Access Control 16

Queueing Models

• Model good for– Requests received by Google– Customers waiting in line– Packets waiting to be transmitted over a line

• Information of interest– Average number of customers in the system– Average delay experienced by a customer

04/18/23 Medium Access Control 17

• Mean arrival rate: • Mean service rate: (service time per job)• Number of customers in system: n• Waiting time (in queue+service): w

Queueing System: Variables of Interest

JobSources

Servers

jobs

Or customers

04/18/23 Medium Access Control 18

A Key Result : Little’s Law

Black BoxArrivals Departure

Mean # in system = Mean arrival rate X mean time spent in systemE(n) = .E(w)

Remarks :- Result independent of A/B distributions or SD- Can be applied to all system or part of it- Crowded system long delays

04/18/23 Medium Access Control 19

A Key Result : Little’s LawExample

A monitor on an HTTP server showed that the average time to satisfy a request was about 50 milliseconds. The requestsarrival rate is 200 requests per second.What should be the buffer size (unit is requests) at the http server For the requests ?

Little’s law states E(n) = . E(w)

Here =200 req/s and E(w) = 0.050 s

The expected number of customers in the system is E(n)

E(n) = 200 x 0.050 = 10

It would be safe to have a buffer size of 20

04/18/23 Medium Access Control 20

Arrival Process

• Packets arrive according to some random process

• There are many stochastic processes.

• A nice stochastic process is the Poisson process– Mean arrival rate of packets per second– Prob(n arrivals during T) = [(.T)n e-T]/n!

04/18/23 Medium Access Control 21

Example• The number of phone calls arriving to a

switch can be closely modeled as a Poisson process. Suppose that the mean arrival rate is 100 per hour.

• What is the probability to receive 10 calls in 6 minutes?

T = 0.1 hour, = 100/h

Prob(n arrivals during T) = [(.T)n e-T]/n!Prob(10 arrivals during 0.1 h)= (100x0.1)10xe-(100x0.1)/10!=0.12Prob(10 arrivals during 15 mn) = 0.003

04/18/23 Medium Access Control 22

InterArrival Times of Poisson Process

• This is the time between consecutive arrivals. IA is a continuous random variable

• What is its probability distribution function?

• Prob(IA <= t) = 1 – Prob(IA > t)

• = 1 - Prob(0 arrivals within t)• Prob(0 arrivals during t) = [(.t)0 e-t]/0!= e-t

• So, Prob(IA <= t) = 1 - e-t

04/18/23 Medium Access Control 23

InterArrival Times of Poisson Process (2)

• The cumulative distribution function (CDF) is:– Prob(IA <= t) = 1 - e-t

• The probability distribution function is the derivative of CDF, i.e., PDF = .e-t

• This what is called the exponential distribution

• This distribution is largely used to model the service times, time between error losses, ..

04/18/23 Medium Access Control 24

Memoryless Property

• Def: A random variable X is said to be without memory, or memoryless, – P(X>s+t|X>t) = P(X>s) for all s, t ≥ 0

• In words: “When I get to the bus station, I am told that the probability that the bus comes within the next 10 minutes is 0.90. After one hour waiting, I am told that the probability that the bus comes within the next 10 minutes is still 0.90 ”

• Important result : X is memoryless iff it is exponentially distributed

04/18/23 Medium Access Control 25

More Examples

• Suppose that the time to graduate from AU is exponentially distributed with mean 4 years.

• Given that a student already spent 3 years at AU, what is the expected remaining time before he graduates?

04/18/23 Medium Access Control 26

• Merging of K P.P with mean rate i results in a P.P with mean rate the sum of the i’s.

• Splitting (randomly) a P.P with mean rate with probabilities pi results in P.Ps with mean rates pi. .

Properties of Poisson Process (PP)

1

2

i

n

i

p1.1

p2.2

pi.ipn.n

04/18/23 Medium Access Control 27

Analysis of an M/M/1

• Interarrival exponentially distributed (Memoryless)• Service time exponentially distributed (Memoryless)• One server• Infinite capacity of system• Infinite population• First come, first served

JobsSource Server

Queue

04/18/23 Medium Access Control 28

Analysis of an M/M/1 (2)

• We are interested in the average number of jobs in the system, the average waiting time in the system, or in the probability to have a given number of customers in the system.

• Notations– N(t): number of jobs in system at time t– Pn(t) = Prob{N(t)=n}– Pn = lim t-->∞ Pn(t)– = arrival rate– = service rate (service time = 1/ )

04/18/23 Medium Access Control 29

Markov Chain for M/M/1 System

• Circle i = state i means there are i customers in the system

• What is the probability Prob(i,j), i.e, the probability of transition from state i and j?

• Prob(j,j+1) = and Proj(j,j-1) =

0

1

2

3

4

5

04/18/23 Medium Access Control 30

Remarks about M/M/1

• > , otherwise the system will be instable

• After some time in operation, an M/M/1 gets into some equilibrium.

• When in equilibrium Pi = Pi+1

0

1

2

3

4

5

i

04/18/23 Medium Access Control 31

Determining Pn

0

1

2

3

4

5

Po = P1

P1 = P2

…………..Pn = Pn+1

Using the equations above and the sum Pi = 1, we can derive Pi’s

P1 = (\P0

P2 = (\P1

…………..Pn+1 = (\Pn

Pn = (\nP0

Pi = (\iP0 = P0.(\i = P0/(1-(\= P0/(1-

P0 =(1- Pi = i(1-

04/18/23 Medium Access Control 32

Mean Queue Length E(N) = /(1-) =/ is the traffic intensity

• The average number of customers in the system is E(N)

• E(N) = ii(1- = (1-

• E(N) = (1-.ii

• E(N) = (1-

• E(N) = (-

04/18/23 Medium Access Control 33

Mean Waiting Time E(W) = (1-)

• What is the average time in the system? (queueing delay + service time)

• We use Little’s formula: E(N) = l.E(W)

04/18/23 Medium Access Control 34

Prob{Server is busy} ?

04/18/23 Medium Access Control 35

Prob{Server is idle} ?

04/18/23 Medium Access Control 36

Analysis of M/M/m (m=3)

0

1

2

3

4

5

Po = P1P1 = 2P2…………..Pn = 3Pn+1

Using the equations above and the sum Spi = 1, we can derive Pi’s

04/18/23 Medium Access Control 37

Example

• Comparison source partition vs global FCFS• Let the system have n sources and m servers.Jobs

generate at each source as P.P with rate • Job’s computation time is exponentially

distributed 1/• Source partition is m M/M/1 while global FCFS

may be viewed as M/M/m with Arrival rate n..

04/18/23 Medium Access Control 38

A Fundamental Result In Queueing Theory

• One powerful server for all is better than one weak server for each one !

• Why ? Better utilization, as a dedicated channel may stay IDLE.

One server

Analysis of MAC Protocols

Read Tanenbaum Chapter 4

Key sections (Intro, 4.1, 4.2.1,4.2.2, 4.3)

04/18/23 Medium Access Control 40

Multiple Access Protocols

• Competing stations (possible collisions)– Aloha– Slotted Aloha– CSMA– CSMA/CD

• Collision-free– Bit-map protocol– Binary countdown

• Limited contention– Adaptive tree walk protocol

04/18/23 Medium Access Control 41

Pure Aloha• Designed by Abramson (wireless)

• A station emits whenever it has something to send

• If other station emits, a collision happens

• If collision, frame must be resent

• Best possible utilization at high load 18%

04/18/23 Medium Access Control 42

Analysis of Pure Aloha• Assume infinite population of users• Let Tr=time to trasmit a frame (“frame time”)• The population generates a traffic that is Poisson

with mean N per “frame time” (new frames)• Since there are also retransmissions, the total

traffic generated is Poisson with mean G• What is the throughput S?• S = G.Po where Po is the probability that a frame

does not suffer a collision

04/18/23 Medium Access Control 43

Analysis of Pure Aloha (2) (Example)

• Suppose that the bandwidth is 10 Mbps, and packet size is 1500 bytes

• Tr= 1500.8/10 Mbps = 1.2 ms• Possible values for N (mean number of frames

generated per time frame): between 0 and 1• Values for generated traffic (G > N)

– No retransmissions at all G = N– Low load G~N– High load G > N

• Po will be higher at low load

04/18/23 Medium Access Control 44

Analysis of Pure Aloha (3)• What is the probability to generate k frames

during a “frame time”?– Prob(k arrivals during 1) = [(G.1)k e-G.1]/k!

(page 20)

• What is the probability Po that that a frame does not suffer a collision?

Tr

t0 t0+2Trt0+Tr t0+3Tr

04/18/23 Medium Access Control 45

Analysis of Pure Aloha (4)• Po is the probability that ZERO frame is generated during the

vulnerable period

– Po = Prob(0 arrivals during 2) =

– = [(G.2)0 e-G.2]/0!

– Po = e-G.2

– S = G.Po = G. e-G.2 (When is S maximum?)

– The maximum throughput S is 1/(2.e) = 18.4%

Tr

t0 t0+2Trt0+Tr t0+3Tr

04/18/23 Medium Access Control 46

Slotted Aloha• Designed by Roberts (wireless)

• Requires synchronization and division of time in discrete slots

• A station emits whenever it has something to send AND must wait for beginning of slot

• Best possible utilization at high load 37%t

t0 t0+2tt0+t t0+3t

04/18/23 Medium Access Control 47

Analysis of Slotted Aloha (2)• The key: slotted time reduces the vulnerable

period to Tr (instead of 2Tr).– Po = Prob(0 arrivals during 1) =– = [(G.1)0 e-G.1]/0!– Po = e-G.1

– S = G.Po = G. e-G (When is S maximum?)– The maximum throughput S is 1/e = 36%

• Exercise: derive the average number of transmissions of one frame before being successful.

t

t0 t0+2tt0+t t0+3t

04/18/23 Medium Access Control 48

Carrier Sense Multiple AccessCSMA

• Designed by Metcalfe, analyzed by Kleinrock and Tobaggi

• A station listens to the channel before sending.

• If channel busy, wait until it becomes idle

• When channel free, send with probability 1

• Are collisions still possible?

04/18/23 Medium Access Control 49

Collisions with CSMA

• Key: signal takes time p to propagate• Problem 1: If two stations are listening to grab the channel…• Problem 2: If S1 starts transmitting, S2 may well send during

p.• Problem 3: S1 is not aware of the collision

Sender S1 Sender S2

p

04/18/23 Medium Access Control 50

Solving Problem 1: p-persistent CSMA

• 1-persistent: after collision, waits a random time and starts over (slide 48)

• Non persistent: if channel busy, the station does not keep listening, but rather waits for a random time before listening again.

• p-persistent: for slotted, if idle, send with probability p, otherwise defers to next slot

• Much better utilization than Aloha, may go beyond 95%.

04/18/23 Medium Access Control 51

Problem 2 and 3:Vulnerability Period with CSMA• At time t, S1 sends a frame f1• At time p-, S2 may well send a frame f2 because

S2 does not hear yet first bit of f1• At time 2p-, S1 does not hear yet first bit of f2• Vulnerability period is 2p

Sender 1 Sender 2

p

04/18/23 Medium Access Control 52

Solving Problem 2 and 3: Collision Detection (1)

• Objective:

1) Sender must detect collision

2) Stop transmission of damaged frames to avoid waste of medium

• CD: while sending, a sender must keep listening to detect a collision

• Can the sender always detect collisions?

• Relationship with medium length

04/18/23 Medium Access Control 53

Solving Problem 2 and 3: Collision Detection (2)

• Collision detection imposes a minimum frame length based on bandwidth and maximum medium length

• Sender must listen for at least the time it takes for the signal to tral between the farthest points on the medium (max)

• The sender listens while sending: it takes Tr to send a frame.

• To detect collision: Tr > 2.max

04/18/23 Medium Access Control 54

Solving Problem 2 and 3: Collision Detection (Example)

• A medium has a length of 1 km, the speed of light on the medium is 2/3 the speed in free space. What is max?

• The bandwidth is 10 Mbps

• What should be the smallest Tr?

• What is the minimum size of a frame?

04/18/23 Medium Access Control 55

Binary Exponential Backoff

• Problem: CSMA/CD does not adapt to the number of competing stations.

• What should be INTERVAL of the random time to wait after a collision occurs?

• Should it be 1 second?

• Should it be 1ms?

• Should it be 2.max? Or 8.max?

04/18/23 Medium Access Control 56

Binary Exponential Backoff (2)

• Problem: If the INTERVAL I is constant, there is NO ADAPTATION to the number of competing stations.

• How to solve the problem?– Use (2.max) as the unit of time

– At the ith collision for the same frame, choose randomly a number B beween 0 and 2i-1. (Max is i=10)

– Wait B.(2.max) before trying again

04/18/23 Medium Access Control 57

Efficiency of Ethernet

• Efficiency = Tr/T• Tr: transmission of one frame• T: T is the average time it takes to get a frame

from a sender to a receiver

• T= Tr + X.(2.max) where X is the number of slots we “waste” before sending out a frame successfully

• X is a random variable: we can compute E(X)

04/18/23 Medium Access Control 58

Efficiency of Ethernet (2)

• Efficiency = Tr/(Tr+E(X) .(2.max)). What is E(X)?

• We have to find the average number of collisions before a frame makes it.

• In others words, we have to find the average number of attempts before we get a frame through

• Suppose that I know the probability A that a frame makes it through.

• What would be E(X), based on A?

04/18/23 Medium Access Control 59

Efficiency of Ethernet (3)

• Recall that A is the probability for a packet to get transmitted successfully

• X takes the value 1 with probability A• X takes the value 2 with probability (1-A).A• X takes the value 3 with probability (1-A)2.A• ………………………………………………• X takes the value i with probability (1-A)i-1.A

• What is E(X), based on A?

04/18/23 Medium Access Control 60

Efficiency of Ethernet (3)

• Efficiency = Tr/(Tr+E(X) .(2.max)). What is E(X)?

• We found that E(X) = 1/A

• Then, Efficiency = Tr/(Tr+(2.max)/A).

04/18/23 Medium Access Control 61

Efficiency of Ethernet (4)• Efficiency = Tr/(Tr+(2.max)/A).

• Nice! But, what is the value of A?

• Recall: the probability A that a frame makes it through

• In other words: A is the probability that one station attempts to transmit while the other stations do not.

04/18/23 Medium Access Control 62

Efficiency of Ethernet (5)• Efficiency = Tr/(Tr+(2.max)/A). • Suppose that there are k stations.• Each station tries to send in each slot with

probability p.• Question 1: What is the probability that SOME

station acquires the medium?• A = k.p.(1-p)k-1

• Do we want A to be high or low?• A is maximal for p = 1/k. What is Amax?• Amax = 1/e when k gets large.

04/18/23 Medium Access Control 63

Efficiency of Ethernet (6)• Efficiency = Tr/(Tr+(2.max).e).

• We could express as a function of the bandwidth Bw, the maximal length of the medium L, and the packet size F.

• What is the expression of the Efficiency?

• Hint: 2.max is the is the smallest time to send a frame

04/18/23 Medium Access Control 64

Collision Free MAC• Token Ring MAC Protocol (IEEE 802.5)• N nodes are connected in a ring topology• A special packet (token) is circulated

periodically: only a station possessing the token can transmit:

• IEEE 802.5 Strategy:– Wait for the token and grab it– Transmit packets for at most (10ms in 802.5)– Release the token

04/18/23 Medium Access Control 65

Collision Free MAC• Token Ring MAC Protocol (IEEE 802.5)• N nodes are connected in a ring topology• A special packet (token) is circulated

periodically: only a station possessing the token can transmit:

• IEEE 802.5 Strategy:– Wait for the token and grab it– Transmit packets for at most (10ms in 802.5)– Release the token

04/18/23 Medium Access Control 66

Efficiency of Token Ring

• Suppose, we have N stations

• We want to establish the proportion of time the medium is used to send frames

• We assume that all stations have a frame to send.

• We neglect the transmission time of a token

04/18/23 Medium Access Control 67

Efficiency of Token Ring (2)

• The function of a Token Ring is periodical• Let us consider one cycle:

– Station 1 gets the token and sends for .– Station 2 gets the token and sends for .– Station i gets the token and sends for .– Station N gets the token and sends for .

• The duration of one cycle is then S=N. + . ( is the propagation time around the ring)

04/18/23 Medium Access Control 68

Efficiency of Token Ring (3)

• Recall that the cycle duration is S=N. + • The question now is: how long was the

medium used during a cycle

• The answer is N.q.

• Efficiency = N./S = 1/(1+/(N.))

• Example: N= 40 stations, Ring of 2500m, what is the efficiency?

04/18/23 Medium Access Control 69

Maximum Access time of T.Ring

• If all stations have packets to send, a station may well have to wait for:– All other stations to send their packets ((N-1).)– Wait for the token ()

• What is the maximum with the previous example?

Problem of CSMA on Wireless Networks

04/18/23 Medium Access Control 71

Air Is A Broadcast Medium

• Can we use CSMA/CD ?

– Talking/Listening problem

– Hidden Terminal problem

– Exposed Terminal Problem

04/18/23 Medium Access Control 72

Hidden Terminal Problem

A B C D

•A wants to send to B•AND•C wants to send to B•A and C do not hear each other, they cannot detect collisions

04/18/23 Medium Access Control 73

Exposed Terminal Problem

A B C D

•B wants to send to A•AND•C wants to send to D•B and C believe they are bothering each other

04/18/23 Medium Access Control 74

MACA (Phil Karn)

• When X wants to send to Y:– X sends an RTS frame– if Y gets RTS frame, Y sends a CTS frame

• If you hear an RTS, you should keep quiet (to let the CTS come back)

• If you hear a CTS, keep quiet (to let the incoming frame data)

04/18/23 Medium Access Control 75

MACAW

• Improved version of MACA– Adds acknowledgements for successful data

frames– Use of CSMA– Exponential Backoff mechanism

04/18/23 Medium Access Control 76

MAC Layer for 802.11

• Two kinds of policies– Distributed (with contention) : Distributed

Coordination function– Centralized contention free: Point coordination

function

• The two may be used simultaneously

04/18/23 Medium Access Control 77

Distributed Coordination function

• Check first a logical maintained variable (NAV: Network allocation vector)

• If NAV not null wait

• if NAV null, then sense carrrier

• if idle, transmit (if collision, random exponential backoff)

• otherwise Random exponential backoff

04/18/23 Medium Access Control 78

Delay After Sensing Idle

Medium Busy

time

SIFS

PIFS

DIFS

ACKCTS

PCF DCF