Computer Science, Informatik 4 Communication and Distributed Systems
Simulation Simulation
Modeling and Performance Analysis with Discrete-Event Simulation g y
- Dr. Mesut Güneş
1
Simulation Simulation Modeling and Performance Analysis with - - PowerPoint PPT Presentation
Computer Science, Informatik 4 Communication and Distributed Systems Simulation Simulation Modeling and Performance Analysis with Discrete-Event Simulation g y Dr. Mesut Gne 1 Computer Science, Informatik 4 Communication and
Computer Science, Informatik 4 Communication and Distributed Systems
Modeling and Performance Analysis with Discrete-Event Simulation g y
1
Computer Science, Informatik 4 Communication and Distributed Systems
Introduction to Network Simulators
2
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 3
Computer Science, Informatik 4 Communication and Distributed Systems
Network Simulator Tools Network Simulator Tools
Chapter 4. Introduction to Network Simulators 4
Computer Science, Informatik 4 Communication and Distributed Systems
h research.
and multicast protocols over wired and wireless (local and p ( satellite) networks.
package built on C++ foundations It offers a C++ simulation package built on C++ foundations. It offers a C++ simulation class library and GUI support (graphical network editing, animation).
Chapter 4. Introduction to Network Simulators 5
Computer Science, Informatik 4 Communication and Distributed Systems
event simulation in Java and C++. Several SSF implementations and a large number of open-source protocol models and other and a large number of open source protocol models and other components exist.
A C based sim lation lang age for seq ential and parallel
execution of discrete-event simulation models
and scalability, with real-time simulation as an achievable goal. y, g
simulation of communications networks devices and protocols
Chapter 4. Introduction to Network Simulators
simulation of communications networks, devices, and protocols. It features graphical editors and animation.
6
Computer Science, Informatik 4 Communication and Distributed Systems
that runs over a standard Java virtual machine. It is a prototype f l h t b ildi di t t
simulators, called virtual machine-based simulation, that unifies the traditional systems and language-based simulator designs. The resulting simulation platform is surprisingly efficient. It out- performs existing highly optimized simulation runtimes both in time and memory consumption. For example, JiST has twice the raw event throughput of the highly optimized, C-based Parsec engine, and supports process-oriented simulation using a fraction of the memory.” fraction of the memory.
Chapter 4. Introduction to Network Simulators 7
Computer Science, Informatik 4 Communication and Distributed Systems
several network simulators (ns2, SSFNet, OMNeT++).
p g pp g p p Parallel (MRIP) simulation technique to harness the computing power of a network of inexpensive workstations.
Chapter 4. Introduction to Network Simulators 8
Computer Science, Informatik 4 Communication and Distributed Systems
The Network Simulator, ns-2 The Network Simulator, ns 2
Chapter 4. Introduction to Network Simulators 9
Computer Science, Informatik 4 Communication and Distributed Systems
b t l t ft
infrastructure: stats, tracing, error models, etc.
j p g p
Chapter 4. Introduction to Network Simulators 10
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 11
Computer Science, Informatik 4 Communication and Distributed Systems
simulator for Internet systems targeted primarily for research simulator for Internet systems, targeted primarily for research and educational use. ns-3 is the next major revision of the ns-2
concatenation of ns (network simulator) and nam (network concatenation of ns (network simulator) and nam (network animator).”
Chapter 4. Introduction to Network Simulators 12
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 13
Computer Science, Informatik 4 Communication and Distributed Systems
(p p , ),
Chapter 4. Introduction to Network Simulators 14
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 15
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 16
Computer Science, Informatik 4 Communication and Distributed Systems
t D T il RED CBQ FQ SFQ DRR
Chapter 4. Introduction to Network Simulators 17
Computer Science, Informatik 4 Communication and Distributed Systems
i ht ft [ Si l t ]
type : CtrMcast, DM, ST, BST
Chapter 4. Introduction to Network Simulators 18
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 19
Computer Science, Informatik 4 Communication and Distributed Systems
$ tt h t $ 1 $ d t
Chapter 4. Introduction to Network Simulators 20
Computer Science, Informatik 4 Communication and Distributed Systems
$ tt h t $ 1 $td t
Chapter 4. Introduction to Network Simulators 21
Computer Science, Informatik 4 Communication and Distributed Systems
t l t [ A li ti /T l t]
Chapter 4. Introduction to Network Simulators 22
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 23
Computer Science, Informatik 4 Communication and Distributed Systems
inter packet time (msec) and packet size (byte)
Chapter 4. Introduction to Network Simulators 24
Computer Science, Informatik 4 Communication and Distributed Systems
correctness correctness
Chapter 4. Introduction to Network Simulators 25
Computer Science, Informatik 4 Communication and Distributed Systems
OMNeT++ OMNeT
Chapter 4. Introduction to Network Simulators 26
Computer Science, Informatik 4 Communication and Distributed Systems
http://www.omnetpp.org
http://www.omnetpp.org/doc/manual/usman.html
Chapter 4. Introduction to Network Simulators 27
Computer Science, Informatik 4 Communication and Distributed Systems
systems systems
is suitable.
Chapter 4. Introduction to Network Simulators 28
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 29
Computer Science, Informatik 4 Communication and Distributed Systems
y
p g
system module
compound module
simple module
compound module
simple module simple module
Chapter 4. Introduction to Network Simulators 30
simple module simple module simple module
Computer Science, Informatik 4 Communication and Distributed Systems
p
messages to each another
Module B Module D
functionality
C i ti b h i
Module A
messages via connections
Module C
general C++ stuff
Simulation Kernel are specified in the NED language Simulation Kernel
Chapter 4. Introduction to Network Simulators 31
Computer Science, Informatik 4 Communication and Distributed Systems
Describes beha ior of components
Containing general settings for the execution of the simulation
Chapter 4. Introduction to Network Simulators 32
Computer Science, Informatik 4 Communication and Distributed Systems
OMNeT++
OMNeT
Chapter 4. Introduction to Network Simulators 33
Computer Science, Informatik 4 Communication and Distributed Systems
suffix
Simple module definitions
Chapter 4. Introduction to Network Simulators 34
Computer Science, Informatik 4 Communication and Distributed Systems
Probability that a bit is incorrectly transmitted
Module Module
Chapter 4. Introduction to Network Simulators
Module A Module B
delay, error, datarate
35
Computer Science, Informatik 4 Communication and Distributed Systems
channel ChannelName //... endchannel
channel LeasedLine delay 0 0018 // sec delay 0.0018 // sec error 1e-8 datarate 128000 // bit per sec endchannel
Chapter 4. Introduction to Network Simulators 36
Computer Science, Informatik 4 Communication and Distributed Systems
(compound) modules.
i l Si l M d l N simple SimpleModuleName parameters: //... //... gates: //... endsimple
Chapter 4. Introduction to Network Simulators 37
Computer Science, Informatik 4 Communication and Distributed Systems
simulation program, e.g., in configuration files
method par(“name”)
input gates input gates.
Chapter 4. Introduction to Network Simulators 38
Computer Science, Informatik 4 Communication and Distributed Systems
simple TrafficGen Upper Layer
parameters: interArrivalTime, numOfMessages : const, address : string; address : string; gates: in: from_upper_layer, from_physical_layer;
TrafficGen
to_physical_layer;
endsimple Physical Layer
Chapter 4. Introduction to Network Simulators 39
Computer Science, Informatik 4 Communication and Distributed Systems
pp
i l i simple RoutingModule parameters: // ... gates: in: input[];
endsimple endsimple
type
Chapter 4. Introduction to Network Simulators
Every instance of the module can have gate vectors of different sizes
40
Computer Science, Informatik 4 Communication and Distributed Systems
p
themselves.
Any module type (simple or compound module) can be used as a submodule.
parameters, and they can be used wherever simple modules can be p , y p used.
The top level module is the system module
system module
compound module
simple module
compound module
simple module simple module
Chapter 4. Introduction to Network Simulators
simple module simple module simple module
41
Computer Science, Informatik 4 Communication and Distributed Systems
g
Chapter 4. Introduction to Network Simulators 42
Computer Science, Informatik 4 Communication and Distributed Systems
module CompoundModul parameters: … gates: … submodules: … ti connections: endmodule
Chapter 4. Introduction to Network Simulators 43
Computer Science, Informatik 4 Communication and Distributed Systems
module Router parameters: packetsPerSecond : numeric, bufferSize : numeric, numOfPorts : const; gates: in: inputPort[];
submodules: //... connections: //... endmodule
Chapter 4. Introduction to Network Simulators 44
Computer Science, Informatik 4 Communication and Distributed Systems
“submodules:” section of a compound module declaration
y
module CompoundModule
either simple or compound
submodules: submodule1: ModuleType1 parameters: //...
parameters
gatesizes: //... submodule2: ModuleType2 parameters: //...
vectors
parameters: //... gatesizes: //... endmodule
Chapter 4. Introduction to Network Simulators 45
Computer Science, Informatik 4 Communication and Distributed Systems
module CompoundModule parameters: parameters: size: const; submodules: submod1: Node[3] // submod1: Node[3] //... submod2: Node[size] //... submod3: Node[2*size+1] //... endmodule endmodule
Chapter 4. Introduction to Network Simulators 46
Computer Science, Informatik 4 Communication and Distributed Systems
module CompoundModule parameters: //... gates: //...
g submodules: //... connections: node1.output --> node2.input; node1.input <-- node2.output;
p p sender.outGate --> rec.inGate; sender.inGate <-- Fiber <-- rec.outGate; //...
error rate or data rate)
endmodule
parent module parent module Module A Module B
Chapter 4. Introduction to Network Simulators 47
Computer Science, Informatik 4 Communication and Distributed Systems
( p p ) just define module types.
S t i i il t th t f b d l d l ti
Assign values to submodule parameters
network wirelessLAN: WirelessLAN parameters: numUsers=10, httpTraffic=true, ftpTraffic=true, p distanceFromHub=truncnormal(100,60); endnetwork
Chapter 4. Introduction to Network Simulators 48
Computer Science, Informatik 4 Communication and Distributed Systems
OMNeT++
OMNeT
Chapter 4. Introduction to Network Simulators 49
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 50
Computer Science, Informatik 4 Communication and Distributed Systems
' d ti ti d l message's destination module
Chapter 4. Introduction to Network Simulators 51
Computer Science, Informatik 4 Communication and Distributed Systems
g
simulation
Creating a message
S h d
g g ( g )
> tBitE ( )
Chapter 4. Introduction to Network Simulators 52
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 53
Computer Science, Informatik 4 Communication and Distributed Systems
id h dl ( * )
start time.
recording of statistics collected during simulation run recording of statistics collected during simulation run.
Chapter 4. Introduction to Network Simulators 54
Computer Science, Informatik 4 Communication and Distributed Systems
g ()
event processing strategies:
these functions.
message
interaction approach
Chapter 4. Introduction to Network Simulators
pp
55
Computer Science, Informatik 4 Communication and Distributed Systems
// file: HelloModule.cc #include <omnetpp h> #include <omnetpp.h> class HelloModule : public cSimpleModule { t t d protected: virtual void initialize(); virtual void handleMessage(cMessage *msg); }; // register module class with OMNeT++ Define_Module(HelloModule); void HelloModule::initialize() { ev << "Hello World!\n"; } void HelloModule::handleMessage(cMessage *msg) { delete msg; // just discard everything we receive
Chapter 4. Introduction to Network Simulators 56
delete msg; // just discard everything we receive }
Computer Science, Informatik 4 Communication and Distributed Systems
cancelEvent()
Chapter 4. Introduction to Network Simulators 57
Computer Science, Informatik 4 Communication and Distributed Systems
Chapter 4. Introduction to Network Simulators 58
Computer Science, Informatik 4 Communication and Distributed Systems
message
Chapter 4. Introduction to Network Simulators 59
Computer Science, Informatik 4 Communication and Distributed Systems
OMNeT++
OMNeT
Chapter 4. Introduction to Network Simulators 60
Computer Science, Informatik 4 Communication and Distributed Systems
i d l t
documenting the programmer s assumptions using ASSERT()
Chapter 4. Introduction to Network Simulators 61
Computer Science, Informatik 4 Communication and Distributed Systems
// file: FFGenerator.h #include <omnetpp.h> /** * Generates messages or jobs; see NED file for more info * Generates messages or jobs; see NED file for more info. */ class FFGenerator : public cSimpleModule { private: p cMessage *sendMessageEvent; long numSent; public: FFGenerator(); virtual ~FFGenerator(); protected: virtual void initialize(); virtual void handleMessage(cMessage *msg);
Chapter 4. Introduction to Network Simulators
g g g virtual void finish(); };
62
Computer Science, Informatik 4 Communication and Distributed Systems
// file: FFGenerator.cc #include "FFGenerator.cc" // Register module class with OMNeT++ Define Module(FFGenerator); Define_Module(FFGenerator); FFGenerator::FFGenerator() { sendMessageEvent = NULL; } void FFGenerator::initialize() { numSent = 0; sendMessageEvent = new cMessage("sendMessageEvent"); sendMessageEvent = new cMessage( sendMessageEvent ); scheduleAt(0.0, sendMessageEvent); }
Chapter 4. Introduction to Network Simulators 63
Computer Science, Informatik 4 Communication and Distributed Systems
void FFGenerator::handleMessage(cMessage *msg) { ASSERT(msg==sendMessageEvent); cMessage *m = new cMessage("packet"); m->setLength(par("msgLength")); send(m "out"); send(m, "out"); numSent++; double deltaT = (double)par("sendIaTime"); ( )p ( ) scheduleAt(simTime()+deltaT, sendMessageEvent); } void FFGenerator::finish(){ recordScalar("packets sent", numSent); } FFGenerator::~FFGenerator(){ cancelAndDelete(sendMessageEvent); }
Chapter 4. Introduction to Network Simulators 64
Computer Science, Informatik 4 Communication and Distributed Systems
// file: FFGenerator.ned simple FFGenerator parameters: sendIaTime: numeric; gates: gates:
endsimple
Chapter 4. Introduction to Network Simulators 65
Computer Science, Informatik 4 Communication and Distributed Systems
simple Node gates: in: inPort; module Network submodules: nodeA: Node; d B N d
endsimple nodeB: Node; connections: nodeA.outPort --> nodeB.inPort; nodeA.inPort <-- nodeB.outPort;
Chapter 4. Introduction to Network Simulators 66
endmodule
Computer Science, Informatik 4 Communication and Distributed Systems
AChannel AChannel
channel AChannel delay 0.0015 error 0.000001
module Network submodules: nodeA: Node; nodeB: Node;
datarate 1000000 endsimple
; connections: nodeA.outPort --> AChannel --> nodeB.inPort; nodeA.inPort <-- Achannel <-- nodeB.outPort; endmodule
Chapter 4. Introduction to Network Simulators 67
Computer Science, Informatik 4 Communication and Distributed Systems
OMNeT++
OMNeT
Chapter 4. Introduction to Network Simulators 68
Computer Science, Informatik 4 Communication and Distributed Systems
nmake f Makefile.vc
Chapter 4. Introduction to Network Simulators 69
Computer Science, Informatik 4 Communication and Distributed Systems
style style
Chapter 4. Introduction to Network Simulators 70