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

What's hot (20)

PDF
Neural Networks: Multilayer Perceptron
Mostafa G. M. Mostafa
 
PPTX
Computer Graphic - Lines, Circles and Ellipse
2013901097
 
PPTX
Sutherland hodgman polygon clipping algorithm
Tawfiq Ahmed
 
PPTX
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Simplilearn
 
PPT
Pretty good privacy
Pushkar Dutt
 
PDF
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
PPTX
Meessage authentication and hash functions.pptx
JohnLagman3
 
PDF
Convolutional Neural Networks (CNN)
Gaurav Mittal
 
PDF
4. The Advanced Encryption Standard (AES)
Sam Bowne
 
PPTX
Introduction to deep learning
Junaid Bhat
 
PPTX
Cryptography and network security
patisa
 
PPTX
C# 101: Intro to Programming with C#
Hawkman Academy
 
PDF
AES-Advanced Encryption Standard
Prince Rachit
 
PPTX
RSA algorithm
Arpana shree
 
PPTX
RSA Algorithm
Srinadh Muvva
 
PPTX
Computer graphics LINE DRAWING algorithm.pptx
R S Anu Prabha
 
PDF
Modified aes algorithm using multiple s boxes
chuxuantinh
 
PPT
Introduction to Visual Studio.NET
Dutch Dasanaike {LION}
 
PPT
basics of compiler design
Preeti Katiyar
 
PPTX
Advanced encryption standard (aes)
farazvirk554
 
Neural Networks: Multilayer Perceptron
Mostafa G. M. Mostafa
 
Computer Graphic - Lines, Circles and Ellipse
2013901097
 
Sutherland hodgman polygon clipping algorithm
Tawfiq Ahmed
 
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Simplilearn
 
Pretty good privacy
Pushkar Dutt
 
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
Meessage authentication and hash functions.pptx
JohnLagman3
 
Convolutional Neural Networks (CNN)
Gaurav Mittal
 
4. The Advanced Encryption Standard (AES)
Sam Bowne
 
Introduction to deep learning
Junaid Bhat
 
Cryptography and network security
patisa
 
C# 101: Intro to Programming with C#
Hawkman Academy
 
AES-Advanced Encryption Standard
Prince Rachit
 
RSA algorithm
Arpana shree
 
RSA Algorithm
Srinadh Muvva
 
Computer graphics LINE DRAWING algorithm.pptx
R S Anu Prabha
 
Modified aes algorithm using multiple s boxes
chuxuantinh
 
Introduction to Visual Studio.NET
Dutch Dasanaike {LION}
 
basics of compiler design
Preeti Katiyar
 
Advanced encryption standard (aes)
farazvirk554
 

Viewers also liked (20)

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

Similar to Introduction to OMNeT++ (20)

PPTX
An Introduction to OMNeT++ 6.0
Alpen-Adria-Universität
 
PDF
An Introduction to OMNeT++ 5.4
Alpen-Adria-Universität
 
PDF
Wireless Communication Network Communication
Vrushali Lanjewar
 
PDF
Computer Networks Omnet
Shivam Maheshwari
 
PDF
INET for Starters
Fayruz Rahma
 
PPTX
Om net++
prisonbreak4950
 
PDF
[Thomas chamberlain] learning_om_ne_t++(z-lib.org)
wissem hammouda
 
PPTX
OMNET++ Research Projects Guidance
Network Simulation Tools
 
PPTX
OMNeT++ Research Projects Guidance
Network Simulation Tools
 
DOCX
Seminar report on Introduction to OMNeT++
Shivang Bajaniya
 
PPTX
OMNeT Simulation Projects Guidance
Network Simulation Tools
 
PDF
Features
kq4pgkim1e
 
PDF
Manual
Elhabib Atiea
 
PDF
IRJET- Implementation and Simulation of Failsafe Network Architecture
IRJET Journal
 
PDF
Report_Ines_Swayam
Swayam Tibrewal
 
PDF
KHAN_FAHAD_FL14
Fahad Naeem
 
PDF
WiMAX implementation in ns3
Mustafa Khaleel
 
PPT
Webinar ethernet basics part a v1.3
wilbertl
 
PDF
Computer Network Performance evaluation based on Network scalability using OM...
Jaipal Dhobale
 
PPTX
Performance Analysis Of AOMDV In Terms Of Mobility Speed And Pause Time
Akmal
 
An Introduction to OMNeT++ 6.0
Alpen-Adria-Universität
 
An Introduction to OMNeT++ 5.4
Alpen-Adria-Universität
 
Wireless Communication Network Communication
Vrushali Lanjewar
 
Computer Networks Omnet
Shivam Maheshwari
 
INET for Starters
Fayruz Rahma
 
Om net++
prisonbreak4950
 
[Thomas chamberlain] learning_om_ne_t++(z-lib.org)
wissem hammouda
 
OMNET++ Research Projects Guidance
Network Simulation Tools
 
OMNeT++ Research Projects Guidance
Network Simulation Tools
 
Seminar report on Introduction to OMNeT++
Shivang Bajaniya
 
OMNeT Simulation Projects Guidance
Network Simulation Tools
 
Features
kq4pgkim1e
 
IRJET- Implementation and Simulation of Failsafe Network Architecture
IRJET Journal
 
Report_Ines_Swayam
Swayam Tibrewal
 
KHAN_FAHAD_FL14
Fahad Naeem
 
WiMAX implementation in ns3
Mustafa Khaleel
 
Webinar ethernet basics part a v1.3
wilbertl
 
Computer Network Performance evaluation based on Network scalability using OM...
Jaipal Dhobale
 
Performance Analysis Of AOMDV In Terms Of Mobility Speed And Pause Time
Akmal
 
Ad

More from Md. Mahedee Hasan (10)

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

Recently uploaded (20)

PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
PPTX
How to Manage Promotions in Odoo 18 Sales
Celine George
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PPTX
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
PDF
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
How to Manage Promotions in Odoo 18 Sales
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
community health nursing question paper 2.pdf
Prince kumar
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 

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