Omnet Tutorial
Omnet Tutorial
OMNET++
AND
MIXIM FRAMEWORK
Introduction
What is OMNeT++?
OMNET++ Frameworks
What is MiXiM?
MiXiM project
Pseudorandom generators
Flexibility
Programming model
Model management
Support for hierarchical models
Debugging, tracing, and experiment
specifications
Documentation
Large scale simulation
Parallel simulation
Flexibility
6
OMNET++ Programming
model
Hierarchical models
Network interface
card, a compound
module consisting
of a simple
module MAC and
a compound
module Phy
Model management
9
Add behavior
for (int i=0;i<10;i++) {
}
...
[General]
network=test_disk
Analyze
Run
[Parameters]
...
Set up parameters
Model
structure
Compile
Build process
Network
description
nedtool
compiler
Generated C+
+ code
Module
behavior C++
code
C++ compiler
C++ compiler
Linker
Simulatio
n
program
Simulation
kernel
libraries
User
interface
libraries
NED Overview
Components of a NED
description
Import directives
Channel definitions
Simple and compound module
definitions
Network definitions
Import directives
Channel definitions
channel LeasedLine
delay 0.0018 // sec
error 1e-8
datarate 128000 // bit/sec
endchannel
Compound module
definitions
module CompoundModule
parameters: //...
gates: //...
submodules: //...
connections: //...
endmodule
Connections
module CompoundModule
parameters: //...
gates: //...
submodules: //...
connections:
node1.output --> node2.input;
node1.input <-- node2.output;
//...
endmodule
Network definitions
network wirelessLAN: WirelessLAN
parameters:
numUsers=10, httpTraffic=true,
ftpTraffic=true,
distanceFromHub=truncnormal(100,60);
endnetwork
Simulation Model
//
// Ethernet CSMA/CD MAC
//
simple EtherMAC {
parameters: string address; // others omitted for
brevity
gates:
input phyIn; // to physical layer or the network
output phyOut;
network
input llcIn;
// toviaEtherLLC
or higher
Modules can be connected
with each other
gates and combined
to layer
output
llcOut; are
// to
EtherLLC
or higher
form compound modules.
Connections
created
within a single
level of layer
module
hierarchy:
a submodule can be connected with another, or with the containing
}
compound module. Every simulation model is an instance of a compound module
type. This level (components and topology) is dealt with in NED files
Simulation Model
//
// Host with an Ethernet interface
//
module EtherStation {
parameters: ...
gates: ...
input in; // connect to
switch/hub, etc
output out;
submodules:
app: EtherTrafficGen;
llc: EtherLLC;
mac: EtherMAC;
connections:
app.out --> llc.hlIn;
app.in <-- llc.hlOut;
llc.macIn <-- mac.llcOut;
llc.macOout --> mac.llcIn;
mac.phyIn <-- in;
mac.phyOut --> out;
}
network EtherLAN {
submodules: EtherStation;
Running a model
#> make
To run the executable, you need
anomnetpp.inifile.
Running a model
(omnetpp.ini)
[General]
network = etherLAN
*.numStations = 20
**.frameLength = normal(200,1400)
**.station[0].numFramesToSend = 5000
**.station[1-5].numFramesToSend =
1000
One function
of the ini file is to tell which network to simulate. You =
can 0
also specify
**.station[*].numFramesToSend
in there which NED files to load dynamically, assign module parameters, specify
how long the simulation should run, what seeds to use for random number
generation, how much results to collect, set up several experiments with different
parameter settings, etc.
Output of a simulation
The simulation may write output vector and output scalar files
number of packets sent, number of packet drops, average end-toend delay of received packets, peak throughput
MiXiM
MiXiM
ObjectHouse, ObjectWall
Objects influence radio signals and the mobility of
other objects
ObjectManager decides which objects are
interfering
Node Modules
Node Modules
Connection Modeling
Definition of connection:
Utility module
Example
BaseNetwork.ned
BaseHost.ned
config.xml
BaseNic.ned
omnetpp.ini
BaseNic.ned
MiXiMs provides two MAC
layer implementations
CSMAMacLayer and
Mac80211.
If you use only MiXiMs
Decider and AnalogueModel
implementations you can use
the PhyLayer module.
BaseNode.ned
BaseUtility is a mandatory module
BaseArp is used for address
resolution
IBaseMobility is a mandatory module
which defines current position and the
movement pattern of the node.
IBaseApplLayer, IBaseNetwLayer
and BaseNic define the network stack
of this host.
IBaseApplLayer is the module for the
application layer to use. You can
implement you own by sub classing
MiXiMs "BaseApplLayer".
INetwLayer is the module for the
network layer to use. Sub-class your
own network layer from MiXiMs
BaseNetwLayer.
BaseNetwork.ned
Path inside MiXiM directory
Module parameters
ConnectionManager
checks if any two hosts can hear each other
updates their connections accordingly.
If two hosts are connected, they can receive
something from each other
BaseWorldUtility
contains global utility methods and parameters
node[numNodes]: BaseNode
defines the hosts/nodes of our simulation.
config.xml
The AnalogueModels section
defines the analogue models to
use.. You can find all of the
already implemented
AnalogueModels under
"modules/analogueModel/".
omnet.ini
Example II
Channel sensing:
Switch radio:
During initialization we set the initial state of our MAC layer to receiving and
we initialize or "UNTIL_IDLE"-request.
The first parameter to the constructor is the name for our message and the
second is the kind, which has to be
"MacToPhyInterface::CHANNEL_SENSE_REQUEST" for every
ChannelSenseRequest.
We further set the mode and the timeout (in seconds) of our request.
If the channel is idle we can start the transmission process, if not we will
need to start an "UNTIL_IDLE request to wait for it to turn back idle.
After the transmission of the packet is over the phy module will
send us a message of kind "TX_OVER" over the control channel.
When this happens our MAC layer has to switch the radio back
to RX state
phy->setRadioState(Radio::RX);
Now the whole transmission process is over and our MAC layer
goes back to receiving state
http://mixim.sourceforge.net
http://www.omnetpp.org/
Questions?
55
OMNET++
AND
MIXIM FRAMEWORK
Installation