A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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>, He Wu <mdzz@u.washington.edu>
19  */
20 
21 #ifndef WIFI_RADIO_ENERGY_MODEL_H
22 #define WIFI_RADIO_ENERGY_MODEL_H
23 
24 #include "ns3/device-energy-model.h"
25 #include "ns3/nstime.h"
26 #include "ns3/event-id.h"
27 #include "ns3/traced-value.h"
28 #include "ns3/wifi-phy.h"
29 
30 namespace ns3 {
31 
39 {
40 public:
43 
50 
58  virtual void NotifyRxStart (Time duration);
59 
68  virtual void NotifyRxEndOk (void);
69 
78  virtual void NotifyRxEndError (void);
79 
88  virtual void NotifyTxStart (Time duration);
89 
95  virtual void NotifyMaybeCcaBusyStart (Time duration);
96 
102  virtual void NotifySwitchingStart (Time duration);
103 
104 private:
108  void SwitchToIdle (void);
109 
110 private:
116 
118 };
119 
120 // -------------------------------------------------------------------------- //
121 
147 {
148 public:
153 
154 public:
155  static TypeId GetTypeId (void);
157  virtual ~WifiRadioEnergyModel ();
158 
166  virtual void SetEnergySource (Ptr<EnergySource> source);
167 
173  virtual double GetTotalEnergyConsumption (void) const;
174 
175  // Setter & getters for state power consumption.
176  double GetIdleCurrentA (void) const;
177  void SetIdleCurrentA (double idleCurrentA);
178  double GetCcaBusyCurrentA (void) const;
179  void SetCcaBusyCurrentA (double ccaBusyCurrentA);
180  double GetTxCurrentA (void) const;
181  void SetTxCurrentA (double txCurrentA);
182  double GetRxCurrentA (void) const;
183  void SetRxCurrentA (double rxCurrentA);
184  double GetSwitchingCurrentA (void) const;
185  void SetSwitchingCurrentA (double switchingCurrentA);
186 
190  WifiPhy::State GetCurrentState (void) const;
191 
198 
206  virtual void ChangeState (int newState);
207 
213  virtual void HandleEnergyDepletion (void);
214 
219 
220 
221 private:
222  void DoDispose (void);
223 
229  virtual double DoGetCurrentA (void) const;
230 
237  void SetWifiRadioState (const WifiPhy::State state);
238 
239 private:
241 
242  // Member variables for current draw in different radio modes.
243  double m_txCurrentA;
244  double m_rxCurrentA;
248 
249  // This variable keeps track of the total energy consumed by this model.
251 
252  // State variables.
253  WifiPhy::State m_currentState; // current state the radio is in
254  Time m_lastUpdateTime; // time stamp of previous energy update
255 
256  // Energy depletion callback
258 
259  // WifiPhy listener
261 };
262 
263 } // namespace ns3
264 
265 #endif /* WIFI_RADIO_ENERGY_MODEL_H */
void SetWifiRadioState(const WifiPhy::State state)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
TracedValue< double > m_totalEnergyConsumption
Base class for device energy models.
State
The state of the PHY layer.
Definition: wifi-phy.h:123
virtual void ChangeState(int newState)
Changes state of the WifiRadioEnergyMode.
WifiRadioEnergyModelPhyListener * m_listener
virtual double GetTotalEnergyConsumption(void) const
virtual void NotifyTxStart(Time duration)
Switches the WifiRadioEnergyModel to TX state and switches back to IDLE after TX duration.
WifiRadioEnergyModelPhyListener * GetPhyListener(void)
void SwitchToIdle(void)
A helper function that makes scheduling m_changeStateCallback possible.
void SetRxCurrentA(double rxCurrentA)
virtual void NotifyRxEndOk(void)
Switches the WifiRadioEnergyModel back to IDLE state.
Callback< void > WifiRadioEnergyDepletionCallback
Callback type for energy depletion handling.
void SetCcaBusyCurrentA(double ccaBusyCurrentA)
double GetCcaBusyCurrentA(void) const
void SetChangeStateCallback(DeviceEnergyModel::ChangeStateCallback callback)
Sets the change state callback.
virtual void NotifySwitchingStart(Time duration)
receive notifications about phy events.
Definition: wifi-phy.h:44
virtual void NotifyMaybeCcaBusyStart(Time duration)
virtual void NotifyRxEndError(void)
Switches the WifiRadioEnergyModel back to IDLE state.
WifiPhy::State GetCurrentState(void) const
DeviceEnergyModel::ChangeStateCallback m_changeStateCallback
Change state callback used to notify the WifiRadioEnergyModel of a state change.
virtual void SetEnergySource(Ptr< EnergySource > source)
Sets pointer to EnergySouce installed on node.
A WifiPhy listener class for notifying the WifiRadioEnergyModel of Wifi radio state change...
void SetTxCurrentA(double txCurrentA)
A WiFi radio energy model.
virtual void NotifyRxStart(Time duration)
Switches the WifiRadioEnergyModel to RX state.
void SetEnergyDepletionCallback(WifiRadioEnergyDepletionCallback callback)
an identifier for simulation events.
Definition: event-id.h:46
void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
WifiRadioEnergyDepletionCallback m_energyDepletionCallback
void SetSwitchingCurrentA(double switchingCurrentA)
virtual double DoGetCurrentA(void) const
a unique identifier for an interface.
Definition: type-id.h:49
void SetIdleCurrentA(double idleCurrentA)
double GetSwitchingCurrentA(void) const
virtual void HandleEnergyDepletion(void)
Handles energy depletion.