How to make omnetpp.ini variable randomized

How to make omnetpp.ini variable randomized

In simple modal file test.ned, I defined a variable as 

double delay;

In file omnetpp.ini, I initialized the variable, using

**.delay = uniform(0,1)

In cpp file, I read the variable as

double delay=par("delay");

Unfortrunicately, the delay I read out are always the same value.

After read the "help file", I modifies it's defination as:

volatile double delay;

And the problem was solved!

The keyword volatile ask the CPU to read the variable everytime, So, It can get the randomized value among each reading process. That's the same as that works in C++.

原文地址:https://www.cnblogs.com/CUCmehp/p/1551472.html