Reputation: 89
I have two questions:
I wonder if anyone can help me in that, in how to use the addsleep command for example.
Another question: Besides consuming energy in transmitting and receiving, our modem draws 2.5 mA from a 5V supply while listening for the start of a packet, and can go to sleep and draw about 0.24 mA from a 5V supply, with the ability to wake up and return to the listening mode after a programmable time period. So my question is, is there a way to consider energy consumed in idle listening and sleeping in a simple energy model? We implemented a very simple energy model, something like the following (found this example in stackoverflow):
class MyHalfDuplexModem extends HalfDuplexModem {
float energy = 1000
@Override
boolean send(Message m) {
if (m instanceof TxFrameNtf) energy -= 10
if (m instanceof RxFrameNtf) energy -= 1
return super.send(m)
}
}
How to add energy consumed in idle listening, and sleeping to the above code? shall we need to use something like WakeFromSleepNtf ()
Thanks and any help is much appreciated. Marwa
Upvotes: 2
Views: 84
Reputation: 2280
The scheduler service is usually hardware dependent, as it requires interaction with the specific single board computer (SBC) to put it into a sleep state and allow it to be woken up. On modems, this is usually the modem driver agent.
The HalfDuplexModem
simulated modem doesn't provide this service, and so it won't work out of the box. Since HalfDuplexModem
doesn't have an energy model build into it, "sleep" doesn't mean much to it. If you wanted to simulate networks where nodes slept and consumed less energy during the sleep, it would be possible to extend the HalfDuplexModem
to implement the SCHEDULER service. The service is quite simple, with just 4 messages (AddScheduledSleepReq
, RemoveScheduledSleepReq
, GetSleepScheduleReq
and WakeFromSleepNtf
). Your implementation could keep track of the energy used by each node, based on whether it is sleeping, listening or transmitting, since you can keep track of the sleep schedule and hence know how much time the node has been awake/sleeping.
Commands addsleep
, showsleep
etc are simply convenience shortcuts in the shell extension that use the above 4 messages to do the actual work. They are enabled in the shell by loading the SchedulerShellExt
, and you can simply use the messages directly from agents or in simulation scripts.
Upvotes: 1