Hi,
Please if anyone can guide me about global variable specific to one router.
I have four modules in router (scheduler, inport , ouput port calculator and vc calculator) . I want to access one variable of type int to be accessible by all modules of every router (16 routers in Mesh).
I am trying with header file i.e. declared public variable in header file and added that header file in every module. And declared that variable as public in every module. But I don’t know the value doesn't remain same or constant. This is some thing related to C++ but still not able to use in OMNET.
Any suggestion will be highly appreciated.
Thank you.
Dear Rudolf,
In my case I want to collect the network metrics at the very end of the simulation when all the finish() methods for all modules are called.
I though about a class that could contain a static metric, which should be updated each time a finish() method is called.
what do you exactly mean by signal based statistics gathering? Using what the chapter 4.14 describes?
I could inherate from cListener indeed and update the metrics as soon as the signals are being emitted. However,
think about having 200 nodes and collecting metrics from 4 different layers (I use MiXiM).
Don't you think that it could be slow?
Could it be better a singleton pattern approach?
On Tuesday, 19 February 2013 11:31:49 UTC+1, Humberto wrote:Dear Rudolf,
In my case I want to collect the network metrics at the very end of the simulation when all the finish() methods for all modules are called.
I though about a class that could contain a static metric, which should be updated each time a finish() method is called.
While this is feasible (perhaps that class should be a simple module itself at the network level) you will have an issue here: the order in which the finish methods are called at the end of simulation is undefined, so how do you know that ALL finish methods are called already and you have to write out your own global network statistic.
(I admit you can do some tricks here like on each call to the global statistics module you increase a counter and you will now when the last call occurred (if you know the number of nodes in the network in advance), and after that call, you can write out also the global statistics. This is a bit hackish, but works.
i.e. you would have a networkStatistics simple module. It would have a parameter that tells how many calls can be made to its gatherStatistics() methods before it assumes that all modules has sent the values in and writes out the summary results. On the other hand if you gather a lot of data from a lot of different submodules inside a node, this becomes quite�unmanageable.��
what do you exactly mean by signal based statistics gathering? Using what the chapter 4.14 describes?
Yes, but that chapter�describes�only the base mechanism of signals. Statistics are covered here:
I could inherate from cListener indeed and update the metrics as soon as the signals are being emitted. However,
�think about having 200 nodes and collecting metrics from 4 different layers (I use MiXiM).
It depends really on what data you need. The question is: if you can do the network level statistics at the last step (i.e. in finish stage) why cant you do that AFTER the simulation has finished totally. (i.e. doing some post processing on the results itself). I admit it is not so pretty as you have to do an additional step in R or with some other approach.
�Don't you think that it could be slow?
No, signals are pretty fast and all of the statistics are already gathered at the module level, so gathering them at the network level just duplicates the amount of work required. please note also that you DO NOT have to do this manually. All you need is that you insert the needed @statistics definitions at the network level (i.e. copy it out from the NEd definitions from the modules).
Now unfortunately (after a quick look into MIXIM): it seems that mixim does not use the signal based statistics gathering at all so you are out of luck and cannot use the @statistics declarations :( (INET does use signals and it is much easier to gather signal network level stats)Could it be better a singleton pattern approach?
For MIXIM, I think you should either�
- go with the singleton based one (although I would implement it as a separate simple module instead of using static variables)- do some postprocessing on the results after the simulation finished
I do not recommend going with the litener/signal based approach (for MIXIM). For INET, signals would be the best choice.
�
What is your opinion?
Kind regards
El lunes, 26 de noviembre de 2012 14:42:14 UTC+1, Rudolf Hornig escribi�:
What you are looking for is called static member variables (and has nothing to do with the access modifies (i.e. public)
as an added note: It is a very bad design decision to have global variables in a simulation. With perhaps the exception of global statistics variables (but global statistics also can be gathered with signal based statistics gathering). Generally, if you need a global variable, chances are that you are �doing something wrong...
Rudolf
On Monday, November 26, 2012 1:49:02 PM UTC+1, Athar wrote:
Hi,
Please if anyone can guide me about global variable specific to one router.�
I have four modules in router (scheduler, inport , ouput port calculator and vc calculator) . I want to access one variable of type int to be accessible by all modules of every router (16 routers in Mesh).
I am trying with header file i.e. declared public variable in header file and added that header file in every module. And declared that variable as public in every module. But I don�t know the value�doesn't�remain same or constant. This is some thing related to C++ but still not able to use in OMNET.
Any suggestion will be highly appreciated.
Thank you.
--
--
Sent from the OMNeT++ mailing list. To configure your membership,
visit http://groups.google.com/group/omnetpp
�
---
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
�
�
Postprocessing is what I am trying to avoid in order to optimize the analysis of my results
Now I am trying to populate everything through static structs inside my external class, that does not inherits� from cSimpleModule. By now, compiles without troubles :D
For your remark ("order in which the finish methods are called at the end of simulation is undefined") I guess, I will use my GlobalMetrics::destructor().
I believe all the finish() methods had been already called once the simulation_main()� ends, right? but not the destructor.