MN2018 Lecture02
MN2018 Lecture02
1 KTLO/EIE/HKPolyU/2018 EIE4104 MN
Queueing Theory
▪ What is queuing theory?
▪ Queuing theory is the study of queues (sometimes called waiting lines)
▪ A queueing model is constructed so that queue lengths and waiting time
can be predicted
▪ Queueing theory is generally considered a branch of operations
research because the results are often used when making business
decisions about the resources needed to provide a service.
▪ Queueing theory has its origins in research by Agner Krarup Erlang when
he created models to describe the Copenhagen telephone exchange
▪ Applications include telecommunication, traffic
engineering, computing and, particularly in industrial engineering, in the
design of factories, shops, offices and hospitals, as well as in project
management
2 EIE4104 MN
Queueing Theory
▪ Queueing theory was originally developed to study behaviour of
telephone switching systems, but has been widely used to solve
network problems.
Example: In a LAN, contention problem arises because many terminals may
try to access the channel at the same time what is the probability?
▪ More generally, in a packet-switched networks, packets follow some
prescribed paths and share transmission facilities as they traverse the
network.
▪ Network protocols must be designed to minimize the mean time
delay experienced by a packet.
3 EIE4104 MN
Queueing Theory
4 EIE4104 MN
Queueing Theory
6 EIE4104 MN
General Discussion
The set of possible values (or states) that X(t) may take on is called the state
space.
- Can be continuous or discrete.
- In the discrete case, it is called a chain.
If the permitted times at which changes in position may take place are finite
or countable, we have a discrete-(time) parameter; else continuous-
parameter process. In the former we write X(t) and the later X, or X(n).
8 EIE4104 MN
Introduction to Random Process
9 EIE4104 MN
Important Definitions
▪ Customer/packet arrival rate (): this is the mean number of packets arriving
per second.
▪ Service rate ():This is the mean number of packets served per second.
▪ Traffic intensity or link utilization ():This is the ratio
load on system
= =
system capacity
▪ Example: A link handling 1000-bit packets and transmitting at a rate C = 2400 bps
would be capable of transmitting at a rate = 2.4 packets/sec.
10 EIE4104 MN
Remarks
▪ As approaches , the queue will start to build up. For a finite buffer,
the queue will eventually be saturated as exceeds and continue to
increase.
▪ If buffer is infinite, the queue becomes unstable as tends to .
▪ , must be less than to ensure stability in the case of single-server
queue.
▪ For a single-server case. as approaches and exceeds unity, the region of
congestion is encountered, and time delays being to increase rapidly, and
packets arriving are blocked more often.
▪ To quantify discussions of time-delay, blocking performance, packet
throughput (i.e. actual number of packets that get through the system per
unit time) and their relation to and size of buffer, we need a more detailed
model of the queueing system.
11 EIE4104 MN
Remarks
12 KTLO/EIE/HKPolyU/2018 EIE4104 MN
Kendal Variables
13 EIE4104 MN
Kendal Variables
Notation Characteristics Symbol Explanation
A Inter-arrival time M Exponential
distribution Ek Erlang type k
H Hyperexponential
h Hypoexponential
G General
D Deterministic
B Serivce time as A as A above
distribution
c Service channel, 1,2,..., Number of servers
server
k System capacity 1,2,..., Waiting position +
servers
s Source population 1,2,...,
Z Queue discipline FIFO First in First out
LIFO Last in First out
SIRO Service in random order
GD General discipline
RR Round robin
14 EIE4104 MN
Arrival Pattern
▪ In a queueing system, tasks (or customers) arrive to obtain service,
examples of tasks are telephone calls or packets of data.
▪ The jobs usually arrive in random.
▪ The following is an example where the job arrivals are recorded
against time:
▪
Task Task Task Task
Source
× × × ×
15
t t+t EIE4104 MN
Poisson Process
▪ The Poisson process is one of the most widely-used counting processes.
▪ It is usually used in scenarios where we are counting the occurrences of certain events
that appear to happen at a certain rate, but completely at random (without a certain
structure).
16 EIE4104 MN
Poisson Process
▪ Events occur continuously and independently of one another
▪ The rate of a Poisson process is the average number of events per unit
time (over a long time)
17 EIE4104 MN
Properties of a Poisson Process
▪ Properties of a Poisson process
▪ For a time interval [0, t] , the probability of n arrivals in t
units of time is
(t ) n −t
Pn(t ) = e
n!
The rate of a Poisson process is the average number of events per
unit time (over a long time)
▪ For two disjoint (non overlapping ) intervals (t1, t2) and (t3,
t4), (i.e. , t1 < t2 < t3 < t4), the number of arrivals in (t1, t2) is
independent of arrivals in (t3, t4)
18
,
Example 1
The number of customers arriving at a convenient store can be modeled by a Poisson process with
rate λ=10 customers per hour.
1. Find the probability that there are 2 customers between 10:00 and 10:20.
2. Find the probability that there are 3 customers between 10:00 and 10:20 and 7 customers
between 10:20 and 11:00.
[Solution]
1. Here, λ=10 and the interval between 10:00 and 10:20 has length1/3 hours. Apply the Poisson
distribution function, we have
2
10 × 1ൗ3 −10
𝑃2 1ൗ3 = 𝑒 ൗ3 ≈ 0.2
2!
2. Here, we have two non-overlapping intervals I1=(10:00 a.m., 10:20 a.m.] and I2= (10:20 a.m., 11
a.m.]. Thus, we can write
t
t t+t
▪ The probability of one arrival in the interval t is defined to be t + o(t) [
o(t) implies that other terms are higher order in t and that they go to zero
more rapidly than t as t → 0], t <<1, and is just a constant of
proportionality, but it will be shown below that is in fact the mean arrival rate of
a Poisson arrival.
▪ The probability of zero arrivals in t is 1 - t + o(t)
▪ Arrivals are memoryless: An arrival (event) in one time interval of length t is
independent of events in previous or future intervals.
20
Derivation of Poisson Distribution
▪ Let Pn(t) = P[X(t) = n] = P(number of arrivals = n at time t)
▪ and let pi,j(t) be the probability of going from i arrivals to j arrivals in a time interval
of t. The number of arrivals is the “state” of the system.
Pn(t+t) = Pn(t) Pn,n(t) + Pn-1(t) Pn-1,n(t) (1)
0 1 2 3 4
21 EIE4104 MN
Derivation of Poisson Distribution
By substituting the three statements into eqn.(1)
Pn(t+t) = Pn(t) (1-t) + Pn-1(t) (t) (3)
P0(t+t) = P0(t) (1-t) (4)
Pn (t + t ) − Pn (t )
= −Pn (t ) + Pn−1 (t ) (5)
t
P0 (t + t ) − P0 (t )
= −P0 (t ) (6)
t
Let t→0 and we have a set of differential equations:
dPn (t )
= −Pn (t ) + Pn −1 (t ) (7)
dt
dP0 (t )
= −P0 (t ) (8)
dt
22 EIE4104 MN
Derivation of Poisson Distribution
▪ Solving the second equation, we have
P0 (t ) = e−t (9)
▪ Now dP1 (t )
= −P1 (t ) + e −t (10)
dt
But
(t ) n
n =0 n!
= et
So
n =0
Pn (t ) = 1
as expected
24 EIE4104 MN
Mean Number of Arrival in Time t
E (n) = nPn = nPn
n =0 n =1
(t ) n
(t ) n
=e − t
n =1
n
n!
=e
− t
n =1 ( n − 1)!
(t ) n −1
(t ) k
= e t
− t
= e t
− t
n =1 (n − 1)! k =0 (k )!
▪ Let k = n+1, as
(t ) k
k =0 k!
= et
▪ we have
E(n) = t (14)
▪ In other words, = mean arrival rate, i.e. mean number of arrivals per second. Hence
mean inter-arrival time is 1/ seconds.
25 EIE4104 MN
Probability Density Function of
Inter-Arrival Time
The times between successive events in an arrival process are called the inter-arrival
times. For Poisson process these times are independent exponentially distributed
random variables.
Consider the timing diagram
Time
▪ The probability that > x is just the probability that no arrivals occur in (0,x), i.e.,
P(>x) = prob.(number if arrivals in (0,x) = 0)
= e-x
▪ Then the probability that x is
27 KTLO/EIE/HKPolyU/2018 EIE4104 MN
Probability Density Function of
Inter-Arrival Time
From which the probability density function f(x) is obtained by differentiating F(x)
with respect to x, we have
f(x) = e-x
This exponential inter-arrival distribution means that small inter-arrival times are more
likely than large ones.
28 EIE4104 MN
Mean Inter-Arrival Time
E ( ) = f ( )d = e − d
0 0
1
E ( ) =
as found before
29 EIE4104 MN
Property of Poisson Process
30 EIE4104 MN
M/M/1 Queue
This is a queue
- of single server
- with Poisson arrivals
- and exponential service-time statistic
- and FIFO queueing discipline
Note that, the assumption of exponential service time is an adequate
approximation if “increasing lone service times are increasingly less
likely”.
31 KTLO/EIE/HKPolyU/2018 EIE4104 MN
M/M/1 Queue
n server Exponential
Poisson Arrival Service
Queue (infinite buffer)
The statistical properties of M/M/1 queue (i.e. average queue occupancy, probability of
blocking for a finite queue, average throughput, etc.) are readily determined once we find
the probabilities of state pn (probability of finding n customers in system including the one
in service).
By implication, the system is at steady-state so these probabilities do not vary with time.
32 EIE4104 MN
M/M/1 Queue
▪ Even when the system is in equilibrium, transitions between states take place, i.e. a
new arrival will change the state from n to n+1.
▪ Similarily, when a customer departs after being served, the system moves down one
state.
▪ Queueing in which only transitions are to adjacent states are known as birth-death
systems. This is illustrated below:
p0 p1 p2 p k −1 pk
0 1 2 • • • k-1 k k+1 • • •
p1 p2 p k −1 pk p k +1
State Transition Diagram of M/M/1 Queue
▪ Here pk is the rate of entering state (k+1) from state k, and pk+1 is the rate of
33 leaving state (k+1) for state k.
M/M/1 - Relationship between pk
and Channel Utilization
▪ At equilibrium, we must have:
p0 = p1
p1 = p2
• •
• •
• •
pk = pk+1
Hence
( p0) ( p1) • • • ( pk) = ( p1) ( p2) • • • ( pk+1)
or
k+1p0 = k+1 pk+1 (15)
So, in general we have
k
pk = p0 = p0 k (16)
34 EIE4104 MN
M/M/1 - Relationship between pk
and Channel Utilization
Since
k =0
pk = 1 = p0 k = p0 (1 + + 2 + ...)
k =0
(17)
Eqn.(17) holds if <1, because p0 must not be zero (because by (16), all pk=0, which
cannot happen).Therefore for <1, we have
p0
1 = p0 k = p0 = 1 − (18)
k =0 1−
Hence
pk = (1 − ) k (19)
(18) shows that = 1 – p0 = probability that system is not empty
35 EIE4104 MN
M/M/1 - Mean Number of
Customers in System (N)
N =
k =0
kpk = k (1 − ) = (1 − ) k k −1
k =0
k
k =0
1
= (1 − ) k = (1 − )
k =0 1 −
1
= (1 − ) =
(1 − ) 2 1− (20)
Using =
, we have
N= =
1− −
36 EIE4104 MN
M/M/1 - Total Wait Time
▪ This is the mean interval between customer arrival and customer departure, including
time in the queue and time being served.
▪ Consider customer A arriving to join in the queue at t = t0. By definition of T, by time
= t0 + T, he will depart from the system. Since customers arrive per second, at time
t0 + T the system has received T customers after A. All of them are still in the system
and are the only customers in the system (i.e. equal to N).
▪ Hence
N 1
T=N or T= =
μ- (21)
37 EIE4104 MN
M/M/1 – Average Queue Size
𝑁𝑄
𝑇𝑄 = = (23)
𝜇 𝜇−
38 EIE4104 MN
Finite Queue M/M/1 (M/M/1/N)
N server Exponential
Poisson Arrival Service
Queue (Finite buffer N)
39 EIE4104 MN
Finite Queue M/M/1 (M/M/1/N)
▪ Here the queue buffer is finite can can accommodate at most N customers. When the
buffer is full, customers will be turned away (blocked).
▪ The balance equations obtained before are still valid, but now we have
N N
k =0
pk = 1 = p0 k = p0 (1 + + 2 + ... + N )
k =0
Hence
1− (24)
p0 = (22)
1 − N +1
and
(1 − ) n
pn =
1 − N +1
for 1 (25)
40
M/M/1/N - Probability of Blocking (PB)
(1 − ) N
pB = (26)
(22)
1 − N +1
41 EIE4104 MN
Finite Queue M/M/1 - Throughput
= load Thoughput
pB = - pB
Relationship between throughput and load
▪ From the diagram, the throughput is
= ( 1 - pB ) (27)
▪ But throughput is also the average rate of service if the system is NOT empty.
Hence
probability that system is not empty
= ( 1 – p0 ) (28)
Therefore,
= ( 1 - pB ) = ( 1 – p0 ) (29)
42 EIE4104 MN
M/M/1/N - Remarks
2. Problems:What is the required buffer size (N) to provide a blocking probability of 10-3?
Solutions:This depends on “traffic intensity” (or channel utilization, .)
For small pB and with <1, N>>1, we have
pB (1 - ) N (as with infinite buffer)
Therefore if = 0.5, then N 9
Thus for packet-switched network, the concentrator needs to be capable of handling 9
packets.
43 EIE4104 MN
M/M/1/N - Remarks
Note:
If pB = 10-6 is required (i.e. one in 106 packets is rejected on average)
and = 0.5 as before, then N 19 (i.e. a larger buffer is required).
Larger value of (increased traffic) also requires correspondingly
larger buffer.
44 EIE4104 MN
M/M/1/N - Remarks
With finite queue, equilibrium probabilities still exit for > 1. Thus eqn.(26) is valid for
all values of .
As = increases, the queue fills up more often, and probability of blocking increases.
pB
0 1 Traffic intensity
45
M/M/ Queue
▪ With this system, the number of servers is always equal to the number
of customers, i.e. the number of trunk lines is always equal to number
of packets.
▪ The service rate increases with the number of packets. In other words,
n = n (30)
where = service rate when there is ONE customer.
46 EIE4104 MN
M/M/ Queue
0 1 2 • • • n-1 n •••
▪ Therefore
N= = (32)
48 EIE4104 MN
M/M/ Queue
N 1
T= = (33)
49 EIE4104 MN
M/M/ Queue - Throughput ()
From eqn.(32),
= (34)
50 EIE4104 MN
M/M/N/N Queue
▪ This is the same as M/M/ for n < N but all further arrivals are blocked when n = N.
This model was the basic design model for telephone exchanges. Using similar
argument as that for M/M/ case, we have
n
pn = n!
N
l
(35)
l =0 l!
=
where
Therefore, the blocking probability is
N This is ERLANG LOSS
pB = p N = N!
FORMULA (or Erlang B
N
l
(36) distribution)
l =0 l!
51 EIE4104 MN
M/M/N/N Queue
1 E ( n)
T= = (38)
= (1 − pB ) (39)
52 EIE4104 MN
M/G/1 Queue
▪ Main Characteristics:
- Single server
- Customers arrive according to Poisson process with rate
- Customer service times have a general distribution (but
necessarily exponential as in M/M/1 – special case in M/G/1)
with average service time = 1/
▪ Properties:
1
Let X = E{ X } = = average service time
2 X 2 (40)
N =+
2(1 − )
2 X 2 (41)
NQ =
2(1 − )
54 EIE4104 MN
M/G/1 Queue - Average Wait Time
X 2
W= (43)
2(1 − )
55 EIE4104 MN
M/G/1 Queue
▪ Eqns.(40) and (42) show that all infinite buffer queues tend to exhibit
the same queue congestion behaviour as →1.
▪ Note that 1
W =T −
Time spent in the Queue Average service time
NQ = W
56 EIE4104 MN
M/G/1 Queue - Special Cases
1 (M/D/1)
T= 1 −
(1 − ) 2
57 EIE4104 MN
Networks of M/M/1 Queues
Results derived from M/M/1 and other queues can be applied to queue
delay for packets in a network.
Here,
packets customers
server transmission facility
In addition, if c = channel capacity in bps and 1/v = mean packet size in
bits per packet, then the service rate, , in packets/set is
c
= = vc
1/ v
Hence from eqn.(21), the average time delay is
1 1
T= =
− vc −
58 EIE4104 MN
Networks of M/M/1 Queues
▪ Note that, in network, the communication channels are not isolated. The
output of one channel becomes input to another. Thus, the input to a
certain line may be the sum of outputs of several other lines.
59 KTLO/EIE/HKPolyU/2018 EIE4104 MN
Example 2
▪ Consider a router with four input ports and one 1000 Mbps output port. Given that the mean
packet size (1/v) is 10 Mbits and each input port delivers Poisson traffic of i = 20 packets/sec,
what is the mean delay experienced by a packet? (i.e. from the time the last bit arrives at the
router until the time it is retransmitted on output line) Also, what is the mean number of packets
in the router (including the one in service)?
[Solution]
Solution:
i = 2, hence = 4 x 20 = 80 packets/sec
v = 1/10M, c = 1000M, hence = vc = 100 packets/sec
Therefore, mean delayT
1
𝑇= = 0.05s
𝜇−
60 EIE4104 MN
Example 2
This example demonstrates the need to have buffer (size = 4 packets) in the router
61 KTLO/EIE/HKPolyU/2018 EIE4104 MN
Example 3
▪ Two ground stations are connected by a 64 Mbps wireless link. There are 8 parallel sessions using
the line. Each session generates Poisson traffic with a mean of 2000 packets/sec. The packet
lengths are exponentially distributed with a mean of 2000 bits. The system designer must choose
between giving each session a dedicated 8 Mbps piece of bandwidth (via TDM/FDM) or having
all packets compete for a single 64 Mbps shared channel. Which alternative gives a better
response time?
[Solution]
Here: 1/v = 2000; ci = 8 Mbps
Therefore, service rate (i) of 8 Mbps line = 4000 packets/ses.
Since i = 2000 packets/sec, the mean delay for each 8 Mbps line (which is also mean delay of
system because these 8 lines work in parallel) is
1 1
𝑇= = = 0.5ms
𝜇𝑖 − 𝑖 4000 − 2000
62 EIE4104 MN
Example 3
But, if a single 64 kbps line is used (shared by all) then =8i = 16000 packets/sec and c =
64000 packets/sec, therefore, =64M/2000=32000.
HenceT=1/(32000-16000) = 0.0625 ms
i.e. The performance of one 64 Mbps line is 8 times better than EIGHT 8 Mbps lines.
63 EIE4104 MN
Summary
▪ Introduction to queueing theory
▪ Queueing systems
▪ Poisson process
▪ M/M/1 queue
▪ M/M/1/N queue
▪ M/M/ queue
▪ M/M/N/N queue
▪ M/G/1 queue
64 EIE4104 MN
Reading
65 KTLO/EIE/HKPolyU/2018 EIE4104 MN