0% found this document useful (0 votes)
63 views20 pages

Introduction To Omnet++

The document provides an introduction to OMNeT++, including how to install it, the basic components of simulation models in OMNeT++ like modules, gates and connections, and an example tic-toc simulation. It also discusses enhancing the basic tic-toc example by adding parameters, random numbers, processing delays, and modeling message loss.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views20 pages

Introduction To Omnet++

The document provides an introduction to OMNeT++, including how to install it, the basic components of simulation models in OMNeT++ like modules, gates and connections, and an example tic-toc simulation. It also discusses enhancing the basic tic-toc example by adding parameters, random numbers, processing delays, and modeling message loss.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

MODELING AND SIMULATION

[NETW707]

TUTORIAL5 – INTRODUCTION TO
OMNET++
Eng. Minar El-Aasser minar.elaasser@guc.edu.eg #C3.314
What Is Omnet++?
It’s not only a network simulator. It provides a base for
network simulations
A generalized framework for building 'network‘ simulations
Communication networks
Queuing networks
Digital logic networks
' …. ' networks
Open Source =)
How to Install Omnet++? Windows
install
Self contained, simply follow directions:
Download, unzip somewhere (no spaces in path)
Double-click mingwenv.cmd
If Windows 8 doesn't like this, click 'more info', then 'run
anyway‘
Type: ./configure
Type: make
doc/InstallGuide.pdf
Simulation Model – Module Types
Simulation Models in Omnet++
In Omnet++, a simulation model is also called a network

Declared in NED Files


1. A network (simulation model) is itself a module
2. Components of your simulation model are defined as simple
or compound modules (Simple modules group together to
form compound modules.)
◦ Simple Modules are the Base building blocks
◦ They are the only active components and their behavior
implemented in c++ files
Simulation Models in Omnet++ cont’d
4. Gates allow for Message passing

Defined in NED Files


◦ Messages could represent packets, jobs, timers, timeout, etc.
5. Messages Passes between gates using Connections
◦ Two gates can be directly linked via connection (Think wired
communication network)
◦ Connections can also be used to directly pass a message to
an unlinked gate (Think wireless communication network)
6. Connections can be defined and reused: called Channels
FAMOUS TIC-TOC EXAMPLE
1. Define your model components ≡ Adding NED Files
◦ Network & 2 instances of Txc1 [Tic and Toc]
◦ Command: File > New > Network // creates the NED file for the network
N.B: Omnet++ editor has 2 modes that you can switch between them: Design [edited graphically] and Source
[edited as text].
Modules (simple or compound) can be placed in the same
NED file as the network NED file or a separate one.
FAMOUS TIC-TOC EXAMPLE
2. Implement the functionality of each component ≡ Declaring Simple Modules NED files and Adding
their C++ files
◦ File > New > Omnet++ Class // creates the NED file for the simple module as well as the associated C++ files to
describe its behavior [2 file: Txc1.h and Txc1.cc]
N.B:
- the 2 files Txc1.h and Txc1.cc are both merged in the Txc1.cc of the tictoc tutorial in Omnet++ projects.
However, its common practice to split the headers from the functions implementation when your project gets
more complex.
-Make sure that the code in C++ files is associated with their perspective NED components by placing the
command “Define_Module (Txc1)” in your .cc file. Txc1:same name as that given to the NED component
“case_sensitive”
-The Omnet++ class created to declare the functionality of the simple module sub-classes from the public
Omnet++ cSimpleModule and thus it has 2 “popular” functions that defines it and are automatically created in a
simple Omnet++ class module.
void initialize(); //called at the beginning of the simulation; only once!
void handleMessage(cMessage *msg); // called whenever a message arrives
C++ functionality of the simple modules could be kept in 1
file or split on 2 file [.cc and .h]
FAMOUS TIC-TOC EXAMPLE
3. Create the configuration file ≡ Adding Omnet.ini
◦ File > New > INI
◦ N.B: -The configuration file tells the simulation program which network to simulate
- Through .ini files you can pass parameters to the model, explicitly specific seeds for RNG
- It has 2 modes that you can switch between them: Form and Source

Same name as declared


inside the NED file
FAMOUS TIC-TOC EXAMPLE
4. Launching the simulation program ≡ Build and Run your program
◦ Building and compiling your project: Project > Build Project
◦ Building, compiling and running your project from the IDE :
◦ N.B:
- Main Window shows simulation time. i.e. It has nothing to do
with the actual time it took to run the simulation.
- How many seconds you can simulate in 1 real world second
depends on:
1. the speed of your hardware
2. Nature and complexity of simulation model
FAMOUS TIC-TOC EXAMPLE
Visualizing on a sequence chart
◦ In the configuration file : record-eventlog = true
◦ A “.elog” file is created in the Results folder in your project folder
Enhancing the 2-node Tic Toc Tutorial
 Adding Icons : Making GUI looks prettier
 Adding Logging : Add log statements in your C++ code using “EV”command.
 Adding State Variables: EX.: Add a counter to the module and delete after 10 messages.
The Command “WATCH(counter)” in the source makes it possible to see the counter value in the
graphical runtime environment
 Adding Parameters: Ex. Turn the "magic number" 10 into a parameter and add a boolean
parameter to decide whether the module should send out the first message in its initialization code
First module parameters have to be declared in the NED file. The data type can be numeric, string or
bool. Then the C++ code has to be modified to read the parameter.
N.B: we can assign the parameters in the NED file or from omnetpp.ini.
Enhancing the 2-node Tic Toc Tutorial
 Modeling Processing Delay: Ex. Instead of immediately sent back the received message. Let tic and
toc hold the message for 1 simulated second before sending it back.
- In OMNeT++ such timing is achieved by the module sending a message to itself. Such messages
are called self-messages (but only because of the way they are used, otherwise they are ordinary
message objects).
- We "send" the self-messages with the scheduleAt() function, specifying when it should be
delivered back to the module “scheduleAt(simTime()+1.0, event);”
In handleMessage() we differentiate whether a new message has arrived via the input gate or the
self-message came back (timer expired) by either comparing the message with timer name: if (msg
== event) or using if (msg->isSelfMessage())
Enhancing the 2-node Tic TocTutorial
 Random Numbers and Parameters: Ex. Change the delay from 1s to a random value which can be
set from the NED files or from omnet.ini.
-Module parameters are able to return random variables; however, to make use of this feature we
have to read the parameter in handleMessage() every time we use it.
- No matter how many times you re-run the simulation or restart it, you'll get exactly the same
results.
- This is because OMNeT++ uses a deterministic algorithm (by default the Mersenne Twister RNG) to
generate random numbers, and initializes it to the same seed. This is important for reproducible
simulations. You can experiment with different seeds if you add the following lines to omnetpp.ini:
[General]
seed-0-mt=532569 # or any other 32-bit value
- OMNeT++ supports more than one RNGs.
Milestone 1 – Introduction to Omnet+
+
Deadline: Thursday 21st March, 2019.
1. Carry out the tic-toc tutorial
2. Choose a different distribution for Tic and Toc
2.1 Plot the first 100 arrival delays for each
2.2 Change the seed of your simulation and repeat step 2.1
3. Modify your C++ code so that Toc "loses" (delete) the message with a
50% probability.
3.1 Record the message Success rate for each of the 2 nodes
Project
 Groups of 2
 Register your group on the google sheet
https://
drive.google.com/open?id=1-ITFUJU-kLt6kj7tSD_w5FDtwO1WaXmuJsi29
HxiEHw
 Zip and send your zipped project folder, along with the required output
to: modsimnetw707@gmail.com
Other Milestones
Detailed description: to be updated
Milestone 2 – Modeling a Network Protocol
Deadline: 11th of April, 2019
Milestone 3 – Modeling a Real Network
Deadline: 25th of April, 2019
References
https://doc.omnetpp.org/omnetpp/manual/
Tic Toc Tutorial in Omnet++ Help

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy