OMNeT++ Tips

Computer and Communication Systems
(Lehrstuhl für Technische Informatik)
OMNeT++ Tips
Stefan Joerer, Bastian Bloessl,
Christoph Sommer and Falko Dressler
[NwSim] Winter 2012/2013
OMNeT++ Tips
1
Coding Guidelines
Interest on readability and maintainability, achievable by:
Short methods
Comments, where useful (doxygen comments appreciated)
Naming guidelines
Plain, simple English for names and comments
Constants and parameters instead of “magic numbers”
Class names start with an uppercase letter (e.g. Factory)
Use all-uppercase for constants (e.g. DEFAULT_DELAY)
All other names start with a lowercase letter
Constants
Use module parameters or static const class members
[NwSim] Winter 2012/2013
OMNeT++ Tips
2
Coding Guidelines
Our preferred code style:
Use tabs to indent lines
Use spaces everywhere else
Avoid inserting “hard” line breaks
If a line is too long to be readable, split it into multiple statements
Opening curly braces go at the end of the preceding line
Closing curly braces go on a line of their own
We use the following ~/.astylerc:
--suffix=none --style=kr --indent=tab --indent-switches
--indent-classes --unpad-paren --keep-one-line-statements
[NwSim] Winter 2012/2013
OMNeT++ Tips
3
Debugging
Use debugging options in omnetpp.ini
debug-on-errors = true
**.debug = true
**.coreDebug = true
Use watches of OMNeT++
WATCH(i);
WATCH_OBJ(cObject);
WATCH_PTR(cObject*);
WATCH_LIST(std::list<…>);
WATCH_RW(i);
Debugging tools
gdb for general debugging
valgrind for hunting memory leaks
[NwSim] Winter 2012/2013
OMNeT++ Tips
4
Example Experiment Design
Experiment 1: impact of broadcasting interval?
Measurement 1.1: broad cast interval = 0.1
Replication 1.1.1: random seeds 7, 34
Replication 1.1.2: random seeds 42, 25
Replication 1.1.3: random seeds 47, 9
Replication 1.1.4: random seeds 17, 67
Replication 1.1.5: random seeds 13, 87
(= run 0)
(= run 1)
(= run 2)
(= run 3)
(= run 4)
Measurement 1.2: broad cast interval = 0.2
…
(= run 49)
Experiment 2: impact of data generation interval?
Measurement 1.1: data generation interval = 1
Replication 1.1.1: random seeds 7, 34
Replication 1.1.2: random seeds 42, 25
(= run 0)
(= run 1)
…
Measurement 2.2: data generation interval = 2
…
[NwSim] Winter 2012/2013
(= run 49)
OMNeT++ Tips
5
Related omnetpp.ini
repeat = 5
[Config Test-bc-interval]
**.appl.broadcastInterval = ${interval=0.1..1 step 0.1}s
**.appl.dataGenerationInterval = 3s
sim-time-limit = ${100..1000 step 100 !interval}s
output-scalar-file = ${configname}-bc-${interval}s-run-${repetition}.sca
output-vector-file = ${configname}-bc-${interval}s-run-${repetition}.vec
[Config Test-dg-interval]
**.appl.broadcastInterval = 0.2s
**.appl.dataGenerationInterval = ${interval=1..10 step 1}s
sim-time-limit = 200s
output-scalar-file = ${configname}-dg-${interval}s-run-${repetition}.sca
output-vector-file = ${configname}-dg-${interval}s-run-${repetition}.vec
[NwSim] Winter 2012/2013
OMNeT++ Tips
6
Parameter Studies
repeat = 5
[Config broadcast-interval]
**.appl.broadcastInterval = ${interval=0.1..0.5 step 0.1}s
interval
0.1
0.2
X
0.3
X
0.4
X
0.5
X
X
repeat = 5
[Config broadcast-interval]
**.appl.broadcastInterval = ${interval=0.1, 0.23, 0.3, 0.42, 0.48}s
interval
0.1
0.23
X
[NwSim] Winter 2012/2013
0.3
X
0.42
X
OMNeT++ Tips
0.48
X
X
7
Parameter Studies
repeat = 5
[Config broadcast-interval]
**.appl.broadcastInterval = ${interval=0.1..0.4 step 0.1}s
**.appl.dataGenerationInterval = ${data=0.5..0.8 step 0.1}s
interval
data
0.1
0.2
0.3
0.4
0.5
X
X
X
X
0.6
X
X
X
X
0.7
X
X
X
X
0.8
X
X
X
X
[NwSim] Winter 2012/2013
OMNeT++ Tips
8
Parameter Studies
repeat = 5
[Config broadcast-interval]
**.appl.broadcastInterval = ${interval=0.1..0.4 step 0.1}s
**.appl.dataGenerationInterval = ${data=0.5..0.8 step 0.1 ! interval}s
interval
0.1
data
0.5
0.6
0.2
0.3
X
X
0.7
X
0.8
[NwSim] Winter 2012/2013
0.4
X
OMNeT++ Tips
9
Parameter Studies
repeat = 5
[Config broadcast-interval]
**.appl.broadcastInterval = ${interval=0.1..0.4 step 0.1}s
**.appl.dataGenerationInterval = ${data=0.1..$interval step 0.1}s
interval
data
0.1
0.1
0.2
0.2
X
0.3
X
X
X
X
X
X
X
X
0.3
0.4
[NwSim] Winter 2012/2013
0.4
X
OMNeT++ Tips
10
Parameter Studies
Check your configuration
$ aloha -u Cmdenv -x AlohaStudy -g
`\opp` Discrete Event Simulation
Config: AlohaStudy
Number of runs: 24
Run 0: $0=1, $1=0.2, $repetition=0
Run 1: $0=1, $1=0.4, $repetition=0
Run 2: $0=1, $1=0.6, $repetition=0
Run 3: $0=2, $1=0.2, $repetition=0
Run 4: $0=2, $1=0.4, $repetition=0
Run 5: $0=2, $1=0.6, $repetition=0
Run 6: $0=5, $1=0.2, $repetition=0
Run 7: $0=5, $1=0.4, $repetition=0
[NwSim] Winter 2012/2013
OMNeT++ Tips
11
Seed
Seed the Random Number Generator (RNG)
seed-set = ${runnumber}
seed-set = ${repetition}
seed-set = ${5,6,8..11}
# default, every run has a different seed
# measurements have the same seed
# set seed manually
Multiple RNGs
num-rngs = 2
**.mobility.rng-0 = 1
# other modules have RNG 0 as default
Seed RNGs individually
num-rngs = 2
seed-0-mt = 12
seed-1-mt = 9
[NwSim] Winter 2012/2013
OMNeT++ Tips
12