Warning: Trying to access array offset on value of type bool in /data/www/freeminded.org/www/wp-content/plugins/wp-latex/wp-latex.php on line 39 OMNeT++ – talking directly to a different module @ Freeminded.org Warning: Trying to access array offset on value of type bool in /data/www/freeminded.org/www/wp-content/plugins/wp-latex/wp-latex.php on line 46

OMNeT++ – talking directly to a different module

This entry was posted by on Monday, 8 August, 2011 at

OSI-type stacks with communication by passing messages is nice an all, but not always the easiest (or fastest) way to do it. Say you have a module ‘host’ which has ‘appl’, ‘netw’ and ‘nic’. You can then navigate this ‘virtual’ structure (present in the NED files) to get to your module’s netw block.

My appl.cc:

myNetwLayer = dynamic_cast(getParentModule()->getModuleByRelativePath("netw"));

My appl.h:

private BeaconNetwLayer myNetwLayer;

Then, BeaconNetwLayer has a function ‘setLambda_g()’ which I can call from appl.cc:

myNetwLayer->setLambda_g(10);

You can also do this thing in reverse, where the netw can pass info directly to the appl. You’ll need to be careful not to get cyclic inclusions as these will cause the compiler to loop. I think there’s a workaround this using prototypes (although I’m not sure if that’s the correct name).

Likewise, you can make a direct connection to myMobility. So say that my BeaconNetwLayer wants to add position and speed information in it’s beacons:

pkt->setPosX(myMobility->getMove().getStartPos().getX());
pkt->setPosY(myMobility->getMove().getStartPos().getY());
pkt->setSpeed(myMobility->getMove().getSpeed());

Simple as Pi.

Trackbacks/Pingbacks

  1. IEEE802.11 implementation in MiXiM @ Freeminded.org

Leave a Reply