how to stop simulation when remaining energy is zero?

99 views
Skip to first unread message

Soumya Banerjee

unread,
Mar 21, 2014, 8:36:59 AM3/21/14
to ns-3-...@googlegroups.com
I am trying to simulate a wsn network in which nodes die when out of energy


i was looking at the following script

https://www.nsnam.org/oxygen/energy-model-example_8cc_source.html

but here the simulation does not stop even when the remaining energy has reached negative values.  how to modify it so that it does?



a semi-related query in lines 253 and 258  how are the parameters  to the following functions being passed?
97 void
98 RemainingEnergy (double oldValue, double remainingEnergy


57 void


250  // all sources are connected to node 1
251  // energy source
252  Ptr<BasicEnergySource> basicSourcePtr = DynamicCast<BasicEnergySource> (sources.Get (1));
253  basicSourcePtr->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
254  // device energy model
255  Ptr<DeviceEnergyModel> basicRadioModelPtr =
256  basicSourcePtr->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
257  NS_ASSERT (basicRadioModelPtr != NULL);
258  basicRadioModelPtr->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));

Konstantinos

unread,
Mar 21, 2014, 9:14:29 AM3/21/14
to ns-3-...@googlegroups.com
Hi,

I am not an expert on the Energy module, but I think it only "measures" the energy depending on the states of the WiFi (sending, receiving etc).
You will need to implement an application or any other mechanism that will look at the Energy level of the node and decide to send or not. The example you posted does not do that. It only prints in the output the energy.

Regards,
K.

Tommaso Pecorella

unread,
Mar 21, 2014, 4:29:39 PM3/21/14
to ns-3-...@googlegroups.com
Hi,

this is a feature being reviewed. Expect it soon™ (i.e., when we'll be able to find enough time to review it).

T.
Reply all
Reply to author
Forward
0 new messages