omnet++ introduction - unibo.itdonat/omnet.pdf · outline what is omnet++? how can i use it? how...

Post on 08-May-2018

217 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Omnet++Introduction

Luca Bedogni <lbedogni@cs.unibo.it>31/10/2012

Outline

● What is Omnet++?

● How can I use it?

● How can it be useful for me?

● How much is it easy to develop in it?

● How much effort is needed to learn it?

??

What is Omnet++

● Omnet++ → discrete event simulator - C++– Hierarchical modules

– Modules communication

● A good set of developed modules● Free for academic use● OpenSource

– Download it from www.omnetpp.org

Pros and Cons

● Pros– Easy

– Well structured

– Highly modular

– Could be used for different kind of simulations

● Cons– Young, not so much models available

Main applications

● Modeling of network protocols

● Modeling of queuing networks

● Modeling of multiprocessor systems

● Performance evaluation of software systems

Frameworks

Main components

● Kernel Library

● Topology description (NED)

● Tkenv/Cmdenv

● Plotting and output analysis

Omnet++ in 6 steps

Create a project

Define its location, its name, referenced projects

and so on

Create a project

Define its location, its name, referenced projects

and so on

Create a project

Define its location, its name, referenced projects

and so on

Create a project

Define its location, its name, referenced projects

and so on

Omnet++ in 6 steps

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Create a project

Define its location, its name, referenced projects

and so on

Create a project

Define its location, its name, referenced projects

and so on

Omnet++ in 6 steps

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Program it

Define the behavior, what happens when it is istantiated, when a message arrives,

when it has to send messages

Program it

Define the behavior, what happens when it is istantiated, when a message arrives,

when it has to send messages

Create a project

Define its location, its name, referenced projects

and so on

Create a project

Define its location, its name, referenced projects

and so on

Omnet++ in 6 steps

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Program it

Define the behavior, what happens when it is istantiated, when a message arrives,

when it has to send messages

Program it

Define the behavior, what happens when it is istantiated, when a message arrives,

when it has to send messages

Create a scenario

Define the number of modules, how they are connected, scenario parameters

Create a scenario

Define the number of modules, how they are connected, scenario parameters

Create a project

Define its location, its name, referenced projects

and so on

Create a project

Define its location, its name, referenced projects

and so on

Omnet++ in 6 steps

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Program it

Define the behavior, what happens when it is istantiated, when a message arrives,

when it has to send messages

Program it

Define the behavior, what happens when it is istantiated, when a message arrives,

when it has to send messages

Configure a simulation

Assign values to parameters, to or not to record charts,

maybe change the modules names

Configure a simulation

Assign values to parameters, to or not to record charts,

maybe change the modules names

Configure a simulation

Assign values to parameters, to or not to record charts,

maybe change the modules names

Configure a simulation

Assign values to parameters, to or not to record charts,

maybe change the modules names

Create a project

Define its location, its name, referenced projects

and so on

Create a project

Define its location, its name, referenced projects

and so on

Omnet++ in 6 steps

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Layout a module

Define its parameters, its gates, as well as interfaces and display setting

Program it

Define the behavior, what happens when it is istantiated, when a message arrives,

when it has to send messages

Program it

Define the behavior, what happens when it is istantiated, when a message arrives,

when it has to send messages

Configure a simulation

Assign values to parameters, to or not to record charts,

maybe change the modules names

Configure a simulation

Assign values to parameters, to or not to record charts,

maybe change the modules names

Configure a simulation

Assign values to parameters, to or not to record charts,

maybe change the modules names

Configure a simulation

Assign values to parameters, to or not to record charts,

maybe change the modules names

Run it

Run the simulation, multiple times, analyze results, and maybego back to the second step

Run it

Run the simulation, multiple times, analyze results, and maybego back to the second step

Omnet++ module structure

● Each simulated object is a module– Could be simple or nested

● Modules communicate through messages● Each module is composed by

– Interface description (NED)

– Behavior (C++ class)

– One or more .msg files

NED example

What should we declare in a NED?

● Module – the module definition● Channels – medium used to communicate● Parameters – to configure the module● Gates – where messages exit and enter● Connection – connections of gates

NED compound modules

● Modules made of other modules (not only)● In omnet++ modules could be seen as a

black box● Through gates, you talk with someone else● Very easy to build complex modules● Very easy to change small things in big

simulations

Compound module

Modules structure

Simple Module

Simple Module

Simple Module

Simple Module

Simple Module

Simple Module

Gates

Networks

● A network is a .ned file

● Defines the layout of the simulation

● Could be further configured by omnetpp.ini (see later)

● Could be extended by other networks

C/C++ modules

● Basically composed of three functions– initialize(int stage)

● Called when module is created

– handleMessage(cMessage *msg)● When a message arrives to the module

– Finish()● Called when module is destroyed

● Of course one can add more functions

C/C++ modules

● Start by creating a subclass of cSimpleModule

● Declare initialize and handleMessage● Register the class with Define_Module()● Start adding your own methods● Schedule messages through:

– send → to other modules

– scheduleAt() → to yourself

Messages

● Jobs, entities or any other kind of communication, customers

● Describe how to talk to others

● Place a .msg file inside a directory– C/C++ class is automatically generated

Automaticallygenerated

Message example

message packet {fields:

int srcAddr;int destAddr;bool flag;

}

Header

C++ class

Reading parameters

● Define only the structure of the module– Don't use magic numbers

● Use module parameters– Easier to configure different kind of

simulations

● Faster to run simulations

Running a simulation

● Create an omnetpp.ini● Inside, you can configure your simulation● You can also have different configurations

to run● Very easy to replicate results

– Or to run the same simulation multiple times

Analysis

● You (may) want to record what happens during the simulation

● You can record– Queue lenghts

– Percentages

– Packet drops

– ….

Analysis

● Once you ran a simulation, you could have– .vec files – tstamp/values

– .sca files – summary of statistics

● These files contains the raw results of the simulation

● How can we (easily) read them?

Chart generations

Sequence diagrams

Advices

● How to go from 0 to top in omnet++?– Impossible!

● Start with simple things● Add some details● Try, fail, try again, succeed● A place to start?

– http://www.omnetpp.org/documentation

– http://www.omnetpp.org/doc/omnetpp/tictoc-tutorial

top related