midterm exam review - national university of …midterm exam review richard t. b. ma school of...

39
Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Upload: others

Post on 29-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Midterm Exam Review

Richard T. B. Ma

School of Computing

National University of Singapore

CS 5229 (2012): Advanced Compute Networks

Page 2: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Mark Distribution Comparison

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0-9 10--19 20-29 30-39 40-49 50-59 60-69 70-79

Last Year (mean=32)

This Year (mean=40)

Page 3: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Last Year’s Grade Distribution

0

0.05

0.1

0.15

0.2

0.25

A+ A A- B+ B B- C+ C D

Last Year's

Grade

Distribution

Page 4: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 1A

SoC admits 40 students in the PhD program every year. On average, SoC has 160 students at any time. Suppose 20% of them will eventually stay only 2 years and graduate with a master’s degree. The remaining 80% will graduate with a PhD degree. For this 80%, what is the average number of years they expect to spend in SoC?

𝜆 = 40, 𝐿 = 160; Little’s Law ⇒ E 𝑊 =𝐿

𝜆= 4 (𝑦𝑟𝑠)

E 𝑊 = 20% ∗ 2 + 80% ∗ 𝑥 = 4 ⇒ 𝑥 = 4.5 (𝑦𝑟𝑠)

E 𝑊 = E 𝑊|𝑊 = 2 P 𝑊 = 2 + E 𝑊|𝑊 ≠ 2 P 𝑊 ≠ 2

Page 5: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 1B

Suppose the inter-arrival times of the A1 buses are i.i.d. random variable 𝑇 (minutes) with P 𝑇 = 5 = 0.25 and P 𝑇 = 10 = 0.75. If you arrive at a random time, what is the probability that you need to wait for longer than 7 minutes?

Page 6: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Illustration: Deterministic Case

Often, we use 𝑇𝑒 ≝ 𝑅 to denote the equilibrium inter-arrival time

P(𝑇𝑒 > 𝑎) = P(𝑅 > 𝑎) = 𝜆E 𝑇 − 𝑎 +

Suppose 𝑇𝑖 = 𝐴 for all 𝑖 some constant 𝐴

P 𝑇𝑒 > 𝑎 = 𝜆E 𝑇 − 𝑎 + =𝐴 − 𝑎 +

𝐴

𝐴 − 𝑎 𝑎 𝒕𝒊 𝒕𝒊+𝟏

Page 7: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 1B

Suppose the inter-arrival times of the A1 buses are i.i.d. random variable 𝑇 (minutes) with P 𝑇 = 5 = 0.25 and P 𝑇 = 10 = 0.75. If you arrive at a random time, what is the probability that you need to wait for longer than 7 minutes?

P 𝑇𝑒 > 𝑎 = 𝜆E 𝑇 − 𝑎 +

or P 𝑇𝑒 > 7 = 𝜆E 𝑇 − 7 +

Page 8: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

RCL : Applications

𝑅′ 𝑡 = −1; 𝑅 𝑡𝑖− − 𝑅 𝑡𝑖

+ = −𝑇𝑖

By RCL, (if {𝑇𝑖: 𝑖 = 1, ⋯ } are i.i.d. r.v.s as 𝑇)

𝑋′ = −1 = 𝜆𝐽 = 𝜆 lim𝑛→∞

1

𝑛 −𝑇𝑖

𝑛

𝑖=1= −𝜆E 𝑇

Average inter-arrival time is 𝐄 𝑻 =𝟏

𝝀

𝒙 𝒕 = 𝑹(𝒕)

𝑻𝟏 𝑻𝟐 𝑻𝟑 𝑻𝟒 𝑻𝟓 Time 𝑡

Page 9: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 1B

Suppose the inter-arrival times of the A1 buses are i.i.d. random variable 𝑇 (minutes) with P 𝑇 = 5 = 0.25 and P 𝑇 = 10 = 0.75. If you arrive at a random time, what is the probability that you need to wait for longer than 7 minutes?

P 𝑇𝑒 > 7 = 𝜆E 𝑇 − 7 + =E 𝑇 − 7 +

E 𝑇= 9/35

E 𝑇 = 5P 𝑇 = 5 + 10P 𝑇 = 10 = 35/4

E 𝑇 − 7 + = 5 − 7 +P 𝑇 = 5 + 10 − 7 +P 𝑇 = 10 = 3P 𝑇 = 10 = 9/4

Page 10: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 2A

For a single server queueing system, the arrival rate is 𝜆 = 5 customers per minute. Mean sojourn time of the customers is E[𝑊] = 15 seconds.

A. If the system is a FIFO M/M/1 queueing system, on average, how often is the server idle?

𝜋0 = 1 − 𝜌; for M/M/1, E 𝑊 =1

𝜆

𝜌

1−𝜌 or E 𝐿 =

𝜌

1−𝜌

Use the same time unit:

E 𝑊 =1

𝜆

𝜌

1 − 𝜌=

1

5

𝜌

1 − 𝜌=

1

4𝑚𝑖𝑛𝑠 ⇒

𝜌

1 − 𝜌=

5

4

4𝜌 = 5 − 5𝜌 ⇒ 𝜌 = 5/9 ⇒ 𝜋0 = 1 − 𝜌 = 4/9

Page 11: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 2B

For a single server queueing system, the arrival rate is 𝜆 = 5 customers per minute. Mean sojourn time of the customers is E[𝑊] = 15 seconds.

B. If the system is a LIFO M/M/1 queueing system, on average, how often is the server idle?

Workload curve does not change under work-conserving disciplines.

Page 12: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

𝑾𝟏

𝑾𝟐

𝑳(𝒕) Arrival curve 𝑵(𝒕)

Time 𝑡 𝒕𝟏 𝒕𝟐 𝒕𝟏𝒅 𝒕𝟐

𝒅

Departure curve 𝑵𝒅(𝒕)

Workload Curve

𝑽(𝒕)

𝑺𝟏

𝑺𝟑

𝑺𝟐

Page 13: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 2B

For a single server queueing system, the arrival rate is 𝜆 = 5 customers per minute. Mean sojourn time of the customers is E[𝑊] = 15 seconds.

B. If the system is a LIFO M/M/1 queueing system, on average, how often is the server idle?

Workload curve does not change under work-conserving disciplines.

𝜋0 = 1 − 𝜌 = 1 − P 𝑉 > 0 = P 𝑉 = 0 , which should be the same as under FIFO M/M/1.

Page 14: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 2C

For a single server queueing system, the arrival rate is 𝜆 = 5 customers per minute. Mean sojourn time of the customers is E[𝑊] = 15 seconds.

C. If the system is a LIFO G/G/1 system and the average queue size of the system is 𝐸[𝑄] = 1. On average, how often is the server idle?

By Little’s Law, E 𝐿 = 𝜆E 𝑊 = 5 ∗1

4

Denote 𝐴 = 𝐿 − 𝑄 as the # of customers in service

Page 15: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

M/M/1 Model: E 𝑄

Average # of customers waiting in the queue

E 𝑄 = 𝑖 − 1 𝜋𝑖

𝑖=1

= 𝑖 − 1 𝜋𝑖

𝑖=0

+ 𝜋0

= 𝑖𝜋𝑖

𝑖=0

− 1 + 𝜋0 =𝜌

1 − 𝜌− 1 + 1 − 𝜌 =

𝜌2

1 − 𝜌

What is the value of E[𝐿 − 𝑄] ?

Average amount of time spent in “system”: E[𝑊], E[𝐷] ? How about E 𝑊 − E[𝐷] ?

Page 16: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 2C

For a single server queueing system, the arrival rate is 𝜆 = 5 customers per minute. Mean sojourn time of the customers is E[𝑊] = 15 seconds.

C. If the system is a LIFO G/G/1 system and the average queue size of the system is 𝐸[𝑄] = 1. On average, how often is the server idle?

By Little’s Law, E 𝐿 = 𝜆E 𝑊 = 5/4

Denote 𝐴 = 𝐿 − 𝑄 as the # of customers in service 𝜌 = E 𝐴 = E 𝐿 − 𝑄 = E 𝐿 − E 𝑄 = 5/4 − 1 = 1/4

E 𝐴 = E 𝐴|𝑉 > 0 P 𝑉 > 0 + E 𝐴|𝑉 = 0 P 𝑉 = 0 = 1P 𝑉 > 0 + 0P 𝑉 = 0 = 𝜌 ⇒ 𝜋0 = 1 − 𝜌 = 3/4

Page 17: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 3A

Consider a LIFO single server queueing system. Denote 𝑡𝑖 and 𝑡𝑖

𝑑 as the arrival and departure time of the 𝑖th customer to a system. Let 𝑉(𝑡) denote the workload of the system at time 𝑡.

A. Assume 𝑡1 = 1, 𝑡1𝑑 = 4, 𝑡2 = 2, 𝑡2

𝑑 = 7, 𝑡3 = 3, and 𝑡3𝑑 = 6. Draw the function of 𝑉(𝑡) for 𝑡 ∈ [0,10].

Page 18: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

𝑾𝟏

𝑾𝟐

𝑳(𝒕) Arrival curve 𝑵(𝒕)

Time 𝑡 𝒕𝟏 𝒕𝟐 𝒕𝟏𝒅 𝒕𝟐

𝒅

Departure curve 𝑵𝒅(𝒕)

Workload Curve

𝑽(𝒕)

𝑺𝟏

𝑺𝟑

𝑺𝟐

Page 19: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 3A

Consider a LIFO single server queueing system. Denote 𝑡𝑖 and 𝑡𝑖

𝑑 as the arrival and departure time of the 𝑖th customer to a system. Let 𝑉(𝑡) denote the workload of the system at time 𝑡.

A. Assume 𝑡1 = 1, 𝑡1𝑑 = 4, 𝑡2 = 2, 𝑡2

𝑑 = 7, 𝑡3 = 3, and 𝑡3𝑑 = 6. Draw the function of 𝑉(𝑡) for 𝑡 ∈ [0,10].

Workload depends only on arrival & service times

𝑆1 = 𝑡1𝑑 − 𝑡1 = 3 ( C1 enters service at 𝑡1 = 1)

Upon the 1st customer’s departure at 𝑡1𝑑 = 4, the

3rd customer has arrived. 𝑆3 = 𝑡3𝑑 − 𝑡1

𝑑 = 6 − 4 = 2

𝑆2 = 𝑡2𝑑 − 𝑡3

𝑑 = 7 − 6 = 1

Page 20: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 3A

Consider a LIFO single server queueing system. Denote 𝑡𝑖 and 𝑡𝑖

𝑑 as the arrival and departure time of the 𝑖th customer to a system. Let 𝑉(𝑡) denote the workload of the system at time 𝑡.

𝑡1 = 1, 𝑡2 = 2, 𝑡3 = 3

𝑆1 = 3, 𝑆2 = 1, 𝑆3 = 2

𝑽(𝒕)

𝑺𝟏

𝑺𝟑 𝑺𝟐

𝟏 𝟐 𝟑 𝟕

𝟑

𝟒

𝟏

𝟐

Page 21: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 3B

Consider a LIFO single server queueing system. Denote 𝑡𝑖 and 𝑡𝑖

𝑑 as the arrival and departure time of the 𝑖th customer to a system. Let 𝑉(𝑡) denote the workload of the system at time 𝑡.

B. Apply Rate Conservation Law to the function 𝑥(𝑡) = 𝑉(𝑡) and show your result.

RCL: 𝑋′ ≝ lim𝑡→∞

1

𝑡 𝑥′ 𝑠 𝑑𝑠

𝑡

0= 𝜆𝐽 ≝ 𝜆 lim

𝑛→∞

1

𝑛 𝐽𝑘

𝑛𝑘=1

Left hand side:

𝑥′ 𝑠 = −1 𝑖𝑓 𝑉 𝑡 > 0

0 𝑖𝑓 𝑉 𝑡 = 0⇒ 𝑋′ ≝ lim

𝑡→∞

1

𝑡 𝑥′ 𝑠 𝑑𝑠

𝑡

0

= −𝜌

Page 22: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

𝑾𝟏

𝑾𝟐

𝑳(𝒕) Arrival curve 𝑵(𝒕)

Time 𝑡 𝒕𝟏 𝒕𝟐 𝒕𝟏𝒅 𝒕𝟐

𝒅

Departure curve 𝑵𝒅(𝒕)

Workload Curve

𝑽(𝒕)

𝑺𝟏

𝑺𝟑

𝑺𝟐

Page 23: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

RCL : Applications

𝑅′ 𝑡 = −1; 𝑅 𝑡𝑖− − 𝑅 𝑡𝑖

+ = −𝑇𝑖

By RCL, (if {𝑇𝑖: 𝑖 = 1, ⋯ } are i.i.d. r.v.s as 𝑇)

𝑋′ = −1 = 𝜆𝐽 = 𝜆 lim𝑛→∞

1

𝑛 −𝑇𝑖

𝑛

𝑖=1= −𝜆E 𝑇

Average inter-arrival time is 𝐸 𝑇 =1

𝜆

𝒙 𝒕 = 𝑹(𝒕)

𝑻𝟏 𝑻𝟐 𝑻𝟑 𝑻𝟒 𝑻𝟓 Time 𝑡

Page 24: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 3B

Consider a LIFO single server queueing system. Denote 𝑡𝑖 and 𝑡𝑖

𝑑 as the arrival and departure time of the 𝑖th customer to a system. Let 𝑉(𝑡) denote the workload of the system at time 𝑡.

B. Apply Rate Conservation Law to the function 𝑥(𝑡) = 𝑉(𝑡) and show your result.

RCL: 𝑋′ ≝ lim𝑡→∞

1

𝑡 𝑥′ 𝑠 𝑑𝑠

𝑡

0= 𝜆𝐽 ≝ 𝜆 lim

𝑛→∞

1

𝑛 𝐽𝑘

𝑛𝑘=1

Right hand side: for each jump 𝐽𝑘

−𝐽𝑘 = 𝑥 𝑡𝑘+ − 𝑥 𝑡𝑘

− = 𝑉 𝑡𝑘+ − 𝑉 𝑡𝑘

− = 𝑆𝑘

⇒ 𝜆𝐽 = −𝜆E 𝑆

Page 25: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

𝑾𝟏

𝑾𝟐

𝑳(𝒕) Arrival curve 𝑵(𝒕)

Time 𝑡 𝒕𝟏 𝒕𝟐 𝒕𝟏𝒅 𝒕𝟐

𝒅

Departure curve 𝑵𝒅(𝒕)

Workload Curve

𝑽(𝒕)

𝑺𝟏

𝑺𝟑

𝑺𝟐

Page 26: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 3B

Consider a LIFO single server queueing system. Denote 𝑡𝑖 and 𝑡𝑖

𝑑 as the arrival and departure time of the 𝑖th customer to a system. Let 𝑉(𝑡) denote the workload of the system at time 𝑡.

B. Apply Rate Conservation Law to the function 𝑥(𝑡) = 𝑉(𝑡) and show your result.

RCL: 𝑋′ ≝ lim𝑡→∞

1

𝑡 𝑥′ 𝑠 𝑑𝑠

𝑡

0= 𝜆𝐽 ≝ 𝜆 lim

𝑛→∞

1

𝑛 𝐽𝑘

𝑛𝑘=1

𝑋′ = −𝜌 = 𝜆𝐽 = −𝜆E 𝑆 ⇒ 𝜌 = 𝜆E 𝑆

Page 27: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

How About Workload E 𝑉 ?

Brumelle’s formula: E 𝑉 = 𝜆E 𝑆𝐷 +𝜆

2E 𝑆2

More generally, (under FIFO G/G/1),

E 𝑉 = 𝜆E 𝑆 E 𝐷 + 𝜆E 𝑆E 𝑆2

2E[𝑆]

= 𝝀𝐄 𝑺 E 𝐷 +E 𝑆2

2E[𝑆]≝ 𝝆 E 𝐷 + E 𝑅𝑠

E 𝑉 = E 𝑉|𝑉 = 0 𝑃 𝑉 = 0 + E 𝑉|𝑉 > 0 𝑃 𝑉 > 0

Page 28: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

M/M/1 Discouraged Arrival

Poisson dist. of # of customers E[𝐿] =𝛼

𝜇

Utilization: 𝝆 = 1 − 𝜋0 = 1 − 𝑒−

𝛼

𝜇 = 𝝀𝐄 𝑺 =𝜆

𝜇

Effective arrival rate: 𝜆 = 𝜇 1 − 𝑒−𝛼/𝜇

Mean sojourn time: E 𝑊 =E 𝐿

𝜆=

𝛼

𝜇2 1−𝑒−𝛼/𝜇

0 1 2 n-1 n n+1

a a/2 a/𝒏 a/(𝒏 +1)

m m m m

a/3 a/(𝒏 -1)

m m

Page 29: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 4A

Let 𝑋 and 𝑌 be two independent exponential random variables with E[𝑋] = 𝑚𝑥 and E[𝑌] = 𝑚𝑦. What is the probability P 𝑋 > 𝑌 ?

𝜆𝑥 = 1/𝑚𝑥; 𝜆𝑦 = 1/𝑚𝑦

P 𝑋 > 𝑌 = P 𝑋 > 𝑌|𝑌 = 𝑦 𝑓𝑌 𝑦∞

0

𝑑𝑦

= P 𝑋 > 𝑦 𝜆𝑦𝑒−𝜆𝑦𝑦∞

0

𝑑𝑦 = 𝑒−𝜆𝑥𝑦 𝜆𝑦𝑒−𝜆𝑦𝑦∞

0

𝑑𝑦

= 𝜆𝑦 𝑒− 𝜆𝑥+𝜆𝑦 𝑦∞

0

𝑑𝑦 = 𝜆𝑦 −1

𝜆𝑥 + 𝜆𝑦𝑒− 𝜆𝑥+𝜆𝑦 𝑦

0

=𝜆𝑦

𝜆𝑥 + 𝜆𝑦=

1/𝑚𝑦

1/𝑚𝑥 + 1/𝑚𝑦=

𝑚𝑥

𝑚𝑥 + 𝑚𝑦

Page 30: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 4B

Consider an M/M/1 system with arrival rate 𝜆 and service rate 𝜇. If I obverse the system at a random time, what is the probability that the next event is an arrival? Express it using 𝜆 and 𝜇.

Let 𝑋 be the amount of waiting time till the next arrival happens

Let Y be the amount of waiting time till the next departure happens

The question becomes

𝑃 𝑋 < 𝑌 =?

Page 31: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Birth-Death Process

State-transition matrix:

𝑸 =

−𝜆 𝜆 0 ⋯𝜇 −(𝜆 + 𝜇) 𝜆 ⋯0 𝜇 −(𝜆 + 𝜇) ⋯⋮ ⋮ ⋮ ⋱

𝑞𝑖𝑗: rate from state 𝑖 to state 𝑗

𝑞𝑖𝑖 = − 𝑞𝑖𝑗𝑗≠𝑖 : rate of going out of state 𝑖

0 1 2 n-1 n n+1

l l l l

m m m m

l l

m m

Page 32: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 4B

Consider an M/M/1 system with arrival rate 𝜆 and service rate 𝜇. If I obverse the system at a random time, what is the probability that the next event is an arrival? Express it in terms of 𝜆 and 𝜇.

If I observe an empty system, with probability 1, the next event is an arrival, i.e., P 𝑋 < 𝑌|𝐿 = 0 = 1

If I observe a busy system, by memeoryless, 𝑋 and 𝑌 are exponential with rate 𝜆 and 𝜇

Arrival before departure probability

P 𝑋 < 𝑌|𝐿 > 0 =𝜆𝑥

𝜆𝑥 + 𝜆𝑦=

𝜆

𝜆 + 𝜇

Page 33: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 4B

Consider an M/M/1 system with arrival rate 𝜆 and service rate 𝜇. If I obverse the system at a random time, what is the probability that the next event is an arrival? Express it in terms of 𝜆 and 𝜇.

P 𝑋 < 𝑌= P 𝑋 < 𝑌|𝐿 = 0 P 𝐿 = 0+ P 𝑋 < 𝑌|𝐿 > 0 P 𝐿 > 0

= P 𝑋 < 𝑌|𝐿 = 0 1 − 𝜌 + P 𝑋 < 𝑌|𝐿 > 0 𝜌

⇒ P 𝑋 < 𝑌 = 1 1 − 𝜌 +𝜆

𝜆 + 𝜇𝜌 =

𝜇

𝜆 + 𝜇

Page 34: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 5A

A discrete-time system with a FIFO queue and a single work-conserving server. 1) At each time slot, with probability 𝑝, one customer

arrives; with probability 1 − 𝑝, no customer arrives.

2) The system can hold at most two customers. Upon arrival, if a new customer finds that there are two existing customers in the system, it leaves the system immediately; otherwise, it will enter the system at the beginning of the next time slot.

3) At each time slot, if the server is busy, with probability 𝑞, the customer in service will finish and leave the system just before the beginning of the next time slot; with probability 1 − 𝑞, this customer will stay in the server and continue its service.

Page 35: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

A. Draw the state transition diagram and write down the state transition matrix P.

When 1 customer in system, four events: a) 0 arrival, 0 departure; b) 1 arrival, 1 departure

c) 1 arrival, 0 departure; d) 0 arrival, 1 departure

Problem 5A

1 2 0

𝒑

𝟏 − 𝒑

𝒒

𝟏 − 𝒒

Page 36: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 5A

𝑷 =

1 − 𝑝 𝑝 0

𝑞 1 − 𝑝 𝑝𝑞 + 1 − 𝑝 1 − 𝑞 𝑝 1 − 𝑞0 𝑞 1 − 𝑞

1 2

𝒒

𝒑 𝟏 − 𝒒

0

𝒒 𝟏 − 𝒑

𝒑

𝟏 − 𝒑

𝒑𝒒 + 𝟏 − 𝒑 𝟏 − 𝒒

𝟏 − 𝒒

Page 37: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 5B

Calculate the expected # of customers E[𝐿]. Express E[𝐿] as a function of 𝑝 and 𝑞.

E 𝐿 = 0𝜋0 + 1𝜋1 + 2𝜋2 = 𝜋1 + 2𝜋2

𝑷 =

1 − 𝑝 𝑝 0

𝑞 1 − 𝑝 𝑝𝑞 + 1 − 𝑝 1 − 𝑞 𝑝 1 − 𝑞0 𝑞 1 − 𝑞

𝜋0, 𝜋1, 𝜋2 = 𝜋0, 𝜋1, 𝜋2 𝑷;

𝜋0 + 𝜋1 + 𝜋2 = 1

Page 38: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 5B

𝑷 =

1 − 𝑝 𝑝 0

𝑞 1 − 𝑝 𝑝𝑞 + 1 − 𝑝 1 − 𝑞 𝑝 1 − 𝑞0 𝑞 1 − 𝑞

𝜋0, 𝜋1, 𝜋2 = 𝜋0, 𝜋1, 𝜋2 𝑷; 𝜋0 + 𝜋1 + 𝜋2 = 1

𝜋0 1 − 𝑝 + 𝜋1𝑞 1 − 𝑝 = 𝜋0 ⇒ 𝜋0 = 𝜋1𝑞 1 − 𝑝 /𝑝

𝜋1𝑝 1 − 𝑞 + 𝜋2 1 − 𝑞 = 𝜋2 ⇒ 𝜋2 = 𝜋1𝑝 1 − 𝑞 /𝑞

⇒𝑞 1 − 𝑝

𝑝+ 1 +

𝑝 1 − 𝑞

𝑞𝜋1 = 1

Page 39: Midterm Exam Review - National University of …Midterm Exam Review Richard T. B. Ma School of Computing National University of Singapore CS 5229 (2012): Advanced Compute Networks

Problem 5B

Calculate the expected # of customers E[𝐿]. Express E[𝐿] as a function of 𝑝 and 𝑞.

E 𝐿 = 0𝜋0 + 1𝜋1 + 2𝜋2 = 𝜋1 + 2𝜋2

𝜋2 =𝑝 1 − 𝑞

𝑞𝜋1 =

𝑝 1 − 𝑞𝑞

𝑞 1 − 𝑝𝑝

+ 1 +𝑝 1 − 𝑞

𝑞

E 𝐿 =1 + 2

𝑝 1 − 𝑞𝑞

𝑞 1 − 𝑝𝑝 + 1 +

𝑝 1 − 𝑞𝑞