A Discrete-Event Network Simulator
API
wifi-radio-energy-model.h
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  * Authors: Sidharth Nabar <snabar@uw.edu>
19  * He Wu <mdzz@u.washington.edu>
20  */
21 
22 #ifndef WIFI_RADIO_ENERGY_MODEL_H
23 #define WIFI_RADIO_ENERGY_MODEL_H
24 
25 #include "ns3/device-energy-model.h"
26 #include "ns3/traced-value.h"
27 #include "ns3/event-id.h"
28 #include "ns3/nstime.h"
29 #include "wifi-phy-listener.h"
30 #include "wifi-phy-state.h"
31 
32 namespace ns3 {
33 
34 class WifiTxCurrentModel;
35 
43 {
44 public:
49 
52 
59 
66 
74  void NotifyRxStart (Time duration) override;
75 
84  void NotifyRxEndOk (void) override;
85 
94  void NotifyRxEndError (void) override;
95 
105  void NotifyTxStart (Time duration, double txPowerDbm) override;
106 
112  void NotifyMaybeCcaBusyStart (Time duration) override;
113 
119  void NotifySwitchingStart (Time duration) override;
120 
124  void NotifySleep (void) override;
125 
129  void NotifyOff (void) override;
130 
134  void NotifyWakeup (void) override;
135 
139  void NotifyOn (void) override;
140 
141 
142 private:
146  void SwitchToIdle (void);
147 
153 
159 
161 };
162 
163 
214 {
215 public:
220 
225 
230  static TypeId GetTypeId (void);
232  virtual ~WifiRadioEnergyModel ();
233 
241  void SetEnergySource (const Ptr<EnergySource> source);
242 
248  double GetTotalEnergyConsumption (void) const;
249 
250  // Setter & getters for state power consumption.
256  double GetIdleCurrentA (void) const;
262  void SetIdleCurrentA (double idleCurrentA);
268  double GetCcaBusyCurrentA (void) const;
274  void SetCcaBusyCurrentA (double ccaBusyCurrentA);
280  double GetTxCurrentA (void) const;
286  void SetTxCurrentA (double txCurrentA);
292  double GetRxCurrentA (void) const;
298  void SetRxCurrentA (double rxCurrentA);
304  double GetSwitchingCurrentA (void) const;
310  void SetSwitchingCurrentA (double switchingCurrentA);
316  double GetSleepCurrentA (void) const;
322  void SetSleepCurrentA (double sleepCurrentA);
323 
327  WifiPhyState GetCurrentState (void) const;
328 
335 
342 
346  void SetTxCurrentModel (const Ptr<WifiTxCurrentModel> model);
347 
354  void SetTxCurrentFromModel (double txPowerDbm);
355 
363  void ChangeState (int newState);
364 
370  Time GetMaximumTimeInState (int state) const;
371 
377  void HandleEnergyDepletion (void);
378 
384  void HandleEnergyRecharged (void);
385 
391  void HandleEnergyChanged (void);
392 
397 
398 
399 private:
400  void DoDispose (void);
401 
406  double GetStateA (int state) const;
407 
413  double DoGetCurrentA (void) const;
414 
421  void SetWifiRadioState (const WifiPhyState state);
422 
424 
425  // Member variables for current draw in different radio modes.
426  double m_txCurrentA;
427  double m_rxCurrentA;
428  double m_idleCurrentA;
433 
436 
437  // State variables.
440 
442 
445 
448 
451 
453 };
454 
455 } // namespace ns3
456 
457 #endif /* WIFI_RADIO_ENERGY_MODEL_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::WifiRadioEnergyModel::SetCcaBusyCurrentA
void SetCcaBusyCurrentA(double ccaBusyCurrentA)
Sets CCA busy current in Amperes.
Definition: wifi-radio-energy-model.cc:162
ns3::WifiRadioEnergyModel::SetEnergyDepletionCallback
void SetEnergyDepletionCallback(WifiRadioEnergyDepletionCallback callback)
Definition: wifi-radio-energy-model.cc:232
ns3::EventId
An identifier for simulation events.
Definition: event-id.h:54
ns3::WifiRadioEnergyModelPhyListener::NotifyRxStart
void NotifyRxStart(Time duration) override
Switches the WifiRadioEnergyModel to RX state.
Definition: wifi-radio-energy-model.cc:491
ns3::WifiRadioEnergyModel::m_listener
WifiRadioEnergyModelPhyListener * m_listener
WifiPhy listener.
Definition: wifi-radio-energy-model.h:450
ns3::WifiRadioEnergyModel::HandleEnergyDepletion
void HandleEnergyDepletion(void)
Handles energy depletion.
Definition: wifi-radio-energy-model.cc:342
ns3::Callback< void, double >
ns3::WifiRadioEnergyModelPhyListener::SwitchToIdle
void SwitchToIdle(void)
A helper function that makes scheduling m_changeStateCallback possible.
Definition: wifi-radio-energy-model.cc:618
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WifiRadioEnergyModel::SetTxCurrentFromModel
void SetTxCurrentFromModel(double txPowerDbm)
Calls the CalcTxCurrent method of the TX current model to compute the TX current based on such model.
Definition: wifi-radio-energy-model.cc:262
ns3::WifiRadioEnergyModel::m_currentState
WifiPhyState m_currentState
current state the radio is in
Definition: wifi-radio-energy-model.h:438
ns3::WifiPhyListener
receive notifications about PHY events.
Definition: wifi-phy-listener.h:33
ns3::WifiRadioEnergyModel::GetCcaBusyCurrentA
double GetCcaBusyCurrentA(void) const
Gets CCA busy current in Amperes.
Definition: wifi-radio-energy-model.cc:155
ns3::WifiRadioEnergyModel::SetSwitchingCurrentA
void SetSwitchingCurrentA(double switchingCurrentA)
Sets switching current in Amperes.
Definition: wifi-radio-energy-model.cc:204
ns3::WifiRadioEnergyModelPhyListener::SetChangeStateCallback
void SetChangeStateCallback(DeviceEnergyModel::ChangeStateCallback callback)
Sets the change state callback.
Definition: wifi-radio-energy-model.cc:475
ns3::WifiRadioEnergyModel::WifiRadioEnergyRechargedCallback
Callback< void > WifiRadioEnergyRechargedCallback
Callback type for energy recharged handling.
Definition: wifi-radio-energy-model.h:224
ns3::WifiRadioEnergyModel::m_switchToOffEvent
EventId m_switchToOffEvent
switch to off event
Definition: wifi-radio-energy-model.h:452
ns3::WifiRadioEnergyModel::GetTxCurrentA
double GetTxCurrentA(void) const
Gets transmit current in Amperes.
Definition: wifi-radio-energy-model.cc:169
ns3::WifiRadioEnergyModel::GetTotalEnergyConsumption
double GetTotalEnergyConsumption(void) const
Definition: wifi-radio-energy-model.cc:123
ns3::WifiRadioEnergyModel::GetSleepCurrentA
double GetSleepCurrentA(void) const
Gets sleep current in Amperes.
Definition: wifi-radio-energy-model.cc:211
wifi-phy-listener.h
ns3::WifiRadioEnergyModel::m_rxCurrentA
double m_rxCurrentA
receive current in Amperes
Definition: wifi-radio-energy-model.h:427
ns3::WifiRadioEnergyModel::DoDispose
void DoDispose(void)
Destructor implementation.
Definition: wifi-radio-energy-model.cc:390
ns3::WifiRadioEnergyModel::SetWifiRadioState
void SetWifiRadioState(const WifiPhyState state)
Definition: wifi-radio-energy-model.cc:427
ns3::WifiRadioEnergyModel::m_sleepCurrentA
double m_sleepCurrentA
sleep current in Amperes
Definition: wifi-radio-energy-model.h:431
ns3::WifiRadioEnergyModel::GetCurrentState
WifiPhyState GetCurrentState(void) const
Definition: wifi-radio-energy-model.cc:225
ns3::WifiRadioEnergyModel::GetIdleCurrentA
double GetIdleCurrentA(void) const
Gets idle current in Amperes.
Definition: wifi-radio-energy-model.cc:141
ns3::WifiRadioEnergyModel::ChangeState
void ChangeState(int newState)
Changes state of the WifiRadioEnergyMode.
Definition: wifi-radio-energy-model.cc:284
ns3::WifiRadioEnergyModel::m_txCurrentA
double m_txCurrentA
transmit current in Amperes
Definition: wifi-radio-energy-model.h:426
ns3::WifiRadioEnergyModel::SetEnergyRechargedCallback
void SetEnergyRechargedCallback(WifiRadioEnergyRechargedCallback callback)
Definition: wifi-radio-energy-model.cc:244
ns3::WifiRadioEnergyModel::DoGetCurrentA
double DoGetCurrentA(void) const
Definition: wifi-radio-energy-model.cc:421
ns3::WifiRadioEnergyModelPhyListener::NotifyRxEndOk
void NotifyRxEndOk(void) override
Switches the WifiRadioEnergyModel back to IDLE state.
Definition: wifi-radio-energy-model.cc:503
ns3::WifiRadioEnergyModelPhyListener::SetUpdateTxCurrentCallback
void SetUpdateTxCurrentCallback(UpdateTxCurrentCallback callback)
Sets the update TX current callback.
Definition: wifi-radio-energy-model.cc:483
ns3::WifiRadioEnergyModel::GetRxCurrentA
double GetRxCurrentA(void) const
Gets receive current in Amperes.
Definition: wifi-radio-energy-model.cc:183
ns3::WifiRadioEnergyModel::GetPhyListener
WifiRadioEnergyModelPhyListener * GetPhyListener(void)
Definition: wifi-radio-energy-model.cc:379
ns3::WifiRadioEnergyModel::SetEnergySource
void SetEnergySource(const Ptr< EnergySource > source)
Sets pointer to EnergySouce installed on node.
Definition: wifi-radio-energy-model.cc:112
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::WifiRadioEnergyModel::WifiRadioEnergyModel
WifiRadioEnergyModel()
Definition: wifi-radio-energy-model.cc:89
ns3::WifiRadioEnergyModelPhyListener::NotifySleep
void NotifySleep(void) override
Defined in ns3::WifiPhyListener.
Definition: wifi-radio-energy-model.cc:572
ns3::WifiRadioEnergyModelPhyListener::NotifyRxEndError
void NotifyRxEndError(void) override
Switches the WifiRadioEnergyModel back to IDLE state.
Definition: wifi-radio-energy-model.cc:514
ns3::WifiRadioEnergyModelPhyListener::m_updateTxCurrentCallback
UpdateTxCurrentCallback m_updateTxCurrentCallback
Callback used to update the TX current stored in WifiRadioEnergyModel based on the nominal TX power u...
Definition: wifi-radio-energy-model.h:158
ns3::WifiRadioEnergyModelPhyListener::m_changeStateCallback
DeviceEnergyModel::ChangeStateCallback m_changeStateCallback
Change state callback used to notify the WifiRadioEnergyModel of a state change.
Definition: wifi-radio-energy-model.h:152
ns3::WifiRadioEnergyModel::m_energyRechargedCallback
WifiRadioEnergyRechargedCallback m_energyRechargedCallback
Energy recharged callback.
Definition: wifi-radio-energy-model.h:447
ns3::WifiRadioEnergyModel::HandleEnergyChanged
void HandleEnergyChanged(void)
Handles energy changed.
Definition: wifi-radio-energy-model.cc:366
wifi-phy-state.h
ns3::WifiRadioEnergyModelPhyListener::NotifyMaybeCcaBusyStart
void NotifyMaybeCcaBusyStart(Time duration) override
Definition: wifi-radio-energy-model.cc:544
ns3::WifiRadioEnergyModel::GetStateA
double GetStateA(int state) const
Definition: wifi-radio-energy-model.cc:398
ns3::WifiRadioEnergyModel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: wifi-radio-energy-model.cc:35
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::WifiRadioEnergyModel::HandleEnergyRecharged
void HandleEnergyRecharged(void)
Handles energy recharged.
Definition: wifi-radio-energy-model.cc:354
ns3::WifiRadioEnergyModel::SetRxCurrentA
void SetRxCurrentA(double rxCurrentA)
Sets receive current in Amperes.
Definition: wifi-radio-energy-model.cc:190
ns3::WifiRadioEnergyModel::m_lastUpdateTime
Time m_lastUpdateTime
time stamp of previous energy update
Definition: wifi-radio-energy-model.h:439
ns3::WifiRadioEnergyModel::SetTxCurrentModel
void SetTxCurrentModel(const Ptr< WifiTxCurrentModel > model)
Definition: wifi-radio-energy-model.cc:256
ns3::WifiRadioEnergyModel::m_switchingCurrentA
double m_switchingCurrentA
switching current in Amperes
Definition: wifi-radio-energy-model.h:430
ns3::WifiRadioEnergyModel::m_totalEnergyConsumption
TracedValue< double > m_totalEnergyConsumption
This variable keeps track of the total energy consumed by this model in watts.
Definition: wifi-radio-energy-model.h:435
ns3::WifiRadioEnergyModel::~WifiRadioEnergyModel
virtual ~WifiRadioEnergyModel()
Definition: wifi-radio-energy-model.cc:104
ns3::WifiRadioEnergyModel::GetMaximumTimeInState
Time GetMaximumTimeInState(int state) const
Definition: wifi-radio-energy-model.cc:271
WifiPhyState
WifiPhyState
The state of the PHY layer.
Definition: wifi-phy-state.h:32
ns3::WifiRadioEnergyModelPhyListener::NotifySwitchingStart
void NotifySwitchingStart(Time duration) override
Definition: wifi-radio-energy-model.cc:558
ns3::WifiRadioEnergyModel::m_energyDepletionCallback
WifiRadioEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
Definition: wifi-radio-energy-model.h:444
ns3::WifiRadioEnergyModelPhyListener
A WifiPhy listener class for notifying the WifiRadioEnergyModel of Wifi radio state change.
Definition: wifi-radio-energy-model.h:43
ns3::TracedValue< double >
ns3::DeviceEnergyModel
Base class for device energy models.
Definition: device-energy-model.h:44
ns3::WifiRadioEnergyModelPhyListener::~WifiRadioEnergyModelPhyListener
virtual ~WifiRadioEnergyModelPhyListener()
Definition: wifi-radio-energy-model.cc:469
ns3::WifiRadioEnergyModelPhyListener::UpdateTxCurrentCallback
Callback< void, double > UpdateTxCurrentCallback
Callback type for updating the transmit current based on the nominal TX power.
Definition: wifi-radio-energy-model.h:48
ns3::WifiRadioEnergyModelPhyListener::NotifyTxStart
void NotifyTxStart(Time duration, double txPowerDbm) override
Switches the WifiRadioEnergyModel to TX state and switches back to IDLE after TX duration.
Definition: wifi-radio-energy-model.cc:525
ns3::WifiRadioEnergyModelPhyListener::WifiRadioEnergyModelPhyListener
WifiRadioEnergyModelPhyListener()
Definition: wifi-radio-energy-model.cc:462
ns3::WifiRadioEnergyModel
A WiFi radio energy model.
Definition: wifi-radio-energy-model.h:214
ns3::WifiRadioEnergyModel::SetIdleCurrentA
void SetIdleCurrentA(double idleCurrentA)
Sets idle current in Amperes.
Definition: wifi-radio-energy-model.cc:148
ns3::WifiRadioEnergyModelPhyListener::m_switchToIdleEvent
EventId m_switchToIdleEvent
switch to idle event
Definition: wifi-radio-energy-model.h:160
ns3::WifiRadioEnergyModel::m_txCurrentModel
Ptr< WifiTxCurrentModel > m_txCurrentModel
current model
Definition: wifi-radio-energy-model.h:432
ns3::WifiRadioEnergyModel::m_source
Ptr< EnergySource > m_source
energy source
Definition: wifi-radio-energy-model.h:423
ns3::WifiRadioEnergyModelPhyListener::NotifyWakeup
void NotifyWakeup(void) override
Defined in ns3::WifiPhyListener.
Definition: wifi-radio-energy-model.cc:584
ns3::WifiRadioEnergyModel::m_ccaBusyCurrentA
double m_ccaBusyCurrentA
CCA busy current in Amperes.
Definition: wifi-radio-energy-model.h:429
ns3::WifiRadioEnergyModel::m_nPendingChangeState
uint8_t m_nPendingChangeState
pending state change
Definition: wifi-radio-energy-model.h:441
ns3::WifiRadioEnergyModelPhyListener::NotifyOn
void NotifyOn(void) override
Defined in ns3::WifiPhyListener.
Definition: wifi-radio-energy-model.cc:607
ns3::WifiRadioEnergyModelPhyListener::NotifyOff
void NotifyOff(void) override
Defined in ns3::WifiPhyListener.
Definition: wifi-radio-energy-model.cc:595
ns3::WifiRadioEnergyModel::SetSleepCurrentA
void SetSleepCurrentA(double sleepCurrentA)
Sets sleep current in Amperes.
Definition: wifi-radio-energy-model.cc:218
ns3::WifiRadioEnergyModel::SetTxCurrentA
void SetTxCurrentA(double txCurrentA)
Sets transmit current in Amperes.
Definition: wifi-radio-energy-model.cc:176
ns3::WifiRadioEnergyModel::GetSwitchingCurrentA
double GetSwitchingCurrentA(void) const
Gets switching current in Amperes.
Definition: wifi-radio-energy-model.cc:197
ns3::WifiRadioEnergyModel::m_idleCurrentA
double m_idleCurrentA
idle current in Amperes
Definition: wifi-radio-energy-model.h:428
ns3::WifiRadioEnergyModel::WifiRadioEnergyDepletionCallback
Callback< void > WifiRadioEnergyDepletionCallback
Callback type for energy depletion handling.
Definition: wifi-radio-energy-model.h:219