Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

29 total results found

Introduction

OMNeT++ Single Node Tutorial

This tutorial is organized into three chapters: Chapter 1 will cover how to navigate in OMNeT++, how to create and program a single node, and how to run simple simulations. We will create a single node, which is able to change it...

Installing and running OMNeT++

OMNeT++ Single Node Tutorial Chapter 1: Setup a simple simulation

Step 1. Install and run OMNeT++ Download the current OMNeT++ version and install it, following the instructions under: OMNeT++ Downloads omnetpp.org Once completed, run OMNeT++, then skip th...

Excursion: Discrete events and simulation time

OMNeT++ Single Node Tutorial Chapter 1: Setup a simple simulation

This is an excursion from the tutorial into the theory of discrete events and simulation time. If you are familiar with these concepts, you can proceed straight to the next page. There are two types of simulators ...

Exploring the code

OMNeT++ Single Node Tutorial Chapter 1: Setup a simple simulation

Let's explore the code you just imported. When you expand all of the folders, you will notice two folders with files inside: SRC and SIMULATIONS. Following the modular architecture of OMNeT++, all of the network descriptions (SingleNodeNetwork.ned), pa...

Setup a simple simulation: Summary

OMNeT++ Single Node Tutorial Chapter 1: Setup a simple simulation

Let us summarize what we have until now. We set up our very first simulation, which consists of a single node. It is essential to understand the underlying structure, visualized here: Each simple module in OMNeT++ consists of three parts (files): CC, ...

Creating and handling a self message

OMNeT++ Single Node Tutorial Chapter 2: Self messages

Creating and handling a self message In the last section, we have explored the code of our simple module Node and have noticed some code lines, that look like creating a message. Let's revisit them: #include "Node.h" Define_Module(Node); void Node::initial...

Exercise 1: Play with the self message

OMNeT++ Single Node Tutorial Chapter 2: Self messages

Try to change the scheduled time for the message first to 20, then to 10000. Re-run the simulation for each - do you see any difference? To more clearly see that something changes, add the following code to handleMessage() - it doesn't matter where exactly fo...

Exercise 1: Discussion

OMNeT++ Single Node Tutorial Chapter 2: Self messages

In fact, you should not see any difference. As explained in discrete event simulation, it doesn't matter when exactly a message is scheduled - the kernel jumps to the next message directly. However, in the debugging output, you will see a change with the time ...

Exercise 2: Resend the message

OMNeT++ Single Node Tutorial Chapter 2: Self messages

Now, let's us resend the message to ourselves. In handleMessage(), instead of deleting the message, add the following code: scheduleAt(simTime()+10, msg); This line of code sends the same message back to the kernel to be fired 10 seconds after now (simTime()...

Exercise 2: Discussion

OMNeT++ Single Node Tutorial Chapter 2: Self messages

The difference is obvious this time: the message keeps turning back and the simulation never stops... In the graphical output, no difference can be seen, as the color stays red. You would need to stop the simulation manually. Try also something else here: bri...

State variables

OMNeT++ Single Node Tutorial Chapter 2: Self messages

State variables are a very handy tool to track the internal state of a module: for example, to count how often we already changed the color (and then stop) or to track to which color to change (from red to blue and back). To use a state variable, you need to ...

Different self messages

OMNeT++ Single Node Tutorial Chapter 2: Self messages

We can of course define and use also different self messages, for example, to switch to blue or to switch to red. For this, we can use the attribute kind of messages. In our ongoing example, we will define the kind of the first message we created in the initia...

Random behavior

OMNeT++ Single Node Tutorial Chapter 2: Self messages

It is relatively simple to schedule a message randomly in OMNeT++. In fact, the kernel offers you many different random number generators, which you can use directly, like here with the uniform integer-based one: scheduleAt(simTime()+intuniform(10,1000), msg)...

Two nodes side by side

OMNeT++ Single Node Tutorial Chapter 3: Two nodes

We have seen how to create a single node and how to implement its behavior. Now, we will create two nodes of the same type. All we need to do is to create two nodes instead of one in the network NED file: network SingleNodeNetwork { submodules: ...

Exploring messages

OMNeT++ Single Node Tutorial Chapter 3: Two nodes

OMNeT++ has some very powerful tools to log information during a simulation and to analyze it later. Let's add the following line to the omnetpp.ini file: record-eventlog = true This is to log information about all events in the simulation. Now, run the simu...

Connecting nodes to each other

OMNeT++ Single Node Tutorial Chapter 3: Two nodes

OMNeT++ is quite strict on how to exchange messages between any nodes (or modules) - you have to explicitly connect them via gates. If you don't, you cannot send messages - full stop, no workarounds, please. Connecting nodes or modules is a two-step process: ...

Sending messages to another node

OMNeT++ Single Node Tutorial Chapter 3: Two nodes

We will start over with our code, for simplicity. We will write a simulation with two blue nodes. Both nodes will change to RED at time 10 and then change the color every now and then randomly. We already know how to do this. Additionally, each node will send...

Add delays to connections

OMNeT++ Single Node Tutorial Chapter 3: Two nodes

OMNeT++ allows you to easily setup a delay for any connection in Network.NED like this : node1.my_gate <--> {delay=2s;} <--> node2.my_gate; If you re-run your code now, you will observe a different between when the node has sent out a message and when it was...

Add parameters

OMNeT++ Single Node Tutorial Chapter 3: Two nodes

Setting up parameters for a module in OMNeT++ always consists of three steps: Define the parameter in the module NED file. For example, in Node.ned: simple Node { parameters: int triggerYellow; @display("b=60,10,rect,blue,black,2...

More parameters

OMNeT++ Single Node Tutorial Chapter 3: Two nodes

Parameters and the way you set them up and use them is one of the most useful features in OMNeT++. You can setup full simulation campaigns with parameter exploration studies that run fully automatically. Here are some further tips and tricks how to use them. ...