问题描述
S.node[0..4].forwarding = false
我想做的是在UDPBasicApp模块中动态更改参数“ forwarding”(在真假之间动态切换)。
void UDPBasicApp::processForwardSwitch(){
if (isSelfish) {
//std::cout << host->par("forwarding").str() << std::endl;
if (rand()%10<5)
host->par("forwarding").setBoolValue(false);
else
host->par("forwarding").setBoolValue(true);
}
scheduleAt(simTime()+forwardSwitchInterval,forwardSwitchTimer);
}
我可以确认参数值在仿真过程中确实发生了变化,但是似乎对与此参数相关的模块没有影响,例如路由模块。 有人帮忙吗? 预先感谢!
解决方法
通常,在模块初始化期间,参数只能读取一次。