Since version 4.1
OMNeT++ introduced the concept of statistics/metrics collection and recording using the signal mechanisms.
In brief, the signal mechanism works as follows: a given value is attached to a (built-in object of type) signal and this information is recorded to output files (either as scalars or as vectors) which later on can be analyzed in order to infer certain behavior.
If you don't understand really how this mechanism works please make sure to first read the following sections of the OMNeT++ manual:
- 4.15 Signal-Based Statistics Recording
- 12 Result Recording and Analysis
Once you wrap your head around these concepts you will feel more comfortable to get what you want in terms of output results.
As far as your question is concerned if you want to use the signalling mechanisms in the SimpleServerApp
you will first have to declare the signals and the corresponding statistic in the .ned
file:
@signal[nameOfSignal](type="sameAsTypeOfVariable");
@statistic[nameOfStatistic](title="nameToAppearInTheOutputFile"; source="nameOfTheSourceOfThisStatistic"; record=typeOfStat1, typeOfStat2, typeOfStat2);
Then you need to declare the signal variable in .h
:
simsignal_t nameOfMetricSignal;
Then register the signal in the initialize()
in .cc
same as the name that you used in the .ned
for the signal:
nameOfMetricSignal = registerSignal("nameOfSignal");
Lastly, all you have to do is emit()
the signal. That is, attach the value to the signal and let it be recorded. The location where you want to do that depends on your implementation.
emit(nameOfMetricSignal, theVariableToBeAttached);
For you that would be something like:
NED:
@signal[delay](type="float");
@statistic[delay](title="delay"; source="delay"; record=mean, sum, stats, vector);
.h
simsignal_t delaySignal;
.cc
delaySignal = registerSignal("delay");
.cc
emit(delaySignal, delay);
If you are getting 0
or Nan
that could be due to division by wrong number, wrong type of signal compared to the type of the variable. Also, make sure vector and scalar recording is not turned off (false
) in the omnetpp.ini