简体   繁体   中英

OMNET++: How to set node position manually in INET 4.0?

I am using INET Framework 4.0 with OMNET++ . Is there a way to manually change the position of my node to the custom position I want through the c++ files of my node's submodules (in my case, the Ieee80211MgmtAdhoc module)?

Specifying the node position from C++ code is exactly what a mobility module does. So the short answer, yes. Implement your own mobility module by deriving from a base mobility module which suits your need and then install that module into your hosts.

Note that the approach you implied, that there is a mobility model where you can call a setPosition() function from an other module (like Ieee80211MgmtAdhoc ) is an anti pattern . All code that determines the position of your node should be provided in its own (mobility) module. Mixing the positioning logic into an unrelated module (management module) is against the separation of concerns principle and will get in the way when you try to reuse your components later.

You should do it the other way. If the module position depends somehow on the state of the management module (ie you want to move towards an access point when you are associated to it), then mobility module should reach into the management module (or wherever the needed state is) and then calculate the position based on that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM