21 #include "ns3/rv-battery-model.h" 
   22 #include "ns3/wifi-radio-energy-model.h" 
   23 #include "ns3/rv-battery-model-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" 
   29 #include "ns3/simulator.h" 
   30 #include "ns3/double.h" 
   31 #include "ns3/config.h" 
   32 #include "ns3/string.h" 
   33 #include "ns3/yans-wifi-helper.h" 
   34 #include "ns3/nqos-wifi-mac-helper.h" 
   64   void CreateLoadProfiles (
void);
 
   74   bool ConstantLoadTest (
double load, 
Time expLifetime);
 
   85   bool VariableLoadTest (std::vector<double> loads,
 
   86                          std::vector<Time> timeStamps,
 
  119   std::vector<double> loads;
 
  120   std::vector<Time> timeStamps;
 
  123   loads.push_back (0.628);
 
  125   loads.push_back (0.628);
 
  127   timeStamps.push_back (
Seconds (0));
 
  128   timeStamps.push_back (
Seconds (19.5 * 60));
 
  129   timeStamps.push_back (
Seconds (26.0 * 60));
 
  131   profile.
loads = loads;
 
  136   m_loadProfiles.push_back (profile);
 
  142   loads.push_back (0.4947);
 
  144   loads.push_back (0.4947);
 
  146   timeStamps.push_back (
Seconds (0));
 
  147   timeStamps.push_back (
Seconds (31.0 * 60));
 
  148   timeStamps.push_back (
Seconds (41.3 * 60));
 
  150   profile.
loads = loads;
 
  155   m_loadProfiles.push_back (profile);
 
  161   loads.push_back (0.4256);
 
  163   loads.push_back (0.4256);
 
  165   timeStamps.push_back (
Seconds (0));
 
  166   timeStamps.push_back (
Seconds (41.0 * 60));
 
  167   timeStamps.push_back (
Seconds (54.6 * 60));
 
  169   profile.
loads = loads;
 
  174   m_loadProfiles.push_back (profile);
 
  180   loads.push_back (0.2923);
 
  182   loads.push_back (0.2923);
 
  184   timeStamps.push_back (
Seconds (0));
 
  185   timeStamps.push_back (
Seconds (74.6 * 60));
 
  186   timeStamps.push_back (
Seconds (99.5 * 60));
 
  188   profile.
loads = loads;
 
  193   m_loadProfiles.push_back (profile);
 
  199   loads.push_back (0.2227);
 
  201   loads.push_back (0.2227);
 
  203   timeStamps.push_back (
Seconds (0));
 
  204   timeStamps.push_back (
Seconds (105.7 * 60));
 
  205   timeStamps.push_back (
Seconds (140.9 * 60));
 
  207   profile.
loads = loads;
 
  212   m_loadProfiles.push_back (profile);
 
  218   loads.push_back (0.628);
 
  220   loads.push_back (0.628);
 
  222   timeStamps.push_back (
Seconds (0));
 
  223   timeStamps.push_back (
Seconds (19.5 * 60));
 
  224   timeStamps.push_back (
Seconds (29.9 * 60));
 
  226   profile.
loads = loads;
 
  231   m_loadProfiles.push_back (profile);
 
  237   loads.push_back (0.628);
 
  239   loads.push_back (0.628);
 
  241   timeStamps.push_back (
Seconds (0));
 
  242   timeStamps.push_back (
Seconds (19.5 * 60));
 
  243   timeStamps.push_back (
Seconds (22.1 * 60));
 
  245   profile.
loads = loads;
 
  250   m_loadProfiles.push_back (profile);
 
  256   loads.push_back (0.628);
 
  258   loads.push_back (0.628);
 
  260   timeStamps.push_back (
Seconds (0));
 
  261   timeStamps.push_back (
Seconds (23.4 * 60));
 
  262   timeStamps.push_back (
Seconds (29.9 * 60));
 
  264   profile.
loads = loads;
 
  269   m_loadProfiles.push_back (profile);
 
  275   loads.push_back (0.628);
 
  277   loads.push_back (0.628);
 
  279   timeStamps.push_back (
Seconds (0));
 
  280   timeStamps.push_back (
Seconds (15.6 * 60));
 
  281   timeStamps.push_back (
Seconds (22.1 * 60));
 
  283   profile.
loads = loads;
 
  288   m_loadProfiles.push_back (profile);
 
  294   loads.push_back (0.300);
 
  295   loads.push_back (0.628);
 
  296   loads.push_back (0.4947);
 
  297   loads.push_back (0.2523);
 
  298   loads.push_back (0.2341);
 
  299   loads.push_back (0.1379);
 
  300   loads.push_back (0.1139);
 
  301   loads.push_back (0.2656);
 
  303   timeStamps.push_back (
Seconds (0));
 
  304   timeStamps.push_back (
Seconds (0.5 * 60));
 
  305   timeStamps.push_back (
Seconds (5.5 * 60));
 
  306   timeStamps.push_back (
Seconds (10.5 * 60));
 
  307   timeStamps.push_back (
Seconds (35.5 * 60));
 
  308   timeStamps.push_back (
Seconds (60.5 * 60));
 
  309   timeStamps.push_back (
Seconds (85.5 * 60));
 
  310   timeStamps.push_back (
Seconds (110.5 * 60));
 
  312   profile.
loads = loads;
 
  317   m_loadProfiles.push_back (profile);
 
  323   loads.push_back (0.300);
 
  324   loads.push_back (0.1139);
 
  325   loads.push_back (0.1379);
 
  326   loads.push_back (0.2341);
 
  327   loads.push_back (0.2523);
 
  328   loads.push_back (0.4947);
 
  329   loads.push_back (0.628);
 
  330   loads.push_back (0.2656);
 
  332   timeStamps.push_back (
Seconds (0));
 
  333   timeStamps.push_back (
Seconds (0.5 * 60));
 
  334   timeStamps.push_back (
Seconds (25.5 * 60));
 
  335   timeStamps.push_back (
Seconds (50.5 * 60));
 
  336   timeStamps.push_back (
Seconds (75.5 * 60));
 
  337   timeStamps.push_back (
Seconds (100.5 * 60));
 
  338   timeStamps.push_back (
Seconds (105.5 * 60));
 
  339   timeStamps.push_back (
Seconds (110.5 * 60));
 
  341   profile.
loads = loads;
 
  346   m_loadProfiles.push_back (profile);
 
  352   loads.push_back (0.300);
 
  353   loads.push_back (0.1139);
 
  354   loads.push_back (0.1379);
 
  355   loads.push_back (0.2341);
 
  356   loads.push_back (0.2523);
 
  357   loads.push_back (0.4947);
 
  358   loads.push_back (0.0);
 
  359   loads.push_back (0.300);
 
  360   loads.push_back (0.628);
 
  361   loads.push_back (0.2656);
 
  363   timeStamps.push_back (
Seconds (0));
 
  364   timeStamps.push_back (
Seconds (0.5 * 60));
 
  365   timeStamps.push_back (
Seconds (25.5 * 60));
 
  366   timeStamps.push_back (
Seconds (50.5 * 60));
 
  367   timeStamps.push_back (
Seconds (75.5 * 60));
 
  368   timeStamps.push_back (
Seconds (100.5 * 60));
 
  369   timeStamps.push_back (
Seconds (105.5 * 60));
 
  370   timeStamps.push_back (
Seconds (130.5 * 60));
 
  371   timeStamps.push_back (
Seconds (131.0 * 60));
 
  372   timeStamps.push_back (
Seconds (136.0 * 60));
 
  374   profile.
loads = loads;
 
  379   m_loadProfiles.push_back (profile);
 
  385   loads.push_back (0.300);
 
  386   timeStamps.push_back (
Seconds (0));
 
  388   for (
int i = 0; i < 5; i++)
 
  390       loads.push_back (0.628);
 
  391       loads.push_back (0.4947);
 
  392       loads.push_back (0.2523);
 
  393       loads.push_back (0.2341);
 
  394       loads.push_back (0.1379);
 
  395       loads.push_back (0.1139);
 
  397       timeStamps.push_back (
Seconds ((0.5 + i * 22.5) * 60));
 
  398       timeStamps.push_back (
Seconds ((1.5 + i * 22.5) * 60));
 
  399       timeStamps.push_back (
Seconds ((2.5 + i * 22.5) * 60));
 
  400       timeStamps.push_back (
Seconds ((7.5 + i * 22.5) * 60));
 
  401       timeStamps.push_back (
Seconds ((12.5 + i * 22.5) * 60));
 
  402       timeStamps.push_back (
Seconds ((17.5 + i * 22.5) * 60));
 
  405   loads.push_back (0.2656);
 
  406   timeStamps.push_back (
Seconds (110.5 * 60));
 
  408   profile.
loads = loads;
 
  413   m_loadProfiles.push_back (profile);
 
  419   loads.push_back (0.300);
 
  420   timeStamps.push_back (
Seconds (0));
 
  422   for (
int i = 0; i < 5; i++)
 
  424       loads.push_back (0.1139);
 
  425       loads.push_back (0.1379);
 
  426       loads.push_back (0.2341);
 
  427       loads.push_back (0.2523);
 
  428       loads.push_back (0.4947);
 
  429       loads.push_back (0.628);
 
  431       timeStamps.push_back (
Seconds ((0.5 + i * 22.5) * 60));
 
  432       timeStamps.push_back (
Seconds ((5.5 + i * 22.5) * 60));
 
  433       timeStamps.push_back (
Seconds ((10.5 + i * 22.5) * 60));
 
  434       timeStamps.push_back (
Seconds ((15.5 + i * 22.5) * 60));
 
  435       timeStamps.push_back (
Seconds ((20.5 + i * 22.5) * 60));
 
  436       timeStamps.push_back (
Seconds ((21.5 + i * 22.5) * 60));
 
  439   loads.push_back (0.2656);
 
  440   timeStamps.push_back (
Seconds (112.5 * 60));
 
  442   profile.
loads = loads;
 
  447   m_loadProfiles.push_back (profile);
 
  453   loads.push_back (0.2227);
 
  454   loads.push_back (0.2045);
 
  455   loads.push_back (0.1083);
 
  456   loads.push_back (0.0843);
 
  457   loads.push_back (0.2227);
 
  459   timeStamps.push_back (
Seconds (0));
 
  460   timeStamps.push_back (
Seconds (50.0 * 60));
 
  461   timeStamps.push_back (
Seconds (100.0 * 60));
 
  462   timeStamps.push_back (
Seconds (150.0 * 60));
 
  463   timeStamps.push_back (
Seconds (200.0 * 60));
 
  465   profile.
loads = loads;
 
  470   m_loadProfiles.push_back (profile);
 
  476   loads.push_back (0.0843);
 
  477   loads.push_back (0.1083);
 
  478   loads.push_back (0.2045);
 
  479   loads.push_back (0.2227);
 
  480   loads.push_back (0.2227);
 
  482   timeStamps.push_back (
Seconds (0));
 
  483   timeStamps.push_back (
Seconds (50.0 * 60));
 
  484   timeStamps.push_back (
Seconds (100.0 * 60));
 
  485   timeStamps.push_back (
Seconds (150.0 * 60));
 
  486   timeStamps.push_back (
Seconds (200.0 * 60));
 
  488   profile.
loads = loads;
 
  493   m_loadProfiles.push_back (profile);
 
  499   loads.push_back (0.0843);
 
  500   loads.push_back (0.1083);
 
  501   loads.push_back (0.2045);
 
  502   loads.push_back (0.0);
 
  503   loads.push_back (0.2227);
 
  504   loads.push_back (0.2227);
 
  506   timeStamps.push_back (
Seconds (0));
 
  507   timeStamps.push_back (
Seconds (50.0 * 60));
 
  508   timeStamps.push_back (
Seconds (100.0 * 60));
 
  509   timeStamps.push_back (
Seconds (150.0 * 60));
 
  510   timeStamps.push_back (
Seconds (200.0 * 60));
 
  511   timeStamps.push_back (
Seconds (250.0 * 60));
 
  513   profile.
loads = loads;
 
  518   m_loadProfiles.push_back (profile);
 
  524   for (
int i = 0; i < 10; i++)
 
  526       loads.push_back (0.0843);
 
  527       loads.push_back (0.1083);
 
  528       loads.push_back (0.2045);
 
  529       loads.push_back (0.2227);
 
  531       timeStamps.push_back (
Seconds ((0.0 + i * 20.0) * 60));
 
  532       timeStamps.push_back (
Seconds ((5.0 + i * 20.0) * 60));
 
  533       timeStamps.push_back (
Seconds ((10.0 + i * 20.0) * 60));
 
  534       timeStamps.push_back (
Seconds ((15.0 + i * 20.0) * 60));
 
  537   loads.push_back (0.2227);
 
  538   timeStamps.push_back (
Seconds (200.0));
 
  540   profile.
loads = loads;
 
  545   m_loadProfiles.push_back (profile);
 
  551   for (
int i = 0; i < 10; i++)
 
  553       loads.push_back (0.0755);
 
  554       loads.push_back (0.0949);
 
  555       loads.push_back (0.2045);
 
  556       loads.push_back (0.2227);
 
  558       timeStamps.push_back (
Seconds ((0.0 + i * 20.0) * 60));
 
  559       timeStamps.push_back (
Seconds ((5.0 + i * 20.0) * 60));
 
  560       timeStamps.push_back (
Seconds ((10.0 + i * 20.0) * 60));
 
  561       timeStamps.push_back (
Seconds ((15.0 + i * 20.0) * 60));
 
  564   loads.push_back (0.2227);
 
  565   timeStamps.push_back (
Seconds (200.0));
 
  567   profile.
loads = loads;
 
  572   m_loadProfiles.push_back (profile);
 
  578   for (
int i = 0; i < 50; i++)
 
  580       loads.push_back (0.4947);
 
  581       loads.push_back (0.628);
 
  583       timeStamps.push_back (
Seconds ((0.0 + i * 2.0) * 60));
 
  584       timeStamps.push_back (
Seconds ((1.0 + i * 2.0) * 60));
 
  587   profile.
loads = loads;
 
  592   m_loadProfiles.push_back (profile);
 
  598   for (
int i = 0; i < 50; i++)
 
  600       loads.push_back (0.4947);
 
  601       loads.push_back (0.628);
 
  602       loads.push_back (0.0576);
 
  604       timeStamps.push_back (
Seconds ((0.0 + i * 3.0) * 60));
 
  605       timeStamps.push_back (
Seconds ((1.0 + i * 3.0) * 60));
 
  606       timeStamps.push_back (
Seconds ((2.0 + i * 3.0) * 60));
 
  609   profile.
loads = loads;
 
  614   m_loadProfiles.push_back (profile);
 
  620   for (
int i = 0; i < 150; i++)
 
  622       loads.push_back (0.005 + 0.005 * i);
 
  623       timeStamps.push_back (
Seconds ((0.0 + i * 1.0) * 60));
 
  626   profile.
loads = loads;
 
  631   m_loadProfiles.push_back (profile);
 
  638 main (
int argc, 
char **argv)
 
  648       std::cerr << 
"Problems with constant load test (640mA)." << std::endl;
 
  653       std::cerr << 
"Problems with constant load test (320mA)." << std::endl;
 
  658       std::cerr << 
"Problems with constant load test (128mA)." << std::endl;
 
  663       std::cerr << 
"Problems with constant load test (64mA)." << std::endl;
 
  668       std::cerr << 
"Problems with constant load test (32mA)." << std::endl;
 
  687           std::cerr << 
"Problems with variable load test (Itsy)." << std::endl;
 
  704           std::cerr << 
"Problems with variable load test (DUALFOIL)." << std::endl;
 
  718   std::string phyMode (
"DsssRate1Mbps");
 
  753   wifiMac.
SetType (
"ns3::AdhocWifiMac");
 
  760   rvModelHelper.
Set (
"RvBatteryModelAlphaValue", 
DoubleValue (m_alpha));
 
  761   rvModelHelper.
Set (
"RvBatteryModelBetaValue", 
DoubleValue (m_beta));
 
  762   rvModelHelper.
Set (
"RvBatteryModelLowBatteryThreshold", 
DoubleValue (0.0));
 
  781   NS_LOG_DEBUG (
"Actual lifetime = " << actualLifetime.GetSeconds () << 
"s");
 
  785   if (actualLifetime != expLifetime)
 
  787       std::cerr << 
"ConstantLoadTest: Incorrect lifetime for load " << load << std::endl;
 
  796                                        std::vector<Time> timeStamps,
 
  799   NS_ASSERT (loads.size () == timeStamps.size ());
 
  805   std::string phyMode (
"DsssRate1Mbps");
 
  840   wifiMac.
SetType (
"ns3::AdhocWifiMac");
 
  847   rvModelHelper.
Set (
"RvBatteryModelAlphaValue", 
DoubleValue (m_alpha));
 
  848   rvModelHelper.
Set (
"RvBatteryModelBetaValue", 
DoubleValue (m_beta));
 
  849   rvModelHelper.
Set (
"RvBatteryModelLowBatteryThreshold", 
DoubleValue (0.0));
 
  862   for (uint32_t i = 1; i < loads.size (); i++)
 
  865                            wifiDevicePtr, loads[i]);
 
  877   NS_LOG_DEBUG (
"Actual lifetime = " << actualLifetime.GetSeconds () << 
"s");
 
  883   if ((actualLifetime.GetSeconds ()) > (expLifetime.
GetSeconds ()) + (120) ||
 
  884       (actualLifetime.GetSeconds ()) < (expLifetime.
GetSeconds ()) - (120))
 
  886       std::cerr << 
"VariableLoadTest: Incorrect lifetime." << std::endl;
 
DeviceEnergyModelContainer Install(Ptr< NetDevice > device, Ptr< EnergySource > source) const 
 
Simulation virtual time values and global simulation resolution. 
 
Assign WifiRadioEnergyModel to wifi devices. 
 
Smart pointer class similar to boost::intrusive_ptr. 
 
Holds a vector of ns3::EnergySource pointers. 
 
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. 
 
std::vector< LoadProfile > m_loadProfiles
 
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())
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
 
static void Run(void)
Run the simulation. 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used. 
 
void Set(std::string name, const AttributeValue &v)
 
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state. 
 
std::vector< double > loads
 
helps to create WifiNetDevice objects 
 
Include Radiotap link layer information. 
 
Holds a vector of ns3::DeviceEnergyModel pointers. 
 
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const 
 
void CreateLoadProfiles(void)
Creates load profiles according to D. 
 
void SetChannel(Ptr< YansWifiChannel > channel)
 
double GetSeconds(void) const 
Get an approximation of the time stored in this instance in the indicated unit. 
 
std::vector< Time > timeStamps
 
Time GetLifetime(void) const 
 
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay. 
 
bool ConstantLoadTest(double load, Time expLifetime)
 
holds a vector of ns3::NetDevice pointers 
 
virtual void SetStandard(enum WifiPhyStandard standard)
 
Creates a RvBatteryModel object. 
 
static NqosWifiMacHelper Default(void)
Create a mac helper in a default working state. 
 
create non QoS-enabled MAC layers for a ns3::WifiNetDevice. 
 
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy(). 
 
Ptr< DeviceEnergyModel > Get(uint32_t i) const 
Get the i-th Ptr stored in this container. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
keep track of a set of node pointers. 
 
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18) 
 
void Set(std::string name, const AttributeValue &v)
 
EnergySourceContainer Install(Ptr< Node > node) const 
 
manage and create wifi channel objects for the yans model. 
 
void Set(std::string name, const AttributeValue &v)
 
Ptr< EnergySource > Get(uint32_t i) const 
Get the i-th Ptr stored in this container. 
 
This example was originally devised as a test, then it was converted to an example. 
 
static void Stop(void)
Tell the Simulator the calling event should be the last one executed. 
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
 
Time Seconds(double value)
Construct a Time in the indicated unit. 
 
void SetDefault(std::string name, const AttributeValue &value)
 
virtual ~BatteryLifetimeTest()
 
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer. 
 
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())
 
This class can be used to hold variables of floating point type such as 'double' or 'float'...
 
bool VariableLoadTest(std::vector< double > loads, std::vector< Time > timeStamps, Time expLifetime)
 
void test(void)
Example use of ns3::SystemThread. 
 
void SetIdleCurrentA(double idleCurrentA)