Simulation Tutorial By Bing Wang Assistant professor, CSE Department, University of Connecticut Web site.

Slides:



Advertisements
Similar presentations
Based on Law & Kelton, Simulation Modeling & Analysis, McGraw-Hill
Advertisements

Simulating Single server queuing models. Consider the following sequence of activities that each customer undergoes: 1.Customer arrives 2.Customer waits.
Ns-2 tutorial Karthik Sadasivam Banuprasad Samudrala CSCI 5931 Network Security Instructor : Dr. T. Andrew Yang.
Modeling & Simulation. System Models and Simulation Framework for Modeling and Simulation The framework defines the entities and their Relationships that.
Statistics review of basic probability and statistics.
 1  Outline  terminating and non-terminating systems  analysis of terminating systems  generation of random numbers  simulation by Excel  a terminating.
Sampling Distributions (§ )
 1  Outline  Model  problem statement  detailed ARENA model  model technique  Output Analysis.
Output analyses for single system
Simulation Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2003) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
Output Analysis and Experimentation for Systems Simulation.
ECS 152A Acknowledgement: slides from S. Kalyanaraman & B.Sikdar
Performance Analysis and Monitoring Facilities in CPN Tools Tutorial CPN’05 October 25, 2005 Lisa Wells.
Fall 2006 – Fundamentals of Business Statistics 1 Chapter 6 Introduction to Sampling Distributions.
Lecture 9 Output Analysis for a Single Model. 2  Output analysis is the examination of data generated by a simulation.  Its purpose is to predict the.
Variance Reduction Techniques
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 Introduction to Simulation Shiv Kalyanaraman Rensselaer Polytechnic Institute
4. Review of Basic Probability and Statistics
1 Simulation Modeling and Analysis Output Analysis.
Lab 01 Fundamentals SE 405 Discrete Event Simulation
Cmpt-225 Simulation. Application: Simulation Simulation  A technique for modeling the behavior of both natural and human-made systems  Goal Generate.
COMPUTER NETWORK: MODELING AND SIMULATION -Abhaykumar Kumbhar Computer Science Department.
Model and tools. Traffic Model Poisson law – Napoléon worries about the statistics of horse accidents of his generals – Poisson confirms these are unfrequent.
Analysis of Simulation Results Andy Wang CIS Computer Systems Performance Analysis.
Simulation Output Analysis
(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.
Simulation Examples ~ By Hand ~ Using Excel
1 Performance Evaluation of Computer Networks: Part II Objectives r Simulation Modeling r Classification of Simulation Modeling r Discrete-Event Simulation.
SIMULATION MODELING AND ANALYSIS WITH ARENA
Steady-State Statistical Analysis By Dr. Jason Merrick.
Verification & Validation
The University of Texas at Arlington Topics in Random Processes CSE 5301 – Data Modeling Guest Lecture: Dr. Gergely Záruba.
1 Introduction to Estimation Chapter Concepts of Estimation The objective of estimation is to determine the value of a population parameter on the.
MS 305 Recitation 11 Output Analysis I
MIT Fun queues for MIT The importance of queues When do queues appear? –Systems in which some serving entities provide some service in a shared.
© 2003, Carla Ellis Simulation Techniques Overview Simulation environments emulation exec- driven sim trace- driven sim stochastic sim Workload parameters.
Analysis of Simulation Results Chapter 25. Overview  Analysis of Simulation Results  Model Verification Techniques  Model Validation Techniques  Transient.
0 K. Salah 2. Review of Probability and Statistics Refs: Law & Kelton, Chapter 4.
TexPoint fonts used in EMF.
Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast.
1 Network Simulator Tutorial. 2 Network Simulation * Motivation: Learn fundamentals of evaluating network performance via simulation Overview: fundamentals.
1 Chapters 8 Overview of Queuing Analysis. Chapter 8 Overview of Queuing Analysis 2 Projected vs. Actual Response Time.
Chapter 2 – Fundamental Simulation ConceptsSlide 1 of 46 Chapter 2 Fundamental Simulation Concepts.
SIMULATION OF A SINGLE-SERVER QUEUEING SYSTEM
Interconnect simulation. Different levels for Evaluating an architecture Numerical models – Mathematic formulations to obtain performance characteristics.
Interconnect simulation. Different levels for Evaluating an architecture Numerical models – Mathematic formulations to obtain performance characteristics.
Simulation & Confidence Intervals COMP5416 Advanced Network Technologies.
1 Introduction to NS-2 r Tutorial overview of NS m Create basic NS simulation r Walk-through a simple example m Model specification m Execution and trace.
Network Simulation Motivation: r learn fundamentals of evaluating network performance via simulation Overview: r fundamentals of discrete event simulation.
1 OUTPUT ANALYSIS FOR SIMULATIONS. 2 Introduction Analysis of One System Terminating vs. Steady-State Simulations Analysis of Terminating Simulations.
Network Simulator Tutorial Wireless Networks. Acknowledgements Material is taken from the presentations by Jim Kurose, University of Massachusetts, Amherst.
OPERATING SYSTEMS CS 3530 Summer 2014 Systems and Models Chapter 03.
Review Session Jehan-François Pâris. Agenda Statistical Analysis of Outputs Operational Analysis Case Studies Linear Regression.
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
 Simulation enables the study of complex system.  Simulation is a good approach when analytic study of a system is not possible or very complex.  Informational,
Simulation. Types of simulation Discrete-event simulation – Used for modeling of a system as it evolves over time by a representation in which the state.
Evaluating Hypotheses. Outline Empirically evaluating the accuracy of hypotheses is fundamental to machine learning – How well does this estimate its.
Ch 1: Simulation of Computer Networks. 1.1 Computer Networks and the Layering Concept Layering Concept Service Interface Protocol.
K. Salahpp.1 Chapter 9 Output Analysis for Single Systems.
Variance reduction techniques Mat Simulation
Confidence Intervals Cont.
Sampling Distributions and Estimation
Introduction to ns-2: “The” Network Simulator
Karthik Sadasivam Banuprasad Samudrala
Computer Systems Performance Evaluation
Computer Systems Performance Evaluation
Where real stuff starts
Modeling and Simulation: Exploring Dynamic System Behaviour
Presentation transcript:

Simulation Tutorial By Bing Wang Assistant professor, CSE Department, University of Connecticut Web site

Network Simulation Motivation: r learn fundamentals of evaluating network performance via simulation Overview: r fundamentals of discrete event simulation r analyzing simulation outputs r ns-2 simulation

The evaluation spectrum numerical models simulation emulation prototype operational system

What is simulation? system under study (has deterministic rules governing its behavior) exogenous inputs to system (the environment) system boundary observer “real” life computer program simulates deterministic rules governing behavior pseudo random inputs to system (models environment) program boundary observer “simulated” life

Why Simulation? r goal: study system performance, operation r real-system not available, is complex/costly or dangerous (eg: space simulations, flight simulations) r quickly evaluate design alternatives (eg: different system configurations) r evaluate complex functions for which closed form formulas or numerical techniques not available

Simulation: advantages/drawbacks r advantages: r drawbacks/dangers:

Programming a simulation What ‘s in a simulation program? r simulated time: internal (to simulation program) variable that keeps track of simulated time r system “state”: variables maintained by simulation program define system “state” m e.g., may track number (possibly order) of packets in queue, current value of retransmission timer r events: points in time when system changes state m each event has associated event time e.g., arrival of packet to queue, departure from queue precisely at these points in time that simulation must take action (change state and may cause new future events) m model for time between events (probabilistic) caused by external environment

Discrete Event Simulation r simulation program maintains and updates list of future events: event list r simulator structure: initialize event list get next (nearest future) event from event list time = event time process event (change state values, add/delete future events from event list update statistics done? n Need: r well defined set of events r for each event: simulated system action, updating of event list y

Simulation: example  packets arrive (avg. interrarrival time: 1/ ) to router (avg. execution time 1/  ) with two outgoing links  arriving packet joins link i with probability  i   r state of system: size of each queue r system events: m job arrivals m service time completions r define performance measure to be gathered

Simulation: example   Simulator actions on arrival event r choose a link m if link idle {place pkt in service, determine service time (random number drawn from service time distribution) add future event onto event list for pkt transfer completion, set number of pkts in queue to 1} m if buffer full {increment # dropped packets, ignore arrival} m else increment number in queue where queued r create event for next arrival (generate interarrival time) stick event on event list

Simulation: example   Simulator actions on departure event r remove event, update simulation time, update performance statistics r decrement counter of number of pkts in queue r If (number of jobs in queue > 0) put next pkt into service – schedule completion event (generate service time for put)

Gathering Performance Statistics r avg delay at queue i: record D ij : delay of customer j at queue i. Let N i be # customers passing through queue i r average queue length at i: total simulated time  throughput at queue i,  i = Little’s Law

Analyzing Output Results Each time we run a simulation, (using different random number streams), we will get different output results! distribution of random numbers to be used during simulation (interarrival, service times) random number sequence 1 simulation output results 1 input output random number sequence 2 simulation output results 2 input output random number sequence M simulation output results M input output …

Analyzing Output Results r W 2,n : delay of nth departing customer from queue 2  

Analyzing Output Results r each run shows variation in customer delay r one run different from next r statistical characterization of delay must be made m expected delay of n-th customer m behavior as n approaches infinity m average of n customers  

Transient Behavior r simulation outputs that depend on initial condition (i.e., output value changes when initial conditions change) are called transient characteristics m “early” part of simulation m later part of simulation less dependent on initial conditions  

Effect of initial conditions r histogram of delay of 20 th customer, given initially empty (1000 runs) r histogram of delay of 20 th customer, given non-empty conditions (1000 runs)

Simulation: example  packets arrive (avg. interrarrival time: 1/ ) to router (avg. execution time 1/  ) with two outgoing links  arriving packet joins link i with probability  i  

Steady state behavior r output results may converge to limiting “steady state” value if simulation run “long enough” r discard statistics gathered during transient phase, e.g., ignore first n 0 measurements of delay at queue 2 avg delay of packets [n, n+10] pick n 0 so statistic is “approximately the same” for different random number streams and remains same as n increases avg of 5 simulations

Example: Random Waypoint Model Simplest random waypoint model: r mobile picks next waypoint M n uniformly in area, independent of past and present r mobile picks next speed V n uniformly in [v min ; v max ] independent of past and present r mobile moves towards M n at constant speed V n MnMn M n+1

Issue with RWP Model: Decay r Distributions of node speed, position, distances, etc change with time 100 users average 1 user Time (s) Speed (m/s)

Confidence Intervals r run simulation: get estimate X 1 as estimate of performance metrics of interest r repeat simulation M times (each with new set of random numbers), get X 2, … X M – all different! r which of X 1, … X M is “right”? r intuitively, average of M samples should be “better” than choosing any one of M samples How “confident” are we in X?

Confidence Intervals  cannot get perfect estimate of true mean, , with finite # samples r look for bounds: find c1 and c2 such that: Probability(c1 <  < c2) = 1 –   c1,c2  confidence interval 100(1-  ): confidence level

Confidence Intervals: Central Limit Thm  Central Limit Theorem: If samples X 1, … X M independent and from same population with population mean  and standard deviation  then is approximately normally distributed with mean u and standard deviation sample mean:

Confidence Intervals.. more r don’t know population standard deviation; estimate it using sample (observed) standard deviation:  given we find upper and lower tails of normal distributions containing  100% of mass

Confidence Intervals.. the recipe Given samples X 1, …, X M, (e.g., having repeated simulation M times), compute 95% confidence interval:

Interpretation of Confidence Interval If we calculate confidence intervals as in recipe, 95% of confidence intervals thus computed will contain true (unknown) population mean.

Generating confidence intervals for steady state measures r independent replications with deletions r method of batch means r autoregressive method r regenerative method

Independent replications 1. generate n independent replications with m samples, remove first l 0 samples from each to obtain 2. calculate sample mean and variance from 3. use t-distribution to compute confidence intervals 4. can combine with sequential stopping rule to obtain confidence interval of specified width.

0ther methods r batch means: take single run, delete first l 0 observations, divide remainder into n groups and obtain X i for i-th, i = 1,…,n m follow procedure for independent replications m complication due to nonindependence of X i s m potential efficiency due to deletion of only l 0 observation r autoregressive method: spectrum analysis: based on study of correlation of observations

r regenerative method: applicable to systems with regeneration points m regeneration point  future independent of past m can construct observations for intervals between regeneration points that will be iid m use of CLT provides confidence intervals

Comparing two different systems Example: want to compare mean response times of two queues where arrival process remains unchanged but speed of servers are different. r run each system n times (n sufficiently large) to get {X 1,j } and {X 2,j } and take Z j = (X 1,j,X 2,j ) as the observations to determine confidence intervals for r method of common random number m using the same streams to generate rvs for j-th runs of both systems usually results in smaller sample variance of {Z j }

ns-2, the network simulator r discrete event simulator r modeling network protocols m wired, wireless, satellite m TCP, UDP, multicast, unicast m web, telnet, ftp m ad hoc, sensor nets m infrastructure: stats, tracing, error models, etc. r prepackaged protocols and modules, or create your own Our goal: r flavor of ns: simple example, modification, execution and trace analysis

“ns” components r ns, the simulator itself (this is all we’ll have time for) r nam, the Network AniMator m visualize ns (or other) output m GUI input simple ns scenarios r pre-processing: m traffic and topology generators r post-processing: m simple trace analysis, often in Awk, Perl, or Tcl r tutorial: r ns by example: