Advanced Search
Search Results
43 total results found
Introduction
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++
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...
OMNeT++ Single Node Tutorial
This is an introductory tutorial to start with OMNeT++. It is made for people with no or very little experience with discrete event simulation and has a low pace. It should be completed before the oficial OMNeT++ tic-toc tutorial.
Chapter 1: Setup a simple simulation
In this section, 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 its color throughout the simulation. We will explore simulation time and h...
Excursion: Discrete events and simulation time
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
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
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, ...
Chapter 2: Self messages
In this section, we will explore the simplest messages in OMNeT++: messages to "self". We will see how to create them, send and receive them. We will also do some exercises!
Creating and handling a self message
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
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
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
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
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
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
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
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)...
Chapter 3: Two nodes
In this section, we will extend our simulation to two nodes and see how we can send messages between them.
Two nodes side by side
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++ 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++ 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: ...