在OMNeT++中,如何在模拟过程中更改网络配置
How to change configuration of network during simulation in OMNeT++?
我想在模拟运行期间,例如当节点接收到一些控制消息时,修改OMNeT++中元素的.ini文件的一些参数,比如节点的传输速率。
我发现有信息表明,可以以某种方式循环如下所述的配置:some_variable=${几个值},但.ini文件中没有条件子句,也没有办法将C++函数的任何数据传递给这些文件(就我而言)。
我使用INET,但可能其他一些型号的用户已经遇到了这样的问题。
我发现有信息表明,可以以某种方式循环如下所述的配置:some_variable=${几个值},,但.ini文件中没有条件子句,也没有办法将C++函数的任何数据传递给这些文件(就我而言)。
实际上,您可以在INI文件中使用内置的约束表达式。这将允许您为给定配置创建运行,同时遵守指定的约束(条件)。
但是,这个约束只适用于.ini文件中指定的参数,也就是说,如果您试图更改的变量是作为代码的一部分动态计算的,这对您没有帮助
下面,我从.ini文件中为您提供了一个相当复杂的"代码片段",它使用了您提到的许多内置函数(变量迭代、条件等)
# Parameter assignment using iteration loops and constrains #
# first define the static values on which the others depend #
scenario.node[*].application.ADVlowerBound = ${t0= 0.1}s
scenario.node[*].application.aggToServerUpperBound = ${t3= 0.9}s
#
## assign values to "dependent" parameters using variable names and loop iterations #
scenario.node[*].application.ADVupperBound = ${t1= ${t0}..${t3} step 0.1}s # ADVupperBound == t1; t1 will take values starting from t0 to t3 (0.1 - 0.9) iterating 0.1
scenario.node[*].application.CMtoCHupperBound = ${t2= ${t0}..${t3} step 0.1}s
#
## connect "dependent" parameters to their "copies" -- this part of the snippet is only variable assignment.
scenario.node[*].application.CMtoCHlowerBound = ${t11 = ${t1}}s
scenario.node[*].application.joinToServerLowerBound = ${t12 = ${t1}}s
#
scenario.node[*].application.aggToServerLowerBound = ${t21 = ${t2}}s
scenario.node[*].application.joinToServerUpperBound = ${t22 = ${t2}}s
#
constraint = ($t0) < ($t1) && ($t1) < ($t2) && ($t2) < ($t3)
# END END END #
上面的代码创建了t0
到t3
的所有可能的时间值组合,其中它们可以取0.1
和0.9
之间的值。
t0
和t3
分别是起点和终点。CCD_ 7和CCD_。
t1
每次递增0.1
时将取t0
和t3
之间的值(参见上面的语法)。t2
也是如此。
但是,我希望t0
总是小于t1
,t1
小于t2
,t2
小于t3
。我在constraint
部分中指定了这些条件。
我相信,仔细阅读本手册的这一部分,将有助于您找到解决方案。
如果你想在模拟过程中更改一些值,你可以在C++代码中这样做。类似于:
handleMessage(cMessage *msg){
if(msg->getKind() == yourKind){ // replace yourKind with the one you are using for these messages
transmission_rate = new_value;
}
您所指的some_variable=${几个值}可以用于使用不同的参数执行多次运行。例如,一次运行的速率为1s,一次为2s,另一次为10s。那就是:
transsmission_rate = ${1, 2, 10}s
有关如何使用此类值(如循环)的更多详细信息,请参阅OMNeT++用户手册中的相关章节
虽然您当然可以手动更改volatile参数,但OMNeT++(据我所知)不提供在运行时自动更改参数的集成支持。
但是,您可以编写一些模型代码,以编程方式更改volatile参数。
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- 我的神经网络不起作用 [XOR 问题]
- 无法找到/读取配置文件.conf-FileIOException
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 通过网络、跨平台传递std::变体是否安全
- 如何在MNIST上提高网络运行的准确性
- 一种在C++中读取TXT配置文件的简单方法
- 生成MRPT库时cmake配置失败
- Active Directory:从网络服务帐户下运行的Windows服务调用ADsOpenObject时失败
- FFMPEG配置文件级别id大小无效
- 如何通过Conan和CMake找到用于pkg配置的.pc文件
- OpenCV 4.1.2 - 从网络摄像头获取帧并将其拆分
- 使用OpenCV和覆盆子上的多个网络摄像头拍摄延时摄影,出现多个V4L错误
- 配置文件解析器仅返回以前的值
- 我的程序有一个保存配置文件的GUI,如何双击此配置文件以直接加载带有配置数据的GUI?
- 更改命令行 qt5 源代码构建配置的正确/快速方法
- 神经网络不学习.卡在50%
- 如何绑定 C++ gRPC 客户端的网络接口
- 在OMNeT++中,如何在模拟过程中更改网络配置