Sebi
Sebi

Reputation: 4532

Getting real time statistics in Omnet++

In:

https://docs.omnetpp.org/tutorials/tictoc/part5/

and

https://doc.omnetpp.org/omnetpp/manual/#sec:simple-modules:declaring-statistics

it's shown how network statistics can be processed after a simulation.

Is it possible to get network parameters dynamically?

Upvotes: 0

Views: 808

Answers (1)

Rudi
Rudi

Reputation: 6681

TL;DR: Use signals (not statistics) and hook up your own simple module on these signals and compute the required statistics in that module.

You cannot access the value of @statistics in your code, and there is a reason for this as this would be an anti pattern. NED based statistics were introduced as a method to add calculations and measurements to your model without modifying your models behavior and code. This means that statistics are NOT considered part of a model, but rather they are considered as a configuration. Changing a statistics (i.e. deciding that you want to measure something else) should never change the behavior of your model. That's why the actual value of a given statistic is not exposed (easily) to the C++ code. You could dig them out, but it is highly discouraged.

Now, this does not mean that what you want to achieve is not legitimate but the actual statistics gathering must be an integral part of your model. I.e. you should not aim for using built-in statistics, but rather create an explicit statistics gathering submodule that should hook up on the necessary signals (https://doc.omnetpp.org/omnetpp/manual/#sec:simple-modules:subscribing-to-signals) and do the actual statistics computation you need in its C++ code. After that, other modules are free to access this information and make decisions based on that.

Upvotes: 2

Related Questions