First Steps with OMNET++

The goal of this post is to clarify the structure of an OMNET++ simulation, explaining how the file structure works and where you should include each part of your simulation.

As described in the post about the Network Simulators, OMNET++ has an IDE based on Eclipse that makes it easier to create a project and run simulations. The structure of an OMNET++ simulation can be explained by three file levels:

OMNET++ file structure

OMNET++ file structure

The source code (C++)

This is the bottom level. Here, you should include the algorithms that will be used, which is the intelligence of your simulation. You can imagine that if you are simulating a system which is going to be sold, the C++ code is the part that you would sell to your clients. Therefore, it should be as generic as possible and have no dependency with specific use cases.  Usually, you have one source code that works for every simulation and you do not have to recompile to observe how your system would behave in a different scenario.

OMNET++ has a component-based structure. Each component has a different description and its behavior, which is defined by the algorithm implemented at this level.

Examples at this level: Protocols to manage queues, access control and messages that are used by the network components.

The Network Description (NED files)

In these files, you should set up the structures that you are planning to simulate, link the components and establish a relationship between them.

The most relevant observation is that  each NED file may describe only one topology level. For example, if you are describing the network, your components will be computers, switches, routers and so on. To describe the protocol stack of a computer you must create another NED file, which components will be the different layers: physical, MAC, link, presentation, application, etc.

In the end, you may have a tree like this:

OMNET++ network description

OMNET++ network description

In summary, if you want to connect your Computer with your Router, you should:

  1. In the Computer description, define a link between its physical layer and the external input/output connection;
  2. In the Router description, define a link between its physical layer and the external input/output connection;
  3. In the Network description, define the Channel and connect the external interface of the Computer and the external interface of the Router to the Channel.

Link between the Network Description and the Source code:

The link between a component and its algorithm is done by the command “Define_Module(ned_filename)” in the source code. By doing this connection, you will be able to set, in the upper layers, the parameters that will be used by the algorithm.

The Configuration File (omnet.ini)

In this text file, you can describe simulation-specific parameters that you may want to compare. For example, you can change the size of the packets that you are transmitting in order to see how good your computer will handle the network traffic. The recommendation is that you create one ini file with multiple configurations of different simulations, but you can reuse the lower levels to make multiple simulations and compare different parameters on each one.

Each configuration is defined by a section “Config”, for example:

[Config Simulation_A]

*.packetSize = 20b

[Config Simulation_B]

*.packetSize = 100b

In the case above, you have two different simulations (A and B) and you may choose one to run.

Link between the Configuration File and the Network Description:

At this level, it is also possible to set which modules you want to use, according to your requirements. For example, if your tests want to compare the performance of different MAC protocols in the Computer, it is possible to define:

[Config Simulation_1]

Computer.MACprotocol = CSMA

[Config Simulation_2]

Computer.MACprotocol = TDMA

Important: The content of this file depends on what you need to compare with the simulations. For example, if you want to compare different MAC protocols, you should consider setting the network interface at the Network description.


By default, each run will generate output files with vectors and scalar values and those files are saved in a folder called “results” and have extensions .vec and .sca, respectively. Using the tools available in the IDE, it is possible to generate different types of charts (bars, lines, etc) using as well as create macros to plot charts later.

Step-by-step procedure

If you are creating your first simulation, you may follow these steps:

  1. Translate your system into a hierarchy of communicating modules (the tree described above)
  2. Define the model structure in the NED files
  3. Develop the source code (C++)
  4. Create the omnetpp.ini
  5. Run it
Cite this article as: gabriel, "First Steps with OMNET++," in Gabriel Martins Dias, June 3, 2014,

16 Responses

  1. shobha says:

    Hi Gabriel Martins Dias

    Is it possible to build new scenario , in OMNet++ and MiXiM, using existing projects???

    I have installed OMNet++ and Mixim… want to know hoe to run the scenario with our specification and see the result, may i know where the details regarding the set up of scenario and running is available,,

    It would of great help , if you can guide me in this regard…

    • Gabriel Martins Dias says:

      Yes, you can reuse the existing code to develop your scenario.
      If you don’t need to develop a new algorithm, you should setup your .ned file according to the components that you’ll use and than the omnet.ini file to change the configurations.

      • anna says:

        I would like to create a new project to simulate power consumption in different network topologies. I don’t need to develop a new algorithm, so that is my question: where to start? What should I use in source code if I haven’t got new algorithm?
        I’m just beggining work with MiXiM so forgive my questions, please. 😉

        • Gabriel Martins Dias says:

          You can start by running the example “Mac80211” in MiXiM. There, you can find a configuration with 3 nodes including a hidden station.
          You will be able to add more nodes and set their positions. Just check the omnetpp.ini file.

          Let me know if you have any problem.

          • anna says:

            Now I use ieee802154Narrow example, where battery module is included.
            I have set parameters:
            **.batteryStats.detail = true
            **.batteryStats.timeSeries = true
            **.batteryStats.debug = true
            but in .anf file I have only scalars: mean power consumption, total and energy. I would like to see power consumption in time on chart. Have you got any idea?
            OMNeT++ has so many options, it’s powerfull tool, but so complicated. 🙂

  2. Zeeshan Abbas says:

    Dear Gabriel Martins Dias,
    I am a student of BS and I am doing my Final year project on Omnet/MiXim. The project title is “Multimedia Streaming over wireless sensor networks”. We are at the basic stage. If you can provide us a basic project for our understanding. Or can share some tips to start the project please.

    • Gabriel Martins Dias says:

      Dear Zeeshan, have you tried the examples in MiXiM?

      • Zeeshan Abbas says:

        yes dear,
        Now we have made a small topology on omnet++ but we have to include multimedia in it and have to apply compression techniques on it… So how we can achieve this???

        • Gabriel Martins Dias says:

          You will have to develop an application using C++.
          Take a look on the .cc files such as “”. It is an example of code that can be used in the application layer, which is the same as you will need.

      • Preetha says:

        Sir I have an idea of simulating multimedia streaming via cross layer in omnet . But I don’t have any idea about this tool. Will you please guide me??? It will be more helpful
        Thanking you in anticipation….

  3. Mohssine says:

    Hi Gabriel Martins Dias,

    I want to Implement an intrusion detection architecture based on MAS and learning new attacks with Case Based Reasoning CBR.

    It is possible to do simulation with Omnet ++?

    If yes,can you help me please to do it?

    Thank you in advance.

  4. Farman Ali says:

    Hi everybody
    I am working on WBAN .
    We are stuck at one point in working with Omnet++ that stop our further progress .

    Now a days I am working on Mixim CSMA Mac Layer (NED, INI AND CC file) coding. During editing the code I am facing a Problem.

    whatever we edit in .CC file that does not effect the result.
    for example.
    we create a new function in which we calculate the total data and take its result from Finish() function as:
    void csmaMaclayer::totaltransdata()
    double timeBackoff =7*aUnitBackoffPeriod + 0.000000128;
    double tFrame = (aMaxPhyPacketSize + PHR )*32;
    tData =timeBackoff + tFrame + turnAtime + tAcktime;
    void csmaMaclayer::finish() {
    recordScalar(“nbBackoffs”, nbBackoffs);
    recordScalar(“backoffValues”, backoffValues);

    recordScalar(“txAttempts”, txAttempts);
    recordScalar(“tData”, tData);

    But the result show only above three values which it already define.
    further more if delete hole function this will not effect the result the output show the same result.

    please anyone tell me why this happen and how can we sold it?

  5. Dharam Gami says:

    Hello every one,
    I want to simulate an active RFID Authentication protocol. To do so, first I have to make a topology which consist 4 component. Moreover, authentication process need to simulate Radio link and internet link. So, how can I start? how to import Mixim’s radio link channel to my project?

  6. zahra says:

    I m a master student who wants to simulate CRN using MIXIM
    would you please guide me how to start or guide me to start the code please?
    many thnaks in advance
    zahra fathipour.

Leave a Reply

Your email address will not be published. Required fields are marked *