9#include "ns3/basic-energy-source-helper.h"
10#include "ns3/basic-energy-source.h"
11#include "ns3/config.h"
12#include "ns3/device-energy-model-container.h"
13#include "ns3/double.h"
14#include "ns3/energy-source-container.h"
17#include "ns3/simulator.h"
18#include "ns3/string.h"
19#include "ns3/wifi-radio-energy-model-helper.h"
20#include "ns3/wifi-radio-energy-model.h"
21#include "ns3/yans-wifi-helper.h"
85 std::cerr <<
"Problem with state switch test (WifiPhy idle)." << std::endl;
90 std::cerr <<
"Problem with state switch test (WifiPhy cca busy)." << std::endl;
95 std::cerr <<
"Problem with state switch test (WifiPhy tx)." << std::endl;
100 std::cerr <<
"Problem with state switch test (WifiPhy rx)." << std::endl;
105 std::cerr <<
"Problem with state switch test (WifiPhy switching)." << std::endl;
110 std::cerr <<
"Problem with state switch test (WifiPhy sleep)." << std::endl;
125 node->AggregateObject(
source);
140 std::cerr <<
"Model list is empty!." << std::endl;
148 std::cerr <<
"NULL pointer to device model!." << std::endl;
161 static_cast<int>(state));
179 double current = 0.0;
182 case WifiPhyState::IDLE:
183 current =
devModel->GetIdleCurrentA();
185 case WifiPhyState::CCA_BUSY:
186 current =
devModel->GetCcaBusyCurrentA();
188 case WifiPhyState::TX:
189 current =
devModel->GetTxCurrentA();
191 case WifiPhyState::RX:
192 current =
devModel->GetRxCurrentA();
194 case WifiPhyState::SWITCHING:
195 current =
devModel->GetSwitchingCurrentA();
197 case WifiPhyState::SLEEP:
198 current =
devModel->GetSleepCurrentA();
200 case WifiPhyState::OFF:
220 std::cerr <<
"Incorrect remaining energy!" << std::endl;
230 std::cerr <<
"Incorrect end state!" << std::endl;
308 std::cerr <<
"Depletion test case problem." << std::endl;
330 std::string
phyMode(
"DsssRate1Mbps");
359 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
365 wifiMac.SetType(
"ns3::AdhocWifiMac");
403 std::cerr <<
"Not all callbacks are invoked!" << std::endl;
Test case of energy depletion handling for BasicEnergySource and WifiRadioEnergyModel.
BasicEnergyDepletionTest()
double m_updateIntervalS
update interval of each device model
double m_simTimeS
maximum simulation time, in seconds
double m_timeStepS
simulation time step size, in seconds
int m_numOfNodes
number of nodes in simulation
virtual ~BasicEnergyDepletionTest()
bool DepletionTestCase(double simTimeS, double updateIntervalS)
bool DoRun()
Performs some tests involving energy depletion.
void DepletionHandler()
Callback invoked when energy is drained from source.
int m_callbackCount
counter for # of callbacks invoked
Test case of update remaining energy for BasicEnergySource and WifiRadioEnergyModel.
double m_timeS
Time in seconds.
ObjectFactory m_energySource
Energy source factory.
ObjectFactory m_deviceEnergyModel
Device energy model factory.
bool StateSwitchTest(WifiPhyState state)
virtual ~BasicEnergyUpdateTest()
bool DoRun()
Performs some tests involving state updates and the relative energy consumption.
double m_tolerance
Tolerance for power estimation.
Creates a BasicEnergySource object.
void Set(std::string name, const AttributeValue &v) override
This class can be used to hold variables of floating point type such as 'double' or 'float'.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
AttributeValue implementation for Time.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
void Set(std::string name, const AttributeValue &v)
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
Assign WifiRadioEnergyModel to wifi devices.
A WiFi radio energy model.
void ChangeState(int newState) override
Changes state of the WifiRadioEnergyMode.
void SetEnergySource(const Ptr< energy::EnergySource > source) override
Sets pointer to EnergySource installed on node.
manage and create wifi channel objects for the YANS model.
void SetPropagationDelay(std::string name, Ts &&... args)
Make it easy to create and manage PHY objects for the YANS model.
BasicEnergySource decreases/increases remaining energy stored in itself in linearly.
void SetInitialEnergy(double initialEnergyJ)
void UpdateEnergySource() override
Implements UpdateEnergySource.
Holds a vector of ns3::DeviceEnergyModel pointers.
Holds a vector of ns3::EnergySource pointers.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiPhyState
The state of the PHY layer.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...