SlideShare a Scribd company logo
Introduction to OMNet++
Prepared by
Md. Mahedee Hasan
M.Sc Engg. IICT, BUET
Web: http://mahedee.net
Reviewed by
Amit Karmaker
Md. Abir Hossain
M.Sc Engg. IICT, BUET
Supervised by
Dr. Mohammad Shah Alam
Assistant Professor
IICT, BUET
Contents
What is OMNeT++?.......................................................................................................................................2
Modeling concepts........................................................................................................................................2
Module..........................................................................................................................................................3
Message, gets and links ................................................................................................................................3
Parameters....................................................................................................................................................3
Classes that are part of simulation class library ...........................................................................................4
OMNeT++ Consists of....................................................................................................................................4
How OMNeT++ Works? ................................................................................................................................4
NED Features ................................................................................................................................................5
The Network .................................................................................................................................................5
.ini (Initialization) Files..................................................................................................................................6
.cc (C++) Files.................................................................................................................................................7
Channel .........................................................................................................................................................7
Simple and Compound Module ....................................................................................................................8
Simple Module............................................................................................................................................10
Compound Modules ...................................................................................................................................11
Channels......................................................................................................................................................12
Parameter ...................................................................................................................................................12
Gates...........................................................................................................................................................14
Sub Modules ...............................................................................................................................................15
Connections ................................................................................................................................................16
Inheritance..................................................................................................................................................16
Packages......................................................................................................................................................16
Create First Simulation Project using OMNeT++ ........................................................................................17
References ..................................................................................................................................................26
History Card ................................................................................................................................................26
What is OMNeT++?
 OMNeT++ is a Simulator
 For discrete event network
 It is object oriented and modular
 Used to simulate
o Modeling of wired and wireless communication networks
o Protocol modeling
o Modeling of queuing networks etc.
 Modules are connected using gates to form compound module
o In other system sometimes gates are called port
Modeling concepts
 Modules are communicate with message passing
 Active modules are called simple modules
 Message are sent through output gates and receive through input gates
 Input and output gates are linked through connection
 Parameters such as propagation delay, data rate and bit error rate, can be assigned to
connections
Fig – simple and compound module
Module
 In hierarchical module, the top level module is system module
 System module contains sub modules
 Sub modules contains sub modules themselves
 Both simple and compound modules are instance of module type
Message, gets and links
 Module communicate by exchanging message
 Message can represent frames or packets
 Gates are the input and output interface of modules
 Two sub modules can be connected by links with gates
 Links = connections
 Connections support the following parameter
o Data rate, propagation delay, bit error rate, packet error rate
Parameters
 Modules parameters can be assigned
o in either the NED files or
o the configuration file omnetpp.ini.
 Parameter can take string, numeric or Boolean data values or can contains XML data trees
Classes that are part of simulation class library
The following classes are the part of simulation class library
 Module, gates, parameter, channel
 Message, packet
 Container class (e.g. queue and array)
 Data collection classes
 Statistics and distribution estimated classes
 Transition and result accuracy detection classes.
OMNeT++ Consists of
 NED language topology description(s)(.ned files)
 Message definitions (.msg files)
 Simple module sources. They are C++ files, with .h/.cc suffix.
How OMNeT++ Works?
 When Program started
o Read all NED files containing model topology
o Then it reads a configuration file(usually called omnetpp.ini)
 Output is written in result file
 Graph is generated from result file using Matlab, Phython etc
NED Features
NED has several features which makes it scale well to large project
 Hierarchical
 Component-based
 Interfaces
 Inheritance
 Packages
 Metadata annotation
The Network
 Network consists of
o Nodes
o Gates and
o Connections
Fig: The network
network Network
{
submodules:
node1 : Node;
node2 : Node;
node3 : Node;
………………………
connections:
node1.port++<-->{datarate=100Mbps;}<-->node2.port++;
node2.port++<-->{datarate=100Mbps;}<-->node3.port++;
node3.port++<-->{datarate=100Mbps;}<-->node1.port++;
………………………
}
 The double arrow means bi-directional connection
 The connection points of the modules are called gates
 The port++ notation adds a new gate to the port[] gate vector
 Nodes are connected with a channel
 Specify the network option in to the configuration like below
[General]
network = Network
.ini (Initialization) Files
 Defines the network initialization point with/without some parameters
[General]
network = TicToc1
.cc (C++) Files
 Contains class definition and function for modules.
#include <string.h>
#include <omnetpp.h>
class Txc1 : public cSimpleModule
{
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};
Define_Module(Txc1);
void Txc1::initialize()
{
// Am I Tic or Toc?
if (strcmp("tic", getName()) == 0)
{
cMessage *msg = new cMessage("tictocMsg");
send(msg, "out");
}
}
void Txc1::handleMessage(cMessage *msg)
{
send(msg, "out");
}
Channel
 Predefined Channel type
o IdealChannel
o DelayChannel
 delay (double with s, ms, us)
 diabled (boolean)
o DatarateChannel
 delay (double with s, ms, us)
 disabled (boolean)
 datarate (double with unit as bps, kbps, Mbps, Gbps)
 ber (double bit error rate [0,1])
 per (double packet error rate [0,1])
 One can create new channel type
network net
{
@display("bgb=340,233");
types:
channel customChannel extends ned.DatarateChannel{
datarate=100Mbps;
}
submodules:
computer1: computer {
@display("p=63,55");
}
computer2: computer {
@display("p=260,55");
}
connections:
computer1.out -->customChannel--> computer2.in;
computer2.out -->customChannel--> computer1.in;
}
Simple and Compound Module
 Simple module is a basic building block
 Denoted by simple keyword
simple App
{
parameters:
int destAddress;
...
@display("i=block/browser");
gates:
input in;
output out;
}
simple Routing
{
...
}
simple Queue
{
...
}
 Convention : Module name should be Pascal case
 Simple module combines into compound module
simple App
{
parameters:
int destAddress;
@display("i=block/browser");
gates:
input in;
output out;
}
simple Routing
{
gates:
input localIn;
output localOut;
}
simple Queue
{
gates:
input in;
output out;
}
module Node
{
parameters:
int address;
@display("i=misc/node_vs,gold");
gates:
inout port[];
submodules:
app: App;
routing: Routing;
queue[sizeof(port)]: Queue;
connections:
routing.localOut --> app.in;
routing.localIn <-- app.out;
for i=0..sizeof(port)-1 {
routing.out[i] --> queue[i].in;
routing.in[i] <-- queue[i].out;
queue[i].line <--> port[i];
}
}
Fig – The node compound module
 When simulation program started its load NED file first.
 Then it load corresponding simple module written in C++ such as App, Queue
Simple Module
 Simple module is the active component defined by simple keyword
simple Queue
{
parameters:
int capacity;
@display("i=block/queue");
gates:
input in;
output out;
}
 Parameters and gates sections are optional here
 Parameters keywords is optional too, parameters can be defined without parameters keyword
 One can explicitly specify the C++ class with the @class property
simple Queue
{
parameters:
int capacity;
@class(mylib::Queue);
@display("i=block/queue");
gates:
input in;
output out;
}
 The C++ classes will be mylib::App, mylib::Router and mylib::Queue
@namespace(mylib);
simple App{
...
}
simple Router{
...
}
simple Queue{
...
}
Compound Modules
 Groups other modules into a larger unit
 A compound modules may have gates and parameters like simple module but not active
 A compound modules may have several sections all of them optional
module Host
{
types:
...
parameters:
...
gates:
...
submodules:
...
connections:
...
}
 Modules contains in compound module are called sub module – are in sub module section
 Compound module may be inherited via sub classing
module WirelessHost extends WirelessHostBase
{
submodules:
webAgent:WebAgent;
connections:
webAgent.tcpOut-->tcp.appIn++;
webAgent.tcpIn<--tcp.appOut++;
}
module DesktopHost extends WirelessHost
{
gates:
inout ethg;
submodules:
eth:EthernetNic;
connections:
ip.nicOut++-->eth.ipIn;
ip.nicIn++<--eth.ipOut;
eth.phy<-->ethg;
}
Channels
 Channels are connections between nodes
 Predefined channel types are: ned.IdealChannel, ned.DelayChannel and ned.DatarateChannel
 Can use import ned.*
channel Ethernet100 extends ned.DatarateChannel
{
datarate = 100Mbps;
delay = 100us;
ber = 1e-10;
}
Or
channel DatarateChannel2 extends ned.DatarateChannel
{
double distance @unit(m); // @unit is a property
delay = this.distance/200000km * 1s;
}
Parameter
 Parameters are variables that belong to a module.
 Parameters can be used in building the topology (number of nodes, etc)
 To supply input to C++ code that implements simple modules and channels
 For the numeric types, a unit of measurement can also be specified (@unit property), to
increase type safety.
 Parameters can get their values from NED files or from the configuration(Omnetpp.ini)
simple App
{
parameters:
string protocol; //protocoltouse:"UDP"/"IP"/"ICMP"/...
int destAddress; //destinationaddress
volatile double sendInterval@unit(s)= default(exponential(1s));
//timebetweengeneratingpackets
volatile int packetLength@unit(byte)= default(100B);
//lengthofonepacket
volatile int timeToLive= default(32);
//maximumnumberofnetworkhopstosurvive
gates:
input in;
output out;
}
Assigning a Value
Another example
 * matches any index
 .. matches ranges
 If number of individual hosts instead of a sub module vector, network definition can be like this:
Example:
Gates
 Connection points of Module
 OMNeT++ has three types of gates
o Input, output and inout
Example 1:
Example 2:
Example 3:
 Gates around the edges of the grid are expected to remain unconnected, hence the @loose
annotation used.
Sub Modules
 Modules that a compound module is composed of are called its sub modules.
 A sub module has a name, and it is an instance of a compound or simple module type.
Example:
Connections
 Connections are defined in connections section in compound module
Inheritance
 In NED, a type may only extend an element of the same component type
 A simple module may only extend a simple module, compound module may only extend a
compound module, and so on.
 Single inheritance is supported for modules and channels
 Multiple inheritance is supported for module interfaces and channel interfaces
 Inheritance may:
o Add new properties, parameters, gates, inner types, sub modules, connections, as long
as names do not conflict with inherited names
o Modify inherited properties, and properties of inherited parameters and gates
Packages
 Group together similar modules
 Reduces name conflicts
 Before use the class, must reference the package
Create First Simulation Project using OMNeT++
Step 1: Create a OMNeT++ Project
Go to File -> New -> OMNeT++ Project
Step 2: Type project Name
Type project Name (ex. FirstSim) in Project Name text box
Step 3: Add Initial Contents
Here I add Empty project
Step 4: Choose C++ Project Type
Here we choose OMNeT++ simulation
Step 5: Select Configuration
Step 6: Create NED File
File -> New -> Network Description file (NED)
Step 7: Select Project for the NED file
Step 8: Choose initial content for NED file
Step 9: Click finish
Step 10: Modify and add the code below to source of ned file
//
// TODO documentation
//
simple computer
{
gates:
input in;
output out;
}
//
// TODO documentation
//
network net
{
@display("bgb=340,233");
submodules:
computer1: computer {
@display("p=63,55");
}
computer2: computer {
@display("p=260,55");
}
connections:
computer1.out --> computer2.in;
computer2.out --> computer1.in;
}
Step 11: Modify the source of Package.ned
//package firstsim;
//
//@license(LGPL);
@license(omnetpp);
Step 12: Create Initialization File (ini)
Step 13: Choose project for ini file
Step 14: Choose initial content for ini file
Step 15: Choose ned file for ini file
Step 16: Click finish
Step 17: Create a C++ source file
File->New->Source File
Step 18: Type name of the C++ File (example: computer.cc)
Step 19: Modify the computer.cc
/*
* computer.cc
*
* Created on: Aug 25, 2015
* Author: mahedee
*/
#include<string.h>
#include<omnetpp.h>
/*computer is a simple module. A simple module is nothing more than a C++ class which
has to be
sub classed from cSimpleModule,with one or more virtual member functions redefined to
define its behavior.*/
class computer : public cSimpleModule
{
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};
/* The class has to be registered with OMNeT++ via the Define_Module() macro.The
Define_Module() line
should always be put into .cc or .cpp file and not header file (.h), because the
compiler generates code from it. */
Define_Module(computer);
void computer :: initialize()
{
if(strcmp("computer1",getName())==0)
{
cMessage *msg = new cMessage("checkMsg");
send(msg,"out");
}
}
void computer::handleMessage(cMessage *msg)
{
send(msg,"out");
}
Now build the project, if it succeed then run the project. Mission complete..
References
1. OMNeT++ User Manual – Version 4.4
2. OMNeT++ User Guide – Version 4.4
3. OMNeT++ Video Tutorial
4. Stack Overflow
5. A Quick Overview of OMNeT++ IDE
History Card
Version Description Update Date Published Date
1 Draft Preparation 14 Aug 2015
2

More Related Content

PPTX
An Introduction to OMNeT++ 5.1
PPT
Simulation using OMNet++
DOCX
Udp vs-tcp
PDF
IT8602 Mobile Communication - Unit I Introduction
PPT
Mobility management in adhoc network
PPTX
Security issues in manet
PPT
PDF
IT8602 Mobile Communication Unit II
An Introduction to OMNeT++ 5.1
Simulation using OMNet++
Udp vs-tcp
IT8602 Mobile Communication - Unit I Introduction
Mobility management in adhoc network
Security issues in manet
IT8602 Mobile Communication Unit II

What's hot (20)

PDF
Mobile Communication
PPTX
Green cloud computing India
PPTX
CCNA PPT
PPTX
Routers.ppt
PPTX
Vanet ppt
PPTX
Multicastingand multicast routing protocols
PPTX
It6601 mobile computing unit 5
PPTX
VANET in Mobile Computing
PPTX
Cloud of things (IoT + Cloud Computing)
PPT
Presentation on router
DOCX
Seminar report-networking
PDF
Mobile Network Layer
PPTX
Cisco Networking (Routing and Switching)
PPTX
T mac protocol
PPTX
Web services
PDF
Operating System fo IoT
PPTX
CCNA 1 Routing and Switching v5.0 Chapter 1
PPTX
Network address translation
Mobile Communication
Green cloud computing India
CCNA PPT
Routers.ppt
Vanet ppt
Multicastingand multicast routing protocols
It6601 mobile computing unit 5
VANET in Mobile Computing
Cloud of things (IoT + Cloud Computing)
Presentation on router
Seminar report-networking
Mobile Network Layer
Cisco Networking (Routing and Switching)
T mac protocol
Web services
Operating System fo IoT
CCNA 1 Routing and Switching v5.0 Chapter 1
Network address translation
Ad

Viewers also liked (20)

PPTX
Introduction to om ne t++
PPTX
IWSN with OMNET++ Simulation
PPTX
Omnet++
PPTX
Tutorial 5 adding more nodes
PPTX
Tutorial 6 queues & arrays & results recording
PPTX
Tutorial 4 adding some details
PPTX
Tutorial 1 installing mixim and mixnet
PDF
Simulators for Wireless Sensor Networks (OMNeT++)
PPTX
Using Omnet++ in Simulating Ad-Hoc Network
PPTX
Tutorial 3 getting started with omnet
PPTX
Feature and Future of ASP.NET
PPSX
C#.net applied OOP - Batch 3
PDF
Object Oriented Programming
PPSX
Oop principles
PPSX
C# - Part 1
PDF
The world of enterprise solution development with asp.net and C#
PPSX
MS SQL Server
PDF
Introduction to TFS 2013
PDF
Generic repository pattern with ASP.NET MVC and Entity Framework
PPTX
Om net++
Introduction to om ne t++
IWSN with OMNET++ Simulation
Omnet++
Tutorial 5 adding more nodes
Tutorial 6 queues & arrays & results recording
Tutorial 4 adding some details
Tutorial 1 installing mixim and mixnet
Simulators for Wireless Sensor Networks (OMNeT++)
Using Omnet++ in Simulating Ad-Hoc Network
Tutorial 3 getting started with omnet
Feature and Future of ASP.NET
C#.net applied OOP - Batch 3
Object Oriented Programming
Oop principles
C# - Part 1
The world of enterprise solution development with asp.net and C#
MS SQL Server
Introduction to TFS 2013
Generic repository pattern with ASP.NET MVC and Entity Framework
Om net++
Ad

Similar to Introduction to OMNeT++ (20)

PPTX
An Introduction to OMNeT++ 6.0
PDF
Computer Networks Omnet
PDF
An Introduction to OMNeT++ 5.4
PPTX
Presentation on Behavioral Synthesis & SystemC
PDF
6. TinyOS_2.pdf
ODP
COinS (eng version)
DOC
2nd sem
DOC
2nd sem
PPT
Composite Message Pattern
PDF
WiMAX implementation in ns3
PDF
Go Faster With Native Compilation
PDF
Go faster with_native_compilation Part-2
PPTX
Splunk Conf 2014 - Getting the message
PDF
Metrics ekon 14_2_kleiner
PDF
EKON 23 Code_review_checklist
PDF
The Ring programming language version 1.8 book - Part 95 of 202
PDF
Embedded C - Lecture 1
PDF
M sc in reliable embedded systems
PDF
Summarizing Software API Usage Examples Using Clustering Techniques
PPTX
embeddedc-lecture1-160404055102.pptx
An Introduction to OMNeT++ 6.0
Computer Networks Omnet
An Introduction to OMNeT++ 5.4
Presentation on Behavioral Synthesis & SystemC
6. TinyOS_2.pdf
COinS (eng version)
2nd sem
2nd sem
Composite Message Pattern
WiMAX implementation in ns3
Go Faster With Native Compilation
Go faster with_native_compilation Part-2
Splunk Conf 2014 - Getting the message
Metrics ekon 14_2_kleiner
EKON 23 Code_review_checklist
The Ring programming language version 1.8 book - Part 95 of 202
Embedded C - Lecture 1
M sc in reliable embedded systems
Summarizing Software API Usage Examples Using Clustering Techniques
embeddedc-lecture1-160404055102.pptx

More from Md. Mahedee Hasan (10)

PPTX
Azure Machine Learning
PPTX
Chatbot development with Microsoft Bot Framework and LUIS
PPTX
Chatbot development with Microsoft Bot Framework
PPTX
ASP.NET MVC Zero to Hero
PPTX
Introduction to Windows 10 IoT Core
PPTX
Whats new in visual studio 2017
PPTX
Increasing productivity using visual studio 2017
PPSX
Exciting features in visual studio 2017
PPTX
Generic Repository Pattern with ASP.NET MVC and EF
PPSX
ASP.NET Web form
Azure Machine Learning
Chatbot development with Microsoft Bot Framework and LUIS
Chatbot development with Microsoft Bot Framework
ASP.NET MVC Zero to Hero
Introduction to Windows 10 IoT Core
Whats new in visual studio 2017
Increasing productivity using visual studio 2017
Exciting features in visual studio 2017
Generic Repository Pattern with ASP.NET MVC and EF
ASP.NET Web form

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Types and Its function , kingdom of life
PDF
Basic Mud Logging Guide for educational purpose
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Complications of Minimal Access Surgery at WLH
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Supply Chain Operations Speaking Notes -ICLT Program
102 student loan defaulters named and shamed – Is someone you know on the list?
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Cell Structure & Organelles in detailed.
TR - Agricultural Crops Production NC III.pdf
Pharma ospi slides which help in ospi learning
Cell Types and Its function , kingdom of life
Basic Mud Logging Guide for educational purpose
Insiders guide to clinical Medicine.pdf
Microbial diseases, their pathogenesis and prophylaxis
Complications of Minimal Access Surgery at WLH
VCE English Exam - Section C Student Revision Booklet
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Computing-Curriculum for Schools in Ghana
Pharmacology of Heart Failure /Pharmacotherapy of CHF
2.FourierTransform-ShortQuestionswithAnswers.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Supply Chain Operations Speaking Notes -ICLT Program

Introduction to OMNeT++

  • 1. Introduction to OMNet++ Prepared by Md. Mahedee Hasan M.Sc Engg. IICT, BUET Web: http://mahedee.net Reviewed by Amit Karmaker Md. Abir Hossain M.Sc Engg. IICT, BUET Supervised by Dr. Mohammad Shah Alam Assistant Professor IICT, BUET Contents What is OMNeT++?.......................................................................................................................................2 Modeling concepts........................................................................................................................................2 Module..........................................................................................................................................................3 Message, gets and links ................................................................................................................................3 Parameters....................................................................................................................................................3 Classes that are part of simulation class library ...........................................................................................4 OMNeT++ Consists of....................................................................................................................................4 How OMNeT++ Works? ................................................................................................................................4 NED Features ................................................................................................................................................5 The Network .................................................................................................................................................5 .ini (Initialization) Files..................................................................................................................................6 .cc (C++) Files.................................................................................................................................................7 Channel .........................................................................................................................................................7 Simple and Compound Module ....................................................................................................................8
  • 2. Simple Module............................................................................................................................................10 Compound Modules ...................................................................................................................................11 Channels......................................................................................................................................................12 Parameter ...................................................................................................................................................12 Gates...........................................................................................................................................................14 Sub Modules ...............................................................................................................................................15 Connections ................................................................................................................................................16 Inheritance..................................................................................................................................................16 Packages......................................................................................................................................................16 Create First Simulation Project using OMNeT++ ........................................................................................17 References ..................................................................................................................................................26 History Card ................................................................................................................................................26 What is OMNeT++?  OMNeT++ is a Simulator  For discrete event network  It is object oriented and modular  Used to simulate o Modeling of wired and wireless communication networks o Protocol modeling o Modeling of queuing networks etc.  Modules are connected using gates to form compound module o In other system sometimes gates are called port Modeling concepts  Modules are communicate with message passing  Active modules are called simple modules  Message are sent through output gates and receive through input gates  Input and output gates are linked through connection  Parameters such as propagation delay, data rate and bit error rate, can be assigned to connections
  • 3. Fig – simple and compound module Module  In hierarchical module, the top level module is system module  System module contains sub modules  Sub modules contains sub modules themselves  Both simple and compound modules are instance of module type Message, gets and links  Module communicate by exchanging message  Message can represent frames or packets  Gates are the input and output interface of modules  Two sub modules can be connected by links with gates  Links = connections  Connections support the following parameter o Data rate, propagation delay, bit error rate, packet error rate Parameters  Modules parameters can be assigned o in either the NED files or o the configuration file omnetpp.ini.  Parameter can take string, numeric or Boolean data values or can contains XML data trees
  • 4. Classes that are part of simulation class library The following classes are the part of simulation class library  Module, gates, parameter, channel  Message, packet  Container class (e.g. queue and array)  Data collection classes  Statistics and distribution estimated classes  Transition and result accuracy detection classes. OMNeT++ Consists of  NED language topology description(s)(.ned files)  Message definitions (.msg files)  Simple module sources. They are C++ files, with .h/.cc suffix. How OMNeT++ Works?  When Program started o Read all NED files containing model topology o Then it reads a configuration file(usually called omnetpp.ini)  Output is written in result file  Graph is generated from result file using Matlab, Phython etc
  • 5. NED Features NED has several features which makes it scale well to large project  Hierarchical  Component-based  Interfaces  Inheritance  Packages  Metadata annotation The Network  Network consists of o Nodes o Gates and o Connections Fig: The network
  • 6. network Network { submodules: node1 : Node; node2 : Node; node3 : Node; ……………………… connections: node1.port++<-->{datarate=100Mbps;}<-->node2.port++; node2.port++<-->{datarate=100Mbps;}<-->node3.port++; node3.port++<-->{datarate=100Mbps;}<-->node1.port++; ……………………… }  The double arrow means bi-directional connection  The connection points of the modules are called gates  The port++ notation adds a new gate to the port[] gate vector  Nodes are connected with a channel  Specify the network option in to the configuration like below [General] network = Network .ini (Initialization) Files  Defines the network initialization point with/without some parameters [General] network = TicToc1
  • 7. .cc (C++) Files  Contains class definition and function for modules. #include <string.h> #include <omnetpp.h> class Txc1 : public cSimpleModule { protected: virtual void initialize(); virtual void handleMessage(cMessage *msg); }; Define_Module(Txc1); void Txc1::initialize() { // Am I Tic or Toc? if (strcmp("tic", getName()) == 0) { cMessage *msg = new cMessage("tictocMsg"); send(msg, "out"); } } void Txc1::handleMessage(cMessage *msg) { send(msg, "out"); } Channel  Predefined Channel type o IdealChannel o DelayChannel  delay (double with s, ms, us)  diabled (boolean) o DatarateChannel  delay (double with s, ms, us)  disabled (boolean)  datarate (double with unit as bps, kbps, Mbps, Gbps)  ber (double bit error rate [0,1])  per (double packet error rate [0,1])  One can create new channel type
  • 8. network net { @display("bgb=340,233"); types: channel customChannel extends ned.DatarateChannel{ datarate=100Mbps; } submodules: computer1: computer { @display("p=63,55"); } computer2: computer { @display("p=260,55"); } connections: computer1.out -->customChannel--> computer2.in; computer2.out -->customChannel--> computer1.in; } Simple and Compound Module  Simple module is a basic building block  Denoted by simple keyword simple App { parameters: int destAddress; ... @display("i=block/browser"); gates: input in; output out; } simple Routing { ... } simple Queue { ... }  Convention : Module name should be Pascal case  Simple module combines into compound module
  • 9. simple App { parameters: int destAddress; @display("i=block/browser"); gates: input in; output out; } simple Routing { gates: input localIn; output localOut; } simple Queue { gates: input in; output out; } module Node { parameters: int address; @display("i=misc/node_vs,gold"); gates: inout port[]; submodules: app: App; routing: Routing; queue[sizeof(port)]: Queue; connections: routing.localOut --> app.in; routing.localIn <-- app.out; for i=0..sizeof(port)-1 { routing.out[i] --> queue[i].in; routing.in[i] <-- queue[i].out; queue[i].line <--> port[i]; } }
  • 10. Fig – The node compound module  When simulation program started its load NED file first.  Then it load corresponding simple module written in C++ such as App, Queue Simple Module  Simple module is the active component defined by simple keyword simple Queue { parameters: int capacity; @display("i=block/queue"); gates: input in; output out; }  Parameters and gates sections are optional here  Parameters keywords is optional too, parameters can be defined without parameters keyword  One can explicitly specify the C++ class with the @class property simple Queue { parameters: int capacity; @class(mylib::Queue); @display("i=block/queue"); gates: input in; output out; }
  • 11.  The C++ classes will be mylib::App, mylib::Router and mylib::Queue @namespace(mylib); simple App{ ... } simple Router{ ... } simple Queue{ ... } Compound Modules  Groups other modules into a larger unit  A compound modules may have gates and parameters like simple module but not active  A compound modules may have several sections all of them optional module Host { types: ... parameters: ... gates: ... submodules: ... connections: ... }  Modules contains in compound module are called sub module – are in sub module section  Compound module may be inherited via sub classing module WirelessHost extends WirelessHostBase { submodules: webAgent:WebAgent; connections: webAgent.tcpOut-->tcp.appIn++; webAgent.tcpIn<--tcp.appOut++; } module DesktopHost extends WirelessHost { gates: inout ethg; submodules:
  • 12. eth:EthernetNic; connections: ip.nicOut++-->eth.ipIn; ip.nicIn++<--eth.ipOut; eth.phy<-->ethg; } Channels  Channels are connections between nodes  Predefined channel types are: ned.IdealChannel, ned.DelayChannel and ned.DatarateChannel  Can use import ned.* channel Ethernet100 extends ned.DatarateChannel { datarate = 100Mbps; delay = 100us; ber = 1e-10; } Or channel DatarateChannel2 extends ned.DatarateChannel { double distance @unit(m); // @unit is a property delay = this.distance/200000km * 1s; } Parameter  Parameters are variables that belong to a module.  Parameters can be used in building the topology (number of nodes, etc)  To supply input to C++ code that implements simple modules and channels  For the numeric types, a unit of measurement can also be specified (@unit property), to increase type safety.  Parameters can get their values from NED files or from the configuration(Omnetpp.ini)
  • 13. simple App { parameters: string protocol; //protocoltouse:"UDP"/"IP"/"ICMP"/... int destAddress; //destinationaddress volatile double sendInterval@unit(s)= default(exponential(1s)); //timebetweengeneratingpackets volatile int packetLength@unit(byte)= default(100B); //lengthofonepacket volatile int timeToLive= default(32); //maximumnumberofnetworkhopstosurvive gates: input in; output out; } Assigning a Value Another example  * matches any index  .. matches ranges  If number of individual hosts instead of a sub module vector, network definition can be like this:
  • 14. Example: Gates  Connection points of Module  OMNeT++ has three types of gates o Input, output and inout Example 1:
  • 15. Example 2: Example 3:  Gates around the edges of the grid are expected to remain unconnected, hence the @loose annotation used. Sub Modules  Modules that a compound module is composed of are called its sub modules.  A sub module has a name, and it is an instance of a compound or simple module type. Example:
  • 16. Connections  Connections are defined in connections section in compound module Inheritance  In NED, a type may only extend an element of the same component type  A simple module may only extend a simple module, compound module may only extend a compound module, and so on.  Single inheritance is supported for modules and channels  Multiple inheritance is supported for module interfaces and channel interfaces  Inheritance may: o Add new properties, parameters, gates, inner types, sub modules, connections, as long as names do not conflict with inherited names o Modify inherited properties, and properties of inherited parameters and gates Packages  Group together similar modules  Reduces name conflicts  Before use the class, must reference the package
  • 17. Create First Simulation Project using OMNeT++ Step 1: Create a OMNeT++ Project Go to File -> New -> OMNeT++ Project Step 2: Type project Name Type project Name (ex. FirstSim) in Project Name text box
  • 18. Step 3: Add Initial Contents Here I add Empty project Step 4: Choose C++ Project Type Here we choose OMNeT++ simulation
  • 19. Step 5: Select Configuration Step 6: Create NED File File -> New -> Network Description file (NED)
  • 20. Step 7: Select Project for the NED file Step 8: Choose initial content for NED file
  • 21. Step 9: Click finish Step 10: Modify and add the code below to source of ned file // // TODO documentation // simple computer { gates: input in; output out; } // // TODO documentation // network net { @display("bgb=340,233"); submodules: computer1: computer { @display("p=63,55"); } computer2: computer { @display("p=260,55"); } connections: computer1.out --> computer2.in; computer2.out --> computer1.in; } Step 11: Modify the source of Package.ned //package firstsim; // //@license(LGPL); @license(omnetpp);
  • 22. Step 12: Create Initialization File (ini) Step 13: Choose project for ini file
  • 23. Step 14: Choose initial content for ini file Step 15: Choose ned file for ini file
  • 24. Step 16: Click finish Step 17: Create a C++ source file File->New->Source File Step 18: Type name of the C++ File (example: computer.cc)
  • 25. Step 19: Modify the computer.cc /* * computer.cc * * Created on: Aug 25, 2015 * Author: mahedee */ #include<string.h> #include<omnetpp.h> /*computer is a simple module. A simple module is nothing more than a C++ class which has to be sub classed from cSimpleModule,with one or more virtual member functions redefined to define its behavior.*/ class computer : public cSimpleModule { protected: virtual void initialize(); virtual void handleMessage(cMessage *msg); }; /* The class has to be registered with OMNeT++ via the Define_Module() macro.The Define_Module() line should always be put into .cc or .cpp file and not header file (.h), because the compiler generates code from it. */ Define_Module(computer); void computer :: initialize() { if(strcmp("computer1",getName())==0) { cMessage *msg = new cMessage("checkMsg"); send(msg,"out"); } } void computer::handleMessage(cMessage *msg) { send(msg,"out"); } Now build the project, if it succeed then run the project. Mission complete..
  • 26. References 1. OMNeT++ User Manual – Version 4.4 2. OMNeT++ User Guide – Version 4.4 3. OMNeT++ Video Tutorial 4. Stack Overflow 5. A Quick Overview of OMNeT++ IDE History Card Version Description Update Date Published Date 1 Draft Preparation 14 Aug 2015 2