User Tools

Site Tools



TODO: Reorganize as sections and add links to Questions to enhance readability

How do I get the id of the current node?

Include palId.h, then you can use palId_id() to get the node id. This only works, when called from a module.

How can I print debugging information?

There are four debugging output levels. LOG_DEBUG, LOG_INFO, LOG_WARN and LOG_ERROR. With

LOG_DEBUG("Message: " << somevariable);

you can print out a Message, if the debugging output for that module in that mode is turned on. For setting the debugging output, use the log.conf in your simulation folder. Every line contains the module name (as specified in the NED File), the debugging level (debug, info, warn, error), the output (stdout for terminal or a filename) and the node id or * for every node.

How do I start a method after some time?

To start a Method after a certain time you can use the method

void schedule(Msg *msg, void(Mod::*handler)(Msg *), timeOffset_t ms = 0)

If you want to wait more than 65536 ms, your module needs to inherit from LongScheduleModule. Then you are able to use the method

LongScheduleMsg* msg = new LongScheduleMsg(createCallback(&ModuleName::Handler));
longSchedule(msg, longTimeOffset_t delay);

The LongScheduleMsg contains the Method (ModuleName::Handler) to be called.

How do I get a pointer to a module of a given name?

With getModule(Moduelname) you get a pointer to the module. The caller needs to be also a module. Also remember to cast the pointer to the right type. If no module by that name exists, the method returns NULL.

ATTENTION: As soon as a module obtains a direct pointer from another module, the danger of producing an initialization race exists. Such a race can lead to arbitrarily mean symptoms, which can be random between builds or on the meaner side different behavior between nodes, depending on some initialization data. As long as there is no support for multiple initialization stages, one can and shall use the schedule method to schedule the critical operation. Thereby it is guaranteed, that all Modules are properly initialized.

Example Bug: StaticRouting used to call a loadRoutes() method, which retrieved static IPv6 routes from the EEPROM and added those to the routing table. RoutingTable, however, uses a pointer to the IPv6InterfaceTable module to check if an added address is a local address of this node for all routes with a prefix of 128 bit length. This pointer is set in RoutingTable's initialize() method, which was in this case called after StaticRouting's initialize method. This caused some nodes to reset directly after startup (those which actually had 128 bit prefix routes in their table) and some to work flawlessly. Changing flags to enable logging somehow caused the initialization order to be changed and let the problem “disappear”…

How can I use parameters from the omnetpp.ini file?

The parameters need to be specified in the module, then you can set a variable by the same name as in the NED file with


Can I stop the simulation on a certain condition?

Yes. with ASSERT(condition) you can check a condition. If the condition is not true, the simulation stops. On real hardware the node will get into a state where it just blinks all its leds and needs to be reset.

Can I use std::vector, std::string etc.?

If you write your code only for simulation this is possible. However, the std Types are not available on the real hardware. Please use the templates in cometos/src/templates. They offer some types similar to those of the std, for e.g. Vector.h and SString.h.

How long can module names be?

In the simulation the module names can be as long as you want, but on hardware they are restricted to four characters. For consistency it is therefore recommended to use only four characters.

projects/cometos/faq.txt · Last modified: 2014/10/10 13:36 by ti5mr