0
votes

There is a wirelessHost which communicates with standardHost through the AP. wirelessHost is moving in LinearMobility with the speed of 40mps that is configured in ini. Now I want to get the speed value in UDPBasicApp, and this value should be send to the reciever(standardHost).

Note: I'm using inet 3.6.7 and omnet++ 5.5.1.

1

1 Answers

0
votes

The easiest way is to access directly to mobility module from the Udp app module. Appp and mobility modules are child of host module. So, you need to write the following inside UDP module:

cModule* mobilityMod = getParentModule()->getSubmodule("mobility", 0);

Usually mobility is the name of the mobility module, if it has another name, then you have to change it in getSubmodule() function. You can make a dynamic_cast to evaluate the tyoe of mobility and you will have access to its internal functions. For example:

dynamic_cast<LinearMobility*>(mobilityMod)->getSpeed();

getSpeed() or any other getter or setter function. More help in this link: https://doc.omnetpp.org/omnetpp/api/classomnetpp_1_1cModule.html