simulation of complex computer networks part ii urban bilstrup (e327) [email protected]

59
Simulation of Complex Computer Simulation of Complex Computer Networks Part II Networks Part II Urban Bilstrup (E327) Urban Bilstrup (E327) [email protected] [email protected] 080328 080328

Post on 21-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

Simulation of Complex Computer Networks Simulation of Complex Computer Networks Part IIPart II

Urban Bilstrup (E327)Urban Bilstrup (E327)

[email protected]@hh.se

080328080328

Page 2: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

2

OutlineOutline

Question Extreme programmingQuestion Extreme programming

Elements of simulation analysisElements of simulation analysis

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

Page 3: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

3

Question – Extreme programmingQuestion – Extreme programming

Page 4: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

4

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

Verification focuses on the process of determining whether Verification focuses on the process of determining whether the operational logic of the model (the computer program) the operational logic of the model (the computer program) corresponds to the logic flow cart (are there any errors in corresponds to the logic flow cart (are there any errors in the program ????). the program ????).

Validation focuses on the process of determining if the Validation focuses on the process of determining if the model is meaningful and accurate representation of the model is meaningful and accurate representation of the real system.real system.

Page 5: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

5

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

Model verification and validation is concerned with three models.Model verification and validation is concerned with three models.

• Conceptual modelConceptual model

• Logic modelLogic model

• Computer modelComputer model

Validating the Validating the conceptual modelconceptual model is the process of establishing the is the process of establishing the

relevance of our abstraction of the real system, and what questions relevance of our abstraction of the real system, and what questions

the simulation model is expected to answer.the simulation model is expected to answer.

Validating the conceptual model can be thought of as a binding Validating the conceptual model can be thought of as a binding

process, in which the simulation analysts, decision makers, and process, in which the simulation analysts, decision makers, and

managers, agree upon which aspects of the real system which should managers, agree upon which aspects of the real system which should

be included in the simulation model and what information that the be included in the simulation model and what information that the

model will provide as output.model will provide as output.

Page 6: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

6

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

The The logical modellogical model, the flow chart, serves as a bridge from , the flow chart, serves as a bridge from the conceptual model to the computer model.the conceptual model to the computer model.

Validating the Validating the logical model logical model is easyis easy if the conceptual if the conceptual model has been well constructed.model has been well constructed.

Three basic questions can be used:Three basic questions can be used:• Are the events within the model processed correctly.Are the events within the model processed correctly.

• Are the mathematical formulas and relationship in the model valid.Are the mathematical formulas and relationship in the model valid.

• Are the statistics and measures of performance calculated Are the statistics and measures of performance calculated correctly. correctly.

Page 7: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

7

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

A common method for verifying and validating the event A common method for verifying and validating the event processing within the logical model is a processing within the logical model is a structured walk-structured walk-through through (a form of review meeting). (a form of review meeting).

In a structured walk-through the developer of the logical In a structured walk-through the developer of the logical model must explain the detailed logic of the model to other model must explain the detailed logic of the model to other members of the simulation project team. members of the simulation project team.

Structured walk-through is not unique for simulation Structured walk-through is not unique for simulation project it is applicable on almost all software development project it is applicable on almost all software development projects.projects.

Page 8: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

8

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

The method of detecting errors in mathematical calculations or The method of detecting errors in mathematical calculations or

formulas is not much different than detecting errors in semantics or formulas is not much different than detecting errors in semantics or

spelling in natural languages. That is, careful scrutiny by the analysts spelling in natural languages. That is, careful scrutiny by the analysts

and proofing by someone else. and proofing by someone else.

A common error in simulation modeling is to fail to update all relevant A common error in simulation modeling is to fail to update all relevant

statistics and measures when an event occurs.statistics and measures when an event occurs.

One method of verifying that the statistics and the measures of One method of verifying that the statistics and the measures of

performance are updated correctly is the use of an event graph. In this performance are updated correctly is the use of an event graph. In this

each event state is associated with a complete list of all statistics and each event state is associated with a complete list of all statistics and

measure of performance that will change when the event occurs.measure of performance that will change when the event occurs.

Page 9: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

9

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

Verifying the computer program for a simulation model is Verifying the computer program for a simulation model is not much different from verifying any software.not much different from verifying any software.

It often requires imagination and ingenuity of the It often requires imagination and ingenuity of the programmer, it is one of the few things that only can be programmer, it is one of the few things that only can be conducted by the persons with programming skills in a conducted by the persons with programming skills in a simulation study team.simulation study team.

Page 10: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

10

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

Six general approaches to verify a computer program Six general approaches to verify a computer program are: are: • Structured programming methodsStructured programming methods

• Tracing the simulation during run timeTracing the simulation during run time

• Program testingProgram testing

• Logical relationship checksLogical relationship checks

• Comparison to analytical modelsComparison to analytical models

• GraphicsGraphics

Page 11: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

11

Elements of simulation analysis – model verification Elements of simulation analysis – model verification and validationand validation

Some rules of the thumb for designing well-structured Some rules of the thumb for designing well-structured computer programs are:computer programs are:• Top-down designTop-down design: The program is designed starting with the : The program is designed starting with the

highest level processes which are then decomposed into highest level processes which are then decomposed into subsidiary modules which themselves can be further decomposed. subsidiary modules which themselves can be further decomposed.

• ModularityModularity: Each subsidiary module is responsible for a single : Each subsidiary module is responsible for a single function.function.

• Stepwise refinementStepwise refinement: Each module is developed using a step-by-: Each module is developed using a step-by-step refinement of the module’s function.step refinement of the module’s function.

• Compact modulesCompact modules: Modules should be short in length, fifty lines : Modules should be short in length, fifty lines of code is often given as a upper bound.of code is often given as a upper bound.

• Structured controlStructured control: All control code should be simple to : All control code should be simple to understand and highly structured IF-THEN-ELSE, WHILE, understand and highly structured IF-THEN-ELSE, WHILE, REPEAT-UNTIL, FOR and CASE statements. REPEAT-UNTIL, FOR and CASE statements.

Page 12: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

12

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

It is always easier to verify 20 modules averaging 25 lines of code, than it is to verify one module of 500 lines of code !!!

Page 13: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

13

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

When the simulation program is designed, mechanisms for When the simulation program is designed, mechanisms for tracingtracing should be included directly and not patched when should be included directly and not patched when erroneous execution is discovered in the simulation erroneous execution is discovered in the simulation program, traces should be possible to turn on and off.program, traces should be possible to turn on and off.

The trace mechanisms can be based on that a print The trace mechanisms can be based on that a print function is included in all functions, printing all relevant function is included in all functions, printing all relevant simulation parameters and simulation time.simulation parameters and simulation time.

However, one should be aware of that the amount of trace However, one should be aware of that the amount of trace output data can be overwhelming. output data can be overwhelming.

Page 14: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

14

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

The two most basic approaches for The two most basic approaches for testingtesting a computer a computer program are program are bottom-upbottom-up and and top-downtop-down testing. testing.

In In bottom-upbottom-up testing the lowest, most basic modules are testing the lowest, most basic modules are tested first (sometimes referred to as unit testing).tested first (sometimes referred to as unit testing).

After the basic units have been tested, integration tests After the basic units have been tested, integration tests are performed in which interfaces between two or more are performed in which interfaces between two or more modules are tested. modules are tested.

This continues iteratively until the whole system can be This continues iteratively until the whole system can be tested as one instance.tested as one instance.

Page 15: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

15

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

In In top-down testingtop-down testing, the testing begins with the main module and , the testing begins with the main module and

incrementally moves down to lower modules.incrementally moves down to lower modules.

In top-down testing, stubs or dummy routines are required to simulate In top-down testing, stubs or dummy routines are required to simulate

the function of lower-level modules.the function of lower-level modules.

An advantage of the top-down approach is that testing can be An advantage of the top-down approach is that testing can be

conducted parallel with the development of the software.conducted parallel with the development of the software.

Programmers and management often feel more comfortable with top-Programmers and management often feel more comfortable with top-

down testing because it gives the down testing because it gives the appearanceappearance that progress is being that progress is being

made. made.

Page 16: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

16

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

Checking the logic expressions in IF-THEN-ELSE Checking the logic expressions in IF-THEN-ELSE statements are crucial.statements are crucial.

Avoid a depth of more than 7 IF statements.Avoid a depth of more than 7 IF statements.

Typically, logic errors are not randomly or uniformly Typically, logic errors are not randomly or uniformly distributed throughout a computer program, they tend to distributed throughout a computer program, they tend to cluster into colonies of bugs. cluster into colonies of bugs.

Queues and lists generate runtime errors, memory Queues and lists generate runtime errors, memory leakage, do not use recursive functions or be extremely leakage, do not use recursive functions or be extremely careful when you use it. careful when you use it.

Page 17: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

17

Elements of simulation analysis – model verification and Elements of simulation analysis – model verification and validationvalidation

When the computer program has been verified, assumed When the computer program has been verified, assumed to be correct, the next step is to validate whether the to be correct, the next step is to validate whether the simulation program generates output that is a valid simulation program generates output that is a valid representation of the real system or not.representation of the real system or not.

Program validationProgram validation is to judge whether the simulation is to judge whether the simulation program have enough confidence in the result to use it as program have enough confidence in the result to use it as part of the decision making process.part of the decision making process.

The most straightforward method is to compare simulation The most straightforward method is to compare simulation result with an existing system. This is however only result with an existing system. This is however only possible if necessary data is available from a real system.possible if necessary data is available from a real system.

Page 18: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

18

Elements of simulation analysis – model Elements of simulation analysis – model experimentation and optimizationexperimentation and optimization

There are some aspects in the interpretation of simulation There are some aspects in the interpretation of simulation models outputs that are unique to simulation. The main models outputs that are unique to simulation. The main issue is that a simulation models only yield estimates of issue is that a simulation models only yield estimates of measures that are subject to sampling errors. measures that are subject to sampling errors.

• As an example; an analytical evaluation provideAs an example; an analytical evaluation provide mean mean and and variance variance and exact and exact probability distributionsprobability distributions for the measures of for the measures of performance. performance.

• Simulations on the other hand provide the Simulations on the other hand provide the sample meansample mean and and sample variancesample variance and and sample distributionssample distributions, from these we must , from these we must estimateestimate population parameterspopulation parameters and and distributionsdistributions..

Page 19: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

19

Elements of simulation analysis – model Elements of simulation analysis – model experimentation and optimizationexperimentation and optimization

The major issue in obtaining useful estimates from The major issue in obtaining useful estimates from samples are:samples are:• that the samples are representative for the typical system behavior that the samples are representative for the typical system behavior

• that the sample size is large enough to provide some stated level that the sample size is large enough to provide some stated level of precision for the performance measure estimates.of precision for the performance measure estimates.

Sample sizeSample size is especially important since the is especially important since the precisionprecision of of estimates is dependent upon the variance of the sample estimates is dependent upon the variance of the sample mean and the variance changes inversely with the sample mean and the variance changes inversely with the sample sizesize

Page 20: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

20

Elements of simulation analysis – model Elements of simulation analysis – model experimentation and optimizationexperimentation and optimization

We may now turn to the ultimate purpose of model We may now turn to the ultimate purpose of model experimentation: to derive information about the system experimentation: to derive information about the system behavior.behavior.

This information should be in a format which is helpful for This information should be in a format which is helpful for decision making.decision making.

When considering system performance we may whish to When considering system performance we may whish to know how well a system behaves in an know how well a system behaves in an absolute senseabsolute sense, , comparativelycomparatively, or , or in contrast to one or several system in contrast to one or several system configurationsconfigurations..

Page 21: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

21

Elements of simulation analysis – model Elements of simulation analysis – model experimentation and optimizationexperimentation and optimization

Even for the modest experimental design, enumeration of Even for the modest experimental design, enumeration of all possible solutions is not recommended nor feasible in all possible solutions is not recommended nor feasible in searching for the best or very good configurations of the searching for the best or very good configurations of the system under consideration.system under consideration.

Consequently we need a more directed, structured Consequently we need a more directed, structured approach for seeking worthwhile solutions.approach for seeking worthwhile solutions.

Two different approaches are:Two different approaches are:• predetermined sets of experimentspredetermined sets of experiments

• optimum seeking techniques.optimum seeking techniques.

Page 22: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

22

Elements of simulation analysis – model Elements of simulation analysis – model experimentation and optimizationexperimentation and optimization

The The predetermined sets of experimentspredetermined sets of experiments approach identifies factors approach identifies factors

which would affect some output measure.which would affect some output measure.

This is done by performing experiments with a limited set of factors, This is done by performing experiments with a limited set of factors,

set at a limited set of values and combination of these.set at a limited set of values and combination of these.

Statistical techniques, often referred to as analysis of variance Statistical techniques, often referred to as analysis of variance

(ANOVA) is then applied to discern whether a specific factor have any (ANOVA) is then applied to discern whether a specific factor have any

large impact on the output measure of performance.large impact on the output measure of performance.

If for example two factors are considered, at three different levels, If for example two factors are considered, at three different levels,

nine runs are necessary.nine runs are necessary.

Page 23: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

23

Elements of simulation analysis – model Elements of simulation analysis – model experimentation and optimizationexperimentation and optimization

The use of predetermined set of model is effective in The use of predetermined set of model is effective in identifying important factors. identifying important factors.

Unfortunately can the technique not lead one toward the Unfortunately can the technique not lead one toward the overall optimal solution (a global optimum).overall optimal solution (a global optimum).

It can not even guarantee one of several very good It can not even guarantee one of several very good solutions (a local optimum). solutions (a local optimum).

Page 24: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

24

Elements of simulation analysis – model Elements of simulation analysis – model experimentation and optimizationexperimentation and optimization

One optimum seeking technique is simply to start generating output to One optimum seeking technique is simply to start generating output to

form a response surface, a two factor experiment defines a surface in form a response surface, a two factor experiment defines a surface in

three dimensions, i.e., compare with a topographic map.three dimensions, i.e., compare with a topographic map.

By using different strategies one can reach high points or even the By using different strategies one can reach high points or even the

summit.summit.

One often used way is One often used way is steepest ascentsteepest ascent, it requires that sufficient , it requires that sufficient

simulations runs are made to determine which direction that seems to simulations runs are made to determine which direction that seems to

yield the greatest increase in altitude.yield the greatest increase in altitude.

The decision variables are changed accordingly, and the process is The decision variables are changed accordingly, and the process is

continued until one can not go higher (a local or global optima is continued until one can not go higher (a local or global optima is

reached). reached).

Page 25: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

25

An implementation and execution An implementation and execution example of a discrete event simulator.example of a discrete event simulator.

Page 26: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

26

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulator.event simulator.

Consider a s service facility with a single server, e.g. an Consider a s service facility with a single server, e.g. an information desk.information desk.

We want to estimate the average delay in the queue, We want to estimate the average delay in the queue, average number of customers in the queue and expected average number of customers in the queue and expected utilization of the service desk.utilization of the service desk.

ServerCustomer in service

Customers in queue

An arriving customer

A departing customer

Try to visualize the problem formulation !!!!!

Page 27: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

27

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulator.event simulator.

We assume the next event time advance, visualize the time domain We assume the next event time advance, visualize the time domain

operation of the simulator and define some related variablesoperation of the simulator and define some related variables..

Page 28: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

28

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulator.event simulator.

Data structuresData structures• System state variablesSystem state variables: The collection of state variables : The collection of state variables

necessary to describe the state of a system at a particular time.necessary to describe the state of a system at a particular time.

• Simulation clockSimulation clock: A variable given the current value of simulated : A variable given the current value of simulated time.time.

• Event listEvent list: A list containing the next time an event will occur.: A list containing the next time an event will occur.

• Statistical countersStatistical counters: Variables used for storing statistical : Variables used for storing statistical information about the system performance.information about the system performance.

Page 29: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

29

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulator.event simulator.

RoutinesRoutines• Initialization routineInitialization routine: A sub program to initialize the simulation : A sub program to initialize the simulation

model at t=0.model at t=0.

• Timing routine:Timing routine: A subprogram that determines the next event A subprogram that determines the next event from the event list and then advances the clock to the time when from the event list and then advances the clock to the time when the event occurs.the event occurs.

• Event routine:Event routine: A subprogram that updates the system state when A subprogram that updates the system state when a particular type of event occurs.a particular type of event occurs.

• Library routines:Library routines: A set of subprograms used to generate random A set of subprograms used to generate random observations from probability distributions that were predetermined observations from probability distributions that were predetermined as part of the simulation model during problem formulation and as part of the simulation model during problem formulation and data collection.data collection.

Page 30: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

30

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

• Report routine:Report routine: A subprogram that computes estimates of the A subprogram that computes estimates of the desired measure of performance and produces a report when the desired measure of performance and produces a report when the simulation ends.simulation ends.

• Main program:Main program: The main program invoke the timing routine to The main program invoke the timing routine to determine the next event and then transfer control to the determine the next event and then transfer control to the corresponding event routine to update the system appropriately. corresponding event routine to update the system appropriately. The main program may also check for termination of the simulation The main program may also check for termination of the simulation and invoke the report generator when the simulation is over.and invoke the report generator when the simulation is over.

Page 31: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

31

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

Page 32: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

32

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

The simulation will begin with in the state, i.e., no The simulation will begin with in the state, i.e., no customer is present and the server is idle. customer is present and the server is idle.

At time 0, we will begin waiting for the arrival of the first At time 0, we will begin waiting for the arrival of the first customer, which will occur after the first inter-arrival time customer, which will occur after the first inter-arrival time AA11..

We wish to simulate this system until a fixed number, We wish to simulate this system until a fixed number, nn, of , of customers have completed their delays in the queue.customers have completed their delays in the queue.

Note that the time the simulation will stop is thus a random Note that the time the simulation will stop is thus a random variable, depending on the observed values of the inter-variable, depending on the observed values of the inter-arrival and the service time random variables.arrival and the service time random variables.

Page 33: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

33

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

To measure the performance of this system, we will look at the To measure the performance of this system, we will look at the

estimates of the three measures of performance, customer delay, estimates of the three measures of performance, customer delay,

queue length and utilization.queue length and utilization.

First the estimate of average customer delay, First the estimate of average customer delay, dd((nn)) of the of the nn customers. customers.

One interpretation of this is that One interpretation of this is that dd((nn),), is the average of the number of is the average of the number of

nn customers delay. customers delay.

From a single run of the simulation resulting in customer delays: From a single run of the simulation resulting in customer delays: DD11, ,

DD22, , DD33…….…….DDnn, and obvious estimator of , and obvious estimator of dd((nn)) is: is:

1( )

n

ii

Dd n

n

Page 34: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

34

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

The average number of customers in the queue, q(n), this is a The average number of customers in the queue, q(n), this is a different kind of average than the previous because it is taken over different kind of average than the previous because it is taken over continuous time, rather than over customers.continuous time, rather than over customers.

Let Let QQ((tt)) denote the number of customers in the queue at time denote the number of customers in the queue at time tt for any for any tt 00, and let , and let TT((nn)) be the time required to observe our be the time required to observe our nn delays in the delays in the queue.queue.

For any time For any time t t between between 00 and and TT((nn)), , Q(Q(tt)) is nonnegative integer. is nonnegative integer. Further if we let Further if we let ppii be the expected proportion of the time be the expected proportion of the time QQ((tt)) is equal is equal

to to ii, then a reasonable estimate of , then a reasonable estimate of qq((nn)) would be: would be:

0

( ) ii

q n ip

q(n) is a weighted average of the possible values of I for the queue length Q(t), with the weights being the expected proportion of time the queue spends at each of its possible position

Page 35: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

35

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

Computationally it is however easier rewrite Computationally it is however easier rewrite qq((nn)) using some using some geometric considerations. If we let geometric considerations. If we let TTii be the total time during the be the total time during the

simulation that the queue is of length simulation that the queue is of length ii, then , then TT((nn)=)=TT00++TT11++TT22…..….. and and

ppii==TTii//TT((nn))

so that we can rewrite it toso that we can rewrite it to

1 0( )( )

iiTq n

T n

Easier understood by a visualization !!!!!

Page 36: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

36

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

T0 = (1.6 - 0.0) + (4.0 - 3.1) + (5.6 - 4.9) = 3.2

T1 = (2.1 - 1.6) + (3.1 - 2.4) + (4.9 - 4.0) + (5.8 - 5.6) = 2.3

T2 = (2.4 - 2.1) + (7.2 - 5.8) = 1.7

T3 = (8.6 - 7.2) = 1.4

Page 37: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

37

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

The numerator is then:The numerator is then:

0

0 3.2 1 2.3 2 1.7 3 1.4 9.9ii

iT x x x x

and our estimate of the time average number in the queue from this particular simulation run is 9.9 / 8.6 = 1.15.

Note that each of the non-zero terms corresponds to one of the shaded areas in the figure.

In other words, the summation is just the area under the Q(t) curve between the beginning and end of the simulation, i.e.,

( )

0

( )

( )( )

T n

Q t dt

q nT n

Page 38: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

38

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

The expected utilization of the server is the expected portion of time The expected utilization of the server is the expected portion of time

during the simulation that the server is busy.during the simulation that the server is busy.

It is easy to look at this quantity as a continuous time average, by It is easy to look at this quantity as a continuous time average, by

defining a busy function, defining a busy function, BB((tt))..

1 if the server is busy at time ( )

0 if the server is idle at time

tB t

t

So So uu((nn) could be expressed as the portion of time that ) could be expressed as the portion of time that BB((tt)) is equal to is equal to

1 (unity).1 (unity).

Easier understood by a visualization !!!!!

Page 39: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

39

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

(3.3 0.4) (8.6 3.8) 7.7( ) 0.90

8.6 8.6u n

Page 40: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

40

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

Again, the numerator can be viewed as the area under the Again, the numerator can be viewed as the area under the BB((tt)) function, i.e., function, i.e.,

( )

0

( )

( )( )

T n

B t dt

u nT n

Page 41: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

41

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

Let us assume that we studyLet us assume that we study e e00 and the times and the times ee11, , ee22, , ee33…..…..ee1313 at which 13 events occurs during the observed at which 13 events occurs during the observed

number of customers, n=6.number of customers, n=6.

We assume that the inter-arrival time (generated by some We assume that the inter-arrival time (generated by some random distribution) of the customers is: random distribution) of the customers is:

AA11=0.4, =0.4, AA22=1.2, =1.2, AA33=0.5, =0.5, AA44=1.7, =1.7, AA55=0.2, =0.2, AA66=0.2, =0.2, AA77=0.2, =0.2, AA88=1.4, =1.4, AA99=1.9,……..=1.9,……..

We further assume that the service time (generated by We further assume that the service time (generated by some random distribution) for the six first customers are: some random distribution) for the six first customers are: SS11=2.0, =2.0, SS22=0.7, =0.7, SS33=0.2, =0.2, SS44=1.1, =1.1, SS55=3.7, =3.7, SS66=0.6,…….=0.6,…….

Page 42: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

42

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

Let us first visualize the execution of 6 customer with a time axis

AA11=0.4, =0.4, AA22=1.2, =1.2, AA33=0.5, =0.5, AA44=1.7, =1.7, AA55=0.2, =0.2, AA66=0.2, =0.2, AA77=0.2, =0.2, AA88=1.4, =1.4, AA99=1.9,….=1.9,….

SS11=2.0, =2.0, SS22=0.7, =0.7, SS33=0.2, =0.2, SS44=1.1, =1.1, SS55=3.7, =3.7, SS66=0.6,…….=0.6,…….

ee11=0.4, =0.4, ee22=1.6, =1.6, ee33=2.1, =2.1, ee44=2.4, =2.4, ee55=3.1, =3.1, ee66=3.3,=3.3, ee77=3.8,=3.8, ee88=4.0,=4.0, ee99=4.9,=4.9, ee1010=5.6, =5.6, ee1111=5.8, =5.8,

ee1212=7.2, =7.2, ee1313=8.6=8.6

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 43: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

43

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 44: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

44

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 45: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

45

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 46: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

46

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 47: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

47

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 48: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

48

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 49: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

49

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 50: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

50

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 51: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

51

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 52: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

52

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 53: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

53

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 54: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

54

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 55: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

55

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 56: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

56

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

0 1 2 3 4 5 6 7 8 9 10

e2e1e0

e3e7 e8 e10 e11 e12

e8

11

A1 A2 A3A4 A5

A6A7 A8

A9

S1 S2

e4 e5 e6

S4

e9

S5 S6

e13

T(6)

Page 57: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

57

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

Page 58: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

58

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

Page 59: Simulation of Complex Computer Networks Part II Urban Bilstrup (E327) Urban.Bilstrup@hh.se080328

59

An implementation and execution example of a discrete An implementation and execution example of a discrete event simulatorevent simulator

The C program you have to implement yourself

QUESTIONS ????