multiple sample rates

78 views
Skip to first unread message

Reham sabri

unread,
Nov 18, 2009, 6:56:01 AM11/18/09
to castalia-...@googlegroups.com
Hello,
I want to have multiple sample rates. The first node sends with 0.7s sample interval and the second node sends with 5s sample interval.

I have tried to achieve that by the following code but it does not work probably..

.......................................

#define APP_FIRST_INTERVAL 0.7

#define APP_SECOND_INTERVAL 5


...........
case APP_NODE_STARTUP:
        {
            disabled = 0;
            scheduleAt(simTime(), new App_ControlMessage("Application self message (request sample)", APP_SELF_REQUEST_SAMPLE));

            break;
        }

.......................................................

case APP_SELF_REQUEST_SAMPLE:
        {
            requestSampleFromSensorManager();

            // schedule the first source to send a sample each 0.7s
            scheduleAt(simTime()+DRIFTED_TIME(APP_FIRST_INTERVAL), new App_ControlMessage("Application self  message (request sample)", APP_SELF_REQUEST_SAMPLE));
          
 // schedule the second source to send a sample each 5s
scheduleAt(simTime()+DRIFTED_TIME(APP_SECOND_INTERVAL), new App_ControlMessage("Application self message (request sample)", APP_SELF_REQUEST_SAMPLE));

            break;
        }

........................................................
Please let me know if any one have tried to do that before......

Thanks in advance
 Reham

Athanassios Boulis

unread,
Nov 18, 2009, 7:37:01 AM11/18/09
to castalia-...@googlegroups.com
The code you just presented here will schedule 2 new APP_SELF_REQUEST_SAMPLE
messages for any one it receives. (Do you see that both scheduleAt commands are executed?)
This will happen to every node.
So as a result the messages will exponentially increase making the simulation slower and slower,
plus you do not get the functionality you want.

If you wanted to to schedule different sampling rates you would have to execute just one
of these statements (may choosing it by node ID). Or even better just have one statement
but have a parameter in the app module that will define the sampling rate. This way
you can specify in the omnetpp.ini file which nodes sample at which rate.

Reham sabri

unread,
Nov 18, 2009, 9:22:26 AM11/18/09
to castalia-...@googlegroups.com
Hello Athanassios,
Oh, I see... thanks very much for the hint, here I modified the code as you suggested and yes it seems fine at least to me:)

.............
initialization :

     packet_rate = hasPar("packet_rate") ? par("packet_rate") : 5;  
     sample_interval  = packet_rate > 0 ? 1/float(packet_rate) : -1;

........................................

case APP_NODE_STARTUP:
        {
           
            disabled = 0;
   
//  Only node0 and node1 samples packets 
            if (self<=1) {

            scheduleAt(simTime(), new App_ControlMessage("Application self message (request sample)", APP_SELF_REQUEST_SAMPLE));

            break;
        }
...................................................................................................

        case APP_SELF_REQUEST_SAMPLE:
        {
            requestSampleFromSensorManager();

            scheduleAt(simTime()+ DRIFTED_TIME(sample_interval), new App_ControlMessage("Application self message (request sample)", APP_SELF_REQUEST_SAMPLE));
           
break;

        }

then in the omnet.ini I have:

SN.node[0].nodeApplication.packet_rate =  1.4
SN.node[1].nodeApplication.packet_rate =  0.2
SN.node[2..4].nodeApplication.packet_rate =  0 # they do not sample

In my example, I only have node0 and node1 sampling with different rates and  the other nodes are just receivers!

Does this look ok :) if yes then I start to do Castalia....
My supervisor asked my,  Why do you named the simulator Castalia ?? is there a reason??

Thank you
 Reham



--

You received this message because you are subscribed to the Google Groups "Castalia Simulator" group.
To post to this group, send email to castalia-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castalia-simulator?hl=.

Athanassios Boulis

unread,
Nov 18, 2009, 9:48:29 AM11/18/09
to castalia-...@googlegroups.com
Almost correct, but yes this is the idea!
If a node has a packet rate 0 (if it is not defined maybe you want to make it 0 instead of 5)
then this means that it should not sample. But you define the sample interval as
being -1 which will then have the effect of trying to schedule an event in the past.
OMNeT will throw an error on this. Instead what you want is to check at the node
start up if the rate is 0, and if it is, never schedule the initial 
APP_SELF_REQUEST_SAMPLE message

Btw, the code you show, just samples and does not transmit a packet.
if you want to transmit a packet with the sample you will have to use 
send2NetworkDataPacket. 

For explanation of the Castalia name see the NAQ page in the web site
It is one of the NAQs/FAQs

Reply all
Reply to author
Forward
0 new messages