SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Security problems in TCP/IP
Security problems in TCP/IPSecurity problems in TCP/IP
Security problems in TCP/IP
Sukh Sandhu
 

Tendances (20)

Media Access Control
Media Access ControlMedia Access Control
Media Access Control
 
Socket Programming with Python
Socket Programming with PythonSocket Programming with Python
Socket Programming with Python
 
Multicastingand multicast routing protocols
Multicastingand multicast routing protocolsMulticastingand multicast routing protocols
Multicastingand multicast routing protocols
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
 
Message authentication and hash function
Message authentication and hash functionMessage authentication and hash function
Message authentication and hash function
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Security problems in TCP/IP
Security problems in TCP/IPSecurity problems in TCP/IP
Security problems in TCP/IP
 
NS3 Overview
NS3 OverviewNS3 Overview
NS3 Overview
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Building Topology in NS3
Building Topology in NS3Building Topology in NS3
Building Topology in NS3
 
Gpu with cuda architecture
Gpu with cuda architectureGpu with cuda architecture
Gpu with cuda architecture
 
Networking in python by Rj
Networking in python by RjNetworking in python by Rj
Networking in python by Rj
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Socket programming or network programming
Socket programming or network programmingSocket programming or network programming
Socket programming or network programming
 
ICMP
ICMPICMP
ICMP
 
Vtu network security(10 ec832) unit 2 notes..
Vtu network security(10 ec832) unit 2 notes..Vtu network security(10 ec832) unit 2 notes..
Vtu network security(10 ec832) unit 2 notes..
 
MPI message passing interface
MPI message passing interfaceMPI message passing interface
MPI message passing interface
 
Introduction to TCP/IP
Introduction to TCP/IPIntroduction to TCP/IP
Introduction to TCP/IP
 
Cryptography
CryptographyCryptography
Cryptography
 

En vedette

Using Omnet++ in Simulating Ad-Hoc Network
Using Omnet++ in Simulating Ad-Hoc Network Using Omnet++ in Simulating Ad-Hoc Network
Using Omnet++ in Simulating Ad-Hoc Network
Ahmed Nour
 
C#.net applied OOP - Batch 3
C#.net applied OOP - Batch 3C#.net applied OOP - Batch 3
C#.net applied OOP - Batch 3
Md. Mahedee Hasan
 

En vedette (20)

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

Similaire à Introduction to OMNeT++

Similaire à Introduction to OMNeT++ (20)

An Introduction to OMNeT++ 6.0
An Introduction to OMNeT++ 6.0An Introduction to OMNeT++ 6.0
An Introduction to OMNeT++ 6.0
 
Computer Networks Omnet
Computer Networks OmnetComputer Networks Omnet
Computer Networks Omnet
 
An Introduction to OMNeT++ 5.1
An Introduction to OMNeT++ 5.1An Introduction to OMNeT++ 5.1
An Introduction to OMNeT++ 5.1
 
An Introduction to OMNeT++ 5.4
An Introduction to OMNeT++ 5.4An Introduction to OMNeT++ 5.4
An Introduction to OMNeT++ 5.4
 
Presentation on Behavioral Synthesis & SystemC
Presentation on Behavioral Synthesis & SystemCPresentation on Behavioral Synthesis & SystemC
Presentation on Behavioral Synthesis & SystemC
 
6. TinyOS_2.pdf
6. TinyOS_2.pdf6. TinyOS_2.pdf
6. TinyOS_2.pdf
 
COinS (eng version)
COinS (eng version)COinS (eng version)
COinS (eng version)
 
2nd sem
2nd sem2nd sem
2nd sem
 
2nd sem
2nd sem2nd sem
2nd sem
 
Composite Message Pattern
Composite Message PatternComposite Message Pattern
Composite Message Pattern
 
WiMAX implementation in ns3
WiMAX implementation in ns3WiMAX implementation in ns3
WiMAX implementation in ns3
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native Compilation
 
Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2
 
Splunk Conf 2014 - Getting the message
Splunk Conf 2014 - Getting the messageSplunk Conf 2014 - Getting the message
Splunk Conf 2014 - Getting the message
 
Metrics ekon 14_2_kleiner
Metrics ekon 14_2_kleinerMetrics ekon 14_2_kleiner
Metrics ekon 14_2_kleiner
 
EKON 23 Code_review_checklist
EKON 23 Code_review_checklistEKON 23 Code_review_checklist
EKON 23 Code_review_checklist
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
M sc in reliable embedded systems
M sc in reliable embedded systemsM sc in reliable embedded systems
M sc in reliable embedded systems
 
Summarizing Software API Usage Examples Using Clustering Techniques
Summarizing Software API Usage Examples Using Clustering TechniquesSummarizing Software API Usage Examples Using Clustering Techniques
Summarizing Software API Usage Examples Using Clustering Techniques
 

Plus de Md. Mahedee Hasan (10)

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

Dernier

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 

Dernier (20)

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 

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