Sunteți pe pagina 1din 25

Computer and Communication Systems

(Lehrstuhl fr Technische Informatik)

Introduction to Network Simulation

[NwSim] Winter 2012/2013

Introduction to Network Simulation

Introduction to Simulation
Ways to study a system
System
Experiment
with the
actual system

expensive,
system may not exist

not typical
in this context

Experiment
with a model
of the system

Physical
model

Mathematical
model

Analytical
solution

desirable if possible,
models easily get too complex
[NwSim] Winter 2012/2013

Introduction to Network Simulation

Simulation
method of last resort?
2

Introduction to Simulation
Classification of models
model: a representation of the system for the purpose of studying the system
static/dynamic
in a static model time plays no role (e.g., Monte-Carlo simulation for certain
integrations)
a dynamic model represents a system evolving over time
deterministic/stochastic
a deterministic model has no random component, although the output of the
model is deterministic it may be impossible to obtain it analytically (e.g., a
complicated system of differential equations)
a stochastic model has some random components
discrete/continuous
in a discrete model variables change instantaneously at separated points in
time (occurring of the events)
in a continuous model variables change continuously with respect to time
(normally described by differential equations)
it is a modeling decision which kind of model is chosen to represent the system
[NwSim] Winter 2012/2013

Introduction to Network Simulation

Introduction to Simulation
Kinds of simulation
dependent on the model type (static/dynamic,
deterministic/stochastic, continuous/discrete)
here we focus on dynamic, stochastic, discrete, commonly known
as discrete-event simulation (DES)

Some variants of DES


trace-driven simulation:
instead of synthetic sources, such as random number generators,
traces are gathered from a real system and are fed as input to the
simulation model
object-oriented and process-oriented simulation:
the related software concepts are used to code the simulation
model, underlying is however DES
parallel and distributed simulation:
DES is performed in parallel or distributed
[NwSim] Winter 2012/2013

Introduction to Network Simulation

Introduction to Simulation
Steps in a Simulation Study
(similar to software engineering, with specific simulation aspects):
Formulate problem and plan the study
Collect data and define the model
Is the conceptual model valid?
Construct a computer program and verify
Make pilot runs
Is the programmed model valid?
Design experiments
Make production runs
Analyze output data
Document, present, and use results

[NwSim] Winter 2012/2013

Introduction to Network Simulation

Advantages, Disadvantages, and Pitfalls


Advantages of simulation
simulation is often the only possible type of investigation
allows to estimate an existing systems behavior under a projected set
of operation conditions
alternate proposed system designs can be compared
control over experimental conditions can be maintained
allows to study systems with a long time frame in compressed time, or
to study the detailed workings in expanded time

Disadvantages of simulation
each run of a stochastic simulation model produces only estimates of a
models true characteristics
simulation models are often expensive and time-consuming to develop
sometimes excessive run-times
the large volume of output data or the realistic animation often creates a
tendency to place more confidence in a studys result than justified
[NwSim] Winter 2012/2013

Introduction to Network Simulation

Advantages, Disadvantages, and Pitfalls (cont.)


Pitfalls of simulation
not well-defined objectives in the beginning
inappropriate level of detail (abstraction)
failure of communication with management throughout the study
treating it just as a programming exercise
having no people with knowledge about simulation and statistics
failure to account for the randomness in the model
failure to collect data
inappropriate simulation software
simulation software with undocumented/unclear features
misuse of animation
making a simple replication of a particular system design and treating
the output statistics as the true answer
using wrong measures
...
[NwSim] Winter 2012/2013

Introduction to Network Simulation

Organization of DES
Typical components in DES:
system state: the collection of state variables necessary to describe the
system at a particular time
simulation clock: a variable giving the current value of simulated time
event list: a list containing the next time when each type of event will occur
statistical counters: variables used for storing statistical information about
system performance
initialization routine: a subprogram to initialize the simulation model at
time 0
timing routine: a subprogram that determines the next event from the
event list and then advances the simulation clock to the time when that
event is to occur

[NwSim] Winter 2012/2013

Introduction to Network Simulation

Organization of DES
event routine: a subprogram that updates the system state when
a particular type of event occurs (there is one event routine for
each event type)
library routines: a set of subprograms used to generate random
observations from probability distributions that were determined
as part of the simulation model (and other statistical features)
report generator: a subprogram that computes estimates (from
the statistical counters) of the desired measures of performance
and produces a report when the simulation ends
main program: a subprogram that invokes the timing routine to
determine the next event and then transfers control to the
corresponding event routine to update the system state
appropriately. The main program may also check for termination
and invoke the report generator when the simulation is over

[NwSim] Winter 2012/2013

Introduction to Network Simulation

Organization of DES
Flow of control

[NwSim] Winter 2012/2013

Introduction to Network Simulation

10

Statistical Issues of DES (Input Modeling)


Possibilities to input observed data into simulations
trace-driven simulation
inject actual data values in simulation
direct and close to real world
can only reproduce what happened historically, inflexible

empirical distribution
use data values to define a connect-the-dots distribution and
sample from it when needed in the simulation
fairly valid, simple, fairly direct
may limit range of generated variants, difficult to change

theoretical distribution
fit a theoretical distribution (e.g., exponential, gamma, ...) and
sample from it when needed in the simulation
compact representation with few parameters, smoothes out data
may be difficult to find good fit
[NwSim] Winter 2012/2013

Introduction to Network Simulation

11

Statistical Issues of DES (Input Modeling)


Distribution fitting
1.
2.
3.

decide what family to use: exponential, gamma, Weibull, ...


estimate parameters (e.g., Maximum Likelihood Estimation)
assess how representative the fit is (e.g., overplots, tests, )

histogram of measured
service times
(622 in this example)

[NwSim] Winter 2012/2013

density f(x) of fitted


probability distribution function
(inverted Weibull in this example)

Introduction to Network Simulation

12

Statistical Issues of DES (Terminating vs. Steady-State Simulations)

Types of simulations
terminating simulations
specific initial and stopping conditions
measures depend on initial and stopping conditions
similar to transient analysis (but not equivalent)

steady-state simulations (nonterminating simulations)


no natural event to specify simulation length
interest in long-run system behavior when operating normally
corresponds to steady-state analysis

[NwSim] Winter 2012/2013

Introduction to Network Simulation

13

Statistical Issues of DES (Terminating vs. Steady-State Simulations)

Statistical Analysis of Terminating Simulations


Approach: make n independent replications
same initial conditions for each replication
same stopping conditions for each replication
separate random numbers for each replication
let Xj be summary measure of jth replication
X1, X2, ... Xn are a random sample
can apply simple statistics
can mostly rely on normality assumption

[NwSim] Winter 2012/2013

Introduction to Network Simulation

14

Statistical Issues of DES (Terminating vs. Steady-State Simulations)

Statistical Analysis of Steady-State Simulations


Characteristics of steady-state simulation
aimed to give insight after a long period of time
initial transient (nonstationary, warm-up) period
after launching, initially in this period
example: a queue started empty
data from this period leads to significant bias and must be discarded

convergence to steady state


the observations are still
fluctuating and are
(typically) correlated
must run simulation long
enough to get specified
precision

[NwSim] Winter 2012/2013

Introduction to Network Simulation

15

Statistical Issues of DES (Terminating vs. Steady-State Simulations)

The two main problems


duration of the initial transient period
need methods to estimate duration
rules of thumb
graphical procedures
statistical tests

must discard data from this period

analysis of correlated data


need stopping criteria to run simulation until a precision is met
must deal with correlations
conceptually simple: independent replications, batch means
also other statistical methods, more sophisticated

[NwSim] Winter 2012/2013

Introduction to Network Simulation

16

Example: Single-Server Queue (scenario)


The single-server queue
arrival
of customers
inter-arrival times, e.g.:
0.4, 1.2, 0.5, 1.7, 0.2, ...

customers depart
from system
waiting room
(queue)

service unit

service times, e.g.:


2.0, 0.7, 0.2, 1.1, 3.7, ...

scenario:
customers arrive randomly
infinite waiting room (unbounded queue)
one service unit with a random service time
abstract model of many systems, e.g.:
an information desk at an airport
a station in a manufacturing cell
a router in the Internet
...
the hello world of simulation and modeling
[NwSim] Winter 2012/2013

Introduction to Network Simulation

17

Example: Single-Server Queue (measures)


Typical questions
how much time do customers spend in the system?
how many customers are in the system (waiting room and server)?
how busy is the service unit?
how many customers are served per hour?
how many customers are served between idle periods?
...

Corresponding measures (in steady state)


Mean delay D: average of the times in system Di (waiting time Wi + service time Si )
Mean queue length N: average value of N(t), the number of customers
in the system, for t
Utilization U: average percentage of time with N(t) > 0
Throughput X: average number of completed services per time unit
Busy period analysis: average duration/mean number of served customers

non-stationary, i.e., transient, measures may also be considered,


e.g., average value of N(t) for fixed t

Performance measures: e.g., via discrete-event simulation


[NwSim] Winter 2012/2013

Introduction to Network Simulation

18

Example: Single-Server Queue (possible realization)


N(t): number of customers in system
(queue + service unit) at time t

N(t)
3

ti : arrival of i'th customer


ci : departure of i'th customer (completed service)

2
1

0
events:
interarrival
times:
service times:

c1

t1

A2

A1

times in system:

t2

t3
A3

S1
D1

c2
A4

c3

S3

D2

Introduction to Network Simulation

t5
A5

S2

Ai : inter-arrival time of i'th customer = ti - ti-1


Si : service time of i'th customer
Di : time in system of i'th customer (in queue + service unit)
Wi : waiting time of i'th customer = Di - Si
[NwSim] Winter 2012/2013

t4

W3

D3

19

Example: Single-Server Queue (remarks)


Discrete simulation
events occur at discrete points in time
variables change instantaneously

Main principles
Input modeling (!)
characterization of randomness by input parameters
based on data fitting with measurements

Computer representation
model paradigm (textual/visual, event-/process-/object-oriented, ...)
random number generation
event list processing (!)

Output analysis (!)


sound statistical analysis of output data to obtain measures of interest

Also relevant: Optimization


Systematic search in the input parameter space for optimal values of
the measures
[NwSim] Winter 2012/2013

Introduction to Network Simulation

20

Example: Single-Server Queue (input modeling)


random arrival and service patterns
may be characterized by probability distributions
density f(x) of fitted
probability distribution function
(inverted Weibull in this example)

histogram of measured
service times
(622 in this example)

software tool: ExpertFit

[NwSim] Winter 2012/2013

Introduction to Network Simulation

21

Example: Single-Server Queue (event list processing)


Event list processing
Data structures
event list: discrete events with time of occurrence, ordered by time
simulation clock: variable giving current value of simulated time
system state variables, statistical counters

Algorithm:
initialization
routine
timing routine

event routine
(one per event type)

report generator

0. initialization of data structures at time 0;


Repeat
1. get next event from event list and advance
simulation clock to its time of occurrence;
2. update system state, event list and counters;
3. generate future events (using random number
generator) and add them to event list;
until stopping criterion satisfied;
library routines
4. Compute measures of interest (from counters);

[NwSim] Winter 2012/2013

Introduction to Network Simulation

22

Example: Single-Server Queue (event list processing)


Event list processing (step by step):
"next-event time advance" (also possible: "fixed-increment
advance")
the simulation clock is advanced from event to event
periods of inactivity are skipped over

t
0

t1

c1

t2

t3

c2

t4

t5

c3

That is why simulation is usually faster than observing the


real world:
simulation time vs. simulated time (i.e., run time vs. model time)
[NwSim] Winter 2012/2013

Introduction to Network Simulation

23

Example: Single-Server Queue (output analysis)


Typical measures
Mean delay D: average of times in system Di
Utilization U: average percentage of time with N(t) > 0
Throughput X: average number of completed services per time
unit
Statistical estimation
unless enough observations
estimation can differ significantly from true value
one needs information about the quality of estimations
confidence intervals
Remark
not straightforward, output data is correlated

[NwSim] Winter 2012/2013

Introduction to Network Simulation

24

Example: Single-Server Queue (output analysis)


Example results
For exponentially distributed interarrival and service times with
means equal to 10 and 9 time units:
Mean delay D = 90 time units
Utilization U = 0.9
Throughput X = 0.1
D

D vs. U:
(steep increase as U 1)
Results from discrete
simulation

15
10
5
0

[NwSim] Winter 2012/2013

Introduction to Network Simulation

0.2

0.4

0.6

0.8

25

S-ar putea să vă placă și