Professional Documents
Culture Documents
Chris+an
Timmerer
Alpen-Adria-Universitt
Klagenfurt
(AAU)
w
Faculty
of
Technical
Sciences
(TEWI)
Department
of
InformaFon
Technology
(ITEC)
w
MulFmedia
CommunicaFon
(MMC)
h<p://research.+mmerer.com
w
h<p://blog.+mmerer.com
w
mailto:chris+an.+mmerer@itec.uni-klu.ac.at
October
2012
Change
Log:
Oct12:
Update
to
4.2
Oct11:
Minor
correc+ons
and
updates
Oct10:
Update
to
4.1
Oct09:
Update
to
4.0
incl.
IDE
Oct08:
Ini+al
version
based
on
OMNet++
3.3
Outline
Introduc+on
OMNet++
in
a
Nutshell
What
does
OMNeT++
provide
then?
OK.
What
does
an
OMNeT++
simula+on
model
look
like?
How
do
I
run
this
thing?
OK!
Now,
how
do
I
program
a
model
in
C++?
GeYng started Enhancing the 2-node TicToc Turning into a real network Adding sta+s+cs collec+on Visualizing the results with the OMNeT++ IDE
Timmerer - AAU/TEWI/ITEC/MMC
Introduc+on
Discrete
event
simulator
Wri<en
in
C++
Hierarchically
nested
modules
Modules
communicate
using
messages
through
channels
Source
code
publicly
available
Simula+on
model
for
Internet,
IPv6,
Mobility,
etc.
available
Commercial
version
of
OMNESTTM
Well
structured,
highly
modular,
not
limited
to
network
protocol
simula+ons
(e.g.,
like
ns2)
Rela+vely
young
and
only
few
simula+on
models
Timmerer
-
AAU/TEWI/ITEC/MMC
3
Cons
October
2012
OMNet++
in
a
Nutshell:
C++
class
library
Tools
to
document
large
simula+on
models
Extension
interfaces
for
real-+me
simula+on,
emula+on,
MRIP,
parallel
distributed
simula+on,
database
connec+vity
and
so
on
Timmerer
-
AAU/TEWI/ITEC/MMC
4
opp_neddoc
October 2012
OMNet++ in a Nutshell:
llc: EtherLLC; mac: EtherMAC; connecFons: app.out --> llc.hlIn; app.in <-- llc.hlOut; llc.macIn <-- mac.llcOut; llc.macOout --> mac.llcIn; mac.phyIn <-- in; mac.phyOut --> out; }
Timmerer - AAU/TEWI/ITEC/MMC
OMNet++ in a Nutshell:
Run executable
By
default,
all
but
also
graphical
user
interface,
Tkenv
(or
Cmdenv)
-u all -u Tkenv oder
-u Cmdenv
October
2012
Timmerer - AAU/TEWI/ITEC/MMC
OMNet++ in a Nutshell:
October 2012
OMNet++ in a Nutshell:
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
OMNet++ in a Nutshell:
ini+alize(),
nish(),
handleParameterChange(const
char
*paramName)
par(const
char
*paramName)
Typically
done
in
ini+alize()
and
values
are
stored
in
data
members
of
the
module
class
Returns
cPar
object
which
can
be
casted
to
the
appropriate
type
(long,
double,
int,
etc.)
or
by
calling
the
objects
doubleValue()
etc.
methods
Support
for
XML:
DOM-like
object
tree
Timmerer
-
AAU/TEWI/ITEC/MMC
9
October 2012
1. An OMNeT++ model is build from components (modules) which communicate by exchanging messages. Modules can be nested, that is, several modules can be grouped together to form a compound module. When crea+ng the model, you need to map your system into a hierarchy of communica+ng modules.
2. Dene the model structure in the NED language. You can edit NED in a text editor or in the graphical editor of the Eclipse-based OMNeT++ Simula+on IDE. 3. The ac+ve components of the model (simple modules) have to be programmed in C++, using the simula+on kernel and class library. 4. Provide a suitable omnetpp.ini to hold OMNeT++ congura+on and parameters to your model. A cong le can describe several simula+on runs with dierent parameters. 5. Build the simula+on program and run it. You'll link the code with the OMNeT++ simula+on kernel and one of the user interfaces OMNeT++ provides. There are command line Timmerer - AAU/TEWI/ITEC/MMC (batch) and interac+ve, graphical user interfaces.
October 2012
10
TicToc
Tutorial
Short
tutorial
to
OMNeT++
guides
you
through
an
example
of
modeling
and
simula+on
Showing
you
along
the
way
some
of
the
commonly
used
OMNeT++
features
Based
on
the
Tictoc
example
simula+on:
samples/+ctoc
much
more
useful
if
you
actually
carry
out
at
least
the
rst
steps
described
here
h<p://www.omnetpp.org/doc/omnetpp41/ +ctoc-tutorial/
October
2012
Timmerer
-
AAU/TEWI/ITEC/MMC
11
GeYng
Started
Star+ng
point
"network"
that
consists
of
two
nodes
(cf.
simula+on
of
telecommunica+ons
network)
One
node
will
create
a
message
and
the
two
nodes
will
keep
passing
the
same
packet
back
and
forth
Nodes
are
called
+c
and
toc
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Create
a
working
directory
called
+ctoc,
and
cd
to
this
directory
Describe
your
example
network
by
crea+ng
a
topology
le
Implement
the
func+onality
Create
the
Makele
Compile
and
link
the
simula+on
Create
the
omnetpp.ini
le
Start
the
executable
using
graphical
user
interface
Press
the
Run
bu<on
on
the
toolbar
to
start
the
simula+on
You
can
play
with
slowing
down
the
anima+on
or
making
it
faster
You
can
exit
the
simula+on
program
Timmerer
-
AAU/TEWI/ITEC/MMC
Here are the steps you take to implement your rst simula+on from scratch:
October 2012
12
Txc1 is a simple module type, i.e., atomic on NED level and implemented in C++. Txc1 has one input gate named in, and one output gate named out .
// Two instances (tic and toc) of Txc1 connected both ways. // Tic and toc will pass messages to one another. network Tictoc1 { Tictoc1
is
a
network
assembled
from
submodules: tic: Txc1; two
submodules
+c
and
toc
(instances
toc: Txc1; from
a
module
type
called
Txc1).
connections: Connec+on:
+cs
output
gate
(out)
to
tic.out --> { delay = 100ms; } --> toc.in; tocs
input
gate
and
vice
version
w/
tic.in <-- { delay = 100ms; } <-- toc.out; propaga+on
delay
100ms.
}
October
2012
Timmerer
-
AAU/TEWI/ITEC/MMC
13
Compile and link the simula+on: make If you start the executable now, it will complain that it cannot nd the le omnetpp.ini
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
15
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
17
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
19
Step
2:
Rening
the
Graphics,
and
Adding
Debugging
Output
(contd)
Debug
messages
EV
<<
"Sending
ini+al
message\n";
EV
<<
"Received
message
`"
<<
msg->name()
<<
"',
sending
it
out
again\n";
Run
the
simula+on
in
the
OMNeT++
GUI
Tkenv.
Open
separate
output
windows
for
+c
and
toc
by
right-clicking
on
their
icons
and
choosing
Module
output
from
the
menu
useful
for
large
models.
October
2012
Timmerer
-
AAU/TEWI/ITEC/MMC
20
Module
parameters
have
to
be
declared
in
the
NED
le:
numeric,
string,
bool,
or
xml
simple Txc4 { parameters: // whether the module should send out a message on initialization bool sendMsgOnInit = default(false); int limit = default(2); // another parameter with a default value @display("i=block/routing"); gates: Modify
the
C++
code
to
read
the
parameter
in
ini+alize(),
and
assign
it
to
the
counter.
counter = par("limit"); Now,
we
can
assign
the
parameters
in
the
NED
le
or
from
omnetpp.ini.
Assignments
in
the
NED
le
take
precedence.
network Tictoc4 { submodules: tic: Txc4 { parameters: sendMsgOnInit = true; limit = 8; // tic's limit is 8 @display("i=,cyan"); } toc: Txc4 { // note that we leave toc's limit unbound here parameters: sendMsgOnInit = false; @display("i=,gold"); } connections:
October
2012
Timmerer
-
AAU/TEWI/ITEC/MMC
22
or even
with
the
same
eect.
(The
dierence
between
*
and
**
is
that
*
will
not
match
a
dot
and
**
will.)
October
2012
Timmerer
-
AAU/TEWI/ITEC/MMC
23
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
24
handleMessage():
dieren+ate
whether
a
new
message
has
arrived
via
the
input
gate
or
the
self-message
came
back
(+mer
expired)
if (msg==event) or
if (msg->isSelfMessage())
Timmerer
-
AAU/TEWI/ITEC/MMC
October 2012
25
26
October 2012
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
29
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
31
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
32
When the message arrives at +c[3], its handleMessage() will delete the message
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
33
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
34
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
35
Note:
The
special
$i
and
$o
sux
aer
the
gate
name
allows
us
to
use
the
connec+on's
two
direc+on
separately.
October
2012
Timmerer
-
AAU/TEWI/ITEC/MMC
36
opp_msgc
is
invoked
and
it
generates
+ctoc13_m.h
and
+ctoc13_m.cc
Include
+ctoc13_m.h
into
our
C++
code,
and
we
can
use
TicTocMsg13
as
any
other
class
#include
"+ctoc13_m.h"
TicTocMsg13
*msg
=
new
TicTocMsg13(msgname);
msg->setSource(src);
msg->setDes+na+on(dest);
return
msg;
Timmerer
-
AAU/TEWI/ITEC/MMC
37
October 2012
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
39
Add two counters to the module class: numSent and numReceived Set to zero and WATCH'ed in the ini+alize() method Use the Find/inspect objects dialog (Inspect menu; it is also on the toolbar)
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
40
This
info
appears
above
the
module
icons
using
the
t=
display
string
tag
if (ev.isGUI()) updateDisplay();
void Txc11::updateDisplay(){ char buf[40]; sprintf(buf, "rcvd: %ld sent: %ld", numReceived, numSent); getDisplayString().setTagArg("t",0,buf); } October 2012 Timmerer - AAU/TEWI/ITEC/MMC
41
Record
in
the
hop
count
of
every
message
upon
arrival
into
an
output
vector
(a
sequence
of
(+me,value)
pairs,
sort
of
a
+me
series)
Calculate
mean,
standard
devia+on,
minimum,
maximum
values
per
node,
and
write
them
into
a
le
at
the
end
of
the
simula+on
Use
o-line
tools
to
analyse
the
output
les
Timmerer
-
AAU/TEWI/ITEC/MMC
42
October 2012
recordScalar()
calls
in
the
code
below
write
into
the
Tictoc15-0.sca
le
Tictoc15-0.sca
not
deleted
between
simula+on
runs;
new
data
are
just
appended
allows
to
jointly
analyze
data
from
several
simula+on
runs
Timmerer
-
AAU/TEWI/ITEC/MMC
44
October 2012
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
45
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
46
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
47
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
48
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
49
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
50
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
51
Introduc+on
OMNeT++
4.1
Integrated
Development
Environment
is
based
on
the
Eclipse
plaorm
Func+onality
Create/cong
NED
and
ini
les
Perform
batch
execu+ons
Analyze
simula+on
results
Eclipse
func+onality:
C++
edi+ng,
CVS/SVN/GIT
integra+on
and
op+onally
other
features
via
plug-ins
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
52
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
53
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
54
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
55
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
56
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
57
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
58
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
59
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
60
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
61
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
62
Simula+on
Launcher
Run
dialog
showing
a
simula+on
launch
congura+on
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
63
Console View
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
64
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
65
Sequence
Chart
Sequence
Chart
showing
ARP
on
a
wireless
network
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
66
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
67
Conclusions
OMNeT++:
discrete
event
simula+on
system
OMNeT++
is
a
public-source,
component-based,
modular
and
open-architecture
simula+on
environment
with
strong
GUI
support
and
an
embeddable
simula+on
kernel
Dipl.-Ing.
Dr.
Chris+an
Timmerer
Klagenfurt
University,
Department
of
Informa+on
Technology
(ITEC)
Universittsstrasse
65-67,
A-9020
Klagenfurt,
AUSTRIA
chris+an.+mmerer@itec.uni-klu.ac.at
h<p://research.+mmerer.com/
Tel:
+43/463/2700
3621
Fax:
+43/463/2700
3699
Copyright:
Chris;an
Timmerer
October 2012
Timmerer - AAU/TEWI/ITEC/MMC
69