简体   繁体   English

OMNET ++:如何在INET 4.0中手动设置节点位置?

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

I am using INET Framework 4.0 with OMNET++ . 我将INET Framework 4.0与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)? 是否可以通过节点子模块(在我的情况下为Ieee80211MgmtAdhoc模块)的c++文件将节点的位置手动更改为所需的自定义位置?

Specifying the node position from C++ code is exactly what a mobility module does. 从C ++代码指定节点位置正是移动模块所做的。 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 . 请注意,您所暗示的方法是存在一个移动性模型,在该模型中可以从其他模块(例如Ieee80211MgmtAdhoc )调用setPosition()函数是一种反模式 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. 如果模块位置某种程度上取决于管理模块的状态(即,当您与之关联时,您想移向访问点),那么移动性模块应该进入管理模块(或所需状态)。基于此计算位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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