Network Modeling

98
Politecnico di Torino Network Modeling Formulary Fiandrino Claudio - Pievanelli Elisa Academic Year 2010/2011

description

Notes and exercises for the course of Network modeling: theory and simulation - ver 1.1

Transcript of Network Modeling

Page 1: Network Modeling

Politecnico di Torino

Network Modeling

Formulary

Fiandrino Claudio - Pievanelli Elisa

Academic Year 2010/2011

Page 2: Network Modeling

Contents

I Theory 5

1 Elementary Queueing Theory 61.1 Introduction and Basic Definitions . . . . . . . . . . . . . . . . . . . . . 6

1.1.1 Arrivals and Service . . . . . . . . . . . . . . . . . . . . . . . . . 61.1.2 Scheduling Disciplines . . . . . . . . . . . . . . . . . . . . . . . . 111.1.3 Kendall’s Notation . . . . . . . . . . . . . . . . . . . . . . . . . . 121.1.4 Graphical Representation of Queue . . . . . . . . . . . . . . . . . 121.1.5 Measurement of Effectiveness . . . . . . . . . . . . . . . . . . . . 131.1.6 Little’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

1.2 Birth-Death Processes: The M/M/1 Queue . . . . . . . . . . . . . . . . 151.2.1 Description and Steady-State Solution . . . . . . . . . . . . . . . 151.2.2 Performance Measurement . . . . . . . . . . . . . . . . . . . . . . 17

1.3 Finite-Capacity System - The M/M/1/N Queue . . . . . . . . . . . . . . 191.4 Multiservers Systems - The M/M/c Queue . . . . . . . . . . . . . . . . . 211.5 Multiservers Systems - The M/M/c/0 Queue . . . . . . . . . . . . . . . 231.6 Multiservers Systems - The M/M/∞ Queue . . . . . . . . . . . . . . . . 251.7 Finite-Source Systems - The M/M/1/N-1/N Queue . . . . . . . . . . . . 261.8 Finite-Source Systems - The M/M/k/0/N Queue . . . . . . . . . . . . . 26

2 Queues with Phase-Type Laws 282.1 The Erlang-r Service Model - The M/Er/1 Queue . . . . . . . . . . . . 282.2 The Erlang-r Arrival Model - The Er/M/1 Queue . . . . . . . . . . . . 302.3 The M/H2/1 and H2/M/1 Queues . . . . . . . . . . . . . . . . . . . . . 32

3 The M/G/1 and the G/M/1 Queues 343.1 Introduction in the M/G/1 Queue . . . . . . . . . . . . . . . . . . . . . 343.2 Solving the M/G/1 Queue . . . . . . . . . . . . . . . . . . . . . . . . . . 353.3 Average in other type of queue . . . . . . . . . . . . . . . . . . . . . . . 38

4 Queueing Networks 394.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.1.1 Basic Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 394.1.2 The Departure Process - Burke’s Theorem . . . . . . . . . . . . . 39

2

Page 3: Network Modeling

Politecnico di Torino Formulary ver. 1.1

4.1.3 Two M/M/1 Queues in Tandem . . . . . . . . . . . . . . . . . . 414.2 Open Queueing Networks . . . . . . . . . . . . . . . . . . . . . . . . . . 41

4.2.1 Feedforward Networks . . . . . . . . . . . . . . . . . . . . . . . . 414.2.2 Jackson Networks . . . . . . . . . . . . . . . . . . . . . . . . . . 41

4.3 Closed Queueing Networks . . . . . . . . . . . . . . . . . . . . . . . . . . 44

II Exercises 45

5 Preliminary Exercises 46

6 Exercises on Queues 51

7 Network queues exercises 70

8 Simulation of exams 73

III Appendix 92

A Formulas 93

B Integrals 96

C Series 98

3

Page 4: Network Modeling

Introduction

The formulary consists of a theorical part, exercises and formulas.We have wrote it during the course Network modelling: theory and simulation

attended, for the first time, in this year.The first part has been written by Pievanelli Elisa, while the exercises by Fiandrino

Claudio‡.

‡Contact me from http://claudiofiandrino.altervista.org/ section contact & links.

4

Page 5: Network Modeling

Part I

Theory

5

Page 6: Network Modeling

Chapter 1

Elementary Queueing Theory

1.1 Introduction and Basic Definitions

The server(s) and the queue into which arriving customers are directed together con-stitute the service facility or queueing system. Also, it frequently happens that boththe queue and the server are collectively referred to as a queue, such as the M/M/1queue or the M/G/1 queue. One after the other, customers arrive to the service facil-ity, eventually receive service and then depart. We make some assumptions about allqueueing systems we analyze:

• If the server is free (not already serving a customer) an arriving customer goesimmediately into service. No time at all is spent in the queue.

• If the server is busy, then the customer joins a queue of waiting customers andstays in the queue until entering service.

• When the server becomes free, a customer is chosen from the queue according toa scheduling policy and immediately enters into service. The time between thedeparture of one customer and the start of service of the next customer is zero.

• Customers remain in the system until their service is complete and then theydepart. Customers do not become impatient and leave before they receive service.

1.1.1 Arrivals and Service

The length of a queue depends on the complete probabilistic description of the arrivaland service processes - the demand being placed on the resource - and of the capacity ofthe resource to service these demands. It’s evident that, if the average service demandsof arriving customers are greater than the system service capacity, the system will breakdown since unbounded queues will form. On the other hand, if the average arrival rateis less than the system service capacity, then we still get queues. Even when the averagearrival and service rates are held constant, an increase in the variation of arrivals orservice increases the congestion. Thus we use elementary probability theory to predict

6

Page 7: Network Modeling

Politecnico di Torino Formulary ver. 1.1

average waiting times, average queue length, distribution of queue length, etc., on thebasis of:

• the arrival pattern of customers to the resource,

• the service pattern of customers,

• the scheduling algorithm in which the next customer to be served is chosen.

In some scenario, the space available to hold customers waiting for service, may belimited. When the queue has reached its maximum capacity, so it is full; customerswho arrive to find the queue full are lost.

The Arrival Process

The customer arrival process may be described in two ways:

1. By characterizing the number of arrivals per unit time (the arrival time);

2. By characterizing th time between successive arrivals (the interarrival time).

We use the variable λ to denote the mean arrival rate (1/λ denotes the mean timebetween arrivals). If the arrival pattern is not deterministic, the input process is astochastic process, which means that we need its associated probability distribution.The probability distribution of the interarrival time of customers is denoted by A(t)where

A(t) = P (time between arrivals ≤ t)

and1

λ=

∫ ∞0

t dA(t)

where dA(t) is the probability that the interarrival time is between t and t + dt. Weassume that these interarrival times are independent and identically distributed (iid),which means that only A(t) is of significance. The manner in which the arrival patternchanges in time may be important. An arrival pattern that does not change with timeis called homogeneous arrival process. If it is invariant to shifts in the time origin, itis called stationary arrival process.

The Service Process

The service pattern may be describe by a rate, the number of customers served perunit time, or by a time, the time required to serve a customer. The parameter µ is usedto denote the mean service rate (1/µ denotes the mean service time). We use B(x) todenote the probability distribution of the demand placed on the system

B(t) = P (Service time ≤ x)

7

Page 8: Network Modeling

Politecnico di Torino Formulary ver. 1.1

and1

µ=

∫ ∞0

x dB(x)

where dB(x) is the probability that the service time is between x and x + dx. Theservice time is equal to the length of time spent in service and does not include thetime spent waiting in the queue. Although it is usual to associate the service timedistribution with the server, the service time is actually the time that is request orneeded by customer who is taken into service. The service may be batch or single.With batch service, several customers can be served simultaneously. Also, the servicerate may depend on the following factors:

1. Each server has its own queue.

2. There are fewer queues than server. Typically, there is a single queue for allservers.

The servers may or may not be identically, B(x) may be different for different servers.The capacity that a service facility has to hold waiting customers is often taken to beinfinite.

Poisson Arrivals and Exponential Service

In stochastic modelling, numerous random variables are frequently modelled as expo-nentials. These include:

• interarrival time,

• service time,

• time to failure of a component,

• time required to repair a component.

Recall that the cumulative distribution function for an exponential random variable,X, with parameter λ > 0, is given by

F (x) =

{1− e−λx x ≥ 0

0 otherwise

and its corresponding probability density function is

f(x) =

{λe−λx x ≥ 0

0 otherwise

Its mean and variance are given, respectively, by

E [X] =1

λVar [X] =

1

λ2

Reason for the use of exponential distribution include:

8

Page 9: Network Modeling

Politecnico di Torino Formulary ver. 1.1

1. its memoryless property and resulting analytical tractability,

2. its relationship to the Poisson process.

Definitions of Poisson process:

1. {ti} is a Poisson process if:

• ti+1− ti IID (interarrival times are independent and identically distributed),

• ti+1 − ti ∼ eλ (interarrival times are distributed as an exponential withparameter λ)

2. A Poisson process {N(t), t ≥ 0} having a rate λ ≥ 0 is a counting process withindependent and stationary increments, with N(0)=0, and is such that the numberof events that occur in any time interval of length t has a Poisson distributionwith mean λt. This means that

P (N(t+ s)−N(s) = n) = e−λt(λt)n

n!n = 0, 1, 2, . . .

Thus a Poisson process is a continuous-parameter, discrete-state process.

3. Let N(t) be the number of events that occur in an interval (0,t]. When thefollowing four conditions are true, then {N(t), t ≥ 0} is a Poisson process:

(a) N(0)=0,

(b) Events that occur in nonoverlapping time intervals are mutually indepen-dent,

(c) The number of event that occur in any interval depends only on the lengthof the interval and not on the past history of the system,

(d) For sufficiently small h and some positive constant λ, we have

P (One event in(t, t+ h]) = λh+ o(h)

P (Zero events in(t, t+ h]) = 1− λh+ o(h)

P (More Than one event in(t, t+ h]) = o(h)

where o(h) (”little o h”) is any quantity that tends to zero faster than h

limh→0

o(h)

h= 0

These definitions of the Poisson process are equivalent. The number of arrivals, N(t),in the interval (0,t] has a Poisson distribution with parameter λt. To compute the meannumber of arrivals in an interval of length t, we proceed as follows:

E [N(t)] =

∞∑k=1

k pk(t) =

∞∑k=1

k e−λt(λt)k

k!= λt

( ∞∑k=1

((λt)k−1

(k − 1)!

)e−λt =

= λt

( ∞∑k=1

(λt)k

k!

)e−λt = λt

9

Page 10: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Poisson Process Have Exponential Interarrival Times

If the arrival process is a Poisson process, then the associated random variable de-fined as the time between successive arrivals (the intearrival time) has an exponentialdistribution. The arrival process is Poisson:

pn(t) = e−λt(λt)n

n!, n = 0, 1, 2, . . .

Which describes the number of arrivals that have occurred by time t. Let X be therandom variable that denotes the time between successive arrivals. Its probabilitydistribution function is given by

A(t) = P (X ≤ t) = 1− P (X > t)

But P (X > t) = P (0 arrivals in (0, t]) = p0(t). Thus

A(t) = 1− p0(t) = 1− e−λt t ≥ 0

with corresponding density function

a(t) = λe−λt t ≥ 0

This defines the exponential distribution. Thus X is exponentially distributed withmean 1/λ and, consequently, for a Poisson arrival process, the time between arrivals isexponentially distributed.

Superposition and Decomposition of Poisson Process

When two or more independent Poisson streams merge, the resulting stream is alsoa Poisson stream. It follows then that multiple processes to a single service centercan be merged to a single arrival process whose interarrival times are exponentiallydistributed. If the i-th stream, i = 1, 2, ..., n, has parameter λi, then the parameter forthe merged stream is given by

λ =n∑i=1

λi

A single Poisson stream may be decomposed into multiple independent Poisson streamsif the decomposition is such that customers are directed into substreams i, i=1,2,...,nwith probability pi and

n∑i=1

pi = 1

10

Page 11: Network Modeling

Politecnico di Torino Formulary ver. 1.1

PASTA (Poisson Arrivals See Time Average)

An important property of the Poisson arrival process is that the distribution of cus-tomers seen by an arrival to a queueing system is, stochastically, the same as the limitingdistribution of customers at the system. Once the queueing system has reached thesteady state, each arrival from a Poisson process finds the system at equilibrium. If pnis the probability that the system contains n customers at equilibrium and an is theprobability that an arriving customer finds n customers already present, then PASTAsays that pn = an.

π(i)a = lim

∆t→0P (N(t) = i | one arrival in (t, t+ ∆t))

= lim∆t→0

P (N(t) = i, one arrival in (t, t+ ∆t))

P (one arrival in (t, t+ ∆t))

= lim∆t→0

P (one arrival in (t, t+ ∆t) |N(t) = i)

P (one arrival in (t, t+ ∆t))· P (N(t) = i)

P (one arrival in (t, t+ ∆t))

=P (one arrival in (t, t+ ∆t)) · P (N(t) = i)

P (one arrival in (t, t+ ∆t))

= P (N(t) = i) = π(i)

This result is a consequence of the memoryless property if the interarrival time distri-bution of customers to queueing system fed by Poisson process: it does not depend onthe service time distribution. The PASTA property does not hold for arrival processesdifferent from Poisson.

1.1.2 Scheduling Disciplines

The scheduling policy, or discipline, is the manner in which the customers are selectedfrom the queue and taken into service. We assume that the time it takes to select acustomer and to enter that into service is zero. We have two type of policies:

• Preemptive policies: it is used when there are different types of customer (highpriority and low priority). When a high priority customer enters the queue andfinds a lower priority customer in service, the service of the lower priority customeris interrupted and later resumed.

• Nonpreemptive system: in this case the server will commence the service of lowerpriority customer if there are no higher priority customers in the queue. Severalscheduling disciplines exist:

– FCFS (First Come First Served), also called FIFO (First In First Out). Inthis case it is selected the first customer at the head of the queue to be thefirst served.

– LCFS (Last Come First Served) is the opposite of FCFS. The last customerto arrive is the one next chosen to be served.

11

Page 12: Network Modeling

Politecnico di Torino Formulary ver. 1.1

– LCFS-PR (Last Come First Served-Preempt Resume)

– SIRO (Service In Random Order). The next customer to be served is chosenat random among all those waiting.

– RR (Round Robin). In this scheduling discipline, the duration of serviceprovided each time a customer begins service is limited to a fixed amount(time slice). If a customer completes its service at any point during the timeslice, it immediately departs from the service center and the customer at thehead of the queue begins to be served. If, after the time slice has finished,a customer has still not completed its service requirement, that customer isreinserted back into the end of the queue to await its turn.

– PS (Processor Sharing), it is a limiting case of RR in whiche the time slicegoes to zero.

– IS (Infinite Server). In this case the server has the ability to serve all cus-tomers simultaneously.

– PRIO (Priority scheduling). The customer chosen from the queue is the onewith the highest priority.

1.1.3 Kendall’s Notation

Kendall’s notation is used to characterize queueing systems. It is given by A/B/C/X/Y/Zwhere

A indicates the interarrival time distribution

B indicates the service time distribution

C indicates number of servers

X indicates the system capacity

Y indicates the size of the customer population

Z indicates the queue scheduling discipline

Some possible distribution for interarrival and service time are: M for Markovian, E forErlang, G for General and D for Deterministic. The number of servers is often takento be 1. This first three parameters are always provided. The letters that specify thesystem capacity, customer population and scheduling discipline may be omitted withthe understanding that the default values for capacity and population size is infiniteand the default scheduling discipline is FCFS.

1.1.4 Graphical Representation of Queue

There are several ways to graph a queueing system, but we will see only one. for aFCFS, single server queue. one possibility is shown in the figure 1.1.

12

Page 13: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Time

N. customers

1

2

3

4

τ1 τ2 τ3 τ4 τ5 τ6

t2

t3 t4

t5

t6

w2

x1 x2 x3 x4 x5 x6

Figure 1.1: Representation of a queue

Let we denote with Cn the nth customer that enters in the queue. Let we denotewith τn the time at which Cn arrives in the system and tn the arrival time betweenthe arrival of Cn−1 and Cn. We assume that the tn are drawn from a distributionsuch that P (tn ≤ x) = A(t), independent of n, where A(t) is completely arbitraryinterarrival time distribution. Equally, we can define xn to be the service time for Cnand P (xn ≤ x) = B(x), where B(x) is a completely arbitrary service time distribution.In the figure we have plotted N(t), the number of customers in the system at time t;and wn represents the waiting time for Cn and sn represent the system time for Cn.Moreover, we can say that:

. tn are interarrival times;

. xn are interdeparture times.

1.1.5 Measurement of Effectiveness

We analyze a queueing system with the purpose of obtaining the values of certain systemproperties; for example: the number of customers in the system, the waiting time of acustomer, the length of a busy or idle period, the current work backload, etc.. Theseare called measurement of effectiveness. All these values are random variables and wehave to know their complete probabilistic descriptions, but sometimes we are satisfiedto be able to derive just mean and variance. We now consider the most commonlyobtained measures of effectiveness:

• Number of customers: let N the random variable that describes the numberof customers in the system at steady state. The probability that at steady state

13

Page 14: Network Modeling

Politecnico di Torino Formulary ver. 1.1

the number of customer present in the system is n is denote by pn,

pn = P (N = n)

and the average number in the system at steady state is

E [N ] =∞∑i=0

n · pn

Let Nq be the random variable that describes the number of customers waitingin the queue and we denote its mean by E [Nq].

• System time and queueing time: the time that a customer spend in thesystem, from the instant of its arrival to the queue to the instant of its departurefrom the server, is called the response time. This is a random variable and wedenote it by R and its mean value is E [R]. The response time is composed of thetime that the customer spends waiting in the queue, called waiting time, plus thetime the customer spends receiving service, called service time. Let Wq be therandom variable that describes the time spends by the customer waiting in thequeue and its mean is E [Wq].

• System utilization: in a queueing system with a single server, the utilizationU is defined as the fraction of time that the server is busy. If the rate at whichcustomers arrive in the queueing system is λ and if µ is the rate at which these

customers are served, then the utilization is equal to ρ =λ

µ(where ρ is identified

with the utilization). In the case of queueing system with multiple servers, the

utilization is defined as the average fraction of server that are active U =λ

cµ.

• System throughput: The throughput of a queueing system is equal to itsdeparture rate, the average number of customers that are processed per unittime. It is denote by X. In a queueing system in which customers that arriveare eventually served and leave the system, the throughput is equal to the arrivalrate λ.

• Traffic intensity: we define the traffic intensity as the rate at which work entersthe system, so it is given as the product of the average arrival rate of customers

and the service time: λx̄ =λ

µ, where x̄ =

1

µand µ is the mean service rate. In a

queueing system with a single server the traffic intensity is equal to the utilization.For multiple servers, the traffic intensity is equal to cU .

1.1.6 Little’s Theorem

Little’s theorem equates the number of customers in a system to the product of theeffective arrival rate and the time spend in the system. We assume that

E [N ] = limT→∞

1

T

∫ ∞0

N(t) dt

14

Page 15: Network Modeling

Politecnico di Torino Formulary ver. 1.1

E [D] = limN→∞

∑Ni=1Di

N

and the Little’s theorem says:

E [N ] = E [λ] · E [D]

This says that the number of customers in the system is equal to the average arrivalrate of customers in the system multiplied by the average system time per customer.Little’s theorem can be applied individually to the different parts of a queueing system,the queue and the server.

1.2 Birth-Death Processes: The M/M/1 Queue

Birth-Death processes are continuous-time Markov chains with a special structure. Ifthe states of the Markov chain are indexed by integer 0,1,2,.. , then transitions arepermitted only from state i > 0 to its nearest neighbors state i − 1 and i + 1.For thestate i = 0 the Markov chain must enter state 1. These processes are called skip-freeprocesses because to go from any state i to any other state j, each intermediate statemust be visited. An arrival to the queueing system results in one additional unit inthe system, and is defined with a birth, whereas a departure removes a unit from thesystem as is referred to as a death. The simplest of all queeuing system is the M/M/1queue. This is a single server queue with FCFS scheduling discipline, an arrival processthat is Poisson and service time that is exponentially distributed.

1.2.1 Description and Steady-State Solution

At any time t, the state of an M/M/1 queue is completely characterized by specifyingthe number of customers present. The state are denote with an integer number, ndenotes the state in which there are n customers in the system, including the one inservice. We want to know the state probabilities, the probability that the system is inany given state n at any time t.

pn(t) = P (n in the sistem at time t)

This is a difficult task; so we look to the steady-state probabilities

πn = limt→∞

pn(t)

If this limit exists, then the probability of finding the system in any particular stateeventually becomes independent of the starting state. This probability pn can be in-terpreted as the probability of finding n customers in the system at an arbitrary pointin time after the process has reached steady state. Not all systems reach the steadystate, for some queueing systems it is impossible that limt→∞ pn(t) may not yield a trueprobability distribution. This system is a Markov chain so we can draw the diagram

15

Page 16: Network Modeling

Politecnico di Torino Formulary ver. 1.1

0 1 2 n· · · n+ 1

λ

µ

λ

µ

λ

µ

Figure 1.2: State transition diagram of an M/M/1 queue

transition state (figure 1.2):The arrivals are distributed as an exponential with parameter λ and the service timesare exponentially distributed with parameter µ. The steady state equation are:

State 0 : λπ0 = µπ1

State 1 : (λ+ µ) · π1 = λπ0 + µπ2

State n : (λ+ µ) · πn = λπn−1 + µπn+1 n ≥ 1

If we sum the first two equations we obtain: λπ1 = µπ2. If we substitute this resultin one of the first two equations we can find the value of π1 or π2. If we repeat thisprocedure for all the state of the system we’ll find:

λπn = µπn+1 n ≥ 0

πn+1 =λ

µπn n ≥ 0

To find the value of π0 we proceed as follows:

π1 =λ

µπ0

π2 =λ

µπ1 =

µ

)2

π0

πn =

µ

)nπ0

If we impose ρ =λ

µ, we find

πn = ρnπ0

Now we need to know if the M/M/1 system is ergodic.A Markov chain is ergodic if:

• ρ =λ

µ< 1

• π0 = 1− ρ

• πn = (1− ρ)ρn n > 0

16

Page 17: Network Modeling

Politecnico di Torino Formulary ver. 1.1

At this point, we impose∞∑i=0

πi = 1

This implies

π0

∞∑i=0

ρi = 1

π0 =1∑∞i=0 ρ

iwith

∞∑i=0

ρi <∞

1.2.2 Performance Measurement

Mean Number in System

Let N be the random variable that describes the number of customers in the system atsteady state and let E [N ] be the mean number of customers in the M/M/1 queue.

E [N ] =∞∑n=0

nπn =∞∑n=0

n(1− ρ)ρn

For n = 0, the product is zero then we can start the sum from n = 1

E [N ] = (1− ρ)∞∑n=1

nρn = (1− ρ)ρ∞∑n=1

nρn−1

Since nρn−1 can be written as nρn−1 =dρn

E [N ] = (1− ρ)ρ∞∑n=1

d

dρρn = (1− ρ)ρ

d

( ∞∑n=1

ρn

)

We know that∞∑n=1

ρn =

∞∑n=0

ρn − 1 =1

1− ρ− 1 =

ρ

1− ρ

so we can write

E [N ] = (1− ρ)ρd

1− ρ

)=

ρ

1− ρ(ρ < 1)

17

Page 18: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Variance of Number in System

To compute the variance of the number of customers in an M/M/1 queue, we use theformula

Var [N ] = E[N2]− E [N ]2

The second moment is

E[N2]

=∞∑n=0

n2πn =∞∑n=0

n2(1− ρ)ρn = (1− ρ)∞∑n=0

n2ρn

= (1− ρ)ρ∞∑n=0

n2ρn−1 = (1− ρ)ρd

[ ∞∑n=0

nρn

]

= (1− ρ)ρd

(1− ρ)2

]= (1− ρ)ρ

(1− ρ)2 + 2(1− ρ)ρ

(1− ρ)4= ρ

ρ

(1− ρ)2

In this way we can write the variance as follows

Var [N ] = ρρ

(1− ρ)2−(

ρ

1− ρ

)2

(1− ρ)2

Delay - Mean of Waiting in the Queue

If the mean service time is 1/µ and the mean waiting time is n/µ we can write themean of waiting in the queueing system as

E [W | find 0 customer] =1

µ

E [W | find 1 customer] =2

µ

E [W | find n customers] =n+ 1

µ=⇒

(1

µ+n

µ

)In this way we can compute the mean of waiting in the queueing system

E [W ] =

∞∑n=0

E [W |n] · P (finding n customers) =

∞∑n=0

n+ 1

µπ(n)a

Applying PASTA we obtain

E [W ] =∞∑n=0

n+ 1

µπn =

∞∑n=0

n+ 1

µ(1− ρ)ρn =

1/µ

1− ρ

Throughput, Utilization and Traffic Intensity

The throughput of the M/M/1 queue is equal to the arrival rate, X = λ. The utilizationin equal to the traffic intensity and is given by:

U =λ

µ

18

Page 19: Network Modeling

Politecnico di Torino Formulary ver. 1.1

1.3 Finite-Capacity System - The M/M/1/N Queue

In an M/M/1/N queue customers arrive according to a Poisson process at rate λ andreceive service that is exponentially distributed with a mean service time of 1/µ froma single server. The difference from the M/M/1 queue is that at most N customersare allowed into the system. A customer that arrives and find the system full it isdiscarded, and then lost. To analyze the M/M/1/N queue, we use a birth-death modeland choose the parameter so that the Poisson arrivals stop as soon as N customersare present. Figure 1.3 shows the system. The parameters of the exponential servicedistribution are unchanged. Then

λn =

{λ n < N

0 n ≥ N

µn = µ for n = 1 , 2 , · · · , N

We can now write the flow balance equations:

0 1 2 N − 2· · · N − 1 N

λ

µ

λ

µ

λ

µ

λ

µ

Figure 1.3: State transition diagram of an M/M/1/N queue

λπ0 = µπ1

λπ1 = µπ2

λπi = µπi+1 i ≤ N

πi = ρiπ0 ρ =λ

µ

The system is ergodic so we impose

N∑i=0

πi = 1

therefore by substituting πi = ρiπ0

N∑i=0

ρiπ0 = 1

π0 =1∑Ni=0 ρ

i

19

Page 20: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Recall thatN∑i=0

ρi =1− ρN+1

1− ρ

We can write:

π0 =1− ρ

1− ρN+1

And then we can obtain the value of πi

πi = ρi · 1− ρ1− ρN+1

i ≤ N + 1

Now we try to find some important parameter of this type of queue:

- The loss probability is Ploss = π(N+1)a

In this case we can apply PASTA, because the arrival process is Poisson, andwe’ll find:

Ploss = π(N+1)a = πN+1 =

ρN+1(1− ρ)

1− ρN+2

For ρ < 1 and N → ∞ the loss probability tends to 0 while, considering ρ > 1and N →∞ the loss probability is:

Ploss =ρ− 1

ρN+2

ρN+1− 1

ρN+1

=ρ− 1

ρ≈ 1− 1

ρ

- The throughput is the number of customers that arrive in a unit of time; in thiscase the formula for the throughput in input is:

Tin = λ′ = λ(1− Ploss) = λ(1− πN+1)

and the formula for the throughput in output is:

Tout = µ′ = µ(1− π0) = µ

(1− 1− ρ

1− ρN+2

)

If λ < µ and N→∞ : µ′ < λ

If λ > µ and N→∞ : µ′ = µ

If N = 0

Tout = µ

(1− 1− ρ

1− ρ2

)= µ

(−ρ2 + ρ

1− ρ2

)= µρ

1− ρ(1 + ρ)(1− ρ)

=µρ

1 + ρ=

λ

1 + ρ

20

Page 21: Network Modeling

Politecnico di Torino Formulary ver. 1.1

- Delay: for the calculation of the delay we use the Little’s Theorem

E [N ] = E[λ] · E [D]

E [D] =E [N ]

λ(1 + πN+1)

E [N ] =N+1∑i=0

iπi =ρ[1− (N + 2)ρN+1 + (N + 1)ρN+2]

1− ρ2· 1− ρ

1− ρN+2

E [D] =

ρ[1− (N + 2)ρN+1 + (N + 1)ρN+2]

(1− ρ)(1− ρN+2)

λ

(1− ρN+1(1− ρ)

1− ρN+2

)If ρ < 1 and N →∞:

E [D] =ρ

λ(1− ρ)=

1/µ

1− ρIf N = 0:

E [D] =1

µ

1.4 Multiservers Systems - The M/M/c Queue

The M/M/c queue consists of c identical servers. In this queue customers arrive ac-cording to a Poisson process with rate λn = λ for all n and are served in fist-comefirst-served order by any available server. Each of the c servers provides independentand identically distributed exponential service rate µ. When the number of customersis greater or equal to c, n ≥ c, then all the servers are busy and the effective servicerate is equal to cµ. If the number of customer is less than c, then only n out of c serversare busy and the effective service rate is equal to nµ. The term load dependent servicecenter is used to designate a service center in which the customers departure rate is afunction of the number of customers present. With c identical servers, each providingservice at rate µ, and a total of n customers present, the load dependent service rateis equal to

µ(n) = min{n , c} · µ

The state transition diagram of an M/M/c queue is represented in figure 1.4. Itfollows that the arrival rate and the service rate to define the M/M/c queue are givenby

λn = λ ∀n

µn =

{nµ 1 ≤ n ≤ ccµ n ≥ c

21

Page 22: Network Modeling

Politecnico di Torino Formulary ver. 1.1

0 1 c− 2· · · c− 1 c c+ 1 · · ·

λ

µ

λ

(c− 1)µ

λ

λ

Figure 1.4: State transition diagram of an M/M/c queue

The condition for ergodicity is λ < cµ.The flow balance equation are:

λπ0 = µπ1

λπ1 = 2 µπ2

For a generic i we obtain:

λπi = (i+ 1)µπi+1 i < c

λπi = cµπi+1 i ≥ c

And from these equations we find:

1. for i < c

πi+1 =λ

(i+ 1)µπi

πi =

)·(

λ

(i− 1)µ

)·(

λ

(i− 2)µ

)· . . . ·

µ· π0

)πi =

µ

)i 1

i!π0

2. for i ≥ c

πi+1 =λ

cµπi

πi =

)·(λ

)·(λ

)· . . . · πc

πi =

)i−cπc

The system is ergodic only when∞∑i=0

πi <∞

22

Page 23: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Since this is an ergodic sum with radix λ/cµ, the ergodic condition is

λ

cµ< 1

If we normalize by requiring∞∑i=o

πi = 1

we obtain:c∑i=0

1

i!

µ

)iπ0 +

∞∑i=c+1

)i−c 1

c!

µ

)cπ0 = 1

π0 =1∑c

i=0

1

i!

µ

)i+∑∞

i=c+1

)i−c 1

c!

µ

)c=

1∑ci=0

1

i!

µ

)i+

1

c!

µ

)c λ/cµ

1− λ/cµ

From this formula we can find information on the delay:

E [N ] =∞∑i=0

i · πi

E [D] =E [N ]

λ

1.5 Multiservers Systems - The M/M/c/0 Queue

This kind of queue is characterized by the fact of not having the waiting line. It is stilla Markov chain because it has both the arrival process, that is Poisson, and the servicetime distributed as an exponential.This is the state transition diagram of an M/M/c /0 queue (figure 1.5).

0 1 2 c− 2· · · c− 1 c

λ

µ

λ

λ

(c− 1)µ

λ

Figure 1.5: State transition diagram of an M/M/c/0 queue

This system is an irreducible Markov chain.

23

Page 24: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Now we write the flow balance equation:

λπ0 = µπ1

λπ1 = 2µπ2

λπi = (i+ 1)µπi+1 i ≤ c− 1

πi+1 =λ

(i+ 1)µπi i ≤ c− 1

πi =1

i!

µ

)iπ0

If we impose∞∑i=0

πi = 1

we can find π0 as follows

c∑i=0

1

i!

µ

)iπ0 = 1

π0 =1∑c

i=0

1

i!

µ

)i

πi =

1

i!

µ

)i∑c

j=0

1

j!

µ

)jFor the loss probability, that is the fraction of customer that are loss over the customersthat arrived, we can consider that we have a loss when a customer arrives and find ccustomers already in service. In this way we can define the loss probability as:

Ploss = πc =

1

c!

µ

)c∑c

j=0

1

j!

µ

)j = B(ρ, c)

Where B(ρ, c) is the Erlang B formula. This formula is valid for the system M/G/c/0and for this system the loss probability is:

Ploss =

1

c!(λ · E [S])c∑c

i=0

1

j!(λ · E [S])j

The delay of an M/G/c/0 is

E [D] =ρ

1− ρ

24

Page 25: Network Modeling

Politecnico di Torino Formulary ver. 1.1

1.6 Multiservers Systems - The M/M/∞ Queue

This is an infinite server queue and the arrival and service rates are:

λn = λ ∀n (1.1)

µn = nµ ∀n (1.2)

Since no customer will evere wait in an M/M/∞ queue, the mean time spent in thesystem must be equal to the mean service time 1/µ and so the mean number of cus-tomers present must be equal to λ times this, λ/µ.This is the state transition diagram of an M/M/c queue (figure 1.6).

0 1 2· · · n− 1· · · n n+ 1 · · ·

λ

µ

λ

λ

λ

(n+ 1)µ

Figure 1.6: State transition diagram of an M/M/∞ queue

The flow balance equations are:

λπn = (n+ 1)µπn+1

πN+1 =λ

(n+ 1)µπn

πn =1

n!

µ

)nπ0

We impose that∞∑n=0

πn = 1

obtaining

π0

∞∑n=0

1

n!

µ

)n= 1

π0 · e ρ = 1

π0 = e−ρ

The average delay and the average number of customers are:

E [D] =1

µ

E [N ] =λ

µ= ρ

25

Page 26: Network Modeling

Politecnico di Torino Formulary ver. 1.1

1.7 Finite-Source Systems - The M/M/1/N-1/N Queue

In this type of queue there is a total of N customers and a customers is either in thesystem, or else outside the system and is in an idle state. When a customer is in theidle condition, then the time it takes for that particular customer to arrive is a randomvariable with exponential distribution whose means is 1/λ. This is the mean time spentper customer in the idle condition. All customers act indipendently of each other sothat if there are k customers in the idle condition, the total average arrival rate is kλ.The arrival process in this case is not a Poisson process and we cannot apply PASTA.The flow balance equations are:

Nλπ0 = µπ1

(N − i)λπi = µπi+1 0 ≤ i ≤ N − 1

From these equation we can find the relationship between πi and π0

πi+1 =(N − i)λ

µπi

πi =(N − i+ 1)λ

µ

(N − i+ 2)λ

µ· · · =

i∏j=1

(n− i+ j)

λiµπ0

To find π0 we have to impose∑N

i=0 πi = 1 and in this way we find the steady statesolution.

π0 =1∑N

i=0

[∏ij=1(n− i+ j)

] λiµ

Now we try to find the average of this type of queue applying Little’s Theorem:

E [N ] =

N∑i=0

iπi

E [λ] =N∑i=o

λiπi =N∑i=0

(N − i)λπi

E [T ] =E [N ]

E [λ]

1.8 Finite-Source Systems - The M/M/k/0/N Queue

This queue is represented by k identical servers (where k < N), no waiting line andthe population is a maximum of N. This kind of system is typical of the telephonecommunications.

The state transition diagram of an M/M/k/0/N queue is represented in figure 1.7.This system is always ergodic and we can find πi solving the flow balance equations.

26

Page 27: Network Modeling

Politecnico di Torino Formulary ver. 1.1

0 1 2 k − 2· · · k − 1 k

µ

(N − 1)λ

(N − k + 2)λ

(k − 1)µ

(N − k + 1)λ

Figure 1.7: State transition diagram of an M/M/k/0/N queue

For the loss probability we have to refer to the blocking probability ; where Pblock < πk.The blocking probability is the fraction between the rate at which calls are blocked andthe rate at which calls arrive:

Pblock =(N − k)λπk∑ki=0(N − i)λπi

=(N − k)πk∑ki=0(N − i)πi

<πk∑ki=0 πi

= πk N − i ≥ N − k

27

Page 28: Network Modeling

Chapter 2

Queues with Phase-Type Laws

In a single server queue the only probability law used to model the interarrival or servicetime distributions is the exponential distribution. This type of queue are collectivelyreferred to as birth-death processes. In these systems, transitions from any state are ad-jacent states only. But sometimes the exponential distribution is simply not adequate.Phese-type distributions allows us to consider more general situations. Queueing sys-tem with phase-type arrival or service mechanisms are referred to be almost-birth-deathprocesses.

2.1 The Erlang-r Service Model - The M/Er/1 Queue

Consider a single server system for which the arrival process is Poisson with rate λand service time, having an Erlang-r distribution, is represented as a sequence of rexponential services each with rate rµ. There cannot be more than one customerreceiving service at any time - the single server provides each customer taken into servicewith r consecutive service phases and then ejects that customer from the system.The density functions of the arrival and service processes are given by

a(t) = λe−λt , t ≥ 0

b(x) =rµ(rµx)r−1e−rµx

(r − 1)!, x ≥ 0

Our first task is to formulate a state descriptor for this queueing system. In an M/Er/1queue, we must record both the number of customers present and the current phaseof service of the customer in service, if any. Because of the exponential nature of thedistribution of both the times between arrivals and the services times at each of the rphases, a knowledge of the number of customers in the system and the current phase ofservice is sufficient to capture all the relevant past history of this system.It follows thata state of the system can be completely described by the pair (k, i), where k (k ≥ 0) isthe number of customers in the system, including the one in service, and i (1≤ i ≤ k)denotes the current phase of service. If k = 0, then the value of i is irrelevant. If

28

Page 29: Network Modeling

Politecnico di Torino Formulary ver. 1.1

k > 0, then k − i+1 denotes the number of phases of service yet to be completed bythe customer in service. The future evolution of the system is a function only of thecurrent state (k, i) and consequently a Markovian analysis may be carried out.

1,S1 2,S1 3,S1

1,S2 2,S2 3,S2

0 1,S3 2,S3 3,S3

· · · · · · · · ·

1,Sr 2,Sr 3,Sr

λ

λ

λ

rµrµ rµ

λ

λ

rµ rµλ

λ

rµ rµ

λ λ

Figure 2.1: State transition diagram of an M/Er/1 queue

The state transition diagram is represented in figure 2.1, where the states are arrangedinto levels according to the number of customer present. The states that have exactlyk customers are said to constitute the level k.If we consider Y as an Erlang process of order r we can write:

Y = X1 +X2 + · · ·+Xr

Where Xi with i < k is IID and it is a random variable distributed exponentially.We can also calculate the mean of Y :

E [Y ] =1

µwith Y = X1 + X2 + · · ·+ Xr

The second moment of Y is:

E[Y 2]

= E[(X1 +X2 + · · ·+Xr)

2]

=

k∑i=1

E[X2i

]+

k∑i=1

k∑j=1

E [XiXj ]

= k2

(kµ)2+ k(k − 1)

1

(kµ)2=k2 + k

(kµ)2

=1

µ+

1

kµ2

The coefficient of variation, how variant is the random variable is describe by thisformula

Cv =

√Var [X]

E [X]

29

Page 30: Network Modeling

Politecnico di Torino Formulary ver. 1.1

for the exponential this value isCv exp = 1

The variance of an M/Er/1 queue comes from the second moment

Var [Y ] = E[Y 2]− E [Y ]2 =

1

µ2+

1

kµ2− 1

µ2=

1

kµ2

And the coefficient of variation for an Erlang-r distribution is:

Cv Err =

1√kµ1

µ

=1√k

2.2 The Erlang-r Arrival Model - The Er/M/1 Queue

We now introduce the case of a single server queue for which the arrival process isErlang-r and the service time is exponential with rate µ.The density function of the arrival and service processes are given by

a(t) =rλ(rλt)r−1

(r − 1)!t ≥ 0

b(x) = µe−µx x ≥ 0

Before actually appearing in the proper queue, an arriving customer must pass throughr exponential phases each one distributed with parameter rλ. When a customer com-pletes the arrival process another immediately begins. We assume to have an infinitepool of available customers waiting to enter the arrival mechanism. The instant thatone customer completes the arrival process, a second customer simultaneously beginsthe process.The state descriptor for the Er/M/1 queue must specify the number of customers inthe system, k, and the phase at which the arriving customer has to be found, i. In thisway, the state diagram is set up on a two-dimensional grid (k,i), arranged into levelsaccording to the number of customers present, similar to the M/Er/1 system. Thestate transition of Er/M/1 queue is represented in figure 2.2.

30

Page 31: Network Modeling

Politecnico di Torino Formulary ver. 1.1

(0,1) (0,2) (0,3) · · · (0,r)

(1,1) (1,2) (1,3) · · · (1,r)

(2,1) (2,2) (2,3) · · · (2,r)

· · · · · · · · · · · · · · ·

(k,1) (k,2) (k,3) · · · (k,r)

µ

µ

µ

rλµ

µ

µ

µ

rλµ

µ

µ

µ

rλµ

µ

µ

µ

rλ µ

rλ rλ rλ rλ

Figure 2.2: State transition diagram of an Er/M/1 queue

31

Page 32: Network Modeling

Politecnico di Torino Formulary ver. 1.1

2.3 The M/H2/1 and H2/M/1 Queues

In this section we take into account single-server queues with either hyperexponentialservice or arrival distributions. We consider first the M/H2/1 queue, in this case thearrivals are generated according to a Poisson process with rate λ, while the service isrepresented by a two-hyperexponential distribution. With probability α a customerentering service receives service at rate µ1, while with probability 1− α this customerreceives service at rate µ2. Also in this case the state of the system is represented bythe pair (n,i) where n is the total number present and i is the current service phase.The transition diagram is shown in figure 2.3. Increasing the number of phases from 2to r has the effect of incorporating additional columns into this figure. With r possibleservice choices, a departure from any state (n,i), n > 1 can bring the system to any ofthe states (n-1, i) at rate αiµi, where αi is the probability that an arriving customerenters service phase i, for i=1,2,..,r.

(0,0)

(1,1) (1,2)

(2,1) (2,2)

· · · · · ·

(k,1) (k,2)

(1− α)λ

αλµ1µ2

λαµ1

αµ2

λ

(1−α)µ1

(1− α)µ2

λαµ1

αµ2

λ

(1− α

)µ1

(1− α)µ2

λαµ1

αµ2

λ

(1− α

)µ1

(1− α)µ2

Figure 2.3: State transition diagram of an M/H2/1 queue

Now we look at the H2/M/1 queue. In the instant at which a customer enters in thequeue properly, a new customer immediately initiates its arrival process. The time of

32

Page 33: Network Modeling

Politecnico di Torino Formulary ver. 1.1

the moment at which it actually arrives in the queue is exponentially distributed. Withprobability α this exponential distribution has rate λ1, while probability 1-α it has rateλ2.The transition diagram is represented in figure 2.4.

(0,1) (0,2)

(1,1) (1,2)

(2,1) (2,2)

· · · · · ·

(k,1) (k,2)

(1− α)λ1

αλ1µαλ2

(1− α)λ2µ

(1− α)λ1

αλ1µαλ2

(1− α)λ2µ

(1− α)λ1

αλ1µαλ2

(1− α)λ2µ

(1− α)λ1

αλ1µαλ2

(1− α)λ2µ

Figure 2.4: State transition diagram of an H2/M/1 queue

33

Page 34: Network Modeling

Chapter 3

The M/G/1 and the G/M/1Queues

3.1 Introduction in the M/G/1 Queue

The M/G/1 queue is a single-server queue, the arrival process is Poisson with rate λand its distribution function is:

A(t) = 1− e−λt t ≥ 0

The service times are independent and identically distributed and obey a general distri-bution function. In particular, the remaining service time may no longer be independentof the service already received. The mean service rate is denoted by µ. The servicetime distribution function is:

B(x) = P (S ≤ x)

where S is the random variable service time, and the density function is:

b(x)dx = P (x ≤ S ≤ x+ dx)

For the M/G/1 queue, the stochastic process N(t), t ≥ 0 is not a Markov process since,when N(t) ≥ 1, a customer is in service and the time already spent by that customer inservice must be take into account. Consider the conditional probability that the servicefinishes before x+ dx knowing that its duration is greater than x

C(x) = P (S ≤ x+ dx |S > x) =P (x ≤ S ≤ x+ dx)

P (S > x)=

b(x)dx

1−B(x)

In general C(x) depends on x. However, when B(x) is the exponential distribution,B(x) = 1− e−µx, b(x) = µe−µx and

C(x) =µe−µxdx

1− 1 + e−µx

34

Page 35: Network Modeling

Politecnico di Torino Formulary ver. 1.1

which is independent of x.For the M/G/1 queue, where C(x) depends on x, the process N(t), t ≥ 0 is not Marko-vian and if we start to observe the process at an arbitrary time x, the probability thatthe service completes on the interval (x, x+ dx], which implies a transition of the pro-cess N(t), is not independent of x, the time already spent in service for the customercurrently in service. If at some time t we want to summarize the complete releventpast history of an M/G/1 queue, we must specify both:

1. N(t), number of customers present at time t

2. S0(t), the service time already spent by the customer in service at time t

While N(t) is not Markovian, [N(t), S0(t)] is a Markovian process, since it provides allthe past history necessary for describing the future evolution of an M/G/1 queue.

3.2 Solving the M/G/1 Queue

To solve the M/G/1 queue with Markov chain theory we need a trick. If we consider theprocess N(tn) the process sampled in discrete time is better. We can sample the timeat arrival time or at departure time. If we sample at arrival time, the residual servicetime is still dependent on S0(t) and in this case is not possible to say that Markovianproperty is ensured (the next arrival is related to S0(t)). Else, when we sample atdeparture time, if the queue is not empty the interval between two departures dependsonly on service time; if the queue is empty this interval is the sum of one arrival timeand one departure time.We recognize that N(tn) = qn is a discrete time Markov chain (DTMC), where qn isthe number of customers at departure time. If we write

qn+1 = F (qn)

is equivalent to say that Markov property holds because all the system depends on n.F is a function that contains stochasticity but does not depend on the past.

qn+1 = qn + arrivals − departures

If qn > 0 ”departures” are deterministically equal to 1.We define θn as the number of arrivals in (tn, tn+1] and we can check that θn does notdepend on the past. We can write

qn+1 = (θn − 1) + pn

If we define tn and tn+1 the service time of customer in n and n+ 1, we can rewrite θnas the number of arrivals in Sn+1 and for stacasticity θn is in Sn+1 is independent ofanother θn in another Sn time.Now we define θ

′n is the arrivals in Sn+1 we can write

qn+1 = θ′n + qn

35

Page 36: Network Modeling

Politecnico di Torino Formulary ver. 1.1

∆q =

{1 qn > 0

0 qn = 0

The M/G/1 works asqn+1 = qn −∆qn + θn

Now we draw the graph of M/G/1(3.1)

0 1 2 3 4 5p0 p1

p2p3

p4p5

Figure 3.1: Graph of an M/G/1 queue

θn can take any value from 0 to ∞. The probability to having k customers does notdepend on n:

pk = pn(θ = k)

If we consider that G = D, so we have an M/D/1 queue, all Sn have the same value

pn(θ = k) =e−λx(λx)k

k!

Now we defineN(t) as the number of customers after the departure of the n-th customer.Service time are IID so customers that arrive are independent from the number ofcustomers in another service time. This can be write as

P (θn = k) = P (θ = k)

Customers arrive in random window so∫ ∞0P (θ = k |Sn+1 = x)S(x) dx =

∫ ∞0

e−λx(λx)k

k!S(x) dx

However, this solution is too complex to do, so we try in another way.

0 1 2p0

p1p2

p1

p2

p0

n− 1 n n+ 1 n+ j

p1

p2

p0

pj+1

36

Page 37: Network Modeling

Politecnico di Torino Formulary ver. 1.1

We now look at the flow balance equation for state 0 is:

π1p0 = π0(1− p0)

The flow balance equation for state n is:

πn(1− p1) = πn+1p0 + πn−1p2 + · · ·+ π1pn−1 + π0pn

The loops are count twice or are not count at all.

Average

To calculate the average we start from this equation

qn+1 = qn −∆qn + θn

Under ergodic condition we can write

limn→∞

E [qn] = E [q]

And we findE [qn+1] = E [qn]− E [∆qn] + E [θn]

Now we take the limit of this expression

E [q] = E [q]− limn→∞

E [∆qn] + E [θn]

E [θn] this is a constant with respect to n, because of θn does not depend on n.

−P (q > 0) + E [θn] = 0⇒ P (q > 0) = E [θn]

E [θ] = λE [S]

for λE [S] > 1 the system is not ergodic. Now, if we take qn+1 = qn−∆qn + θn and wedo the square and after we take the limit for n→∞ we obtain something like this

E [q] =E[θ2]

+ E [θ]− 2E [θ]2

2(1− E [θ])

This formula is known as Pollack and Klimchine formula.

E [θ] = λE [S]

E[θ2]

= λ2E [S]2 + λE [S]

It can be proved that the distribution if the queue size at departure time is equal tothe steady state distribution at any time.

E [q] =λ2E [S]2 + λE [S] + λE [S] + 2λ2E [S]2

2(1− λE [S])

=λ2E [S]2 + 2λE [S] + 2λ2E [S]2

2(1− λE [S])

37

Page 38: Network Modeling

Politecnico di Torino Formulary ver. 1.1

If we put ρ = λE [S]

E [q] =λ2E [S]2 + 2ρ− 2ρ2

2(1− ρ)=λ2E [S]2 + 2ρ(1− ρ)

2(1− ρ)

=λ2E [S]2

2(1− ρ)+ ρ

We apply Little’s Theorem and we obtain

E [D] =λE[S2]

2(1− ρ)+ E [S]

E [W ] =λE[S2]

2(1− ρ)

This is the average waiting time and we can see that it depends directly to the secondmoment of the service time.

3.3 Average in other type of queue

• M/M/1

cv = 1 V ar(S) =1

µ2E [S] =

1

µE[S2]

=2

µ2= 2E [S]2

E [W ] =λE[S2]

2(1− ρ)=

2λE [S]2

2(1− ρ)=λE [S]2

1− ρ=

λ2/µ2

1− rho= E [S]

ρ

1− ρ

• M/D/1

cv = 0 E [S] =1

µE[S2]

= E [S]2 = S2

E [W ] = E [S]ρ

2(1− ρ)

• M/G/1c2v = 10 E

[S2]

= E [S]2 + V ar(S) = 11E [S]2

E [W ] = E [S] 11ρ

2(1− ρ)

38

Page 39: Network Modeling

Chapter 4

Queueing Networks

4.1 Introduction

4.1.1 Basic Definitions

In this part we consider a ”multi-node” system in which a customer requires serviceat more than one node. This kind of system can be viewed as a network of nodes,in which each node is a service center having storage room for queues to form andperhaps with multiple servers to handle customers requests. In queueing networks weare faced with situation in which customers departing from one service center may mixwith customers leaving a second center and the combined flow may be destined to entera third service center. Thus there is an interaction among the queues in the networkand this ultimately may have a complicating effect on the arrival at downstream servicecenter. Customer arrival times can become correlated with customer service times oncecustomers proceed past their point of entry into the network and this correlation canmake the mathematical analysis of these queues difficult.

4.1.2 The Departure Process - Burke’s Theorem

If we know the various properties of the variables that are associated with the servicecenters, the number of servers, their service time distribution, the scheduling disci-pline and so on, then the only item missing is the stochastic process that describes thearrivals. This linked to the departure processes from nodes that feed the particularservice center as well as the flow of customers directly from the exterior into the center.Consider an M/G/1 system and let A∗(s), B∗(s) and D∗(s) denote the Laplace trans-form of the PDFs describing the interarrival times, the service times, and the interde-parture times, respectively. Let us calculate D∗(s). When a customer depart from theserver, either another customer is available in the queue and ready to be taken intoservice immediately, or the queue is empty. In the first case, the time until the nextcustomer departs from the server will be distributed exactly as a service time and wehave

D∗(s)|server nonempty = B∗(s)

39

Page 40: Network Modeling

Politecnico di Torino Formulary ver. 1.1

On the other hand, if the fist customer leaves an empty system behind, we must waitfor the sum of two intervals: (a) the time until the next customer arrives and (b) theservice time of this next customer. Since these intervals are independently distributed,the transform of the sum PDF is the product of the transforms of the individual PDFs,and we have

D∗(s)|server empty = A∗(s)B∗(s) =λ

s+ λB∗(s)

We know that the probability of a departure leaving behind an empty queue is thesame as the stationary probability of an empty system, 1− ρ. In this way we can writethe unconditional transform for the interdeparture PDF as

D∗(s) = ρB∗(s) + (1− ρ)λ

s+ λB∗(s)

For the case of an M/M/1 queue, the Laplace transform is given by

B∗(s) =µ

s+ µ

where µ is the service rate. Substituting in D∗(s) we obtain

D∗(s) =λ

µ

µ

s+ µ+

(1− λ

µ

s+ λ

µ

s+ µ

s+ µ+

λ

s+ λ

µ

s+ µ− λ

µ

λ

s+ λ

µ

s+ µ

=λ(s+ λ)

(s+ µ)(s+ λ)+

λµ− λ2

(s+ λ)(s+ µ)

=λ(s+ µ)

(s+ µ)(s+ λ)=

λ

s+ λ

and so the interdeparture time distribution is given by

D(t) = 1− e−λt t ≥ 0

We can conclude that the interdeparture times are exponentially distributed with thesame parameters as the interarrival times. This result can be written more generallyad Burke’s theorem:”Consider an M/M/1, M/M/c or M/M/∞ system with arrival rate λ. Suppose thatthe system is in steady state. Then the following hold true:

1. the departure process is Poisson with rate λ

2. at each time t, the number of customers in the system is independent of thesequence of departure time prior to t ”

We know that the systems, such as M/M/1, M/M/c or M/M/∞, are the only suchFCFS queues with this property. In other words, if the departure process of andM/G/1 or G/M/1 system is Poisson, then G=M.

40

Page 41: Network Modeling

Politecnico di Torino Formulary ver. 1.1

4.1.3 Two M/M/1 Queues in Tandem

Consider a queueing system network with Poisson arrivals and two nodes in tandem.We assume that the service times of a customer at the first and second nodes aremutually independent as well as independent if arrival process. We now show that , asa result of this assumption and Burke’s theorem, the distribution of customers in thetwo nodes is the same as if they were isolated independent M/M/1 queues.The rate of Poisson arrival process is λ and the mean service times at servers 1 and 2

be 1/µ1 and 1/µ2, respectively. We introduce ρ1 =λ

µ1and ρ2 =

λ

µ2as the utilization

factors and we assume that ρ1 < 1 and ρ2 < 1. Notice that node 1 is an M/M/1 queue,and by the Burke’s theorem, its departure process (and hence the arrival process ofnode 2) is Poisson. By assumption, the service time at node 2 is independent of node1. But node 2 behaves like an M/M/1 queue, and can analyzed independently of node1. From our result we know:

P (n at node 1) = ρn1 (1− ρ1)

P (m at node 2) = ρm2 (1− ρ2)

From the Burke’s theorem, it follows that the number of customers present in node 1is independent of the sequence of earlier arrivals at node 2. Consequently, it must beindependent of the number of customer present in node 2. This implies that

P (n at node 1ANDm at node 2) = P (n at node 1) ·P (m at node 2) = ρn1 (1−ρ1) ·ρm2 (1−ρ2)

Thus, under steady state conditions, the number of customers at node 1 and node 2 at anygiven time are independent and joint distribution of customers in the tandem queueing systemhas a product form solution.

4.2 Open Queueing Networks

4.2.1 Feedforward Networks

We have a feedforward network when the input to each node in the network is Poisson. Indeed,since the aggregation of mutually independent Poisson processes is a Poisson process, the inputof the nodes that are fed by combined output of other nodes in Poisson. Likewise, since thedecomposition of a Poisson process yields multiple Poisson processes, a single node can providePoisson input to multiple downstream nodes. Feedforward networks do not permit feedbackpaths since this may destroy Poisson nature of the feedback stream.

4.2.2 Jackson Networks

The work of Jackson shows that, even in presence of feedback loops, the individual nodesbehaves as if they were fed by Poisson arrivals, when in fact they are not. We consider nowthe Jackson network. Take an open network consisting of M nodes, where there is at least onenode to which customers arrive from external source and there is at least one node from whichcustomers depart from the system. This network is a Jackson network if the following are truefor i, j = 1, 2, · · · ,M :

41

Page 42: Network Modeling

Politecnico di Torino Formulary ver. 1.1

• node i consists of an infinite FCFS queue and ci exponential servers, each with parameterµi

• external arrivals to node i are Poisson with rate γi

• after completing service at node i, a customer will proceed to node j with probability rijindependent of past history or will depart from the system, never to return again, withprobability 1−

∑Mj=1 rij

The service centers in this network may be load dependent, meaning that the rate at whichcustomers depart from service can be a function of the number of customers present in thenode. The total average arrival rate of customers to service center is i by λi; this is given bythe sum of the arrivals from outside the system plus arrivals from all internal service centers.And we obtains the following equation:

λi = γi +

M∑j=1

λirij i = 1, 2, · · · ,M

In steady state we also have a traffic equation for the network as a whole:

M∑i=1

γi = γ =

M∑i=1

λi

1−M∑j=1

rij

This states that, at equilibrium, the total rate at which customers arrive into the queueingnetwork from the outside γ must be equal to the rate which the leave the network.A Jackson network may be viewed as a continuous-time Markov chain with state descriptorvector k = (k1, k2, · · · , kM ) in which ki denotes the number of customers at service center i. Ata given state k, the possible successor states correspond to a single customer arrival from theexterior, a departure from the network or a movement of a customer from one node to another.The transition from state k to state k(i+) = (k1, · · · , ki−1, ki + 1, ki+1, · · · , kM ) correspond toan external arrival to node i and has transition rate γi. The transition from state k to statek(i−) = (k1, · · · , ki−1, ki − 1, ki+1, · · · , kM ) corresponds to a departure from center i to the

exterior and has transition rate µi(ki)(1 −∑Mj=1 rij). Finally, the transition from state k to

state k(i+, j−) = (k1, · · · , ki−1, ki + 1, ki+1, · · · , kj−1, kj − 1, kj+1, · · · , kM ) corresponds to acustomer moving from node j to node i and has transition rate µj(kj)rij . Let

P (k) = P (k1, k2, · · · , kM )

denote the stationary distribution of the Markov chain (P (k) is the equilibrium probabilityassociated with state k). We denote the marginal distribution of finding ki customers in nodei by Pi(ki).Jackson’s theorem provide the steady state joint distribution for the states of the network.Jackson Theorem: ”For a Jackson network with effective arrival rate λi to node i, and assumingthat λi < ciµi for all i, the following are true in steady state:

1. node i behaves stochastically as if it were subjected to Poisson arrival with rate λi

2. the number of customers at any node is independently of the number of customers atevery other node ”

Jackson’s theorem shows that the joint distribution for all nodes factors into the product ofthe marginal distribution, that is P (k) = P1(k1)P2(k2) · · ·PM (kM ), where Pi(ki) is given as a

42

Page 43: Network Modeling

Politecnico di Torino Formulary ver. 1.1

solution to the classical M/M/1 -type queue. It is an example of a product-form solution. Inspecial case when all the service centers contain a single exponential server, the expression ofP (k) becomes:

P (k) =

M∏i=1

(1− ρi)ρkii ρi =λiµi

The stability condition for a Jackson network is

ρi =λiciµi

< 1 i = 1, 2, · · · ,M

To solve a Jackson network we need to solve the traffic equations to obtain the effective arrivalrate at each node. Each node is then solved in isolation and the global solution formed fromthe product of the individual solutions.

Mean Number of Customers

The mean number of customer in node i, E [Ni], is that of an isolated M/M/1 queue with arrivalrate λi; this is given by:

E [Ni] =ρi

1− ρii = 1, 2, · · · ,M

It follows that the total mean number of customers in the network is given by:

E [N ] =

M∑i=1

ρi1− ρi

Mean Time Spent in Network

The average waiting time is related to the average time that a customer spends in the network,and this can be found by applying Little’s Theorem:

E [W ] =E [N ]

γγ =

M∑i=1

γi

γ is the total arrival rate. The average time that a customer spends at node i, during each visitto node i, is given by:

E [Wi] =E [Ni]

λi=

1

µi(1− ρi)In this case we have that W 6= W1 +W2 + · · ·+WM . The average time that a customer spendsqueueing prior to service on a visit to node i is:

E[WQi

]= E [Wi]−

1

µi=

ρiµi(1− ρi)

Throughput

The throughput of a singe node is the rate al which customers leave that node. The throughputod node i is:

Xi =

∞∑k=1

Pi(k)µi(k)

43

Page 44: Network Modeling

Politecnico di Torino Formulary ver. 1.1

where µi(k) is the load-dependent service rate.The throughput of the entire open queueingnetwork is the rate ant which customers leave the network. If customers are not lost to thenetwork, nor combined nor split in any way, then at steady state, the throughput of the networkis equal to the rate at which customers enter the network.

4.3 Closed Queueing Networks

If Jackson network is a closed queueing network it is called Gordon and Newell network.Consider a closed single-class queueing network composed of M nodes. Let ni be the number ofcustomers at node i. Then the total customer population is given by N = n1 + n2 + · · ·+ nM .A state of the network is defined as n = (n1, n2, · · · , nM ) with ni ≥ 0 and

∑Mi=1 ni = N . The

queueing discipline at each node is FCFS and the service the distributions are exponential. Letµi be the mean service rate at node i. When the service rate is load dependent, we shall denotethe service rate by µi(k). Let pij be the fraction of departures from node i that go next tonode j and let λi be the overall arrival rate to node i. Since the rate if departure is equal tothe rate of arrival, when the network is in steady state, we can write

λi =M∑j=1

λjpij i = 1, 2, · · · ,M

Now we introduce the visit ratio at node i, νi. This gives the mean number of visits to nodei relative to a specified node, in our case we consider the node 1. So, ν1 = 1 and νi is themean number of visits to node i between two consecutive visits to node 1. Notice that νi maybe greater (or smaller) than 1. If Xi(N) is the throughput of node i in a closed network withN customers, then we must have νi = Xi(N)/X1(N). At steady state the rate of arrival to anode is equal to the rate of departure so that νi = λi/λ1 which means that νi uniquely satisfythe system equation

ν1 = 1 and νi =∑Mj=1 νjpij i = 1, 2, · · · ,M

The major result for this closed network is that the equilibrium distribution is given by theproduct form

P (n) = P (n1 , n2 , . . . , nM ) =1

G(N)

M∏i=1

fi(ni)

where

fi(ni) =νnii∏ni

k=1 µi(k)if the node i is load dependent

fi(ni) =

(νiµi

)ni

= Y nii if node i is load dependent

The constant G(N) is called the normalization constant. It ensures that the sum of the prob-abilities is equal to one.

44

Page 45: Network Modeling

Part II

Exercises

45

Page 46: Network Modeling

Chapter 5

Preliminary Exercises

Exercise 1

Text

Compute the probability density function for the smallest among κ independent random vari-ables, all distributed accordingly to a exponential probability density function with the sameparameter λ.

Solution

Xi ∼ Exp(λ) ∀ i = 1, . . . , κ

Moreover, Xi are IID. The minimum will be given by:

Y = min{Xi}

Therefore the probability density function fy(y) is the objective of the problem.

Fy(y) = P (Y ≤ y) = P (min{Xi} ≤ y)

But it is more easy to compute:

F y(y) = 1− Fy(y) = 1− P (Y ≤ y) = P (Y ≥ y)

Indeed:P (Y ≥ y) = P (min{Xi} ≥ y) = P (X1 > y , X2 > y , . . . , Xκ > y)

since they are all IID, it is possible write:

P (X1 > y) · P (X2 > y) · . . . · P (Xκ > y) = [P (X > y)]κ

= [e−λy]κ = e−λκ y

Now, given that F y(y) is obtained, to compute fy(y) it is possible use:

fy(y) =dFy(y)

dyfy(y) = −dF y(y)

dy

Therefore:fy(y) = −[−λκ · e−λκ y] = λκ · e−λκ y

46

Page 47: Network Modeling

Politecnico di Torino Formulary ver. 1.1

It is simply fx(x) = λe−λx where λ = λκ, in conclusion:

Y ∼ Exp(λκ)

Exercise 2

Text

A barber opens his shop at time t0 = 0. Customers arrive at shop randomly, accordingly to aPoisson process, i.e., the probability density function of the time between two customers arriveis:

a(t) = λe−λ t · u(t)

Each air cut requires X seconds, where such X is a random variable.Find the probability, P, that the second arrive customer does not have to wait and his

average waiting time W in the following cases:

. X is a constant: X = c;

. X is uniformly distributed among 0 and 2c: X ∼ U(0 , 2c).

Solution

Case 1: the customer does not wait - X = c

Consider:

tt0 ta1 td1

X

where:

. ta1 is the arrival time of the first customer;

. td1 is the departure time of the first customer;

. the orange line represent possible arrival times for the second customer.

Therefore:P(

2◦customer does not have to wait

)= P (ta2 > td1)

and:td1 = ta1 +X =⇒ td1 = ta1 + c

In conclusion:P (ta2 > td1) = P (ta2 > ta1 + c) = P (ta2 − ta1 > c)

but:ta2 − ta1 ∼ Exp(λ) =⇒ P (ta2 − ta1 > c) = e−λ c

47

Page 48: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Case 2: the customer has to wait - X = c

Consider W the waiting time of the second customer; the average is:

E [W ] =

{0 ta2 > td1ta2 − td1 otherwise

Since:

ta2 − td1 =⇒ ta2 − ta1 + c =⇒ c− (ta2 − ta1) if ta2 − ta1 < c

and ta2 − ta1 ∼ Exp(λ). Thus:

E [W ] =

{0 ta2 > td1c− (ta2 − ta1) otherwise

Let y = (ta2 − ta1):

E [W ] =

{0 ta2 > td1c− y otherwise

The average waiting time of the second customer is:

E [c− y | y < c]

this can be computed as: ∫ c

0

(c− y)fy(y) dy =

∫ c

0

(c− y)λe−λ y dy‡

By solving this integral:

c ·∫ c

0

λe−λ y dy −∫ c

0

y · λe−λ y dy =

c ·(−e−λ y

∣∣c0

)−[−y · e−λ y

∣∣c0

+

∫ c

0

e−λ y dy

]=

c · (1− e−λ c)−[−c · e−λ c +

e−λ y

−λ

∣∣∣∣c0

]=

c · (1− e−λ c) + c · e−λ c +e−λ y

λ− 1

λ= c+

e−λ y

λ− 1

λ

Case 3: the customer does not wait - X ∼ U(0 , 2c)

In this case:td1 = ta1 +X

and:P(

2◦customer does not have to wait

)= P (ta2 > td1) = P (ta2 > ta1 +X)

It can be written as:∫ 2c

0

P (ta2 − ta1 > X) · fx(x) dx =

∫ 2c

0

e−λx · 1

2cdx

‡This is solved by parts, where f = y and g′ = λe−λ y

48

Page 49: Network Modeling

Politecnico di Torino Formulary ver. 1.1

This integral is solvable in such a way:

1

2c·∫ 2c

0

e−λx dx =1

2c· e−λx

−λ

∣∣∣∣2c0

=1

2c· e−2λ c − 1

−λ= − 1

2λ c· e−2λ c

Case 4: the customer has to wait - X ∼ U(0 , 2c)

In this case we have not to compute:

E [c− y | y < c]

but, since:ta2 − td1 =⇒ ta2 − ta1 +X =⇒ ta2 < ta1 +X

therefore:E [W ] = E [X − Y |Y < x] = E [E [X − Y |Y < X , X = x]]x

that can be solved by:∫ 2c

0

(∫ x

0

(X − Y )fy(y) dy

)· fx(x) dx =

∫ 2c

0

(x+

e−λx

λ− 1

λ

)· 1

2cdx =

=1

2c·[

4c2

2− e−2λ c

λ2− 2c

λ+

1

λ2

]�

Exercise 3

Text

Passengers arrive randomly at the bus stop. The random process describing passengers arrivalsis Poisson with rate λ = 1 arrival per minute. Also departures follows a Poisson random process,independent from the customer arrival process, with rate µ = 2 buses per hour.

Assuming that passengers take always the first stopping bus and buses can carry an arbitrarynumber of passengers, compute:

1. the average number of passengers that take the same bus;

2. the average number of passengers on the first bus departing after 9 am.

Solution

Task 1

Let N be the number of passengers in the same bus; the problem requests E [N ]. Let X beinter arrival time of buses:

X ∼ Exp(µ)

The process that counts the number of passengers arriving during X is N(x) and it is a Poissonprocess with rate λ ·X:

N(x) ∼ Poisson(λX)

49

Page 50: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Therefore:

E [N ] = E [E [N(x) |X]] = E [λX] = λ · E [X] = λ · 1

µ

Since λ describe arrivals per minute, it is equivalent say:

1 arrival per minute = 60 arrivals per hour

In conclusion:

E [N ] = 60 · 1

2= 30

Task 2

The situation to take care is:

t0 bus 9 bus

x2 x1

where each random variable is exponentially distributed:

x1 ∼ Exp(µ)

x2 ∼ Exp(µ)

The average number of passengers that take the bus after 9, thanks to memoryless property, isgiven by:

E [N ] = E [E [N(x1) |x1]] + E [E [N(x2) |x2]] = 2 · E [E [N(x) |x]] = 2 · λµ

= 60

50

Page 51: Network Modeling

Chapter 6

Exercises on Queues

Exercise 1

Text

In a M/M/m system, arrivals are distributed according to a Poisson process and service timeare exponentially distributed with rate µ. The queue is served in FIFO and, at time t0 = 0,customer A arrives finding m people into the m servers and n people in the queue. After t0nobody arrives more.

Find:

1. the average time in which A starts being in service (waiting time);

2. the time in which the system will be empty.

3. Let X be κ if A is the κ-th customer leaving the system after t0. Find P (X = κ).

4. the probability that A ends his service before his predecessor B.

5. Let ω̃ be the amount of time spent by A waiting to be in service. Find P (ω̃ > x).

Solution

Task 1

The average waiting time is:E [WA]

It happen after n + 1 departures of customer in the queue. Since there are m servers, theinter departure time is distributed accorded to Exp(mµ) because all of them are distributedas Exp(µ). Therefore, the waiting time of A is the sum of inter departure times (Td) of n + 1customers.

E [WA] =

n+1∑i=1

E [Tdi ]

Since all Tdi are IID:

E [WA] = (n+ 1) · E [Tdi ] = (n+ 1) · 1

mµ=n+ 1

51

Page 52: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Task 2

The time in which the system is empty is the time in which n + 1 + m departures will takeplace. The distribution is not, as before, Exp(mµ) because, in some moments, it is possiblethat not all servers are busy. Representing the situation with a Markov Chain:

0 1 2 m· · · m+ 1 m+ 2

λ

µ

λ

λ

λ

Therefore:

E [Tempty] =n+ 1

mµ+

1

mµ+

1

(m− 1)µ+

1

(m− 2)µ+ · · ·+ 1

µ=

=n+ 1

mµ+

m−1∑i=0

1

(m− i)µ

Task 3

If κ = 1, A is the first customer leaving the system: it could not be possible since the disciplineis FIFO. Therefore:

P (X = 1) = 0

At least, A could leave the system after n+ 1 customers: it means that people in the queue isall in service into the m servers and A is the one that has the service time smaller.

Therefore:

P (X = κ) =

{0 1 ≤ κ ≤ n+ 1

− n+ 1 < κ ≤ n+ 1 +m

Indeed that probability is different than 0 in two cases:

. if all customers are served and A is the last one (m − 1 servers are idle and 1 busy, theone that is serving A);

. if there are some customers in service and A is one of them (m servers, potentially, arebusy: actually they can be less than m, but surely more than 1).

In the first case we have to compute:

P (X = n+ 2) ‡ = P (A is the first leaving) =1

m

since all servers are independent.In the second case, instead, the probability that have to be compute is:

P (X = n+ 3) = P (Ais not the first leaving) ·· P (A is the second leaving |Ais not the first) =

=

(1− 1

m

)· 1

(m− 1)=

1

m

‡The term n+ 2 means that A is the first of the remaining m customers in queue.

52

Page 53: Network Modeling

Politecnico di Torino Formulary ver. 1.1

The probability that A is the second leaving given that is not the first, means that thereare m−1 servers to consider and each one is independent from the others. It is the same of theprevious case because servers are IID and the distribution is exponential, so the memorylessproperty holds.

In conclusion:

P (X = κ) =

0 1 ≤ κ ≤ n+ 11

mn+ 1 < κ ≤ n+ 1 +m

Task 4

The probability that A ends his service before B given that the service time of B is greaterthan the service time of A is:

P (A leaves before B |TdB > WA) =1

2

because once they are both in service they have the same probability of end their service onebefore the other.

Actually, the probability that A leaves before B is:

P (TdB > WA) · P (A leaves before B |TdB > WA)

where P (TdB > WA) is just given by the probability that m − 1 customer are still in service.Therefore:

P (TdB > WA) =m− 1

m

Globally:

P (A leaves before B) =1

2· m− 1

m

Task 5

Given that ω̃ is the waiting time of A, the probability:

P (ω̃ = x)

is simply the distribution. Therefore:

P (ω̃ = x) =

n+1∑i=0

xi

where xi ∼ Exp(mµ). It means that:

n+1∑i=0

xi =

n+1∑i=1

e−mµx · (mµx)i

i!

This term is the Erlang(n+ 1, mµ).�

53

Page 54: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Exercise 2

Text

Consider a M/M/1 system with arrival rate λ and departure rate µ. Knowing that customersarrives always in pair, draw the transition diagram and write the flow balance equations.

Solution

The transition diagram is:

0 1 2 3 4

λ

µ

λ

µ

λ

µ

λ

µ

For a given node i, with i ≥ 2, flows balance equations are:

(πi−2 · λ) + (πi+1 · µ)‡ = (µ+ λ) · πi‡

Considering i = 1:µ · π2 = (λ+ µ) · π1

While, for i = 0:µ · π1 = λ · π0

Globally: µ · πi+1 = λ · πi i = 0

µ · πi+1 = (λ+ µ) · πi i = 1

(πi−2 · λ) + (πi+1 · µ) = (µ+ λ) · πi i ≥ 2

Exercise 3

Text

Consider a system in which the departure rate is µ and the arrival rate is λ̃, where:

λ̃ =

{2 · λ when there are no customers in the system

λ otherwise

Find:

1. the transition diagram;

2. the balance equations, the steady state distribution and discuss the ergodicity;

3. the average number of customers in the system;

4. the average time spent by customers in the system;

5. the average waiting time spent before being served.

‡This is the incoming flow.‡This is the outgoing flow.

54

Page 55: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Solution

Task 1

The transition diagram is:

0 1 2

2 · λ

µ

λ

µ

λ

µ

Task 2

Considering i 6= 0:

λ · πi = µ · πi+1 =⇒ πi+1 =λ

µ· πi

while for i = 0:2λ · π0 = µ · π1

Therefore: {λ · πi = µ · πi+1 i 6= 0

2λ · πi = µ · πi+1 i = 0

where each πi is the stationary distribution. Replacing i+ 1 with j:

πj =λ

µ· πj−1

but it is possible substitute πj−1 with his expression obtaining:

πj =λ

µ·(λ

µ· πj−2

)Iterating, the last term will be:

πj = 2 ·(λ

µ

)j· π0

This holds for each j. In order to be a distribution, the sum of all πj is forced to be equal toone, therefore the two equations that represent the steady state distribution are:

πj = 2 ·(λ

µ

)j· π0 (6.1)

n∑j=0

πj = 1 (6.2)

Substituting (6.1) in (6.2):n∑j=0

µ

)j· π0 = 1

55

Page 56: Network Modeling

Politecnico di Torino Formulary ver. 1.1

It is possible rewrite the expression in:

n∑j=1

2 ·(λ

µ

)j· π0 + π0 = 1

π0 ·

2 ·n∑j=1

µ

)j· 1 + 1

= 1 (6.3)

Let:

ρ =λ

µ

So the sum:n∑j=1

ρj

converge if ρ < 1: under this hypothesis the system is ergodic. Assuming k = j − 1:

n∑k=0

ρk+1 =⇒ ρ ·n∑k=0

ρk

and the last term is the geometric sum, therefore:

n∑j=1

ρj = ρ · 1

1− ρ

Substituting in (6.3):

π0 ·[2 · ρ · 1

1− ρ+ 1

]= 1 =⇒ π0 =

12·ρ1−ρ + 1

=⇒ =1− ρ1 + ρ

In conclusion: πi = 2 ·

µ

)i· 1− ρ

1 + ρ

π0 =1− ρ1 + ρ

The initial π0, in terms of λ and µ, is:

π0 =1− ρ1 + ρ

=µ− λµ+ λ

(6.4)

Task 3

The average number of customer in the system is given by:

E [N ] =

∞∑i=0

i · πi =

∞∑i=1

i · πi

56

Page 57: Network Modeling

Politecnico di Torino Formulary ver. 1.1

since the term with i = 0 is null. Substituting the value of πi:

E [N ] =

∞∑i=1

i ·

[2 ·(λ

µ

)i· 1− ρ

1 + ρ

]

Let:

ρ =

µ

)Therefore:

E [N ] = 2 · 1− ρ1 + ρ

·∞∑i=1

i · ρi (6.5)

The sum:∞∑i=1

i · ρi

is the derivative of the geometric series, so:

∞∑i=1

i · ρi = ρ ·∞∑i=1

i · ρi−1 =⇒ ρ ·

[d

dx

( ∞∑i=0

i · xi)]

x=ρ

Since:∞∑i=0

i · xi =1

1− x

the result is:

ρ ·[d

dx

(1

1− x

)]x=ρ

= ρ ·[d

dx

(1

(1− x)2

)]x=ρ

(1− ρ)2

Substituting this value in (6.5):

E [N ] = 2 · 1− ρ1 + ρ

· ρ

(1− ρ)2=

2 · ρ(1 + ρ) · (1− ρ)

=2ρ

(1− ρ2)

Task 4

The average time spent by customers in the system is given, using the Little Theorem, by:

E [T ] =E [N ]

E [λ]

The value E [N ] is just the average number of customer in the system computed in task 3, whileE [λ] is the expected value of arrival rate. It can be calculated as:

E [λ] = 2λ · π0 +

∞∑i=1

λ · πi = 2λ · π0 + λ ·∞∑i=1

πi

It can be re-written, by putting the common term λ into the sum, as:

2λ · π0 + λ ·∞∑i=1

πi = λ · π0 + λ ·∞∑i=0

πi

57

Page 58: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Since the distribution is stationary:∞∑i=0

πi = 1

Therefore:E [λ] = λ · π0 + λ = λ · (π0 + 1)

Substituting the value of π0 given by (6.4):

E [λ] = λ ·(

1− ρ1 + ρ

+ 1

)= λ ·

(1− ρ+ 1 + ρ

1 + ρ

)=

1 + ρ

Expressed in terms of λ and µ:

E [λ] =2λ

1 + ρ=

2λµ

µ+ λ

Since:

E [T ] =E [N ]

E [λ]

the result is:

E [T ] =

(2ρ

(1− ρ2)

)÷(

2λµ

µ+ λ

)=ρ · (µ+ λ)

λµ(1− ρ2)

Task 5

The average waiting time spent before being served is E [W ]: it is a part of the cumulative timespent in the system. Indeed:

E [T ] = E [W + Ts]

where Ts is the service time. Due to independence:

E [T ] = E [W + Ts] = E [W ] + E [Ts]

Therefore:E [W ] = E [T ]− E [Ts]

Since departures are exponentially distributed:

E [Ts] =1

µ

In conclusion:

E [W ] = E [T ]− E [Ts] =ρ · (µ+ λ)

λµ(1− ρ2)− 1

µ

Exercise 4

Text

Consider a system in which the departure rate is µ and the arrival rate is λκ, where:

λκ =λ

κ+ 1

Find:

58

Page 59: Network Modeling

Politecnico di Torino Formulary ver. 1.1

1. the transition diagram;

2. the steady state distribution and discuss the ergodicity;

3. the average number of customers in the system;

4. the average time spent by customers in the system.

Solution

Task 1

The transition diagram is:

0 1 2

λ

µ

λ/2

µ

λ/3

µ

Task 2

For a given node i, the transition diagram is:

i i+ 1

λ/i+ 1

µ

therefore:λ

i+ 1· πi = µ · πi+1 =⇒ πi+1 =

1

i+ 1· λµ· πi

Replacing the value of πi:

πi+1 =1

i+ 1· λµ· πi =⇒ πi+1 =

1

i+ 1· λµ·[

1

i· λµ· πi−1

]In general:

πi+1 =1

(i+ 1)!·(λ

µ

)i+1

· π0

Imposing that the sum of πi must be equal to one:πi+1 =1

(i+ 1)!·(λ

µ

)i+1

· π0∑∞i=0 πi = 1

Therefore:∞∑i=0

1

i!·(λ

µ

)i· π0 = 1

59

Page 60: Network Modeling

Politecnico di Torino Formulary ver. 1.1

where:

π0 =1∑∞

i=0

1

i!·(λ

µ

)iLet:

ρ =

µ

)The sum becomes:

∞∑i=0

ρi

i!· π0

It converges always because is the exponential series: the system is ergodic ∀ρ. In conclusion:πi =1

(i)!·(λ

µ

)i· e−λ/µ =

1

(i)!· ρi · e−ρ

π0 = e−rho

Task 3

The average number of customer is given by:

E [N ] =

∞∑i=0

i · πi =

∞∑i=0

i · 1

(i)!· ρi · e−ρ

It can be re-written as:

∞∑i=0

i · 1

(i)!· ρi · e−ρ = e−ρ ·

∞∑i=0

1

(i− 1)!· ρi = e−ρ · ρ ·

∞∑i=1

1

(i− 1)!· ρi−1

Imposing j = i− 1:

e−ρ · ρ ·∞∑i=1

1

(i− 1)!· ρi−1 = e−ρ · ρ ·

∞∑j=0

1

(j)!· ρj = e−ρ · ρ · e ρ = ρ

Task 4

The average time spent by customer in the system is given, applying the Little Theorem, by:

E [T ] =E [N ]

E [λ]

The value of E [λ] is unknown:

E [λ] =

∞∑κ=0

λ

κ+ 1· πκ =

∞∑κ=0

λ

κ+ 1·(

1

(κ)!· ρκ · e−ρ

)It becomes:

λ · e−ρ ·∞∑κ=0

1

(κ+ 1)!· ρκ = λ · e−ρ

ρ·∞∑κ=0

1

(κ+ 1)!· ρκ+1

60

Page 61: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Imposing j = κ+ 1 the sum becomes:

∞∑κ=0

1

(κ+ 1)!· ρκ+1 =

∞∑j=1

1

(j)!· ρj = e ρ − 1

Therefore:

E [λ] = λ · e−ρ

ρ· [e ρ − 1]

Exercise 5

Text

Consider a M/M/1 queue in which service times are exponentially distributed with parameterµ and customers arrive according to a Poisson process with rate λ. The server is lazy: aftereach service, the server takes a rest, during which possibly waiting customers can not be served.Rest times are exponentially distributed with parameter α. At the end of the rest time, theserver becomes available to serve waiting customers. If no customers are waiting after the rest,the server waits for the first customer arrival and starts to serve him immediately upont hisarrival.

Draw the transition diagram.

Solution

To identify an arbitrary state of the chain, two descriptors are needed:

. one describing the number of customers in the line;

. one describing the state of the server:

. A if the server is active and can serve a customer;

. R if the server is taking a rest.

The diagram takes care of a population up to 2 customers:

0-A 1-A 2-A

0-R 1-R 2-R

λ

µ

α

λ

µ

α

λ λ

α

61

Page 62: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Exercise 6

Text

Consider a taxi station with 5 parking positions. Taxis arrive to the station according to aPoisson process with rate µ = 2 taxis per minute. The process describing customer arrivals tothe station is independent and Poisson with rate λ = 1 customer per minute. An arriving taxican carry only one customer. When no customer are waiting the arriving taxi can use one freeposition, if any. If no parking position is available and no customers are waiting, the taxi leavesthe station empty.

1. Model the system with a Markov with a suitable state definition.

2. Find the probability of having n customers.

3. Find the average number of waiting customers.

4. Find the average number of waiting taxis.

Solution

Task 1

By using:

. Nt: label describing the number of taxis available;

. Nc: label describing the number of customers;

is possible describe the system in a reliable way. Each state is composed in such a way:

Nt-Nc

Therefore, the resultant Markov Chain is:

62

Page 63: Network Modeling

Politecnico di Torino Formulary ver. 1.1

0-0

1-0

2-0

3-0

4-0

5-0

0-1 0-2 0-3

λ

µ

λ

µ

λ

µµλ

µλ

µλ

µλ

µλ

Notice that it is not possible have taxis and customers waiting at the same time and the numberof customers can be any value, while the number of taxis is bounded (up to 5). When a customerarrives (rate λ) and finds a free taxi (the branch going down of the chain) is immediately served,while if the does not finds free taxis (the branch going right of the chain) he has to wait. Thiskind of queue is and M/M/1 queue, where states can be identify by a label:

κ = 5−Nt +Nc

This order, labels states starting from the bottom to the top.Having in mind this:

πκ = (1− ρ) · ρκ ρ =λ

µ

Using i to label customers arrives and j for taxis, an equivalent notation is:

π0 , i = (1− ρ) · ρ(i+5)

πj , 0 = (1− ρ) · ρ(j−5)

Task 2

The probability of having exactly n customers in the queue happens only if all taxis are alreadybusy, therefore the state of the queue to be considered is:

63

Page 64: Network Modeling

Politecnico di Torino Formulary ver. 1.1

0-n

This implies:π0 , n = (1− ρ) · ρ(n+5)

Task 3

The average number of waiting customers can be computed as:

E [Nc] =

∞∑κ=6

(κ− 5) · πκ

or, in an equivalent way:

E [Nc] =

∞∑i=0

i · πi

Task 4

The waiting number of taxis, instead, is:

E [Nt] =

5∑κ=0

(5− κ) · πκ

or:

E [Nc] =

5∑j=0

j · πj

Exercise 7

Text

Consider a doctor shop with two waiting rooms: the first one has B − 1 seats (i.e. up to Bpatients can be seated including the one being seen by the doctor), while the second can containany number (up to infinite) of standing customers. Assume that the arrival process is Poissonwith rate λ and that service times are exponentially distributed according to rate µ. Find:

1. the transition diagram and draw it;

2. the average number of seated customers;

3. the average number of standing customers.

64

Page 65: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Solution

Task 1

The transition state diagram for this exercise is very simple:

0 1 2 B − 1· · · B B + 2

λ

µ

λ

µ

λ

µ

λ

µ

As usual:

πκ = (1− ρ) · ρκ ρ =λ

µλ < µ

Task 2

If there are B customers all of them are seated, while if they are more, N , B are seated andN −B are upright.

E [Nseat] =

B∑i=1

i · πi +B ·∞∑

i=B+1

πi

Task 3

The average number of standing customers is:

E [Nupright] =

∞∑i=B+1

(i ·B) · πi

Exercise 8

Text

Consider the following system:

λ

µ

µ

65

Page 66: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Assume that arrivals are distributed to a Poisson process of rate λ and, when they arrive, theyselect the shortest line; if a customer arrives and finds the two queues with the same numberof waiting customers, he has to select his own waiting line randomly. Departures takes alwaysplace with average 1/µ.

When a customer ends his service, other waiting customers can move from a queue to theother one in order to improve their service. Movements occurs in zero time and are simultaneousto departures and just customers at the end of queue can move.

The system has global capacity equal to 6.Find:

1. the transition diagram and draw it;

2. similarities with well-known systems.

Solution

Task 1

The transition state diagram, using as descriptors the number of customers into the differentqueues, is:

0 , 0

1 , 0 0 , 1

1 , 1

2 , 1 1 , 2

2 , 2

3 , 2 2 , 3

3 , 3

λ/2

µ λ/2

µ

λ

µ λ

µ

λ/2

µ λ/2

µ

λ

µ λ

µ

λ/2

µ λ/2

µ

λ

µ λ

µ

Since there are two queues the global departure rate is 2µ (therefore a customer leaves froma single queue with rate µ), but arrival rates in the graph are different; this difference is basedon the current state of the system:

66

Page 67: Network Modeling

Politecnico di Torino Formulary ver. 1.1

. if the number of customers is equal in both queues, a new one enters with rate λ/2because it can choose the queue in which it will wait;

. if the number of customers in queues are different, a new one is forced to enter in thequeue with less occupancy with rate λ.

Task 2

If there are no distinctions among queues the system behaves like a M/M/2/4 queue:

. 2 because the waiting line is composed by two servers;

. 4 because the global capacity is 6 element: since 2 can be in service, just other 4 customerscan be accommodated.

0 1 2 3 4 5 6

λ

λ

λ

λ

λ

λ

This chain has been obtained by aggregating intermediate states of the previous graph.

Exercise 9

Text

Consider a single server queuing system with service rate equal to µ customers per second witha FIFO waiting line of limited capacity: at most 3 customers, included the one in service, canbe accepted. Customers arrive in groups and both inter arrival times and service times areexponentially distributed. The arriving group enters in the system only if all customers can beaccepted otherwise the entire group is lost.

Find the transition diagram and the dropping probability for the following distributions ofcustomers:

. groups of one customers with rate 2λ;

. groups of two customers with group arrival rate λ;

. groups comprising, with the same probability, one, two or three customers; the grouparrival rate is λ.

Solution

First scenario

In the first case customers arrive one after the others as in an M/M/1/2 system; the transitiondiagram is, therefore:

0 1 2 3

µ

µ

µ

67

Page 68: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Since PASTA holds, the dropping probability is that the system reaches state 3:

P (loss) = π3

For this system is also easy to compute the average delay expected, the throughput of incomingand outgoing customers; indeed:

E [D] =ρ

2λ · (1− ρ)=

1/µ

(1− ρ)

because here:

ρ =2λ

µ

The incoming throughput is defined as:

Thin= λ · [1− P (loss)]

therefore, in this case:Thin

= 2λ · (1− π3)

The outgoing throughput is:Thout = µ · (1− π0)

Second scenario

For the second scenario, the transition diagram is:

0 1 2 3

λ

µ

λ

µ µ

The state 2 is a state for which a further arrival can not be accommodated because there is notmore rooms. In this case, therefore, the dropping probability is given by:

P (loss) = π2 + π3

It is possible conclude that batch arrivals lead to more burstiness, increasing the droppingprobability and, consequently, reduce the throughput. In this scenario PASTA still hold.

Third scenario

The third case is the most complicated one; the transition diagram is:

0 1 2 3

λ/3

λ/3

λ/3

µ

λ/3

λ/3

µ

λ/3

µ

68

Page 69: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Rates are all λ/3 because the probability of having different batches is uniform.In this case, the size of batches implies difference in losses: batch with higher size are more

probably rejected than others, therefore the dropping probability is state dependent. In thiscase PASTA does not hold any more. To evaluate the dropping probability:

. first the average arrival rate has to be computed: batches can carry one, two or threecustomers, so in average they carry two customers; batches arrival rate is λ so the averagearrival rate for customer is 2λ;

. the rate in which customers are dropped is:

. in state 1 only the batch that carry three customers is lost at rate λ/3;

. in state 2 is possible lose the batch that carry two and three customers, always atrate λ/3;

. in state 3 all batches are lost at rate λ/3.

In conclusion:

P (loss) =

π1 ·(

3 · λ3

)+ π2 ·

(2 · λ

3+ 3 · λ

3

)+ π3 ·

(1 · λ

3+ 2 · λ

3+ 3 · λ

3

)2λ

69

Page 70: Network Modeling

Chapter 7

Network queues exercises

Exercise 1

Text

Given the following network queue:

λ1/

2

λ3

1/2

λ2

1/3

2/3

1

λ1

Assume that each queue is an M/M/1 with infinite storage capacity; moreover, consider arrivaland departure rates exponentially distributed.

Find:

1. the steady state distribution;

2. the average number of customers in all queues.

Solution

Task 1

First of all, arrival rates have to be computed: the Jackson’s Theorem holds because thefollowing conditions:

. service times are exponentially distributed;

. all queues have infinite storage capacity;

70

Page 71: Network Modeling

Politecnico di Torino Formulary ver. 1.1

. exogenous arrival processes are Poisson;

. routing is memoryless (Bernoullian);

are not violated; thanks to this assumption, the departure rate after a given queue (marked inthe picture in green) is equal to its arrival rate; thanks to this:

λ2 = λ3 =λ12

λ1 = λ+

[2

3· λ2]

+ [1 · λ3]

Therefore:

λ1 = λ+

[2

3· λ1

2

]+

[1 · λ1

2

]=⇒ λ1 = 6λ

In conclusion: λ1 = 6λ

λ2 = 3λ

λ3 = 3λ

Now it is possible define the load for each queue:

ρ1 =λ1µ1

=6λ

µ1

ρ2 =λ2µ2

=3λ

µ2

ρ3 =λ3µ3

=3λ

µ3

To ensure ergodicity, simultaneously, all loads must not violate the constraints:ρ1 < 1

ρ2 < 1

ρ3 < 1

With these hypothesis, the steady state distributions are:

π(1)i = (1− ρ1) · ρi1π(2)j = (1− ρ2) · ρj2π(3)k = (1− ρ3) · ρk3

Thanks to the product form property:

πijk = π(1)i · π

(2)j · π

(3)k

71

Page 72: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Task 2

Since all queues are M/M/1, the average number of customers in an M/M/1 is given by:

E [N ] =ρ

1− ρTherefore:

E [N1] =ρ1

1− ρ1E [N2] =

ρ21− ρ2

E [N3] =ρ3

1− ρ3

Globally, in the system there are:

E [N ] = E [N1] + E [N2] + E [N3]

Exercise 2

Text

Consider the following closed-network queue:

λi j k

Assume that the number of customers is N = 5, find the Markov Chain that describe the model.

Solution

Every time, the number of customers must be equal to 5; some examples are:

0 0 50 1 41 1 3

and so on. So, as a descriptor, it is possible to use the number of customers in the system; withthis assumption, the Markov Chain is:

0 1 2 3 4 5

µ

µ

µ

µ

λ

µ

72

Page 73: Network Modeling

Chapter 8

Simulation of exams

Exercise 1

Text

Consider a system M/. . ./2 where arrivals are Poisson and service times are:

. Erlang 2 (E2r ) for q = 0;

. exponential for q = 1.

Assume q be the probability of exit immediately from the system by a customer and p = 1− qbe the probability of going into the second stage.

Find:

1. the transition diagram;

2. if the system is ergodic;

3. flow balance equations;

4. the average number of customers in the system;

5. the average delay of the system.

Solution

Task 1

The state descriptor is composed by:

Ni - St1 - St2

where:

. Ni represents the number of customers in the system;

. St1 represents the stage of the first server: A or B;

73

Page 74: Network Modeling

Politecnico di Torino Formulary ver. 1.1

. St2 similarly with the previous state, represents the stage of the second server: A or B.

For the generic state (κAA):

(κAA) (κ+ 1AA)(κ− 1AA)

(κAB)

λ

2µq

2µp

For the generic state (κAB):

(κAA) (κ+ 1AB)(κ− 1AB)

(κB B)

(κ− 1AA)

λµq

µp

µ

For the generic state (κB B):

(κAA) (κ+ 1BB)(κ− 1AB)λ

Therefore, in general:

74

Page 75: Network Modeling

Politecnico di Torino Formulary ver. 1.1

2AA 3AA

1A

0 2AB 3AB

1B

2BB 3BB

1

2

3 4

1

1

2

3

6

5

7

1

6

7

4 4

1

1

5

3

where:

. 1 means: λ;

. 2 means: µ;

. 3 means: µq; it is used when a customer immediately leave the system;

. 4 means: µp; it is used when a customer goes into the second stage;

. 5 means: 2µ; it is used when the leaving of a customer occurs by choosing one amongtwo in the same state;

. 6 means: 2µq; it is used when one customer among two can exit immediately;

. 7 means: 2µp; it is used when one customer among two goes into the second stage.

Task 2

The system is a particular case of an M/G/2; the average service time is:

E [s] =1

µ+ p · 1

µ

The first time is the service time always present, while the second is considered just withprobability p. Thanks to this, the maximum capacity of the system is:

2

E [s]

so, ergodicity is ensured when:λE [s] < 2

75

Page 76: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Indeed, for a M/M/2 the condition is:λ

µ< 2

where1

µ= E [s].

Task 3

Flow balance equations are written just for two states:

. for state 0:λπ0 = µqπ1A + µπ1B

. for state (2AA):

(2µq + 2µp+ λ)π2AA = λπ1A + 2µqπ3AA + µπ3AB

Globally, the outgoing flow is:(2µ+ λ)π2AA

because:

2µq + 2µp =⇒ 2µq + 2µ(1− q) =⇒ 2µ · (q + 1− q)

Task 4

The average number of customers in the system is:

E [N ] = 1 · (π1A + π1B) + 2 · (π2AA + π2AB + π2BB) +

+ 3 · (π3AA + π3AB + π3BB) =

= 1 · (π1A + π1B) +

∞∑κ=2

κ · (πκAA + πκAB + πκBB)

Task 5

The expected delay can be computed as:

E [D] =E [N ]

λ

by simply applying Little. Take care that the arrival rate is λ = E [λ].�

Exercise 2

Text

Consider the following network queue:

‡Outgoing flows equal to incoming flows.

76

Page 77: Network Modeling

Politecnico di Torino Formulary ver. 1.1

λ 1/3

Q1 Q2 Q3

2/31/3

1/3 2/3

2/3

Find:

1. if there is a steady state product form (Jackson’s Theorem);

2. if the system is ergodic;

3. the steady state distribution;

4. delays of the system:

. traversing time;

. total time spent into a queue.

Solution

Task 1

To verify if the Jackson’s theorem is ensured, the following constraint have to be verified:

. service times are exponentially distributed in every queue;

. all queues must have an infinite storage capacity;

. exogenous arrival processes must be Poisson;

. routing must be memoryless.

Since all these properties are verified, the system has a steady state product form.

Task 2

To find if the system is ergodic, first the following parameters, associated to queues, have to bedefined:

λ1 such thatλ1µ1

< 1

λ2 such thatλ2µ2

< 1

λ3 such thatλ3µ3

< 1

77

Page 78: Network Modeling

Politecnico di Torino Formulary ver. 1.1

All the constraints must be verified simultaneously. The resultant system is:λ3 =

1

3· λ1

λ2 =2

3· λ3

λ1 = λ+2

3· λ1 +

1

3· λ3 +

2

3λ2

Therefore: λ3 =

1

3· λ1

λ2 =2

9· λ1

λ1 =27

2· λ

Task 3

By exploiting the product form, first are defined:

ρ1 =λ1µ1

ρ2 =λ2µ2

ρ3 =λ3µ3

such that:πijk = [(1− ρ1) · ρi1] · [(1− ρ2) · ρj2] · [(1− ρ3) · ρk3 ]

Task 4

By applying Little, it is possible to compute both requests. For what concern the traversingtime of a given queue κ, if λκ is assumed to be the arrival rate:

E [Travκ] =E [Nκ]

λκ

where E [Nκ] is the average number of customers of the queue κ.For what concern the total time spent in a given queue κ, it can be computed starting from

the average time spent in the system:

E [Time in the system] =E [N ]

λ=

E [N1]

λ· E [N3]

λ· E [N3]

λ

Since each term is the time spent in a given queue:

E [Time in the queue κ] =E [Nκ]

λ

For Q1 there are two kinds of delays:

. one, the traversing time, that considers the measurement time as:

λ

λ1

78

Page 79: Network Modeling

Politecnico di Torino Formulary ver. 1.1

by applying Little, this is:

E [TravQ1] =

E [N1]

λ1

it must be shortest than the other!

. the second one, instead, looks at the total time spent in the queue:

λ

2/3

λx λ1

since the internal flow is not considered, the new arrival rate is:

λx = λ1 −2

3· λ1 =

1

3· λ1

and, therefore, the average time spent in Q1 is:

E [Tot timeQ1 ] =E [N1]

λx= 3 · E [N1]

λ1

Exercise 3

Text

Consider an M/M/1 in which arrival and departure rates are exponentially distributed withparameters λ and µ respectively and the server, after having served a packet, takes a rest.Vacation time is also exponentially distributed with parameter α.

Find:

1. the transition diagram;

2. the ergodicity condition.

Solution

Task 1

The state descriptor must contain the number of customers actually present into the systemand the state of the server:

. A if it is active;

. V if it is in vacation.

With this consideration, the markov chain is:

79

Page 80: Network Modeling

Politecnico di Torino Formulary ver. 1.1

0A 1A 2A 3A

0V 1V 2V 3V

λ λ λ

λ λ λ

α α α αµ µ µ

If the parameter α = µ, the system is exactly an M/E2r/1.

Task 2

The time devoted for each customer is:

1 service time + 1 vacation time =1

µ+

1

α

Therefore the maximum capacity C of the system is that value and, to ensure ergodicity:

C · λ < 1 =⇒ λ ·(

1

µ+

1

α

)< 1

Performances of this system are reduced with respect to a traditional M/M/1: indeed, the timein which the server is working is reduced. The efficiency is:

E =

1

µ1

µ+

1

α

<1

µ

Exercise 4

Text

Consider a M/M/2 in which one server is lazy: if the queue is empty, one server becomesinactive until κ customers are again the system. Arrival and departure rates are exponentiallydistributed with with parameters λ and µ respectively.

Find:

1. the transition diagram;

2. the ergodicity condition.

Solution

Task 1

In this case, the state descriptor must contain the number of customers in the system and theactual state of the server lazy; again, is it possible to consider:

80

Page 81: Network Modeling

Politecnico di Torino Formulary ver. 1.1

. A if it is active;

. V if it is in vacation.

With this consideration, the markov chain is:

1V 2V . . . κ− 1V

0 1A 2A . . . κ− 1A κ

λ λ λ

λλ

λ λ λ λ

µ µ µ

µ 2µ 2µ 2µ 2µ

Task 2

To discuss the ergodicity of the system, it has to be considered on the long term: it has thesame performances of an M/M/2 without rest because for n > κ:

πn+1 =λ

2µ· πn

Indeed, the series for the M/M/2 is convergent, so also the series for this case converge: this isdue to the property that adding an arbitrary number of terms at the beginning of a series doesnot affect the convergence. Therefore, the system is ergodic if:

λ

2µ< 1

Exercise 5

Text

Assume that the following random variable has to be simulated:

X = Y + Z

where:

. Y is an hyper-exponential: Y = H2y ;

. Z is Rayleigh:

fz(t) =t

σ2· e−t2

2σ2

Write the pseudo-code to obtain X.

81

Page 82: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Solution

Since X is sum of two independent random variables, it is possible to generate them indepen-dently.

For what concern Y , the hyper-exponential distribution is:

H2y = p1 · µ1 · e−µ1 t + p2 · µ2 · e−µ2 t

where p2 = 1− p1. Therefore, the pseudo-code to generate it is:

generate u=uniform(0,1)

if (u<p1)

negexp( µ1)

else

negexp( µ2)

For what concern Z, it is possible to compute the cumulant and then invert it:

Fz(t) = 1− e−x2

2σ2 =⇒ u = 1− e−x2

2σ2

Now:

1− u = e−x2

2σ2 =⇒ log {1− u} =x2

2σ2=⇒ x =

√2σ2 · log {1− u}

Therefore, the pseudo-code to generate it is:

generate u=uniform(0,1)

apply the formula Z =√

2σ2 · log {1− u}�

Exercise 6

Text

Consider an M/M/1 system with group services: the server provides services for 1, 2 and 3customer simultaneously with arrival time λ and service time µ, independent on the group size.The number of served customer is always the largest as possible, given the number of customersin the waiting line (if in the waiting line there is just one customer, it is served immediatelywithout waiting other arrivals).

Find:

1. the general transition diagram and define when it holds;

2. when the system is ergodic.

82

Page 83: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Solution

Task 1

The state descriptor has to take care of the number of customers currently in the system andon the number of currently in service (this can be 1, 2 or 3). The general transition diagramconsider a node n and looks for possible states reachable from a basic state (n , 1): it meansthat there are n customer in waiting line and 1 in service.

n , 1

n , 2

n− 3 , 3 n− 2 , 3 n− 1 , 3 n , 1

λ

λ

λ

µ

µ

µ

This holds just for N = 5 because at the beginning there are transient effects.

Task 2

The capacity of the system, on the long term, is:

C = 3µ

Therefore, the system is ergodic when:

arrival rate

capacity< number of servers =⇒ λ

3µ< 1

Exercise 7

Text

Consider an E2r/M/1/2 queuing system with group arrivals (each group has at most 3 cus-

tomers). If not all customers of a group can be accepted, only those one that not exceed thecapacity of the system are accepted. The average group interarrival time is λ−1, while theaverage service time is µ−1.

Find:

83

Page 84: Network Modeling

Politecnico di Torino Formulary ver. 1.1

1. the transition diagram for the Markov Chain that model the system;

2. when the system is ergodic;

3. the steady state distribution;

4. the average delay;

5. the average waiting time.

Solution

Task 1

The state descriptor has to take care of the number of customers and the stage of the system(A/B):

N , A/B

The transition diagram is:

0 , A 1 , A 2 , A 3 , A

0 , B 0 , B 2 , B 3 , B

µ µ µ

µ µ µ

2λ 2λ 2λ2λ

2λ 2λ2λ

Arrival rate are 2λ because the average is1

λbut there are two stages A/B. The state 3 B

has an arrow towards 3 A because, if customer arrives are all refused, but the system changesstate.

Task 2

Since the system is finite (up to 3 customer can be present: 1 in service and 2 in waiting line)the system is ergodic.

Task 3

The steady state distribution is not reported, but only balancing equations for some states arewritten:

state 0 , B : 2λ · π0 , B = µ · π1 , B + 2λ · π0 , Astate 2 , A : (2λ+ µ) · π2 , A = µ · π3 , A

84

Page 85: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Task 4

The average delay can be computed by applying Little:

E [D] =E [N ]

E [λ]

where:

. E [N ] is the average number of customers in the system;

. E [λ] is the average arrival rate.

For what concern the first quantity:

E [N ] = 0 · (π0 , A + π0 , B) + 1 · (π1 , A + π1 , B) + 2 · (π2 , A + π2 , B) + 3 · (π3 , A + π3 , B) =

=

3∑i=0

i · (πi , A + πi , B)

For the average arrival rate:

E [λ] = 0·(π0 , A+π1 , A+π2 , A+π3 , A)+3‡ ·2λ·(π0 , B)+2‡ ·2λ·(π1 , B)+1‡ ·2λ·(π2 , B)+0‡ ·(π3 , B)

Task 5

The average waiting time E [W ] can be computed starting from the average delay:

E [D] = E [W ] + E [S]

where E [S] is the average service time and:

E [S] =1

µ

Another approach is to compute first the average number of waiting customers, then applyLittle:

E [W ] =E [Nwaiting]

E [λ]

where:

E [Nwaiting] =

3∑i=1

(i− 1) · (πi , A + πi , B)

because i customers are present and 1 is in service: i − 1 represent the number of waitingcustomers.

‡3 because all customers can be accepted.‡1 customer is dropped.‡2 customers are dropped.‡all customers are dropped.

85

Page 86: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Exercise 8

Text

Consider an M/E2r/2/1 queuing system with group arrivals in which groups arrivals follow a

Poisson process with rate λ and the average service time is equal to µ−1. Each arrival bringsinto the queue 2 customers and if one of the two can not be accepted, it is discarded; the samebehaviour happens in case both of them can not be served.

Find:

1. the transition diagram for the Markov Chain that model the system;

2. the average delay.

Assume to consider the particular case M/E2r/2/∞: when the system is ergodic?

Solution

Task 1

The state descriptor has to take care of the number of customers and all possible stages of thesystem (AA/AB/BB):

N , AA/AB/BB

With respect to the previous exercise, now there are two servers, so there are 3 combinationsof possible stages.

The transition diagram is:

2AA 3AA

1A

0 2AB 3AB

1B

2BB 3BB

λ

λ

λ

λλ

λ

4µ 4µ

2µ 2µ

When there are two customers that potentially can exit from the system, the departure rateis 4µ because each Erlang 2 with rate µ has two stages. From any state x , BB it is possiblereach states x − 1 , AB because one customer exit (and a new one come starting in stage A),but the other one is still in the system in stage B.

86

Page 87: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Task 2

As the previous exercise, by applying Little:

E [D] =E [N ]

E [λ]

Therefore:

E [N ] = 1 · (π1 , A + π1 , B) + 2 · (π2 , AA + π2 , AB + π2 , BB) + 3 · (π3 , AA + π3 , AB + π3 , BB)

E [λ] = 2 · λ(π0 + π1 , A + π1 , B) + λ · (π2 , AA + π2 , AB + π2 , BB) + 0

Task 3

In general, for a system with 2 server, an M/M/2 in which customers arrives one at time, theergodicity condition is:

λ · E [S] < 2 =⇒ λ

µ< 2

considering λ and µ as arrival and departure rate respectively. For batch arrivals (groups of 2customers at time):

2λ · E [S] < 2 =⇒ 2λ

µ< 2 =⇒ λ

µ< 1

Exercise 9

Text

Assume that instances of a random variable X have to be generated starting from:

n

fx(n)

0

β

α 1

Solution

There are two possible approaches.

87

Page 88: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Approach 1

α · β2

+ β · (1− α) = 1

β ·[α

2+ 1− α

]= 1 =⇒ β =

1

1− α

2

Approach 2

In this case the function have to be split into:

n

fx(n)

0

β

α n

fx(n)

0 α 1− α

The graph on the left it is not a distribution; to be a distribution, it has to be normalized asfollows:

n

fx(n)

0

β′

α

where such β′

is:

β′

=2

α

Now the distribution is:

fz(n) =

2

α2· n 0 ≤ n ≤ α

0 otherwise

The first value is due to: cα = 2/α =⇒ c = 2/α2. In this way, by looking at values of n:{X = first graph if 0 ≤ n < α

X = second graph if α ≤ n ≤ 1− α

88

Page 89: Network Modeling

Politecnico di Torino Formulary ver. 1.1

The second part is easy to be generated:

X|α≤n≤1−α = Uniform{α,1,&seed}

For what concern the first, by applying the inversion on the cumulant:

Fz(n)‡ =2

α2· n2 for 0 ≤ n ≤ α

so:

t =2

α2· n2 =⇒ n =

√α2 · t

Since t can be generate as an uniform from 0 to 1:

X|0≤n<α =√α2 · Uniform{0,1,&seed}}

Exercise 10

Text

Assume that a wireless network has to be simulate under the following hypothesis:

. use a spatial approach;

. consider nodes distributed as a Poisson process with rate λ;

. nodes are placed in an independent and uniform manner.

Solution

By using a spatial approach, it is possible to introduce axis x and y to describe a genericcoordinate of a node:

x

y

distribution: Poisson(λ ·Area)

To generate a Poisson process to place nodes:n=Poisson)λ);

‡This is the integral of fz(n)

89

Page 90: Network Modeling

Politecnico di Torino Formulary ver. 1.1

for(k=1; k<= n; k++){

x[k]=Uniform(0,1,&seed);

y[k]=Uniform(0,1,&seed);

}

first it is generated the number of nodes to put into the topology, then they are placed in agiven coordinate.

Each node is placed exactly in the center of a disk with a given radius:

R

and disks can not overlap. To generate it, there are two methods:

1. generate module and phase to exploit polar coordinates:

module=Uniform(0,1,&seed);

phase=Uniform(0,2π,&seed);

2. generate a square outside the disk to have the radius R = 1/2:

then generate the point on the rectangle surface.

Exercise 11

Text

Given a set of random variables: X1 = . . .

X2 = . . ....

Xn = . . .

compute the confidence interval.

90

Page 91: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Solution

As notation, the estimated value are denoted as . . . while non estimated value does not havethe line over them.

To compute the confidence interval, first the estimate mean and variance have to be com-puted:

avg =

n∑i1

xin

= α

var =1

n− 1·n∑i1

(xi − avg)2 = β

where xi are samples. To find the variance as estimator of the mean value, the estimatedstandard deviation has to be computed:

stdev =

√var

n=

√β

n

After that, it is possible to conclude that:

avg ∼= N‡(avg , stdev

)The probability that an error is behind a threshold γ is:

P (|avg − avg|) < γ

Since:

avg − avg ∼= N(0 , stdev

) ∼= N

(0 ,

√β

n

)the expression:

|avg − avg| < γ

is simply:−γ ≤ |avg − avg| ≤ γ

To find this interval: ∫ γ

−γN

(0 ,

√β

n

)= F (γ)

The confidence interval associated to level α (typical values for it are 0.9, 0.95, 0.99) is:

Conf = [avg − γ , avg + γ]

because γ is the solution of the equation:

F (γ) = α

‡Normal distribution

91

Page 92: Network Modeling

Part III

Appendix

92

Page 93: Network Modeling

Appendix A

Formulas

Queue Type of Formula Formula

M/M/1 Ergodicity Conditionλ

µ< 1

Avg Service Time E [S] =1

µ

Second Moment of Service Time E[S2]

=2

µ2

Avg Number of Customers E [N ] =ρ

1− ρVariance V ar(N) =

ρ

(1− ρ)2

Avg Delay E [W ] =1/µ

1− ρThroughput X = λ

Traffic Intensity U =λ

µ

M/M/1/N Avg Number of Customers E [N ] =ρ[1− (N + 2)ρN+1 + (N + 1)ρN+2]

1− ρ2 · 1− ρ1− ρN+2

Average Delay E [D] =

ρ[1− (N + 2)ρN+1 + (N + 1)ρN+2]

(1− ρ)(1− ρN+2)

λ

(1− ρN+1(1− ρ)

1− ρN+2

)Throughput in input tin = λ(1− πN+1)

Throughput in output [N=0] tout =λ

1 + ρ

Loss Probabilityρ− 1

ρ≈ 1− 1

ρ

M/M/c Ergodicity Conditionλ

cµ< 1

Avg Number of Customers E [N ] =∑∞i=0 iπi

Avg Delay E [N ] =

∑∞i=0 iπiλ

93

Page 94: Network Modeling

Politecnico di Torino Formulary ver. 1.1

M/M/c/0 Avg Number of Customers E [N ] =ρ

1− ρ

M/M/∞ Avg Number of Customers E [N ] =λ

µ

Avg Delay E [W ] =1

µ

M/M/1/N-1/N Avg Number of Customers E [N ] =∑Ni=0 iπi

Avg Arrival Time E[λ] =∑Ni=0(N − i)λπi

Avg Delay E [D] =

∑Ni=0 iπi∑N

i=0(N − i)λπi

M/Er/1 Y is an Erlang process Y = X1 +X2 + · · ·+Xr

Mean of Y E [Y ] =1

µ

Second Moment of Y E[Y 2] =1

µ+

1

Coefficient of Variation cv =

√V ar(x)

E [X]

Variance V ar(Y ) =1

kµ2

M/G/1 Pollack Klimchine E [q] =E[θ2] + E [θ]− 2E [θ]

2

2(1− E [θ])Second Moment of Service Time E

[S2]

= E [S]2

+ V ar(S) = 11E [S]2

Avg Delay E [D] =λE [S]

2

2(1− ρ)+ E [S]

Avg Waiting Time E [W ] =λE [S]

2

2(1− ρ)

M/D/1 Avg Service Time E [S] =1

µSecond Moment of Service Time E

[S2]

= S2

Avg Delay E [D] = E [S]ρ

2(1− ρ)

Jackson Networks Stability Condition [i=1,2,..,M] ρi <λiciµi

Mean Number of Customers E [N ] =∑Mi=1

ρi1− ρi

Avg Waiting Time E [W ] =E [N ]∑Mi=1 γi

[γ is the arrival time]

Avg Time spent in node i E [Wi] =1

µi(1− ρi)Throughput Xi =

∑∞k=1 Pi(k)µi(k)

94

Page 95: Network Modeling

Politecnico di Torino Formulary ver. 1.1

For what concern the M/M/k/0/N, the blocking probability is:

Pblock =(N − k)λπk∑ki=0(N − i)λπi

where:(N − k)πk∑ki=0(N − i)πi

<πk∑k

i=0 πi = πk

computed for:N − i ≥ N − k

95

Page 96: Network Modeling

Appendix B

Integrals

In the following formulas are always omitted the sum of the constant c.

Fundamentals

∫xα =

xα+1

α+ 1∫1

x= ln |x|∫

ax =ax

ln a∫aκx =

aκx

κ log aa > 0 , a 6= 1∫

e x = e x∫eκx =

eκx

κ∫x · eκx =

eκx

κ2· (κx− 1)∫

sinx = − cosx∫cosx = sinx

96

Page 97: Network Modeling

Politecnico di Torino Formulary ver. 1.1

Integrals that can be bring back to fundamentals

∫fn(x) · f ′(x) =

fn+1(x)

n+ 1∫f′(x)

f(x)= log |f(x)|∫

e f(x) · f ′(x) = e f(x)∫af(x) · f ′(x) =

af(x)

ln a

Techniques

By substitution

Imposing:g(t) = x =⇒ dx = g′(t)

It is possible obtain: ∫f(x) dx =

∫f [g(t)] · g′(t)dt

By parts ∫f(x) · g′(x)dx = f(x) · g(x)−

∫f ′(x) · g(x)dx

97

Page 98: Network Modeling

Appendix C

Series

∞∑i=0

xi =1

1− x∞∑i=0

i · xκ =1

1− xκ∞∑i=0

i · xi =x

(1− x)2

∞∑i=0

i2 · xi =x · (1 + x)

(1− x)3

∞∑i=0

i3 · xi =x · (1 + 4x+ x2)

(1− x)4

∞∑i=0

i4 · xi =x · (1 + x) · (1 + 10x+ x2)

(1− x)5

∞∑i=1

xi

i= loge

(1

1− x

)∞∑i=0

xi

i!= e x

∞∑i=0

i · xi

i!= x · e x

∞∑i=0

i2 · xi

i!= (x+ x2) · e x

∞∑i=0

i3 · xi

i!= (x+ 3x+ x2) · e x

∞∑i=0

i4 · xi

i!= (x+ 7x2 + 6x3 + x4) · e x

98