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"
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"
57 void CreateLoadProfiles (
void);
74 bool ConstantLoadTest (
double load,
Time expLifetime);
85 bool VariableLoadTest (std::vector<double> loads,
86 std::vector<Time> timeStamps,
105 :
TestCase (
"RV battery model battery lifetime test case.")
122 std::vector<double> loads;
123 std::vector<Time> timeStamps;
126 loads.push_back (0.628);
128 loads.push_back (0.628);
130 timeStamps.push_back (Seconds (0));
131 timeStamps.push_back (Seconds (19.5 * 60));
132 timeStamps.push_back (Seconds (26.0 * 60));
134 profile.
loads = loads;
145 loads.push_back (0.4947);
147 loads.push_back (0.4947);
149 timeStamps.push_back (Seconds (0));
150 timeStamps.push_back (Seconds (31.0 * 60));
151 timeStamps.push_back (Seconds (41.3 * 60));
153 profile.
loads = loads;
164 loads.push_back (0.4256);
166 loads.push_back (0.4256);
168 timeStamps.push_back (Seconds (0));
169 timeStamps.push_back (Seconds (41.0 * 60));
170 timeStamps.push_back (Seconds (54.6 * 60));
172 profile.
loads = loads;
183 loads.push_back (0.2923);
185 loads.push_back (0.2923);
187 timeStamps.push_back (Seconds (0));
188 timeStamps.push_back (Seconds (74.6 * 60));
189 timeStamps.push_back (Seconds (99.5 * 60));
191 profile.
loads = loads;
202 loads.push_back (0.2227);
204 loads.push_back (0.2227);
206 timeStamps.push_back (Seconds (0));
207 timeStamps.push_back (Seconds (105.7 * 60));
208 timeStamps.push_back (Seconds (140.9 * 60));
210 profile.
loads = loads;
221 loads.push_back (0.628);
223 loads.push_back (0.628);
225 timeStamps.push_back (Seconds (0));
226 timeStamps.push_back (Seconds (19.5 * 60));
227 timeStamps.push_back (Seconds (29.9 * 60));
229 profile.
loads = loads;
240 loads.push_back (0.628);
242 loads.push_back (0.628);
244 timeStamps.push_back (Seconds (0));
245 timeStamps.push_back (Seconds (19.5 * 60));
246 timeStamps.push_back (Seconds (22.1 * 60));
248 profile.
loads = loads;
259 loads.push_back (0.628);
261 loads.push_back (0.628);
263 timeStamps.push_back (Seconds (0));
264 timeStamps.push_back (Seconds (23.4 * 60));
265 timeStamps.push_back (Seconds (29.9 * 60));
267 profile.
loads = loads;
278 loads.push_back (0.628);
280 loads.push_back (0.628);
282 timeStamps.push_back (Seconds (0));
283 timeStamps.push_back (Seconds (15.6 * 60));
284 timeStamps.push_back (Seconds (22.1 * 60));
286 profile.
loads = loads;
297 loads.push_back (0.300);
298 loads.push_back (0.628);
299 loads.push_back (0.4947);
300 loads.push_back (0.2523);
301 loads.push_back (0.2341);
302 loads.push_back (0.1379);
303 loads.push_back (0.1139);
304 loads.push_back (0.2656);
306 timeStamps.push_back (Seconds (0));
307 timeStamps.push_back (Seconds (0.5 * 60));
308 timeStamps.push_back (Seconds (5.5 * 60));
309 timeStamps.push_back (Seconds (10.5 * 60));
310 timeStamps.push_back (Seconds (35.5 * 60));
311 timeStamps.push_back (Seconds (60.5 * 60));
312 timeStamps.push_back (Seconds (85.5 * 60));
313 timeStamps.push_back (Seconds (110.5 * 60));
315 profile.
loads = loads;
326 loads.push_back (0.300);
327 loads.push_back (0.1139);
328 loads.push_back (0.1379);
329 loads.push_back (0.2341);
330 loads.push_back (0.2523);
331 loads.push_back (0.4947);
332 loads.push_back (0.628);
333 loads.push_back (0.2656);
335 timeStamps.push_back (Seconds (0));
336 timeStamps.push_back (Seconds (0.5 * 60));
337 timeStamps.push_back (Seconds (25.5 * 60));
338 timeStamps.push_back (Seconds (50.5 * 60));
339 timeStamps.push_back (Seconds (75.5 * 60));
340 timeStamps.push_back (Seconds (100.5 * 60));
341 timeStamps.push_back (Seconds (105.5 * 60));
342 timeStamps.push_back (Seconds (110.5 * 60));
344 profile.
loads = loads;
355 loads.push_back (0.300);
356 loads.push_back (0.1139);
357 loads.push_back (0.1379);
358 loads.push_back (0.2341);
359 loads.push_back (0.2523);
360 loads.push_back (0.4947);
361 loads.push_back (0.0);
362 loads.push_back (0.300);
363 loads.push_back (0.628);
364 loads.push_back (0.2656);
366 timeStamps.push_back (Seconds (0));
367 timeStamps.push_back (Seconds (0.5 * 60));
368 timeStamps.push_back (Seconds (25.5 * 60));
369 timeStamps.push_back (Seconds (50.5 * 60));
370 timeStamps.push_back (Seconds (75.5 * 60));
371 timeStamps.push_back (Seconds (100.5 * 60));
372 timeStamps.push_back (Seconds (105.5 * 60));
373 timeStamps.push_back (Seconds (130.5 * 60));
374 timeStamps.push_back (Seconds (131.0 * 60));
375 timeStamps.push_back (Seconds (136.0 * 60));
377 profile.
loads = loads;
388 loads.push_back (0.300);
389 timeStamps.push_back (Seconds (0));
391 for (
int i = 0; i < 5; i++)
393 loads.push_back (0.628);
394 loads.push_back (0.4947);
395 loads.push_back (0.2523);
396 loads.push_back (0.2341);
397 loads.push_back (0.1379);
398 loads.push_back (0.1139);
400 timeStamps.push_back (Seconds ((0.5 + i * 22.5) * 60));
401 timeStamps.push_back (Seconds ((1.5 + i * 22.5) * 60));
402 timeStamps.push_back (Seconds ((2.5 + i * 22.5) * 60));
403 timeStamps.push_back (Seconds ((7.5 + i * 22.5) * 60));
404 timeStamps.push_back (Seconds ((12.5 + i * 22.5) * 60));
405 timeStamps.push_back (Seconds ((17.5 + i * 22.5) * 60));
408 loads.push_back (0.2656);
409 timeStamps.push_back (Seconds (110.5 * 60));
411 profile.
loads = loads;
422 loads.push_back (0.300);
423 timeStamps.push_back (Seconds (0));
425 for (
int i = 0; i < 5; i++)
427 loads.push_back (0.1139);
428 loads.push_back (0.1379);
429 loads.push_back (0.2341);
430 loads.push_back (0.2523);
431 loads.push_back (0.4947);
432 loads.push_back (0.628);
434 timeStamps.push_back (Seconds ((0.5 + i * 22.5) * 60));
435 timeStamps.push_back (Seconds ((5.5 + i * 22.5) * 60));
436 timeStamps.push_back (Seconds ((10.5 + i * 22.5) * 60));
437 timeStamps.push_back (Seconds ((15.5 + i * 22.5) * 60));
438 timeStamps.push_back (Seconds ((20.5 + i * 22.5) * 60));
439 timeStamps.push_back (Seconds ((21.5 + i * 22.5) * 60));
442 loads.push_back (0.2656);
443 timeStamps.push_back (Seconds (112.5 * 60));
445 profile.
loads = loads;
456 loads.push_back (0.2227);
457 loads.push_back (0.2045);
458 loads.push_back (0.1083);
459 loads.push_back (0.0843);
460 loads.push_back (0.2227);
462 timeStamps.push_back (Seconds (0));
463 timeStamps.push_back (Seconds (50.0 * 60));
464 timeStamps.push_back (Seconds (100.0 * 60));
465 timeStamps.push_back (Seconds (150.0 * 60));
466 timeStamps.push_back (Seconds (200.0 * 60));
468 profile.
loads = loads;
479 loads.push_back (0.0843);
480 loads.push_back (0.1083);
481 loads.push_back (0.2045);
482 loads.push_back (0.2227);
483 loads.push_back (0.2227);
485 timeStamps.push_back (Seconds (0));
486 timeStamps.push_back (Seconds (50.0 * 60));
487 timeStamps.push_back (Seconds (100.0 * 60));
488 timeStamps.push_back (Seconds (150.0 * 60));
489 timeStamps.push_back (Seconds (200.0 * 60));
491 profile.
loads = loads;
502 loads.push_back (0.0843);
503 loads.push_back (0.1083);
504 loads.push_back (0.2045);
505 loads.push_back (0.0);
506 loads.push_back (0.2227);
507 loads.push_back (0.2227);
509 timeStamps.push_back (Seconds (0));
510 timeStamps.push_back (Seconds (50.0 * 60));
511 timeStamps.push_back (Seconds (100.0 * 60));
512 timeStamps.push_back (Seconds (150.0 * 60));
513 timeStamps.push_back (Seconds (200.0 * 60));
514 timeStamps.push_back (Seconds (250.0 * 60));
516 profile.
loads = loads;
527 for (
int i = 0; i < 10; i++)
529 loads.push_back (0.0843);
530 loads.push_back (0.1083);
531 loads.push_back (0.2045);
532 loads.push_back (0.2227);
534 timeStamps.push_back (Seconds ((0.0 + i * 20.0) * 60));
535 timeStamps.push_back (Seconds ((5.0 + i * 20.0) * 60));
536 timeStamps.push_back (Seconds ((10.0 + i * 20.0) * 60));
537 timeStamps.push_back (Seconds ((15.0 + i * 20.0) * 60));
540 loads.push_back (0.2227);
541 timeStamps.push_back (Seconds (200.0));
543 profile.
loads = loads;
554 for (
int i = 0; i < 10; i++)
556 loads.push_back (0.0755);
557 loads.push_back (0.0949);
558 loads.push_back (0.2045);
559 loads.push_back (0.2227);
561 timeStamps.push_back (Seconds ((0.0 + i * 20.0) * 60));
562 timeStamps.push_back (Seconds ((5.0 + i * 20.0) * 60));
563 timeStamps.push_back (Seconds ((10.0 + i * 20.0) * 60));
564 timeStamps.push_back (Seconds ((15.0 + i * 20.0) * 60));
567 loads.push_back (0.2227);
568 timeStamps.push_back (Seconds (200.0));
570 profile.
loads = loads;
581 for (
int i = 0; i < 50; i++)
583 loads.push_back (0.4947);
584 loads.push_back (0.628);
586 timeStamps.push_back (Seconds ((0.0 + i * 2.0) * 60));
587 timeStamps.push_back (Seconds ((1.0 + i * 2.0) * 60));
590 profile.
loads = loads;
601 for (
int i = 0; i < 50; i++)
603 loads.push_back (0.4947);
604 loads.push_back (0.628);
605 loads.push_back (0.0576);
607 timeStamps.push_back (Seconds ((0.0 + i * 3.0) * 60));
608 timeStamps.push_back (Seconds ((1.0 + i * 3.0) * 60));
609 timeStamps.push_back (Seconds ((2.0 + i * 3.0) * 60));
612 profile.
loads = loads;
623 for (
int i = 0; i < 150; i++)
625 loads.push_back (0.005 + 0.005 * i);
626 timeStamps.push_back (Seconds ((0.0 + i * 1.0) * 60));
629 profile.
loads = loads;
699 std::string phyMode (
"DsssRate1Mbps");
734 wifiMac.
SetType (
"ns3::AdhocWifiMac");
753 Simulator::Stop (Seconds (70000.0));
761 NS_LOG_DEBUG (
"Actual lifetime = " << actualLifetime.GetSeconds () <<
"s");
770 Simulator::Destroy ();
777 std::vector<Time> timeStamps,
780 NS_ASSERT (loads.size () == timeStamps.size ());
786 std::string phyMode (
"DsssRate1Mbps");
821 wifiMac.
SetType (
"ns3::AdhocWifiMac");
842 for (uint32_t i = 1; i < loads.size (); i++)
844 Simulator::Schedule (timeStamps[i], &WifiRadioEnergyModel::SetIdleCurrentA,
845 wifiDevicePtr, loads[i]);
849 Simulator::Stop (Seconds (70000.0));
857 NS_LOG_DEBUG (
"Actual lifetime = " << actualLifetime.GetSeconds () <<
"s");
863 "Incorrect lifetime!");
865 Simulator::Destroy ();
DeviceEnergyModelContainer Install(Ptr< NetDevice > device, Ptr< EnergySource > source) const
keep track of time values and allow control of global simulation resolution
Assign WifiRadioEnergyModel to wifi devices.
smart pointer class similar to boost::intrusive_ptr
Holds a vector of ns3::EnergySource pointers.
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
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())
Unit test suite for energy model.
#define NS_ASSERT(condition)
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 RvBatteryModelTestSuite g_rvBatteryModelTestSuite
std::vector< double > loads
helps to create WifiNetDevice objects
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 "Battery Lifetime Prediction for Energy- Aware Computing" paper...
void SetChannel(Ptr< YansWifiChannel > channel)
double GetSeconds(void) const
std::vector< Time > timeStamps
Time GetLifetime(void) const
bool ConstantLoadTest(double load, Time expLifetime)
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Creates a RvBatteryModel object.
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.
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)
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 AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
void Set(std::string name, const AttributeValue &v)
#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...
Ptr< EnergySource > Get(uint32_t i) const
Get the i-th Ptr stored in this container.
Test case of update remaining energy for RvBatteryModel and WifiRadioEnergyModel. ...
#define NS_LOG_DEBUG(msg)
virtual ~BatteryLifetimeTest()
RvBatteryModelTestSuite()
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
#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 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 VariableLoadTest(std::vector< double > loads, std::vector< Time > timeStamps, Time expLifetime)
#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.