Académique Documents
Professionnel Documents
Culture Documents
OMNeT++
OMNeT++
Overview
OMNeT++
Discrete-Event Simulation (DES) kernel Multi-platform, Open Source Modular concept Pure C++ IDE (source code, configuration, , evaluation) optional GUI (simulation execution) optional
Model repositories
OverSim
Upper layers (Overlay networks)
MiXiM
Lower layers (, MAC, PHY)
[Car2X] Summer 2012 OMNeT++
MiXiM
2
Modeling Approach
Hierarchical, modular, object oriented,
Compound Module
Simple Module Simple Module Simple Module
Gate
OMNeT++
Modeling Approach
Compare to layered architecture
Application Transport Network Link Application Transport Network Link
Physical
Physical
OMNeT++
Example
OMNeT++
3.
Repeat
Scheduling events
send/sendDelayed: Send message via output gate
Event scheduled for delivery via connected modules input gate
Alice
Bob
[Car2X] Summer 2012 OMNeT++ 7
Simulation GUI
Event queue
OMNeT++
Separation of Concerns
Simulation components
Runtime parameters
omnetpp.ini
Structure
network description (NED) (plain text file) message format (MSG) (plain text file)
Behavior
C++ code
OMNeT++
Compound Module
import TicModule; import TocModule; module Watch { gates: input lightSwitch; output lcd; submodules: tic: TicModule; toc: TocModule; connections: tic.out --> toc.in; tic.in <-- toc.out; }
OMNeT++ 10
Network definition
network sim extends Watch { }
OMNeT++
11
OMNeT++
12
Packet encapsulation
IP Packet TCP Segment
OMNeT++
13
Runtime Parameters
Defining parameters
Nodes NED file
simple Node { parameters: int foo; double bar; }
Reading parameters
C++ source code
void Node::initialize() { int i = par(foo); double bar = par(bar); }
Setting parameters
omnetpp.ini file
[General] network = sim sim.node.foo = 42
[Car2X] Summer 2012 OMNeT++ 14
[General] sim.tic.tickRate = 42 sim.toc.tickRate = 42 # wildcards (first-match policy) sim.t[io]c.tickRate = 42 sim.*.tickRate = 42 *.*.tickRate = 42 **.tickRate = 42 **.tic.tickRate = intuniform(1, 12) **.tic.tickRate = ${FOO = 1, 5, 10} **.toc.tickRate = ${ 10, 5, 1 ! FOO}
OMNeT++
15
OMNeT++
16
Use of initialize/finish
constructor
set pointers to 0
initialize(int stage)
initialize pointers read parameters schedule messages
finish()
record statistics
destructor
cancel and delete messages free (owned) memory
[Car2X] Summer 2012 OMNeT++ 18
Enter of steady state: FSM_Switch returns Exit branch taken on next call
determines next state
[Car2X] Summer 2012
ONE
TWO
19
Executable Simulation
Results
OMNeT++
Running Simulations
With GUI
$ opp_run u Tkenv l /model-lib c Config1 r 0
Parameters
-u: user interface to load -l: model library to load -c: configuration section (= experiment) to read -r: run (= measurement and replication) to execute
OMNeT++
21
4 2 6 1 4 2 3 3 1
4 2 6 1 4 2 3 3 1
4 2 6 1 4 2 3 3 1
OMNeT++
22
4 2 6 1 4 2 3 3 1
4 2 6 1 4 2 3 3 1
4 6 4 3 1 2 1 2 3
OMNeT++
23
4 4 2 2 if (doBuf && !genk_intrand(2, 100) % 100) { 6 6 std::cout.flush(); 1 1 } 4 4 } 2 2 } 3 3 3 3 1 1 Default seed derived from run #
while (1) { int dice = intrand(6); std::cout << dice << \n;
4 2 6 1 4 2 3 3 1
OMNeT++
24
Accuracy judging
cADByStddev::setParameters( double acc=0.1, int reps=3)
[Car2X] Summer 2012
OMNeT++
25
OMNeT++
27
OMNeT++
28
Error Handling
ASSERT(7 < 42); if (7 >= 42) { this->error(this shouldnt have happened); opp_error(same); throw cRuntimeError(same); }
Error Handling
[General] debug-on-errors = true
OMNeT++
30
Documentation
NED and MSG files
// // Documentation // simple MyModule { parameters: int foo; // The Foo int bar; // The Bar gates: // Leave unconnected input in; }
C++ code
/** * Documentation */ class TicModule { public: int foo; int bar;
OMNeT++
31
OMNeT++
32
Pitfalls
Common and very common pitfalls
Use of pointer after send()
Pointer now owned by kernel; might have moved/destroyed data
OMNeT++
33