Is there a way to put a varying PER(packet error rate) in the omnet.ini file for a single simulation? I know to simulate for different simulations and compare the graph, but I want one simulation which varies PER. Generally, we put the PER in the ini file as in percentage and have a constant PER but I want is varying one between 1% to 50%.
PER = 0.5 #Generally we do like this to show 50% PER
PER= #(0.1 to 0.5) #I need something like this
Hope I am clear.
There are two ways of achieving your goal.
Method 1
In NED declare PER parameter with volatile
:
parameters:
volatile double PER;
In omnetpp.ini
use a random distribution, for example a uniform distribution:
**.somemodule.PER = uniform(0.01, 0.50)
In C++ code of your module use par("PER")
in every place where that value is read.
Thanks to volatile
every time that parameter is read, a new random value is chosen. Reference: OMNeT++ Simulation Manual
Method 2
In NED declare two parameters:
parameters:
double minPER;
double maxPER;
In omnetpp.ini
set the values of these parameters:
**.somemodule.minPER = 0.01
**.somemodule.maxPER = 0.50
In initialize()
of your C++ class read these parameters, e.g.:
minPER = par("minPER");
maxPER = par("maxPER");
In C++ in the place where PER value is necessary generate the current value using a random distribution, for example:
double per = uniform(minPER, maxPER);