How to dynamically change a parameter of module from another one in OMNeT++5.5?

335 views Asked by At

I have written a line of codes in omnetpp.ini file like:

S.node[0..4].forwarding = false

What I want to do is change the parameter "forwarding" dynamically (dynamically switching between true and false) in UDPBasicApp module.

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);

}

I can confirm the value of the parameter does changes during simulation, but it seems no effect to the modules related to this parameter, e.g. routing modules. Anyone help? Thanks in advance!

1

There are 1 answers

0
Jerzy D. On BEST ANSWER

Usually parameters are read only once, during initialization of a module.