Nowadays, I'm doing a little much simulation in opnet.
Here, I find a way to do the custom statistic in OPNET, because I should statistic a value that the opnet does not provided by default.
There are 4 steps to do the custom statistic.
- In the Process Model where you should culculate the statistic, define a Stathandle in the State Variable. Here we define a Stathandle "avg_delay_gsh".
- Still in Process Model, define a "Global Statistic" by clicking Interface Menu, and choose the Global Statistics Menu Item. Here, we define it as "Average Delay".
- in the Enter Execs of the Init State, write the following code:
avg_delay_gsh = op_stat_reg( " Average Delay " ,OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL); - In somewhere you should culculate the statistic value, write the following code:
op_stat_write(avg_delay_gsh,delay);
Now, you have write the statistic value to your simulation system, in the graph tool, you can draw a plot of the statistic Average Delay now.