Sei sulla pagina 1di 50

KKKT 6274

Modeling and Simulation of


Communication and Computer
Network
Prof. Dr. Mahamod Ismail
mahamod@eng.ukm.my
\\10.2.84.119\Public\Lecture\KKKT6274
LECTURE 5

MODELING AND SIMULATION

The Airport System
A certain airport contains a single runway on which arriving
aircrafts must land.
Once an aircraft is cleared to land, it will use the runway, during
which time no other aircraft can be cleared to land.
Once the aircraft has landed, the runway is available for use by
other aircraft. The landed aircraft remains on the ground for a
certain period of time before departing.
Model Development Life Cycle
Fundamentally an
iterative process
Define goals, objectives of study
Develop conceptual model
Develop specification of model
Develop computational model
Verify model
Validate model
Conceptual Model: Single Server Queue
Customer (aircraft)
Entities utilizing the system/resources
Server (runway)
Resource that is serially reused; serves one customer at a time
Queue
Buffer holding aircraft waiting to land
customer
queue
server
Objectives
Objective: Evaluate the performance of the Airport
System
Performance Metrics
Average waiting time: Average time that an aircraft must
wait when arriving at an airport before they are allowed to
land.
Maximum number of aircraft on the ground: Helps to
dimension the required surface for the parking area.
Conceptual Model: Single Server Queue
Customer (aircraft)
Entities utilizing the system/resources
Server (runway)
Resource that is serially reused; serves one customer at a time
Queue
Buffer holding aircraft waiting to land
customer
queue
server
Specification Model (Queueing Networks)
Customers
What is the arrival process?
Schedule of aircraft arrivals, e.g., log from specific dates (trace driven)
Often, probability distribution defines time between successive customer arrivals (interarrival time)
Assumes interarrival times independent, and identically distributed (iid)
Not always true (e.g., customers may leave if lines are too long!)
Customer attributes?
Sometime different flavors, e.g., priorities or other properties
Servers
How much service time is needed for each customer?
May use probability distribution to specify customer service time (iid)
How many servers?
Queue
Service discipline - who gets service next?
First-in-first-out (FIFO), Last-in-first-out (LIFO), random
May depend on a property of the customer (e.g., priority, smallest first)
Preemption?
Queue capacity? What if the queue overflows?
Specification Model (cont.)
Assumptions
Customers
Poisson Arrival Process: Assume arrivals are i.i.d., following an
exponential distribution for inter-arrival times with mean A
Assume all customers are identical (no specific attributes)
Servers
Exponential service time (landing time) with mean L
One server (one runway)
Queue
Assume first-in-first-out queue (FIFO) discipline
Assume queue has unlimited capacity
Computational Model
The System correspond to M/M/1 Queue Model.
Performance evaluation
Analytical: using queuing theory
Simulation: using a computer program
A computer simulation is a computer program that
emulate the behavior of a physical system over time.
How a computer simulation works?
Define state variables: variables that represent a state of
the system (e.g. N: number of customers in the queue)
Define events: a event changes a state variable of the
system (e.g. Arrival, Departure).
Computational Model
The General Algorithm of a simulation program
Define state variables
Define the events
For each Event do
Change the corresponding state variables
Create next events, if any
Collect statistics
Progress simulation time
Simulation time can progress by two means:
Regular progress: Time Step implementation
Irregular progress: Event-based implementation



State Variables
State:
InTheAir: number of aircraft either landing or waiting to land
OnTheGround: number of landed aircraft
RunwayFree: Boolean, true if runway available
customer
queue
server
Time Step Implementation
/* ignore aircraft departures */
Float InTheAir: # aircraft landing or waiting to land
Float OnTheGround: # landed aircraft
Boolean RunwayFree: True if runway available
Float NextArrivalTime: Time the next aircraft arrives
Float NextLanding: Time next aircraft lands (if one is landing)

For (Now = 1 to EndTime) { /* time step size is 1.0 */
if (Now >= NextArrivalTime) { /* if aircraft just arrived */
InTheAir := InTheAir + 1;
NextArrivalTime := NextArrivalTime + RandExp(A);
if (RunwayFree) {
RunwayFree := False;
NextLanding := Now + RandExp(L);
}
}
if (Now >= NextLanding) { /* if aircraft just landed */
InTheAir := InTheAir - 1;
OnTheGround := OnTheGround + 1;
if (InTheAir > 0) NextLanding := Now + RandExp(L)
else {RunWayFree := True; NextLanding := EndTime+1;}
}
}
Advantage
Simple
Drawback
Not efficient
Discrete Event Simulation
Discrete Event Simulation (DES): computer model
for a system where changes in the state of the
system occur at discrete points in simulation time.

Each Event has a timestamp indicating when it
occurs.

A DES computation: a sequence of events, where
each event is assigned a timestamp, which to help
to order/schedule the processing of events.

Discrete Event Simulation Computation
Events that have been scheduled, but have not been simulated (processed)
yet are stored in a pending event list
Events are processed in time stamp order; why?
Example: air traffic at an airport
Events: aircraft arrival, landing, departure
arrival
8:00
departure
9:15
landed
8:05
arrival
9:30
schedules
simulation time
processed event
current event
unprocessed event
schedules


Simulation Application
state variables
code modeling system behavior
I/O and user interface software


Simulation Engine
event list management
managing advances in simulation time
calls to
schedule
events
calls to event
handlers
Discrete Event Simulation System
Model of the
physical
system
Independent
of the
simulation
application
Events
An event must be associated with any change in the
state of the system
Airport example:
Event 1: Aircraft Arrival
(InTheAir, RunwayFree)
Event 2: Aircraft Landing
(InTheAir, OnTheGround, RunwayFree)
Event 3: Aircraft Departure
(OnTheGround)
Event-Oriented World View
state variables
Integer: InTheAir;
Integer: OnTheGround;
Boolean: RunwayFree;
Event handler procedures
Simulation Application
Arrival Event
{

}
Landed Event
{

}
Departure Event
{

}
Pending Event List (PEL)
9:00
9:16
10:10
Now = 8:45
Simulation Engine
Event processing loop
While (simulation not finished)
E = smallest time stamp event in PEL
Remove E from PEL
Now := time stamp of E
call event handler procedure
Example: Air traffic at an Airport
Model aircraft arrivals and departures, arrival queuing
Single runway for incoming aircraft, ignore departure queuing
L = mean time runway used for each landing aircraft (exponential distrib.)
G = mean time on the ground before departing (exponential distribution)
A = mean inter-arrival time of incoming aircraft (exponential distribution)
States
Now: current simulation time
InTheAir: number of aircraft landing or waiting to land
OnTheGround: number of landed aircraft
RunwayFree: Boolean, true if runway available
Events
Arrival: denotes aircraft arriving in air space of airport
Landed: denotes aircraft landing
Departure: denotes aircraft leaving

Arrival Events
Arrival Event:
InTheAir := InTheAir+1;
Schedule Arrival event @ Now + RandExp(A);
If (RunwayFree) {
RunwayFree:=FALSE;
Schedule Landed event @ Now + RandExp(L);
}
A: mean interarrival time of incoming aircraft
Now: current simulation time
InTheAir: number of aircraft landing or waiting to land
OnTheGround: number of landed aircraft
RunwayFree: Boolean, true if runway available
Arrival Process: New aircraft arrives at airport.
If the runway is free, it will begin to land.
Otherwise, the aircraft must circle, and wait to land.
Landed Event
Landed Event:
InTheAir:=InTheAir-1;
OnTheGround:=OnTheGround+1;
Schedule Departure event @ Now + RandExp(G);
If (InTheAir>0)
Schedule Landed event @ Now + RandExp(L);
Else
RunwayFree := TRUE;
L = mean time runway is used for each landing aircraft
G = mean time required on the ground before departing
Now: current simulation time
InTheAir: number of aircraft landing or waiting to land
OnTheGround: number of landed aircraft
RunwayFree: Boolean, true if runway available
Landing Process: An aircraft has completed its landing.
Departure Event
Departure Event:
OnTheGround := OnTheGround - 1;
Departure Process: An aircraft now on the ground departs for a
new destination.
Now: current simulation time
InTheAir: number of aircraft landing or waiting to land
OnTheGround: number of landed aircraft
RunwayFree: Boolean, true if runway available
Execution Example
OnTheGround
Simulation Time
State Variables
RunwayFree
InTheAir
0 1 2 3 4 5 6 7 8 9 10 11
true
0
0
L=3 G=4
Time Event
1 Arrival F1
3 Arrival F2
Now=0
Processing:
false
1
Time Event
4 Landed F1
3 Arrival F2
Arrival F1
Now=1
2
Time Event
4 Landed F1
Arrival F2
Now=3
1
1
Landed F1
Now=4
Time Event
8 Depart F1
7 Landed F2
0
2
true
Time Event
8 Depart F1
11 Depart F2
Landed F2
Now=7
1
Time Event
11 Depart F2
Depart F1
Now=8
0
Time Event
Depart F2
Now=11
Output Statistics
Compute
The maximum number of aircraft that will be on the ground at one time
Average time an aircraft must wait before they are allowed to land

Solution
Maximum on ground
OnTheGround: indicate the number of aircraft currently on ground
Maximum on the ground = Max (OnTheGround).
Average Waiting time
Compute the Waiting time for each aircraft: Wi = Arrival time Landing Time
Compute the total sum of all waiting times: W
total
= sum(W
i
)
Compute the total number of aircraft: N
total
Compute the average waiting time: W
avg
= W
total
/sum(W
i
)

Summary
Methodology
Important to have a reasonably clear conceptual and
specification model before moving to implementation
(computational model)
Key concepts: state variables and changes in state
Simulation engine: largely independent of application
Simulation model: state variables and code to modify state
Time stepped vs. event driven execution
In principle, either can be used to model system
Discrete-event simulation approach more commonly used to
model queuing systems
War gaming: test
strategies; training
Flight Simulator
Transportation systems:
improved operations;
urban planning
Computer communication
network: protocol design
Parallel computer systems:
developing scalable software
Games
A few more applications
Why Modeling and Simulation?
Why to use models?
Implementation on real systems is very complex and costly,
Experimentation on real systems may be dangerous (e.g. chemical
systems)
If models adequately describes the reality, experimenting with
them can save money and time, and reduce the development
complexity
When to use simulations?
Analytic models may be very complex to evaluate, and may lead
to over implication of the real system
Simulation can be a good alternative to evaluate the system
behavior very close to reality

PERFORMANCE EVALUATION
Performance Metrics
The delay metric
how much time do I need to wait?
The throughput metric
how much customer the system is able to serve per time unit?
Performance Metrics
The Queuing Times





Queue
Server
Queuing System
Queuing Time Service Time
Response Time (or Delay)
The Performance Metric is a measurable quantity
that precisely captures what we want to measure
(response time, throughput, delay, etc.).
Performance Metrics
For example, in computer systems, we might
evaluate
The response time of a processor to execute a
given task.
The execution time of two programs in a multi-
processor machine.
In network systems, we might evaluate
The (maximum/average) delay experienced by a
voice packet to reach the destination
The throughput of the network
The required bandwidth to avoid congestion
Performance Metrics
What does affect the
performance?
The performance of a system is dramatically affected by the Workload.
The Workload: it characterizes the
Quantity: e.g. number of cars
Nature: type of cars (cars, trucks,
motocycle, etc.)
In the context of Web Servers, system
inputs are http requests (GET or POST
requests). The workload characterizes:
The intensity of the requests: how many
requests are received by the web server.
High intensities deteriorate the
performance.
The nature of the requests: the request can
be simple GET request or a request that
require the access of a remote database.
The performance will be different for
different request types.
What does affect the
performance?
Benchmarks
Benchmarks: used to generate loads that is intended to
mimic a typical user behaviour.
Wikipedia definition:
In computing, a benchmark is the act of running a computer
program, a set of programs, or other operations, in order to
assess the relative performance of an object, normally by
running a number of standard tests and trials against it.
Benchmarking is usually associated with assessing
performance characteristics of computer hardware:
Example: the floating point operation performance of a CPU.
Software benchmarks: run against compilers or database
management systems.

CS433: Modeling and Simulation
Dr. Anis Kouba
Al-Imam Mohammad Ibn Saud University

02 October 2010
Lecture 02: Modeling
0
0.05
0.1
0.15
0.2
0.25
0 0.2 0.4 0.6 0.8 1 1.2
W
(
s
e
c
)

()
Waiting vs. Utilization
Deterministic Performance
Using Network Calculus
Queueuing System
Stochastic Performance
Using Queueing Theory
Example: Deterministic vs.
Stochastic
Define goals, objectives of study
Develop conceptual model
Develop specification of model
Develop computational model
Verify model
Validate model
Fundamentally an
iterative process
Model Development Lifecycle
Determine Goals and Objectives
What do you want to do with the model?
It may be an end in itself
More often, it is a means to an end
Goals may not be known when you start the project!
One often learns things along the way
Develop Conceptual Model
An abstract representation of the system
What should be included in model? What can be left out?
What abstractions should be used? What is the level of details?
Appropriate choice depends on the purpose of the model

Model Development Lifecycle
Develop Specification Model
A more detailed specification of the model including more specifics
Collect data to populate model
Example:
Traffic: Road geometry, signal timing, expected traffic demand, driver behavior
Communication: network topology, message type, inter-arrival time, data rates
Empirical data or probability distributions often used
Develop a Computational Model
Executable simulation model
Software approach
General purpose programming language
Special purpose simulation language
Other (non-functional) requirements
Performance
Interoperability with other models/tools/data

Model Development Lifecycle
Verification
Did I Build the Model Right?
Does the computational model match the specification model?
Debugging: checking if the program contains any programming errors.
Verification is different from Validation: (see model validation)!
Validation
Did I Build the Right Model?
Does the computational model match the actual (or envisioned) system?
Typically, the validation of a simulation model can be done by comparing
Measurements of actual system
An analytic (mathematical) model of the system
Another simulation model
By necessity, validation is always an incomplete activity!
Often can only validate portions of the model
If you can validate the simulation with 100% certainty, why build the simulation?
Model Development Lifecycle
Example: Airport Check-in Desk
Queuing
We consider flight check-in desks in an Airport. The administration of the airport
wants to improve its quality of service by reducing the waiting time of travelers.
For that purpose, they want to design what could be the best queuing strategy to
have the minimum waiting time.
The main problem is to know what is the best queuing strategy that reduces the
waiting time of travelers in check-in desks.
Step. 1. Define the objectives of the
study
Main Objective: what is the best queuing strategy
that reduces the waiting time of travelers in check-in
desks.
Find a model that enables to compute waiting time of
travelers
Solution 1. Queueing Theory (Analytical Model)
Solution 2. Simulation (Computer Program Model)
Two Possible Models

Model 1 Model 2
Step. 2. Develop Conceptual Model
One Queue
N=3 servers
Three Queues
N=3 servers
Model 1 Model 2
Customers: travelers that arrive to the check-in desk
Servers: represents the agent (officer) that makes the flight
registration
What are the elements of the system?
Step. 3. Develop Specification
Model
One Queue:
Length= 60 Travelers
N=3 Agents
Service rate: 30
travelers/hour
Travelers arrive with a rate
1 travelers/minute
Model 1 Model 2
What are the characteristics of the elements of the system?
Three Queue:
Length= 20 Travelers/Queue
N=3 Agents
Service rate: 30 travelers/hour
Travelers arrive with a rate 1
travelers/minute
Travelers choose a queue with a probability
of 1/3.
Step. 4. Develop Computation
Model
Model 1 Model 2
Analytical Model: Queueing Theory
( )
( )
1
1
2 6 minutes Delay Model

= =

( )
( )
0
2
1 26
( 1) 2.88 minutes
! 9
1
N
N
Delay Model N
N

t


| |
= + = = |
|

\ .
Model 1 is better than Model 2 because it has lower delay
Step. 4. Develop Computation
Model
Model 1 Model 2
Simulation Model: Arena
Model 1 is better than Model 2 because it has lower delay
( )
2 5.86 minutes Delay Model =
( 1) 2.93 minutes Delay Model =
Step. 4. Develop Computation
Model
Simulation Model: Arena
Simulation Tools
Symbolic versus numerical; Open and closed
loop
Software package
Mathematica
Simscript
Scilab
Mathcad
References
Dr. Anis Kouba, CS433: Modeling and Simulation
(http://coins.csrlab.org/imamu/akoubaa/cs433/)
ref

Potrebbero piacerti anche