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

30
Omnet++ Introduction Luca Bedogni <[email protected] > 31/10/2012

Upload: phamkhuong

Post on 08-May-2018

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Omnet++Introduction

Luca Bedogni <[email protected]>31/10/2012

Page 2: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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?

??

Page 3: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 4: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Pros and Cons

● Pros– Easy

– Well structured

– Highly modular

– Could be used for different kind of simulations

● Cons– Young, not so much models available

Page 5: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Main applications

● Modeling of network protocols

● Modeling of queuing networks

● Modeling of multiprocessor systems

● Performance evaluation of software systems

Page 6: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Frameworks

Page 7: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Main components

● Kernel Library

● Topology description (NED)

● Tkenv/Cmdenv

● Plotting and output analysis

Page 8: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 9: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 10: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 11: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 12: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 13: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 14: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 15: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

NED example

Page 16: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 17: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 18: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Compound module

Modules structure

Simple Module

Simple Module

Simple Module

Simple Module

Simple Module

Simple Module

Gates

Page 19: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 20: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 21: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 22: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 23: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Automaticallygenerated

Message example

message packet {fields:

int srcAddr;int destAddr;bool flag;

}

Header

C++ class

Page 24: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 25: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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

Page 26: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Analysis

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

● You can record– Queue lenghts

– Percentages

– Packet drops

– ….

Page 27: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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?

Page 28: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Chart generations

Page 29: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

Sequence diagrams

Page 30: Omnet++ Introduction - unibo.itdonat/omnet.pdf · 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

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