A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::AcousticModemEnergyModel Class Reference

WHOI micro-modem energy model. More...

#include "acoustic-modem-energy-model.h"

+ Inheritance diagram for ns3::AcousticModemEnergyModel:
+ Collaboration diagram for ns3::AcousticModemEnergyModel:

Public Types

typedef Callback< void > AcousticModemEnergyDepletionCallback
 Callback type for energy depletion handling.
 
typedef Callback< void > AcousticModemEnergyRechargeCallback
 Callback type for energy recharge handling.
 
- Public Types inherited from ns3::energy::DeviceEnergyModel
typedef Callback< void, int > ChangeStateCallback
 Callback type for ChangeState function.
 

Public Member Functions

 AcousticModemEnergyModel ()
 Constructor.
 
 ~AcousticModemEnergyModel () override
 Dummy destructor, see DoDispose.
 
void ChangeState (int newState) override
 Changes state of the AcousticModemEnergyModel.
 
int GetCurrentState () const
 Get the current state of the modem.
 
double GetIdlePowerW () const
 Get the idle power of the modem.
 
virtual Ptr< NodeGetNode () const
 Gets pointer to node.
 
double GetRxPowerW () const
 Get the receiving power.
 
double GetSleepPowerW () const
 Get the sleep state power of the modem.
 
double GetTotalEnergyConsumption () const override
 
double GetTxPowerW () const
 Get the transmission power of the modem.
 
void HandleEnergyChanged () override
 Handles energy changed.
 
void HandleEnergyDepletion () override
 Handles energy depletion.
 
void HandleEnergyRecharged () override
 Handles energy recharged.
 
void SetEnergyDepletionCallback (AcousticModemEnergyDepletionCallback callback)
 
void SetEnergyRechargeCallback (AcousticModemEnergyRechargeCallback callback)
 
void SetEnergySource (Ptr< energy::EnergySource > source) override
 
void SetIdlePowerW (double idlePowerW)
 Set the idle state power of the modem.
 
virtual void SetNode (Ptr< Node > node)
 Sets pointer to node.
 
void SetRxPowerW (double rxPowerW)
 Set the receiving power of the modem.
 
void SetSleepPowerW (double sleepPowerW)
 Set the sleep power of the modem.
 
void SetTxPowerW (double txPowerW)
 Set the transmission power of the modem.
 
- Public Member Functions inherited from ns3::energy::DeviceEnergyModel
 DeviceEnergyModel ()
 
 ~DeviceEnergyModel () override
 
double GetCurrentA () const
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::energy::DeviceEnergyModel
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Private Member Functions

void DoDispose () override
 Destructor implementation.
 
double DoGetCurrentA () const override
 
bool IsStateTransitionValid (const int destState)
 
void SetMicroModemState (const int state)
 

Private Attributes

int m_currentState
 Current modem state.
 
AcousticModemEnergyDepletionCallback m_energyDepletionCallback
 Energy depletion callback.
 
AcousticModemEnergyRechargeCallback m_energyRechargeCallback
 Energy recharge callback.
 
double m_idlePowerW
 The idle power, in watts.
 
Time m_lastUpdateTime
 Time stamp of previous energy update.
 
Ptr< Nodem_node
 The node hosting this transducer.
 
double m_rxPowerW
 The receiver power, in watts.
 
double m_sleepPowerW
 The sleep power, in watts.
 
Ptr< energy::EnergySourcem_source
 The energy source.
 
TracedValue< doublem_totalEnergyConsumption
 The total energy consumed by this model.
 
double m_txPowerW
 The transmitter power, in watts.
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Detailed Description

WHOI micro-modem energy model.

Basing on the Device Energy Model interface, has been implemented a specific energy model for the WHOI micro modem. The class follows pretty closely the RadioEnergyModel class as the transducer behaviour is pretty close to the one of a wifi radio, with identical states (rx, tx, idle, sleep).

The power consumption values implemented into the model are as follows [1]:

Modem State Power Consumption TX 50 W RX 158 mW Idle 158 mW Sleep 5.8 mW

References: [1] Freitag et al., The whoi micro-modem: an acoustic communications and navigation system for multiple platforms, in In Proc. IEEE OCEANS05 Conf, 2005. URL: http://ieeexplore.ieee.org/iel5/10918/34367/01639901.pdf

Definition at line 44 of file acoustic-modem-energy-model.h.

Member Typedef Documentation

◆ AcousticModemEnergyDepletionCallback

Callback type for energy depletion handling.

Definition at line 48 of file acoustic-modem-energy-model.h.

◆ AcousticModemEnergyRechargeCallback

Callback type for energy recharge handling.

Definition at line 51 of file acoustic-modem-energy-model.h.

Constructor & Destructor Documentation

◆ AcousticModemEnergyModel()

ns3::AcousticModemEnergyModel::AcousticModemEnergyModel ( )

Constructor.

Definition at line 66 of file acoustic-modem-energy-model.cc.

References ns3::UanPhy::IDLE, m_currentState, m_energyDepletionCallback, m_lastUpdateTime, m_node, m_source, NS_LOG_FUNCTION, ns3::Callback< R, UArgs >::Nullify(), and ns3::Seconds().

+ Here is the call graph for this function:

◆ ~AcousticModemEnergyModel()

ns3::AcousticModemEnergyModel::~AcousticModemEnergyModel ( )
override

Dummy destructor, see DoDispose.

Definition at line 76 of file acoustic-modem-energy-model.cc.

Member Function Documentation

◆ ChangeState()

void ns3::AcousticModemEnergyModel::ChangeState ( int newState)
overridevirtual

Changes state of the AcousticModemEnergyModel.

Parameters
newStateNew state the modem is in.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 195 of file acoustic-modem-energy-model.cc.

References ns3::UanPhy::DISABLED, ns3::Node::GetId(), ns3::Time::GetNanoSeconds(), ns3::Time::GetSeconds(), ns3::UanPhy::IDLE, m_currentState, m_idlePowerW, m_lastUpdateTime, m_node, m_rxPowerW, m_sleepPowerW, m_source, m_totalEnergyConsumption, m_txPowerW, ns3::Simulator::Now(), NS_ASSERT, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::UanPhy::RX, SetMicroModemState(), ns3::UanPhy::SLEEP, and ns3::UanPhy::TX.

+ Here is the call graph for this function:

◆ DoDispose()

void ns3::AcousticModemEnergyModel::DoDispose ( )
overrideprivatevirtual

Destructor implementation.

This method is called by Dispose() or by the Object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.

It is safe to call GetObject() from within this method.

Reimplemented from ns3::Object.

Definition at line 291 of file acoustic-modem-energy-model.cc.

References m_energyDepletionCallback, m_node, m_source, NS_LOG_FUNCTION, and ns3::Callback< R, UArgs >::Nullify().

+ Here is the call graph for this function:

◆ DoGetCurrentA()

double ns3::AcousticModemEnergyModel::DoGetCurrentA ( ) const
overrideprivatevirtual

◆ GetCurrentState()

int ns3::AcousticModemEnergyModel::GetCurrentState ( ) const

Get the current state of the modem.

Returns
Current state.

Definition at line 166 of file acoustic-modem-energy-model.cc.

References m_currentState, and NS_LOG_FUNCTION.

◆ GetIdlePowerW()

double ns3::AcousticModemEnergyModel::GetIdlePowerW ( ) const

Get the idle power of the modem.

Returns
The idle power in Watts

Definition at line 138 of file acoustic-modem-energy-model.cc.

References m_idlePowerW, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetNode()

Ptr< Node > ns3::AcousticModemEnergyModel::GetNode ( ) const
virtual

Gets pointer to node.

Returns
Pointer to node.

Definition at line 89 of file acoustic-modem-energy-model.cc.

References m_node.

◆ GetRxPowerW()

double ns3::AcousticModemEnergyModel::GetRxPowerW ( ) const

Get the receiving power.

Returns
The receiving power in Watts

Definition at line 124 of file acoustic-modem-energy-model.cc.

References m_rxPowerW, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetSleepPowerW()

double ns3::AcousticModemEnergyModel::GetSleepPowerW ( ) const

Get the sleep state power of the modem.

Returns
Sleep power of the modem in Watts

Definition at line 152 of file acoustic-modem-energy-model.cc.

References m_sleepPowerW, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetTotalEnergyConsumption()

double ns3::AcousticModemEnergyModel::GetTotalEnergyConsumption ( ) const
overridevirtual
Returns
Total energy consumption of the device.

DeviceEnergyModel records its own energy consumption during simulation.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 103 of file acoustic-modem-energy-model.cc.

References m_totalEnergyConsumption, and NS_LOG_FUNCTION.

◆ GetTxPowerW()

double ns3::AcousticModemEnergyModel::GetTxPowerW ( ) const

Get the transmission power of the modem.

Returns
The transmission power in Watts.

Definition at line 110 of file acoustic-modem-energy-model.cc.

References m_txPowerW, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::AcousticModemEnergyModel::GetTypeId ( )
static

Register this type.

Returns
The object TypeId.

Definition at line 28 of file acoustic-modem-energy-model.cc.

References GetIdlePowerW(), GetRxPowerW(), GetSleepPowerW(), GetTxPowerW(), m_totalEnergyConsumption, ns3::MakeDoubleAccessor(), ns3::MakeDoubleChecker(), ns3::MakeTraceSourceAccessor(), SetIdlePowerW(), ns3::TypeId::SetParent(), SetRxPowerW(), SetSleepPowerW(), and SetTxPowerW().

+ Here is the call graph for this function:

◆ HandleEnergyChanged()

void ns3::AcousticModemEnergyModel::HandleEnergyChanged ( )
overridevirtual

Handles energy changed.

Not implemented

Implements ns3::energy::DeviceEnergyModel.

Definition at line 280 of file acoustic-modem-energy-model.cc.

References NS_LOG_FUNCTION.

◆ HandleEnergyDepletion()

void ns3::AcousticModemEnergyModel::HandleEnergyDepletion ( )
overridevirtual

Handles energy depletion.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 248 of file acoustic-modem-energy-model.cc.

References ns3::UanPhy::DISABLED, ns3::Node::GetDevice(), ns3::Node::GetId(), ns3::Callback< R, UArgs >::IsNull(), m_energyDepletionCallback, m_node, NS_LOG_DEBUG, NS_LOG_FUNCTION, and SetMicroModemState().

+ Here is the call graph for this function:

◆ HandleEnergyRecharged()

void ns3::AcousticModemEnergyModel::HandleEnergyRecharged ( )
overridevirtual

Handles energy recharged.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 264 of file acoustic-modem-energy-model.cc.

References ns3::Node::GetDevice(), ns3::Node::GetId(), ns3::UanPhy::IDLE, ns3::Callback< R, UArgs >::IsNull(), m_energyRechargeCallback, m_node, NS_LOG_DEBUG, NS_LOG_FUNCTION, and SetMicroModemState().

+ Here is the call graph for this function:

◆ IsStateTransitionValid()

bool ns3::AcousticModemEnergyModel::IsStateTransitionValid ( const int destState)
private
Parameters
destStateModem state to switch to.
Returns
True if the transition is allowed.

This function checks if a given modem state transition is allowed.

Definition at line 332 of file acoustic-modem-energy-model.cc.

References NS_LOG_FUNCTION.

Referenced by SetMicroModemState().

+ Here is the caller graph for this function:

◆ SetEnergyDepletionCallback()

void ns3::AcousticModemEnergyModel::SetEnergyDepletionCallback ( AcousticModemEnergyDepletionCallback callback)
Parameters
callbackCallback function.

Sets callback for energy depletion handling.

Definition at line 173 of file acoustic-modem-energy-model.cc.

References ns3::Callback< R, UArgs >::IsNull(), m_energyDepletionCallback, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ SetEnergyRechargeCallback()

void ns3::AcousticModemEnergyModel::SetEnergyRechargeCallback ( AcousticModemEnergyRechargeCallback callback)
Parameters
callbackCallback function.

Sets callback for energy recharge handling.

Definition at line 184 of file acoustic-modem-energy-model.cc.

References ns3::Callback< R, UArgs >::IsNull(), m_energyRechargeCallback, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ SetEnergySource()

void ns3::AcousticModemEnergyModel::SetEnergySource ( Ptr< energy::EnergySource > source)
overridevirtual
Parameters
sourcePointer to energy source installed on node.

This function sets the pointer to energy source installed on node. Should be called only by DeviceEnergyModel helper classes.

Implements ns3::energy::DeviceEnergyModel.

Definition at line 95 of file acoustic-modem-energy-model.cc.

References m_source, NS_ASSERT, and NS_LOG_FUNCTION.

◆ SetIdlePowerW()

void ns3::AcousticModemEnergyModel::SetIdlePowerW ( double idlePowerW)

Set the idle state power of the modem.

Parameters
idlePowerWIdle power of the modem in watts.

Definition at line 145 of file acoustic-modem-energy-model.cc.

References m_idlePowerW, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetMicroModemState()

void ns3::AcousticModemEnergyModel::SetMicroModemState ( const int state)
private
Parameters
stateNew state the modem is currently in.

Sets current state. This function is private so that only the energy model can change its own state.

Definition at line 339 of file acoustic-modem-energy-model.cc.

References ns3::UanPhy::DISABLED, ns3::UanPhy::IDLE, IsStateTransitionValid(), m_currentState, ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::UanPhy::RX, ns3::UanPhy::SLEEP, and ns3::UanPhy::TX.

Referenced by ChangeState(), HandleEnergyDepletion(), and HandleEnergyRecharged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetNode()

void ns3::AcousticModemEnergyModel::SetNode ( Ptr< Node > node)
virtual

Sets pointer to node.

Parameters
nodePointer to node.

Definition at line 81 of file acoustic-modem-energy-model.cc.

References m_node, NS_ASSERT, and NS_LOG_FUNCTION.

◆ SetRxPowerW()

void ns3::AcousticModemEnergyModel::SetRxPowerW ( double rxPowerW)

Set the receiving power of the modem.

Parameters
rxPowerWReceiving power in watts

Definition at line 131 of file acoustic-modem-energy-model.cc.

References m_rxPowerW, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetSleepPowerW()

void ns3::AcousticModemEnergyModel::SetSleepPowerW ( double sleepPowerW)

Set the sleep power of the modem.

Parameters
sleepPowerWSleep power of the modem in watts.

Definition at line 159 of file acoustic-modem-energy-model.cc.

References m_sleepPowerW, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetTxPowerW()

void ns3::AcousticModemEnergyModel::SetTxPowerW ( double txPowerW)

Set the transmission power of the modem.

Parameters
txPowerWTransmission power in watts.

Definition at line 117 of file acoustic-modem-energy-model.cc.

References m_txPowerW, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_currentState

int ns3::AcousticModemEnergyModel::m_currentState
private

◆ m_energyDepletionCallback

AcousticModemEnergyDepletionCallback ns3::AcousticModemEnergyModel::m_energyDepletionCallback
private

Energy depletion callback.

Definition at line 225 of file acoustic-modem-energy-model.h.

Referenced by AcousticModemEnergyModel(), DoDispose(), HandleEnergyDepletion(), and SetEnergyDepletionCallback().

◆ m_energyRechargeCallback

AcousticModemEnergyRechargeCallback ns3::AcousticModemEnergyModel::m_energyRechargeCallback
private

Energy recharge callback.

Definition at line 228 of file acoustic-modem-energy-model.h.

Referenced by HandleEnergyRecharged(), and SetEnergyRechargeCallback().

◆ m_idlePowerW

double ns3::AcousticModemEnergyModel::m_idlePowerW
private

The idle power, in watts.

Definition at line 214 of file acoustic-modem-energy-model.h.

Referenced by ChangeState(), DoGetCurrentA(), GetIdlePowerW(), and SetIdlePowerW().

◆ m_lastUpdateTime

Time ns3::AcousticModemEnergyModel::m_lastUpdateTime
private

Time stamp of previous energy update.

Definition at line 222 of file acoustic-modem-energy-model.h.

Referenced by AcousticModemEnergyModel(), and ChangeState().

◆ m_node

Ptr<Node> ns3::AcousticModemEnergyModel::m_node
private

◆ m_rxPowerW

double ns3::AcousticModemEnergyModel::m_rxPowerW
private

The receiver power, in watts.

Definition at line 213 of file acoustic-modem-energy-model.h.

Referenced by ChangeState(), DoGetCurrentA(), GetRxPowerW(), and SetRxPowerW().

◆ m_sleepPowerW

double ns3::AcousticModemEnergyModel::m_sleepPowerW
private

The sleep power, in watts.

Definition at line 215 of file acoustic-modem-energy-model.h.

Referenced by ChangeState(), DoGetCurrentA(), GetSleepPowerW(), and SetSleepPowerW().

◆ m_source

Ptr<energy::EnergySource> ns3::AcousticModemEnergyModel::m_source
private

The energy source.

Definition at line 209 of file acoustic-modem-energy-model.h.

Referenced by AcousticModemEnergyModel(), ChangeState(), DoDispose(), DoGetCurrentA(), and SetEnergySource().

◆ m_totalEnergyConsumption

TracedValue<double> ns3::AcousticModemEnergyModel::m_totalEnergyConsumption
private

The total energy consumed by this model.

Definition at line 218 of file acoustic-modem-energy-model.h.

Referenced by ChangeState(), GetTotalEnergyConsumption(), and GetTypeId().

◆ m_txPowerW

double ns3::AcousticModemEnergyModel::m_txPowerW
private

The transmitter power, in watts.

Definition at line 212 of file acoustic-modem-energy-model.h.

Referenced by ChangeState(), DoGetCurrentA(), GetTxPowerW(), and SetTxPowerW().


The documentation for this class was generated from the following files: