0% found this document useful (0 votes)
52 views31 pages

Om Net

OMNeT++ is a component-based, modular and open-architecture discrete event network simulator. It can be used to model communication networks, hardware architectures, and other distributed systems. In OMNeT++, simulations are built from modules defined in the NED language and implemented with C++ classes. Modules communicate by exchanging messages and are connected together hierarchically. The topology and configuration of a model are specified in NED files, while module behavior is programmed in C++.

Uploaded by

vedpk
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views31 pages

Om Net

OMNeT++ is a component-based, modular and open-architecture discrete event network simulator. It can be used to model communication networks, hardware architectures, and other distributed systems. In OMNeT++, simulations are built from modules defined in the NED language and implemented with C++ classes. Modules communicate by exchanging messages and are connected together hierarchically. The topology and configuration of a model are specified in NED files, while module behavior is programmed in C++.

Uploaded by

vedpk
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 31

OMNeT++

Ved Kushwaha
Agenda
• What is OMNeT++
• Programming Model
• NED language
• Simple modules/messages
• How to run a simulation
What is OMNeT++
• OMNeT++ is a component-based, modular and open-
architecture discrete event network simulator.
• simulator can be used for:
– traffic modeling of telecommunication networks
– protocol modeling
– modeling queuing networks
– modeling multiprocessors and other distributed hardware
systems
– validating hardware architectures
– evaluating performance aspects of complex software systems
– modeling any other system where the discrete event approach
is suitable, e.g. communication networks and other distributed
systems.
OMNET++ Programming model
• Efficient tools for describing the structure of the actual system
• Simulated objects are represented by modules
– Modules can be simple or composed (depth of module nesting is
not limited)
– Modules communicate by messages sent
• directly
• along a predefined path through gates and connections
– One module description consists of :
• Interface description (.NED file)
• Behavior description (C++ class)
• Modules, gates and links can be created:
– Statically - at the beginning of the simulation (NED file)
– Dynamically – during the simulation
OMNET++ Programming model
• Simulation objects are represented by C++ classes.
• The following classes are part of the simulation class
library:
– modules, gates, connections etc.
– parameters
– messages
– container classes (e.g. queue, array)
– data collection classes
– statistic and distribution estimation classes (histograms)
– transient detection and result accuracy detection classes
OMNET++ Programming model
• Model consists of the following parts
– NED language topology description(s) (.ned
files)
– Message definitions (.msg files).
– Simple modules sources. They are C++ files,
with .h/.cc suffix.
– configuration file (usually called omnetpp.ini).
NED Overview
• The NED language has several features
– Hierarchical
– Component-Based
– Interfaces
– Inheritance
– Packages
NED Overview …
• Reserved word
– import channel endchannel simple endsimple
module endmodule error delay datarate const
parameters gates submodules connections
gatesizes if for do endfor network endnetwork
nocheck ref ancestor true false like input
numeric string bool char xml xmldoc
NED Overview …
• Identifiers are the names of modules, channels,
networks, submodules, parameters, gates,
channel attributes and functions.
– must be composed of letters of the English alphabet
(a-z, A-Z), numbers (0-9) and the underscore “_”.
– Identifiers may only begin with a letter or the
underscore.
– it is recommended that the names of modules,
channels and networks with a capital letter, and the
names of parameters, gates and submodules with a
lower-case letter.
NED Overview …
• Case sensitivity
– NED is case sensitive
• Comments
– C / C++ style comments (“//”)
NED Overview …
• There are three distinctive elements that can be
described in a NED file
– Module definitions. In these blocks you can describe simple and
compound modules and set parameters of these modules. Also,
you can define gates that connect the modules.
– Channel definitions. Describe channels (links) that connect
modules.
– Network definitions. To get the whole simulation running, you’ll
have to describe which module is the top level module for the
network you wish to simulate. This top level module is an
instance of the system module.
NED Overview …
• simulation in OMNeT++ is written in two different languages,
NED and C++.
• two languages separate the design of a topology and the
implementation of the modules.
• The topology of a model is specified using the NED language.
• Behavior is encapsulated in C++ models.
• NED description can contain the following components, in
arbitrary number or order:
– import directives
– channel definitions
– simple and compound module definitions
– network definitions
Import directives
• import directive is used to import declarations
from another network description file.
• import "ethernet"; // imports ethernet.ned
• import
"Router",
"StandardHost",
"FlatNetworkConfigurator";
Channel definitions
• Channels encapsulate parameters and behavior
associated with connections
• predefined types are :
– ned.IdealChannel
– ned.DelayChannel
– ned.DatarateChannel
Channel definitions …
channel LeasedLine
delay 0.0018 // sec
error 1e-8
datarate 128000 // bit/sec
endchannel

channel C extends ned.DatarateChannel


{
datarate = 100Mbps; delay = 100us; ber = 1e-10;
}
Channel definitions …
network Network
{
types:
channel C extends ned.DatarateChannel { datarate = 100Mbps; }
submodules:
node1: Node;
node2: Node;
node3: Node; ...
connections:
// node1.port++ <--> {datarate = 100Mbps; } <--> node2.port++;
node1.port++ <--> C <--> node2.port++;
// node2.port++ <--> {datarate = 100Mbps; } <--> node4.port++;
node2.port++ <--> C <--> node4.port++;
}
Simple module definitions
simple TrafficGen
parameters:
interarrivalTime,
numOfMessages : const,
address : string;
gates:
in: fromPort, fromHigherLayer;
out: toPort, toHigherLayer;
endsimple
Simple module definitions …
• Parameters
– variables that belong to a module
– used in building the topology (number of
nodes, etc)
– Parameters may get their values from several
places:
• from NED code,
• from the configuration (omnetpp.ini), or
• interactively from the user
Simple module definitions …
• Gates
– OMNeT++ has three types of gates:
• input,
• output and
• inout
– a Gate, cannot be connected to two or more
other gates
Simple Modules
• Simple modules are the active components in
the model.
• Simple modules are programmed in C++, using
the OMNeT++ class library
• events occur inside simple modules
• virtual member functions:
– void initialize()
– void handleMessage(cMessage *msg)
– void activity()
– void finish()
Simple Modules …
// file: HelloModule.cc
#include <omnetpp.h>
class HelloModule : public cSimpleModule
{
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg); };
// register module class with `\opp` Define_Module(HelloModule);
void HelloModule::initialize()
{
ev << "Hello World!\n";
}
void HelloModule::handleMessage(cMessage *msg)
{
delete msg; // just discard everything we receive
}
Simple Modules …
// file: HelloModule.ned
simple HelloModule
{
gates: input in;
}
Messages and packets
• Objects of cMessage and subclasses may
model a number of things:
– events;
– messages;
– packets,
– frames,
– cells,
– bits or signals traveling in a network;
– entities traveling in a system
Messages and packets …
message MyPacket
{
int srcAddress;
int destAddress;
int hops = 32;
};
class MyPacket : public cMessage
{
...
virtual int getSrcAddress() const;
virtual void setSrcAddress(int srcAddress);
...
};
Compound module definitions
module CompoundModule
parameters: //...
gates: //...
submodules: //...
connections: //...
endmodule
Compound module definitions -
submodules
module CompoundModule
//...
submodules:
submodule1: ModuleType1
parameters: //...
gatesizes: //...
submodule2: ModuleType2
parameters: //...
gatesizes: //...
endmodule
Assigning values to submodule
parameters
module CompoundModule
parameters:
param1: numeric,
param2: numeric,
useParam1: bool;
submodules:
submodule1: Node
parameters:
p1 = 10,
p2 = param1+param2,
p3 = useParam1==true ? param1 : param2;
//...
endmodule
Connections
module CompoundModule
parameters: //...
gates: //...
submodules: //...
connections:
node1.output --> node2.input;
node1.input <-- node2.output;
//...
endmodule
Network definitions
network Network
{
types:
channel C extends ned.DatarateChannel
{
datarate = 100Mbps;
}
submodules:
node1: Node;
node2: Node;
node3: Node; ...
connections:
node1.port++ <--> C <--> node2.port++;
node2.port++ <--> C <--> node4.port++;
node4.port++ <--> C <--> node6.port++; ...
}
Running a Simulation
• opp_makemake (for windows opp_zmakemake)
• make (nmake -f Makefile.vc)
• ./identifier (e.g. ./tictoc , ./fifo)
The Beginning

You might also like