[英]Change/set new position of a node during the simulation time in Omnet++
[英]How to change configuration of network during simulation in OMNeT++?
我想在模拟运行期间(例如,当节点收到一些控制消息时)在OMNeT ++中修改元素的.ini文件的某些参数,例如节点的传输速率。
我发现信息说,可以以某种方式循环如下所示的配置: some_variable = $ { 几个值 },但是.ini文件中没有条件子句,也无法将C ++函数中的任何数据传递给这些文件(到目前为止我很担心)。
我使用的是INET,但也许其他一些模型的用户已经为此类问题感到困扰。
我发现信息说,可以以某种方式循环如下所示的配置:some_variable = $ {several values}, 但是 .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
分别是起点和终点。 t1
和t2
基于它们取值。
每次将t1
递增0.1
时, t1
将采用介于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 ++用户手册》中的相关部分。
尽管您当然可以手动更改易失性参数 ,但据我所知,OMNeT ++不提供对运行时自动更改参数的集成支持。
但是,您可以编写一些模型代码,以编程方式更改易失性参数 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.