21 #include "ns3/basic-energy-source.h"
22 #include "ns3/wifi-radio-energy-model.h"
23 #include "ns3/basic-energy-source-helper.h"
24 #include "ns3/wifi-radio-energy-model-helper.h"
25 #include "ns3/energy-source-container.h"
26 #include "ns3/device-energy-model-container.h"
30 #include "ns3/simulator.h"
31 #include "ns3/double.h"
32 #include "ns3/config.h"
33 #include "ns3/string.h"
34 #include "ns3/yans-wifi-helper.h"
35 #include "ns3/nqos-wifi-mac-helper.h"
73 :
TestCase (
"Basic energy model update remaining energy test case")
116 source->AppendDeviceEnergyModel (model);
120 source->FindDeviceEnergyModels (
"ns3::WifiRadioEnergyModel");
125 DynamicCast<WifiRadioEnergyModel> (models.
Get (0));
136 &WifiRadioEnergyModel::ChangeState, devModel, state);
140 &BasicEnergySource::UpdateEnergySource, source);
142 double timeDelta = 0.000000001;
150 double estRemainingEnergy = source->GetInitialEnergy ();
151 double voltage = source->GetSupplyVoltage ();
159 actualTime /= source->GetEnergyUpdateInterval ().GetSeconds ();
160 actualTime = floor (actualTime);
161 actualTime *= source->GetEnergyUpdateInterval ().GetSeconds ();
164 double current = 0.0;
170 case WifiPhy::CCA_BUSY:
179 case WifiPhy::SWITCHING:
189 estRemainingEnergy -= current * voltage *
m_timeS;
192 double remainingEnergy = source->GetRemainingEnergy ();
193 NS_LOG_DEBUG (
"Remaining energy is " << remainingEnergy);
194 NS_LOG_DEBUG (
"Estimated remaining energy is " << estRemainingEnergy);
195 NS_LOG_DEBUG (
"Difference is " << estRemainingEnergy - remainingEnergy);
198 "Incorrect remaining energy!");
205 Simulator::Destroy ();
249 :
TestCase (
"Basic energy model energy depletion test case")
288 double updateIntervalS)
294 std::string phyMode (
"DsssRate1Mbps");
329 wifiMac.
SetType (
"ns3::AdhocWifiMac");
339 basicSourceHelper.
Set (
"BasicEnergySourceInitialEnergyJ",
DoubleValue (0.0));
341 basicSourceHelper.
Set (
"PeriodicEnergyUpdateInterval",
356 Simulator::Stop (
Seconds (simTimeS));
358 Simulator::Destroy ();
361 NS_LOG_DEBUG (
"Update interval = " << updateIntervalS <<
"s");
DeviceEnergyModelContainer Install(Ptr< NetDevice > device, Ptr< EnergySource > source) const
BasicEnergyModelTestSuite()
Assign WifiRadioEnergyModel to wifi devices.
Holds a vector of ns3::EnergySource pointers.
ObjectFactory m_deviceEnergyModel
void SetDepletionCallback(WifiRadioEnergyModel::WifiRadioEnergyDepletionCallback callback)
Ptr< YansWifiChannel > Create(void) const
void SetRemoteStationManager(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
hold variables of type string
Make it easy to create and manage PHY objects for the yans model.
State
The state of the PHY layer.
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Channel is IDLE, no packet is being transmitted.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
BasicEnergySource decreases/increases remaining energy stored in itself in linearly.
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
void SetTypeId(TypeId tid)
#define NS_FATAL_ERROR(msg)
fatal error handling
Test case of update remaining energy for BasicEnergySource and WifiRadioEnergyModel.
void Set(std::string name, const AttributeValue &v)
double GetSleepCurrentA(void) const
void DoRun(void)
Implementation to actually run this TestCase.
Unit test suite for energy model.
helps to create WifiNetDevice objects
void DoRun(void)
Implementation to actually run this TestCase.
Holds a vector of ns3::DeviceEnergyModel pointers.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
BasicEnergyDepletionTest()
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
void SetChannel(Ptr< YansWifiChannel > channel)
double GetCcaBusyCurrentA(void) const
#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
static BasicEnergyModelTestSuite g_energyModelTestSuite
Attribute for objects of type ns3::Time.
Ptr< Object > Create(void) const
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not...
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Creates a BasicEnergySource object.
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
WifiPhy::State GetCurrentState(void) const
bool StateSwitchTest(WifiPhy::State state)
void AggregateObject(Ptr< Object > other)
create non QoS-enabled MAC layers for a ns3::WifiNetDevice.
Ptr< DeviceEnergyModel > Get(uint32_t i) const
Get the i-th Ptr stored in this container.
virtual void SetEnergySource(Ptr< EnergySource > source)
Sets pointer to EnergySouce installed on node.
void SetDefault(std::string name, const AttributeValue &value)
keep track of a set of node pointers.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
EnergySourceContainer Install(Ptr< Node > node) const
double GetTxCurrentA(void) const
Test case of energy depletion handling for BasicEnergySource and WifiRadioEnergyModel.
double GetRxCurrentA(void) const
manage and create wifi channel objects for the yans model.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
A WiFi radio energy model.
virtual ~BasicEnergyUpdateTest()
instantiate subclasses of ns3::Object.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
virtual ~BasicEnergyDepletionTest()
Time Seconds(double value)
Construct a Time in the indicated unit.
void Set(std::string name, const AttributeValue &v)
double GetIdleCurrentA(void) const
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
ObjectFactory m_energySource
void SetPropagationDelay(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Hold a floating point type.
bool DepletionTestCase(double simTimeS, double updateIntervalS)
void DepletionHandler(void)
Callback invoked when energy is drained from source.
double GetSwitchingCurrentA(void) const