22 #include "ns3/double.h"
23 #include "ns3/simulator.h"
24 #include "ns3/trace-source-accessor.h"
40 .AddConstructor<WifiRadioEnergyModel> ()
41 .AddAttribute (
"IdleCurrentA",
42 "The default radio Idle current in Ampere.",
46 MakeDoubleChecker<double> ())
47 .AddAttribute (
"CcaBusyCurrentA",
48 "The default radio CCA Busy State current in Ampere.",
52 MakeDoubleChecker<double> ())
53 .AddAttribute (
"TxCurrentA",
54 "The radio Tx current in Ampere.",
58 MakeDoubleChecker<double> ())
59 .AddAttribute (
"RxCurrentA",
60 "The radio Rx current in Ampere.",
64 MakeDoubleChecker<double> ())
65 .AddAttribute (
"SwitchingCurrentA",
66 "The default radio Channel Switch current in Ampere.",
70 MakeDoubleChecker<double> ())
71 .AddTraceSource (
"TotalEnergyConsumption",
72 "Total energy consumption of the radio device.",
196 NS_LOG_DEBUG (
"WifiRadioEnergyModel:Setting NULL energy depletion callback!");
210 double energyToDecrease = 0.0;
211 double supplyVoltage =
m_source->GetSupplyVoltage ();
246 NS_LOG_DEBUG (
"WifiRadioEnergyModel:Total energy consumption is " <<
254 NS_LOG_DEBUG (
"WifiRadioEnergyModel:Energy is depleted!");
307 std::string stateName;
314 stateName =
"CCA_BUSY";
323 stateName =
"SWITCHING";
326 NS_LOG_DEBUG (
"WifiRadioEnergyModel:Switching to state: " << stateName <<
357 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
369 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
380 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
391 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
405 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
419 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
437 NS_FATAL_ERROR (
"WifiRadioEnergyModelPhyListener:Change state callback not set!");
void SetWifiRadioState(const WifiPhy::State state)
keep track of time values and allow control of global simulation resolution
static TypeId GetTypeId(void)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
TracedValue< double > m_totalEnergyConsumption
Base class for device energy models.
State
The state of the PHY layer.
NS_LOG_COMPONENT_DEFINE("WifiRadioEnergyModel")
bool IsNull(void) const
Check for null implementation.
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void ChangeState(int newState)
Changes state of the WifiRadioEnergyMode.
WifiRadioEnergyModelPhyListener * m_listener
virtual ~WifiRadioEnergyModelPhyListener()
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
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.
#define NS_FATAL_ERROR(msg)
fatal error handling
The PHY layer is switching to other channel.
void SetCcaBusyCurrentA(double ccaBusyCurrentA)
double GetSeconds(void) const
double GetCcaBusyCurrentA(void) const
void SetChangeStateCallback(DeviceEnergyModel::ChangeStateCallback callback)
Sets the change state callback.
WifiPhy::State m_currentState
Ptr< EnergySource > m_source
virtual void NotifySwitchingStart(Time duration)
virtual void NotifyMaybeCcaBusyStart(Time duration)
WifiRadioEnergyModelPhyListener()
virtual void NotifyRxEndError(void)
Switches the WifiRadioEnergyModel back to IDLE state.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
WifiPhy::State GetCurrentState(void) const
DeviceEnergyModel::ChangeStateCallback m_changeStateCallback
Change state callback used to notify the WifiRadioEnergyModel of a state change.
EventId m_switchToIdleEvent
virtual void SetEnergySource(Ptr< EnergySource > source)
Sets pointer to EnergySouce installed on node.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
double GetTxCurrentA(void) const
double GetRxCurrentA(void) const
A WifiPhy listener class for notifying the WifiRadioEnergyModel of Wifi radio state change...
static Time Now(void)
Return the "current simulation time".
void SetTxCurrentA(double txCurrentA)
virtual void NotifyRxStart(Time duration)
Switches the WifiRadioEnergyModel to RX state.
int64_t GetNanoSeconds(void) const
void SetEnergyDepletionCallback(WifiRadioEnergyDepletionCallback callback)
void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
#define NS_LOG_DEBUG(msg)
WifiRadioEnergyDepletionCallback m_energyDepletionCallback
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
double GetIdleCurrentA(void) const
void Nullify(void)
Discard the implementation, set it to null.
virtual void ChangeState(int newState)=0
void SetSwitchingCurrentA(double switchingCurrentA)
double m_switchingCurrentA
virtual double DoGetCurrentA(void) const
The PHY layer is receiving a packet.
Hold a floating point type.
virtual ~WifiRadioEnergyModel()
The PHY layer has sense the medium busy through the CCA mechanism.
a unique identifier for an interface.
The PHY layer is sending a packet.
TypeId SetParent(TypeId tid)
void SetIdleCurrentA(double idleCurrentA)
double GetSwitchingCurrentA(void) const
virtual void HandleEnergyDepletion(void)
Handles energy depletion.