discrete event simulation speaker: yeh, en-hau advisor: phone lin mcn lab., dept. of csie, ntu...

55
Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: [email protected] TEL: +886-2-33664888#538

Upload: shanna-boyd

Post on 23-Dec-2015

229 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

Discrete Event Simulation

Speaker: Yeh, En-HauAdvisor: Phone Lin

MCN Lab., Dept. of CSIE, NTUEmail: [email protected]

TEL: +886-2-33664888#538

Page 2: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

2

Grading

Midterm Exam 40%

Final Exam 30%

Final Project 30%• Step 1: Find a paper with the analytical model• Step 2: Read the paper in detail• Step 3: Write the simulation to validate the analytical model• Step 4: Compare the errors of your simulation results with the results

in the paper• [optional] Step 5: Do some more if you can (e.g., performance analysis

via simulation or analytical models).• Step 6: Prepare your presentation• Report

Page 3: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

3

Grading

Find a paper with the analytical model• Where to find a paper?

- IEEE Xplore: http://ieeexplore.ieee.org/Xplore/guesthome.jsp- ACM Digital Library:

http://portal.acm.org/• Which Journal/Magazine?• Journals

- IEEE Transactions on Vehicular Technology - IEEE Journal on Selected Areas in Communications - IEEE Transactions on Mobile Computing- IEEE Networks - IEEE Transactions on Computer - IEEE Communications Letter - IEEE Transactions on Wireless Communication - IEICE Transactions on Communication - Security and Communication Networks - ACM/Springer Wireless Networks - Journal of Wireless Communications and Mobile Computing - ACM/Springer Mobile Networks and Applications

• Magazines- IEEE Personal Communications Magazine - IEEE Communications Magazine - IEEE Wireless Communications Magazine

Page 4: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

4

Outline

Introduction to Simulation• What is Simulation?• Why Simulate? • System & Simulation

Simulation Implementation

A Simulation Example• M/M/c/c• Handoff Model

Page 5: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

5

What is Simulation?

Simulation is the imitation of some real thing, state of affairs, or process.

Simulation is defined as the process of creating a model of an existing or proposed system to gain some understanding of how the corresponding system behaves.

Page 6: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

6

What is Simulation?

System

Experiment and real system

Experiment with an “ emulation” system (real traffic input/output)

Experiment with simulations and models

Test it in a testing environment (with generated traffic)

Put the system in the real environment and use it

(with real traffic)

Physical models

Mathematical models (execution in no real-time, non

real traffic input/output)

Analysis (Queueing Therory)

Simulation

Page 7: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

7

Why Simulate? (Example)

landingstack

Page 8: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

8

Why Simulate? (Example Cont.)

An Example of Simulation in the Real World• The Airport Problem

- The airport has two runways, one for landing and one for takeoff. If the landing way is busy, the airplane in the air must enter in a stack. However, when the stack is full, the takeoff way must become landing way.

Airports have a waiting stack, where airplanes wait before they can land. In this stack, airplanes fly a holding pattern on an assigned altitude.

• What we want to know?- Calculate the stack length.- The average time a plane waits for takeoff.- The average utilization of the landing way and the takeoff way.

Page 9: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

9

Why Simulate? (Example Cont.)

Such measures of performance can get from historical data records.However, we are interested in the impact of certain proposed changes.• Landing airplane arrival rate.• Takeoff airplane arrival rate.• Increasing the runways.

Page 10: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

10

Why Simulate?

Save time

Reduce cost

Test design ideas (performance measurement)• The impact of certain changes of parameter.

- The arrival rate of certain traffic class.- The service time of certain traffic class.- The number of application server.

Predict the future behavior of the system

Page 11: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

11

Simulation

Static/Dynamic Simulation• Static

- Time simply plays no role• Dynamic

- A system evolves over time

Continuous/Discrete Simulation• Continuous

- The state change continuously with respect to time• Discrete

- The state change instantaneously at separated points in time

Page 12: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

12

Discrete-Event Simulation

Dynamic• Simulation clock

- Keep track of the current value of simulated time as the simulation proceeds

• A mechanism to advance simulated time from one value to another

Discrete• The state change instantaneously at separate points in time

- The system can change at only a countable number of points in time.

• These points in time are the ones at which an event occurs.• Event

- An instantaneous occurrence that may change the state of the system

Page 13: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

13

0 1a 2a 1d 3a 2d Time

0e1e 2e 3e 4e 5e

A1 A2 A3

S1 S2

All state changes occur only at event times for a discrete-event simulation model• Periods of inactivity are skipped over by jumping the clock from event

time to event time

Stochastic• Interarrival times A1, A2,… and service times S1, S2,…

- Are random variables- Have cumulative distribution functions

Discrete-Event Simulation

Page 14: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

14

The Phase of Simulation

Construction• Formularize the problem• Collecting necessary input data as parameter (arrival

rate, departure rate)• Design a simulation model to match the problem

Running• Run this simulation for enough time to estimate the

system’s result.Debugging• See if the result make sense.• Compare to an analytic model

Page 15: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

SIMULATION IMPLEMENTATION

Page 16: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

16

Simulation Implementation

Programming Language• C• C++• Java• C#• …

Event• An instantaneous occurrence that

may change the state of the system

Attributes of an event• Type (e.g., arrival, departure, etc.)• Timestamp• Other attributes

- Location info.

Event List• Event list is a linked list• Events are sorted according to the timestamp value.• Automatically adjusts the event order at each event insertion.

Efficiency• Data structure: link-list v.s. min-Heap data structure

• Time Complexity• Memory allocation management

• Freelist

Priority Queue in C++ Standard Template Librarypriority_queue<T, Sequence, Compare>

Page 17: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

17

Random Number Generator

R.N.G.’s for various probability distributions• Used when we need a time period with a certain

distribution• Uniform, exponential, gamma, etc.

Implementation• The inverse transform method

- CDF: F(x) = Pr[ X ≤ x]

Page 18: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

Inverse Transform Method

18

F(x)

0

1P

roba

bili

ty

X

F-1(yj)

xi

yj

yi

xj

Un

ifor

m(0

,1)

Page 19: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

19

Inverse Transform Method

Validity of this method:• Whether r.v. F-1(U) has the CDF F(x)?

F’(x) = Pr[F-1(U) ≤ x]

= Pr[U ≤ F(x)]

= FU( F(x) )

= F(x)

Page 20: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

20

Inverse Transform Method

Example: exponential distribution with rate• CDF: F(x) = 1 - e -λX

• Set F(X) = U

=> 1 - e-λX = U

=> e-λX = 1-U

=> -λX = ln(1-U)

=> X = -ln(1-U)/ λ

Note: u!=0

Page 21: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

21

Inverse Transform Method

Applicable when the inverse function of F(x), i.e., F-1(x), can be derived

Preferably when F-1(x) has an east-to-use form

Steps:• Generate a uniform (0,1) random number u• Compute x = F-1(u), and x is the desired random

number

Page 22: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

22

Generating Gamma-distributed

Page 23: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

23

Generating Gamma-distributed

Page 24: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

A SIMULATION EXAMPLEM/M/C/C

Page 25: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

25

Queueing System

Key elements: customers and servers• Customer: arrival process• Server: service rate and number of servers

Notation: A/B/c/N/K• A: inter-arrival time distribution (arrival process)• B: service time distribution• c : number of servers/channels• N: system capacity• K: queue discipline (Unless specified, it is assumed to be

First-In-First-Out)

Page 26: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

26

Queueing System

M/M/c/c• The 1st M: Markovian / Memoryless

- Possision arrivals / exponential inter-arrival time• The 2nd M: Markovian

- Exponential service time• c: c servers/channels• c: system capacity

Blocking

Page 27: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

27

Analysis: M/M/c/c (Erlang B)

0 1 2 c-1 c…λ λ λ λ λ

μ 2μ (c-1)μ cμ3μ

Page 28: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

28

Simulation Models: M/M/c/c

arrival1 arrival2

departure1

1. generate next call: arrival2

2. if channel > 0 then channel-- and generate service time: departure1

• ARRIVAL event represents a customer arrival.

Page 29: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

29

Simulation Models: M/M/c/c

arrival1 arrival2

departure1

arrival3

departure2

1. generate next call: arrival3

2. if channel > 0 then channel-- and generate service time: departure2

Page 30: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

30

Simulation Models: M/M/c/c

arrival1 arrival2

departure1

arrival3

departure2

1. channel++

• DEPARTURE event represents a customer departure .

Page 31: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

31

Simulation Models: M/M/c/c

arrival1 arrival2

departure1

arrival3

departure2

1. generate next call: arrival6

2. if channel = 0 then N_blocking++

arrival4 arrival5 arrival6

departure4

Assume that c=2Arrival5 is BlockingPb = N_blocking / N_arrival

Page 32: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

32

Simulation Models: Event Class

Page 33: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

33

Simulation Models: Initialize

實驗次數 100萬次

Page 34: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

34

Simulation Models: Timing Routine

if channel > 0 then channelgenerate service time

generate next call

if channel = 0 then N_blocking++

channel++

Page 35: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

35

Simulation Models: Report

M/M/c/c• Inter-arrival time is Exponential distribution with rate 50.0• Service time is Exponential distribution with rate 10.0• c: number of channels is 8 • c: system capacity is 8

http://www.erlang.com/calculator/erlb

Page 36: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

36

Priority Queue

Page 37: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

A SIMULATION EXAMPLEHANDOFF MODEL

Page 38: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

38

A Simulation Example Handoff Model

When the network attempts to deliver a call to a handset or the handset attempts to originate a call, the call is connected if a channel is available. Otherwise, the call is blocked (referred to as the new call blocking). When a handset moves from one cell to another during a call, in order to maintain call continuation the channel in the old cell is released, and a channel is required in the new cell. This process is called hand-off. If no channel is available in the new base station, then the hand-off call is force-terminated.

Page 39: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

39

MSC

Old BS New BS

MSC

Old BS New BS

(a) Step 1 (b) Step 2

MSC

Old BS New BS

MSC

Old BS New BS

(c) Step 3 (d) Step 4

A Simulation Example Handoff Model

Page 40: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

40

System Model – Assumptions (1/4)

Each cell consists of • One base station• Several channels• Several mobile station

A mobile user can carry only a call

We do not consider batch arrivals of new and handoff calls

Page 41: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

41

System Model – Assumptions (2/4)

Page 42: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

42

System Model – Assumptions (3/4)

Each hard handoff call can only connect to one BS.

BS1 BS2BS3

BS4

BS5

BS1 BS2BS3

BS4

BS5

Page 43: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

System Model – Assumptions (4/4)

Wrapped mesh cell: N*N => 8*8• The boundary cell effects can be ignored

Page 44: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

44

A HANDOFF event

An ARRIVAL eventA RELEASE event

Simulation Models: Event Design

Page 45: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

45

Simulation Models: Event Design

We define three types of events for traditional calls :• ARRIVAL event represents a new call arrival.

- Call_Type is maintained in this event to indicate that the event is for a (Call_type = Traditional)

- A channel is required• HANDOFF event represents a handoff call arrival.

- The Call_Type variable is used to indicate that the event is for a traditional call (Call_type = Traditional)

- The channel in the old cell is released, and a channel is required in the new cell.

• RELEASE event represents the completion of a call.- Call_Type indicates that the event is for a traditional call (Call_type =

Traditional) - The channel is released.

Page 46: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

46

Timing Diagram for one call

tc: the call holding time of a portable.tc,i: the period between the time the portable moves into coverage area i and the time when the call is complete.tm,i: the residence time of a portable at a coverage area i.τ0: the time between the arrival of the call and when the portable moves out of coverage area 0.

Page 47: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

47

Residual-life τ0

Generation of an residual-life random number for gamma residence time with the parameters (k, θ) includes the following steps:

We first generate a uniform random number μ in (0, 1).

Second, we generate a random number t for the gamma random variable T with the parameters (k+1, θ). By multiplying u and t, we obtain a random number for the residual τ0.

τ0=U*Gamma(k+1, θ)

Yi-Bing Lin, “Random Number Generation for Residual Life of Mobile Phone Movement”, IEEE International Conference

on  Networking, Sensing and Control, Vol 1, pp. 30-33, March 2004.

Page 48: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

48

Timing Diagram for multiple call

Call 1Arrival(t=0)

Event List

Call 2Arrival

(6)

1. generate next call arrival2

2. generate service time3. generate cell residence time

insert ARRIVAL event

if channel>0{

channel--if (service time > residence time) insert HANDOFF eventelse insert RELEASE event

}

first call

Call 1Handoff

(t=4)

Call 2Arrival(t=6)

Page 49: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

49

Timing Diagram for multiple call

Call 1Arrival(t=0)

Event List

Call 2Arrival

(6)

Call 1RELEASE(t=14)

1. generate cell residence time

compare the service time and the residence timeif (service time > residence time) insert HANDOFF eventelse insert RELEASE event

Call 1Handoff

(t=4)

Call 2Arrival(t=6)

if channel==0 N_Blocking++

channel++

1. generate next call arrival3

Call 3Arrival(t=20)

Page 50: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

50

Example: Event List and Event Struct 

Event Struct 

Event List

Page 51: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

51

Simulation Models: Timing Routine/* initialization *//* generate the first event and insert it into the event list */While(Number_of_Case <= Bound){

/* retrieve the first event from event list *//* adjust the system clock according to the timestamp of current event */switch(event_type){

case ARRIVAL :/*Process flowchart for ARRIVAL event */break;

case HANDOFF:/*Process flowchart for HANDOFF event */break;

case RELEASE:/*Process flowchart for RELEASE event */break;

}}/*Calculate the desired performance measures and output the result */

Page 52: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

52

Flow Chart

Start

(1) Set initial values(2) Generate a traditional call ARRIVAL event for each cell

(3) Delete next event e from the event list according the timestamp of the event

(4) Check the type of event e

(6) channel available?

(5) Call_Type ?(10)

Call_Type ?

(8) one channel is allocated to the request(9) CRt = CRt + 1;

(7) The request is blocked

(11) Release one channel(12) CRt = CRt - 1;

(13) Call_Type ?

(14) channel available?

(16) one channel is allocated to the request and release old channel(17) CRt = CRt + 1;

(15) The handoff request is block.

Traditional

NO YES

Traditional Traditional

NO YES

ARRIVAL

RELEASE

HANDOFF

Page 53: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

53

The notations

The new traditional call arrival rate to a cell is exponentially distributed with the rate .

The call holding time for a traditional call is exponentially distributed with the mean .

The UE residence time in a cell has an exponential distribution with the mean .

The total channels in a cell are C.

The call incompletion probability for a traditional call is Pnc,t.

Page 54: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

54

Analysis and Simulation Validation

The input parameters and are normalized by .

We assume there are C=10 channels per cell.

Page 55: Discrete Event Simulation Speaker: Yeh, En-Hau Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.twjet.lee@pcs.csie.ntu.edu.tw

55

Reference

Gamma distribution• http://en.wikipedia.org/wiki/Gamma_distribution

Erlang B Calculator• http://www.erlang.com/calculator/erlb

Latex• http://www.latex-project.org/• http://miktex.org/

GNUPlot• http://www.gnuplot.info/

M/M/c/c Sample Source Code • http://pcs.csie.ntu.edu.tw/course/performance/2012/Simulation_MMCC.rar