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
32namespace ns3 {
33
34class WifiTxCurrentModel;
35
43{
44public:
49
52
59
66
67 void NotifyRxStart (Time duration) override;
68 void NotifyRxEndOk (void) override;
69 void NotifyRxEndError (void) override;
70 void NotifyTxStart (Time duration, double txPowerDbm) override;
71 void NotifyCcaBusyStart (Time duration, WifiChannelListType channelType,
72 const std::vector<Time>& per20MhzDurations) override;
73 void NotifySwitchingStart (Time duration) override;
74 void NotifySleep (void) override;
75 void NotifyOff (void) override;
76 void NotifyWakeup (void) override;
77 void NotifyOn (void) override;
78
79
80private:
84 void SwitchToIdle (void);
85
91
97
99};
100
101
152{
153public:
158
163
168 static TypeId GetTypeId (void);
170 virtual ~WifiRadioEnergyModel ();
171
179 void SetEnergySource (const Ptr<EnergySource> source);
180
186 double GetTotalEnergyConsumption (void) const;
187
188 // Setter & getters for state power consumption.
194 double GetIdleCurrentA (void) const;
200 void SetIdleCurrentA (double idleCurrentA);
206 double GetCcaBusyCurrentA (void) const;
212 void SetCcaBusyCurrentA (double ccaBusyCurrentA);
218 double GetTxCurrentA (void) const;
224 void SetTxCurrentA (double txCurrentA);
230 double GetRxCurrentA (void) const;
236 void SetRxCurrentA (double rxCurrentA);
242 double GetSwitchingCurrentA (void) const;
248 void SetSwitchingCurrentA (double switchingCurrentA);
254 double GetSleepCurrentA (void) const;
260 void SetSleepCurrentA (double sleepCurrentA);
261
265 WifiPhyState GetCurrentState (void) const;
266
273
280
285
292 void SetTxCurrentFromModel (double txPowerDbm);
293
301 void ChangeState (int newState);
302
308 Time GetMaximumTimeInState (int state) const;
309
315 void HandleEnergyDepletion (void);
316
322 void HandleEnergyRecharged (void);
323
329 void HandleEnergyChanged (void);
330
335
336
337private:
338 void DoDispose (void);
339
344 double GetStateA (int state) const;
345
351 double DoGetCurrentA (void) const;
352
359 void SetWifiRadioState (const WifiPhyState state);
360
362
363 // Member variables for current draw in different radio modes.
371
374
375 // State variables.
378
380
383
386
389
391};
392
393} // namespace ns3
394
395#endif /* WIFI_RADIO_ENERGY_MODEL_H */
Base class for device energy models.
An identifier for simulation events.
Definition: event-id.h:54
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
a unique identifier for an interface.
Definition: type-id.h:59
receive notifications about PHY events.
A WiFi radio energy model.
double GetStateA(int state) const
double GetSwitchingCurrentA(void) const
Gets switching current in Amperes.
WifiRadioEnergyDepletionCallback m_energyDepletionCallback
Energy depletion callback.
double m_idleCurrentA
idle current in Amperes
void HandleEnergyRecharged(void)
Handles energy recharged.
Callback< void > WifiRadioEnergyRechargedCallback
Callback type for energy recharged handling.
double GetCcaBusyCurrentA(void) const
Gets CCA busy current in Amperes.
double m_ccaBusyCurrentA
CCA busy current in Amperes.
void SetEnergySource(const Ptr< EnergySource > source)
Sets pointer to EnergySouce installed on node.
void ChangeState(int newState)
Changes state of the WifiRadioEnergyMode.
WifiRadioEnergyModelPhyListener * GetPhyListener(void)
double GetSleepCurrentA(void) const
Gets sleep current in Amperes.
void SetCcaBusyCurrentA(double ccaBusyCurrentA)
Sets CCA busy current in Amperes.
Time GetMaximumTimeInState(int state) const
WifiRadioEnergyRechargedCallback m_energyRechargedCallback
Energy recharged callback.
double m_sleepCurrentA
sleep current in Amperes
WifiRadioEnergyModelPhyListener * m_listener
WifiPhy listener.
double GetTotalEnergyConsumption(void) const
Ptr< EnergySource > m_source
energy source
TracedValue< double > m_totalEnergyConsumption
This variable keeps track of the total energy consumed by this model in watts.
void SetTxCurrentModel(const Ptr< WifiTxCurrentModel > model)
void HandleEnergyDepletion(void)
Handles energy depletion.
EventId m_switchToOffEvent
switch to off event
void SetRxCurrentA(double rxCurrentA)
Sets receive current in Amperes.
void HandleEnergyChanged(void)
Handles energy changed.
double m_txCurrentA
transmit current in Amperes
static TypeId GetTypeId(void)
Get the type ID.
Time m_lastUpdateTime
time stamp of previous energy update
void SetTxCurrentA(double txCurrentA)
Sets transmit current in Amperes.
void DoDispose(void)
Destructor implementation.
WifiPhyState GetCurrentState(void) const
double GetRxCurrentA(void) const
Gets receive current in Amperes.
void SetSwitchingCurrentA(double switchingCurrentA)
Sets switching current in Amperes.
void SetTxCurrentFromModel(double txPowerDbm)
Calls the CalcTxCurrent method of the TX current model to compute the TX current based on such model.
void SetEnergyDepletionCallback(WifiRadioEnergyDepletionCallback callback)
void SetSleepCurrentA(double sleepCurrentA)
Sets sleep current in Amperes.
double m_rxCurrentA
receive current in Amperes
WifiPhyState m_currentState
current state the radio is in
double GetTxCurrentA(void) const
Gets transmit current in Amperes.
void SetWifiRadioState(const WifiPhyState state)
Ptr< WifiTxCurrentModel > m_txCurrentModel
current model
void SetIdleCurrentA(double idleCurrentA)
Sets idle current in Amperes.
double GetIdleCurrentA(void) const
Gets idle current in Amperes.
void SetEnergyRechargedCallback(WifiRadioEnergyRechargedCallback callback)
double m_switchingCurrentA
switching current in Amperes
uint8_t m_nPendingChangeState
pending state change
Callback< void > WifiRadioEnergyDepletionCallback
Callback type for energy depletion handling.
A WifiPhy listener class for notifying the WifiRadioEnergyModel of Wifi radio state change.
Callback< void, double > UpdateTxCurrentCallback
Callback type for updating the transmit current based on the nominal TX power.
void NotifyRxEndOk(void) override
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
DeviceEnergyModel::ChangeStateCallback m_changeStateCallback
Change state callback used to notify the WifiRadioEnergyModel of a state change.
void NotifyOn(void) override
Notify listeners that we went to switch on.
void NotifyTxStart(Time duration, double txPowerDbm) override
void NotifyOff(void) override
Notify listeners that we went to switch off.
void NotifyRxStart(Time duration) override
UpdateTxCurrentCallback m_updateTxCurrentCallback
Callback used to update the TX current stored in WifiRadioEnergyModel based on the nominal TX power u...
void NotifyWakeup(void) override
Notify listeners that we woke up.
void NotifySleep(void) override
Notify listeners that we went to sleep.
void SwitchToIdle(void)
A helper function that makes scheduling m_changeStateCallback possible.
void SetUpdateTxCurrentCallback(UpdateTxCurrentCallback callback)
Sets the update TX current callback.
void NotifySwitchingStart(Time duration) override
void SetChangeStateCallback(DeviceEnergyModel::ChangeStateCallback callback)
Sets the change state callback.
EventId m_switchToIdleEvent
switch to idle event
void NotifyCcaBusyStart(Time duration, WifiChannelListType channelType, const std::vector< Time > &per20MhzDurations) override
void NotifyRxEndError(void) override
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiPhyState
The state of the PHY layer.