Documentos de Académico
Documentos de Profesional
Documentos de Cultura
... ...
arrivals unlimited # of waiting positions server
2. Structure of a simulator
We have the following components:
• simulation engine (core);
• a collection of models (link, buffer, etc.);
• frontend (interface);
• preprocessing tools (hidden for a user);
• data postprocessing tools.
Discrete simulations:
• system is observed at discrete times t0 , t0 + ∆t, t0 + 2∆t, . . . .
Discrete-event
t0 t1 t3
Discrete
t0 t1 t2 t3 t4 t5
Continuous
...
t0 t1 t2 t3 t4 t5 t6 t7
E1 E2 E3 Ei
... ...
T1 T2 T3 Ti
t0 t1 t2 t3 t4 t5
event advance:
t0 t1 t3
Example: find the smallest element and its index in array E[i], i = 0, 1, . . . , N − 1:
• variable smallest returns the smallest element;
• variable index returns the index of the smallest element.
smallest = E[0];
index = 0;
Advantages:
• insertion and deletion are made very easily;
• location of the next event depend on the number of event types:
– complexity is linear in time.
Shortcoming:
• if the number of event types is large location is time consuming;
• in this case different organization of the future event list should be considered.
Notes:
• must be long enough to accommodate all events that might be generated;
• all unused nodes must be linked together to form a pool of free nodes.
4. Data collection
How to carry out a simulation:
• set the initial state;
• start the simulation;
• obtain simulation results for some time...
We distinguish between:
• transient simulations (results for warm-up period);
• steady-state simulation (results for steady-state period).
N(t)
warm-up
steady-state
TW T t
M/M/1
0 1 lambda/mu
Note: interval [Ê[X] − zα/2 √sN , Ê[X] + zα/2 √sN ] is 100(1 − α)% confidence interval for µ.
a a
2 2
batch 1
batch 2
batch 3
batch k
...
TW time
Do the following:
• let Ê[Xi ] be the sample mean of the batch i, i = 1, 2, . . . , k;
• if b is large: Ê[X1 ], Ê[X2 ], . . . , Ê[Xk ] are approximately uncorrelated and normally distributed.
Given that Ê[X1 ], Ê[X2 ], . . . , Ê[Xk ] are uncorrelated and normally distributed:
k
1X
Ê[X] = Ê[Xi ],
k i=1
k
2 1 X
ŝ = (Ê[Xi ] − Ê[X])2 . (6)
k − 1 i=1
(X11 , X12 , . . . , X1m ), (X21 , X22 , . . . , X2m ), . . . , (Xn1 , Xn2 , . . . , Xnm ). (8)
• for each sample compute the sample mean using point estimator of the mean:
n
1 X
Ê[Xi ] = x (9)
m j=1
Classic problems:
• determine the length of each simulation run;
• determine the length of the transient period.
Where it is used:
• simulation of queue-related problems.
How to estimate:
• the transient state depends on initial conditions;
• the only way to get independent realizations of X is to use method of replications;
Repeating experiments:
• must start with the same initial condition;
• must use different random numbers (different seeds);
• we have to know the length of transient period.
7. Network simulators
Free simulators
• ns2/ns3: www.isi.edu/nsnam/ns;
• OMNET++: www.omnetpp.org
• QualNet: www.scalable-networks.com
• ITGuru: www.opnet.com
Commercial:
• OPNET: www.opnet.com
• a plenty of others....
8. ns2 Overview
Characteristics:
• discrete-event engine;
• network simulator;
• basically TCP/IP networks;
• wired and wireless components included.
Intended usage:
• research;
• development;
• education.
Developing:
• research institutes and universities;
• freely distributed and open source.
8.2. Components
ns2 distribution consists of:
• ns2 itself;
• nam: Network AniMator
– visualizing ns2 output;
– GUI for simple scenarios.
• Mandatory support tools:
– tcl/tk: script language
– otcl: object-oriented tcl;
– TclCL: tcl library.
• Pre-processing tools:
– traffic, topology generators, converters.
• Post-processing tools:
– trace analysis: awk, sed, perl, tcl.
– very simple and not recommended.
8.3. Installation
Differs for:
• Unix/Linux;
• Windows.
Two types are available:
• Via compilation;
– get ’all-in-one package’;
– get pieces and then compile.
• Obtaining binaries.
– easiest way to run on Win platform.
Hints and notes:
• to compile on Windows you need Cygwin (Unix emulation);
• Size of ’all-in-one’ is around 320Mb (v2.29).
8.4. Support
Documentation:
• mailing list: ns-users@isi.edu
– to get in send message to the address with ”subscribe ns-users” in the body;
– to browse archive go to http://www.isi.edu/nsnam/ns/.
• ns manual:
– available at http://www.isi.edu/nsnam/ns/;
– is only a short reference guide.
• tutorials:
– a number is available on http://www.isi.edu/nsnam/ns/;
– FAQ: http://www.isi.edu/nsnam/ns/ns-faq.html;
– de-facto tutorial: http://www.isi.edu/nsnam/ns/tutorial/index.html;
– installation and bug fixes: http://www.isi.edu/nsnam/ns/ns-problems.html;
– E. Altman, T. Jimenez: http://www-sop.inria.fr/maestro/personnel/Eitan.Altman/ns.htm.
9. Ns 2 architecture
Object-oriented structure:
• advantage: code reuse;
• shortcomings: performance.
Software structure:
• uses two languages to separate control and processing:
– C++: packet processing;
– Otcl: control.
• Packet processing:
– C++ makes it fast and detailed;
– C++ makes it scalable.
• Control:
– Otcl makes it easy to create scenarios;
– Otcl makes it easy to understand third party scripts.
Tcl contains:
• lists, arrays, associative arrays etc.;
• procedures and functions;
• flow controls: if, while, for, etc.
In one command:
• $ns create-connection <src type> <src node> <dst type> <dst node> <packet class>;
• example: $ns create-connection UDP $n0 Null $n1 1.
Other sources:
• TCP (we will consider);
• RTP source, RTCP source.
• TCP for wireless links.
In one command:
• $ns create-connection <src type> <src node> <dst type> <dst node> <packet class>;
• example: $ns create-connection TCP $n0 TCPSink $n1 1.
Some included TCP versions:
• TCP: Tahoe TCP (slow start and AIMD);
• TCP/Reno: Reno TCP (... + fast retransmit/fast recovery);
• TCP/NewReno: TCP Reno with improved fast retransmit;
• TCP/Sack: TCP SACK (Selective ACK).
Connecting to transport:
• $udp defined earlier;
• $src attach-agent $udp.
For example: there is converter for MPEG frame size file to ns2.
Telnet:
• set telnet [new Application/Telnet];
• attaching to TCP: $telnet attach-agent $tcp.
10.8. Tracing
Trace packets on all links of the network:
• $ns trace-all [open test.out w].
Tracing on specific links:
• $ns trace-queue $n0 $n1.
10.9. Monitoring
Queue monitor:
• set qmon [$ns monitor-queue $n0 $n1];
• for packet arrivals and drops:
– set parr [$qmon set parrivals ];
– set drops [$qmon set pdrops ].
Flow monitor:
• enable flow monitoring:
– set fmon [$nssim makeflowmon Fid];
– $nssim attach-fmon [$nssim link $n0 $n1] $fmon.
• count arrivals and drops for flow with id xx:
– set fclassifier [$fmon classifier];
– set flow1 [$fclassifier lookup auto 0 0 xx];
– set parr [$flow1 set parrivals ]; set pdrops [$flow1 set pdrops ].
controls
node
link
packet
time
BODY
What is next:
• two UDP agents with CBR sources at n0 and n1;
• null agent at node n3.
Example: http://www.isi.edu/nsnam/ns/tutorial/examples/example2.tcl
13. Routing
Create 8 nodes:
for {set i 0} {$i < 7} {incr i} {
set n($i) [$ns node]
}
$ns rtproto DV
.
Example: http://www.isi.edu/nsnam/ns/tutorial/examples/example3.tcl
ns at 50.0 ”node (1) setdest 25.0 20.0 15.0”: at 50.0s, it moves to (x=25,y=20) at 15m/s.