A Discrete-Event Network Simulator
API
wifi-radio-energy-model.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/simulator.h"
23 #include "ns3/pointer.h"
24 #include "ns3/energy-source.h"
26 #include "wifi-tx-current-model.h"
27 
28 namespace ns3 {
29 
30 NS_LOG_COMPONENT_DEFINE ("WifiRadioEnergyModel");
31 
32 NS_OBJECT_ENSURE_REGISTERED (WifiRadioEnergyModel);
33 
34 TypeId
36 {
37  static TypeId tid = TypeId ("ns3::WifiRadioEnergyModel")
39  .SetGroupName ("Energy")
40  .AddConstructor<WifiRadioEnergyModel> ()
41  .AddAttribute ("IdleCurrentA",
42  "The default radio Idle current in Ampere.",
43  DoubleValue (0.273), // idle mode = 273mA
46  MakeDoubleChecker<double> ())
47  .AddAttribute ("CcaBusyCurrentA",
48  "The default radio CCA Busy State current in Ampere.",
49  DoubleValue (0.273), // default to be the same as idle mode
52  MakeDoubleChecker<double> ())
53  .AddAttribute ("TxCurrentA",
54  "The radio Tx current in Ampere.",
55  DoubleValue (0.380), // transmit at 0dBm = 380mA
58  MakeDoubleChecker<double> ())
59  .AddAttribute ("RxCurrentA",
60  "The radio Rx current in Ampere.",
61  DoubleValue (0.313), // receive mode = 313mA
64  MakeDoubleChecker<double> ())
65  .AddAttribute ("SwitchingCurrentA",
66  "The default radio Channel Switch current in Ampere.",
67  DoubleValue (0.273), // default to be the same as idle mode
70  MakeDoubleChecker<double> ())
71  .AddAttribute ("SleepCurrentA",
72  "The radio Sleep current in Ampere.",
73  DoubleValue (0.033), // sleep mode = 33mA
76  MakeDoubleChecker<double> ())
77  .AddAttribute ("TxCurrentModel", "A pointer to the attached tx current model.",
78  PointerValue (),
80  MakePointerChecker<WifiTxCurrentModel> ())
81  .AddTraceSource ("TotalEnergyConsumption",
82  "Total energy consumption of the radio device.",
84  "ns3::TracedValueCallback::Double")
85  ;
86  return tid;
87 }
88 
90  : m_source (0),
91  m_currentState (WifiPhyState::IDLE),
92  m_lastUpdateTime (Seconds (0.0)),
93  m_nPendingChangeState (0)
94 {
95  NS_LOG_FUNCTION (this);
97  // set callback for WifiPhy listener
100  // set callback for updating the tx current
102 }
103 
105 {
106  NS_LOG_FUNCTION (this);
107  m_txCurrentModel = 0;
108  delete m_listener;
109 }
110 
111 void
113 {
114  NS_LOG_FUNCTION (this << source);
115  NS_ASSERT (source != NULL);
116  m_source = source;
118  Time durationToOff = GetMaximumTimeInState (m_currentState);
120 }
121 
122 double
124 {
125  NS_LOG_FUNCTION (this);
126 
127  Time duration = Simulator::Now () - m_lastUpdateTime;
128  NS_ASSERT (duration.GetNanoSeconds () >= 0); // check if duration is valid
129 
130  // energy to decrease = current * voltage * time
131  double energyToDecrease = 0.0;
132  double supplyVoltage = m_source->GetSupplyVoltage ();
133  switch (m_currentState)
134  {
135  case WifiPhyState::IDLE:
136  energyToDecrease = duration.GetSeconds () * m_idleCurrentA * supplyVoltage;
137  break;
139  energyToDecrease = duration.GetSeconds () * m_ccaBusyCurrentA * supplyVoltage;
140  break;
141  case WifiPhyState::TX:
142  energyToDecrease = duration.GetSeconds () * m_txCurrentA * supplyVoltage;
143  break;
144  case WifiPhyState::RX:
145  energyToDecrease = duration.GetSeconds () * m_rxCurrentA * supplyVoltage;
146  break;
148  energyToDecrease = duration.GetSeconds () * m_switchingCurrentA * supplyVoltage;
149  break;
150  case WifiPhyState::SLEEP:
151  energyToDecrease = duration.GetSeconds () * m_sleepCurrentA * supplyVoltage;
152  break;
153  case WifiPhyState::OFF:
154  energyToDecrease = 0;
155  break;
156  default:
157  NS_FATAL_ERROR ("WifiRadioEnergyModel:Undefined radio state: " << m_currentState);
158  }
159 
160  // notify energy source
161  m_source->UpdateEnergySource ();
162 
163  return m_totalEnergyConsumption + energyToDecrease;
164 }
165 
166 double
168 {
169  NS_LOG_FUNCTION (this);
170  return m_idleCurrentA;
171 }
172 
173 void
175 {
176  NS_LOG_FUNCTION (this << idleCurrentA);
177  m_idleCurrentA = idleCurrentA;
178 }
179 
180 double
182 {
183  NS_LOG_FUNCTION (this);
184  return m_ccaBusyCurrentA;
185 }
186 
187 void
189 {
190  NS_LOG_FUNCTION (this << CcaBusyCurrentA);
191  m_ccaBusyCurrentA = CcaBusyCurrentA;
192 }
193 
194 double
196 {
197  NS_LOG_FUNCTION (this);
198  return m_txCurrentA;
199 }
200 
201 void
203 {
204  NS_LOG_FUNCTION (this << txCurrentA);
205  m_txCurrentA = txCurrentA;
206 }
207 
208 double
210 {
211  NS_LOG_FUNCTION (this);
212  return m_rxCurrentA;
213 }
214 
215 void
217 {
218  NS_LOG_FUNCTION (this << rxCurrentA);
219  m_rxCurrentA = rxCurrentA;
220 }
221 
222 double
224 {
225  NS_LOG_FUNCTION (this);
226  return m_switchingCurrentA;
227 }
228 
229 void
231 {
232  NS_LOG_FUNCTION (this << switchingCurrentA);
233  m_switchingCurrentA = switchingCurrentA;
234 }
235 
236 double
238 {
239  NS_LOG_FUNCTION (this);
240  return m_sleepCurrentA;
241 }
242 
243 void
245 {
246  NS_LOG_FUNCTION (this << sleepCurrentA);
247  m_sleepCurrentA = sleepCurrentA;
248 }
249 
252 {
253  NS_LOG_FUNCTION (this);
254  return m_currentState;
255 }
256 
257 void
260 {
261  NS_LOG_FUNCTION (this);
262  if (callback.IsNull ())
263  {
264  NS_LOG_DEBUG ("WifiRadioEnergyModel:Setting NULL energy depletion callback!");
265  }
266  m_energyDepletionCallback = callback;
267 }
268 
269 void
272 {
273  NS_LOG_FUNCTION (this);
274  if (callback.IsNull ())
275  {
276  NS_LOG_DEBUG ("WifiRadioEnergyModel:Setting NULL energy recharged callback!");
277  }
278  m_energyRechargedCallback = callback;
279 }
280 
281 void
283 {
284  m_txCurrentModel = model;
285 }
286 
287 void
289 {
290  if (m_txCurrentModel)
291  {
292  m_txCurrentA = m_txCurrentModel->CalcTxCurrent (txPowerDbm);
293  }
294 }
295 
296 Time
298 {
299  Time remainingTime;
300  double remainingEnergy = m_source->GetRemainingEnergy ();
301  double supplyVoltage = m_source->GetSupplyVoltage ();
302  switch (state)
303  {
304  case WifiPhyState::IDLE:
305  remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_idleCurrentA * supplyVoltage))));
306  break;
308  remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_ccaBusyCurrentA * supplyVoltage))));
309  break;
310  case WifiPhyState::TX:
311  remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_txCurrentA * supplyVoltage))));
312  break;
313  case WifiPhyState::RX:
314  remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_rxCurrentA * supplyVoltage))));
315  break;
317  remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_switchingCurrentA * supplyVoltage))));
318  break;
319  case WifiPhyState::SLEEP:
320  remainingTime = NanoSeconds (static_cast<uint64_t> (1e9 * (remainingEnergy / (m_sleepCurrentA * supplyVoltage))));
321  break;
322  default:
323  NS_FATAL_ERROR ("WifiRadioEnergyModel: undefined radio state " << state);
324  }
325  return remainingTime;
326 }
327 
328 void
330 {
331  NS_LOG_FUNCTION (this << newState);
332 
334 
335  if (m_nPendingChangeState > 1 && newState == WifiPhyState::OFF)
336  {
337  SetWifiRadioState ((WifiPhyState) newState);
339  return;
340  }
341 
342  if (newState != WifiPhyState::OFF)
343  {
345  Time durationToOff = GetMaximumTimeInState (newState);
347  }
348 
349  Time duration = Simulator::Now () - m_lastUpdateTime;
350  NS_ASSERT (duration.IsPositive ()); // check if duration is valid
351 
352  // energy to decrease = current * voltage * time
353  double energyToDecrease = 0.0;
354  double supplyVoltage = m_source->GetSupplyVoltage ();
355  switch (m_currentState)
356  {
357  case WifiPhyState::IDLE:
358  energyToDecrease = (duration.GetNanoSeconds () * m_idleCurrentA * supplyVoltage) / 1e9;
359  break;
361  energyToDecrease = (duration.GetNanoSeconds () * m_ccaBusyCurrentA * supplyVoltage) / 1e9;
362  break;
363  case WifiPhyState::TX:
364  energyToDecrease = (duration.GetNanoSeconds () * m_txCurrentA * supplyVoltage) / 1e9;
365  break;
366  case WifiPhyState::RX:
367  energyToDecrease = (duration.GetNanoSeconds () * m_rxCurrentA * supplyVoltage) / 1e9;
368  break;
370  energyToDecrease = (duration.GetNanoSeconds () * m_switchingCurrentA * supplyVoltage) / 1e9;
371  break;
372  case WifiPhyState::SLEEP:
373  energyToDecrease = (duration.GetNanoSeconds () * m_sleepCurrentA * supplyVoltage) / 1e9;
374  break;
375  case WifiPhyState::OFF:
376  energyToDecrease = 0.0;
377  break;
378  default:
379  NS_FATAL_ERROR ("WifiRadioEnergyModel: undefined radio state " << m_currentState);
380  }
381 
382  // update total energy consumption
383  m_totalEnergyConsumption += energyToDecrease;
384  NS_ASSERT (m_totalEnergyConsumption <= m_source->GetInitialEnergy ());
385 
386  // update last update time stamp
388 
389  // notify energy source
390  m_source->UpdateEnergySource ();
391 
392  // in case the energy source is found to be depleted during the last update, a callback might be
393  // invoked that might cause a change in the Wifi PHY state (e.g., the PHY is put into SLEEP mode).
394  // This in turn causes a new call to this member function, with the consequence that the previous
395  // instance is resumed after the termination of the new instance. In particular, the state set
396  // by the previous instance is erroneously the final state stored in m_currentState. The check below
397  // ensures that previous instances do not change m_currentState.
398 
400  {
401  // update current state & last update time stamp
402  SetWifiRadioState ((WifiPhyState) newState);
403 
404  // some debug message
405  NS_LOG_DEBUG ("WifiRadioEnergyModel:Total energy consumption is " <<
406  m_totalEnergyConsumption << "J");
407  }
408 
410 }
411 
412 void
414 {
415  NS_LOG_FUNCTION (this);
416  NS_LOG_DEBUG ("WifiRadioEnergyModel:Energy is depleted!");
417  // invoke energy depletion callback, if set.
419  {
421  }
422 }
423 
424 void
426 {
427  NS_LOG_FUNCTION (this);
428  NS_LOG_DEBUG ("WifiRadioEnergyModel:Energy is recharged!");
429  // invoke energy recharged callback, if set.
431  {
433  }
434 }
435 
436 void
438 {
439  NS_LOG_FUNCTION (this);
440  NS_LOG_DEBUG ("WifiRadioEnergyModel:Energy is changed!");
442  {
444  Time durationToOff = GetMaximumTimeInState (m_currentState);
446  }
447 }
448 
451 {
452  NS_LOG_FUNCTION (this);
453  return m_listener;
454 }
455 
456 /*
457  * Private functions start here.
458  */
459 
460 void
462 {
463  NS_LOG_FUNCTION (this);
464  m_source = NULL;
466 }
467 
468 double
470 {
471  switch (m_currentState)
472  {
473  case WifiPhyState::IDLE:
474  return m_idleCurrentA;
476  return m_ccaBusyCurrentA;
477  case WifiPhyState::TX:
478  return m_txCurrentA;
479  case WifiPhyState::RX:
480  return m_rxCurrentA;
482  return m_switchingCurrentA;
483  case WifiPhyState::SLEEP:
484  return m_sleepCurrentA;
485  case WifiPhyState::OFF:
486  return 0.0;
487  default:
488  NS_FATAL_ERROR ("WifiRadioEnergyModel: undefined radio state " << m_currentState);
489  }
490 }
491 
492 void
494 {
495  NS_LOG_FUNCTION (this << state);
496  m_currentState = state;
497  std::string stateName;
498  switch (state)
499  {
500  case WifiPhyState::IDLE:
501  stateName = "IDLE";
502  break;
504  stateName = "CCA_BUSY";
505  break;
506  case WifiPhyState::TX:
507  stateName = "TX";
508  break;
509  case WifiPhyState::RX:
510  stateName = "RX";
511  break;
513  stateName = "SWITCHING";
514  break;
515  case WifiPhyState::SLEEP:
516  stateName = "SLEEP";
517  break;
518  case WifiPhyState::OFF:
519  stateName = "OFF";
520  break;
521  }
522  NS_LOG_DEBUG ("WifiRadioEnergyModel:Switching to state: " << stateName <<
523  " at time = " << Simulator::Now ());
524 }
525 
526 // -------------------------------------------------------------------------- //
527 
529 {
530  NS_LOG_FUNCTION (this);
533 }
534 
536 {
537  NS_LOG_FUNCTION (this);
538 }
539 
540 void
542 {
543  NS_LOG_FUNCTION (this << &callback);
544  NS_ASSERT (!callback.IsNull ());
545  m_changeStateCallback = callback;
546 }
547 
548 void
550 {
551  NS_LOG_FUNCTION (this << &callback);
552  NS_ASSERT (!callback.IsNull ());
553  m_updateTxCurrentCallback = callback;
554 }
555 
556 void
558 {
559  NS_LOG_FUNCTION (this << duration);
561  {
562  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
563  }
566 }
567 
568 void
570 {
571  NS_LOG_FUNCTION (this);
573  {
574  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
575  }
577 }
578 
579 void
581 {
582  NS_LOG_FUNCTION (this);
584  {
585  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
586  }
588 }
589 
590 void
592 {
593  NS_LOG_FUNCTION (this << duration << txPowerDbm);
595  {
596  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Update tx current callback not set!");
597  }
598  m_updateTxCurrentCallback (txPowerDbm);
600  {
601  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
602  }
604  // schedule changing state back to IDLE after TX duration
607 }
608 
609 void
611 {
612  NS_LOG_FUNCTION (this << duration);
614  {
615  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
616  }
618  // schedule changing state back to IDLE after CCA_BUSY duration
621 }
622 
623 void
625 {
626  NS_LOG_FUNCTION (this << duration);
628  {
629  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
630  }
632  // schedule changing state back to IDLE after CCA_BUSY duration
635 }
636 
637 void
639 {
640  NS_LOG_FUNCTION (this);
642  {
643  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
644  }
647 }
648 
649 void
651 {
652  NS_LOG_FUNCTION (this);
654  {
655  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
656  }
658 }
659 
660 void
662 {
663  NS_LOG_FUNCTION (this);
665  {
666  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
667  }
670 }
671 
672 void
674 {
675  NS_LOG_FUNCTION (this);
677  {
678  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
679  }
681 }
682 
683 void
685 {
686  NS_LOG_FUNCTION (this);
688  {
689  NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!");
690  }
692 }
693 
694 } // namespace ns3
double GetRxCurrentA(void) const
Gets receive current.
void NotifyOn(void)
Defined in ns3::WifiPhyListener.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
static TypeId GetTypeId(void)
Get the type ID.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void HandleEnergyRecharged(void)
Handles energy recharged.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
TracedValue< double > m_totalEnergyConsumption
This variable keeps track of the total energy consumed by this model.
Base class for device energy models.
double GetTxCurrentA(void) const
Gets transmit current.
double m_rxCurrentA
receive current
void SetWifiRadioState(const WifiPhyState state)
The PHY layer is sleeping.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
UpdateTxCurrentCallback m_updateTxCurrentCallback
Callback used to update the tx current stored in WifiRadioEnergyModel based on the nominal tx power u...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
Channel is IDLE, no packet is being transmitted.
Definition: csma-channel.h:75
double m_ccaBusyCurrentA
CCA busy current.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
void ChangeState(int newState)
Changes state of the WifiRadioEnergyMode.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
WifiRadioEnergyModelPhyListener * m_listener
WifiPhy listener.
void SetSleepCurrentA(double sleepCurrentA)
Sets sleep current.
WifiRadioEnergyModelPhyListener * GetPhyListener(void)
void SetUpdateTxCurrentCallback(UpdateTxCurrentCallback callback)
Sets the update tx current callback.
void SwitchToIdle(void)
A helper function that makes scheduling m_changeStateCallback possible.
void SetRxCurrentA(double rxCurrentA)
Sets receive current.
void NotifyRxEndOk(void)
Switches the WifiRadioEnergyModel back to IDLE state.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void SetCcaBusyCurrentA(double ccaBusyCurrentA)
Sets CCA busy current.
Time GetMaximumTimeInState(int state) const
double GetTotalEnergyConsumption(void) const
void SetChangeStateCallback(DeviceEnergyModel::ChangeStateCallback callback)
Sets the change state callback.
Ptr< WifiTxCurrentModel > m_txCurrentModel
current model
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
double m_sleepCurrentA
sleep current
WifiPhyState GetCurrentState(void) const
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1381
Ptr< EnergySource > m_source
energy source
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1038
void SetTxCurrentFromModel(double txPowerDbm)
Calls the CalcTxCurrent method of the tx current model to compute the tx current based on such model...
void SetEnergyRechargedCallback(WifiRadioEnergyRechargedCallback callback)
void NotifyOff(void)
Defined in ns3::WifiPhyListener.
void NotifyRxEndError(void)
Switches the WifiRadioEnergyModel back to IDLE state.
The PHY layer has sense the medium busy through the CCA mechanism.
Time m_lastUpdateTime
time stamp of previous energy update
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
double GetSwitchingCurrentA(void) const
Gets switching current.
DeviceEnergyModel::ChangeStateCallback m_changeStateCallback
Change state callback used to notify the WifiRadioEnergyModel of a state change.
EventId m_switchToOffEvent
switch to off event
EventId m_switchToIdleEvent
switch to idle event
void NotifyTxStart(Time duration, double txPowerDbm)
Switches the WifiRadioEnergyModel to TX state and switches back to IDLE after TX duration.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
The PHY layer is IDLE.
WifiPhyState
The state of the PHY layer.
void NotifyWakeup(void)
Defined in ns3::WifiPhyListener.
WifiPhyState m_currentState
current state the radio is in
A WifiPhy listener class for notifying the WifiRadioEnergyModel of Wifi radio state change...
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
double GetCcaBusyCurrentA(void) const
Gets CCA busy current.
void SetTxCurrentA(double txCurrentA)
Sets transmit current.
void NotifySleep(void)
Defined in ns3::WifiPhyListener.
A WiFi radio energy model.
void NotifyRxStart(Time duration)
Switches the WifiRadioEnergyModel to RX state.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
void SetEnergyDepletionCallback(WifiRadioEnergyDepletionCallback callback)
The PHY layer is sending a packet.
void DoDispose(void)
Destructor implementation.
void HandleEnergyChanged(void)
Handles energy changed.
bool IsPositive(void) const
Definition: nstime.h:298
uint8_t m_nPendingChangeState
pending state change
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
WifiRadioEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
The PHY layer is receiving a packet.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
The PHY layer is switched off.
void Nullify(void)
Discard the implementation, set it to null.
Definition: callback.h:1274
virtual void ChangeState(int newState)=0
The PHY layer is switching to other channel.
void SetSwitchingCurrentA(double switchingCurrentA)
Sets switching current.
void SetEnergySource(const Ptr< EnergySource > source)
Sets pointer to EnergySouce installed on node.
double m_switchingCurrentA
switching current
void SetTxCurrentModel(const Ptr< WifiTxCurrentModel > model)
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
double GetSleepCurrentA(void) const
Gets sleep current.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
void SetIdleCurrentA(double idleCurrentA)
Sets idle current.
WifiRadioEnergyRechargedCallback m_energyRechargedCallback
Energy recharged callback.
double GetIdleCurrentA(void) const
Gets idle current.
void HandleEnergyDepletion(void)
Handles energy depletion.
double m_txCurrentA
transmit current