Search code examples
modulesequenceomnet++event-simulation

How omnet initialize modules and model?


I read manual and inside the manual there is described using pseudo code that first simulation step, when simulation start is "network initialization" from system module to the sub-modules. In simulation example that I have there is "simulation.ned" and it s used for defining some simulation variables and package.ned where I have network defined.

Questions are:

  • When simulation start how omnet intialize modules (maybee seek for all *.ned files to create full network)?

  • when module is created does he wait for all sub-modules to be generated or he immediately apply configuration ( initialize() method) or wait for all modules to be created and then continue with configuration?

thanks


Solution

  • During the simulation preparing (and before the first event is processed) the following steps are performed:

    1. The simulation environment looks into omnetpp.ini and checks the name of network, for example:

      [General]
      network = ARPTest
      
    2. The simulation environment scans NEDfiles and looks for the file which contains:

      network ARPTest {
       // ...
      }
      
    3. The simulation environment calls initialize() for all submodules mentioned in this network. There is the important rule:

    A compound module's initialize() function runs before that of its submodules.


    It is also worth remembering that in OMNeT++ there is an opportunity to use multi stage initialization. It is useful when one submodule cannot be initialized without some information from another submodule, for example: a routing submodule need the addresses of host's interfaces to initialize.