A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
power-rate-adaptation-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Universidad de la República - Uruguay
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Matías Richart <mrichart@fing.edu.uy>
7 */
8
9#include "ns3/adhoc-wifi-mac.h"
10#include "ns3/constant-position-mobility-model.h"
11#include "ns3/fcfs-wifi-queue-scheduler.h"
12#include "ns3/frame-exchange-manager.h"
13#include "ns3/interference-helper.h"
14#include "ns3/node.h"
15#include "ns3/pointer.h"
16#include "ns3/simulator.h"
17#include "ns3/string.h"
18#include "ns3/test.h"
19#include "ns3/wifi-default-ack-manager.h"
20#include "ns3/wifi-default-protection-manager.h"
21#include "ns3/wifi-net-device.h"
22#include "ns3/yans-wifi-channel.h"
23#include "ns3/yans-wifi-phy.h"
24
25using namespace ns3;
26
27/**
28 * @ingroup wifi-test
29 * @ingroup tests
30 *
31 * @brief Power Rate Adaptation Test
32 */
34{
35 public:
37
38 void DoRun() override;
39
40 private:
41 /// Test parf function
42 void TestParf();
43 /// Test aparf function
44 void TestAparf();
45 /// Test rrpaa function
46 void TestRrpaa();
47 /**
48 * Configure nde function
49 * @returns the node
50 */
52
54};
55
57 : TestCase("PowerRateAdaptation")
58{
59}
60
63{
64 /*
65 * Create and configure node.
66 */
69 node->AddDevice(dev);
70
71 /*
72 * Create channel model. Is is necessary to configure correctly the phy layer.
73 */
75
76 /*
77 * Create mobility model. Is needed by the phy layer for transmission.
78 */
80
81 /*
82 * Create and configure phy layer.
83 */
86 phy->SetInterferenceHelper(interferenceHelper);
87 dev->SetPhy(phy);
88 phy->SetChannel(channel);
89 phy->SetDevice(dev);
90 phy->SetMobility(mobility);
91 phy->ConfigureStandard(WIFI_STANDARD_80211a);
92
93 /*
94 * Configure power control parameters.
95 */
96 phy->SetNTxPower(18);
97 phy->SetTxPowerStart(dBm_u{0});
98 phy->SetTxPowerEnd(dBm_u{17});
99
100 /*
101 * Create manager.
102 */
104 dev->SetRemoteStationManager(manager);
105
106 /*
107 * Create mac layer. We use Adhoc because association is not needed to get supported rates.
108 */
110 "Txop",
112 mac->SetDevice(dev);
113 mac->SetAddress(Mac48Address::Allocate());
114 dev->SetMac(mac);
115 mac->SetChannelAccessManagers({CreateObject<ChannelAccessManager>()});
116 mac->SetFrameExchangeManagers({CreateObject<FrameExchangeManager>()});
117 mac->GetFrameExchangeManager(SINGLE_LINK_OP_ID)->SetAddress(mac->GetAddress());
118 mac->SetMacQueueScheduler(CreateObject<FcfsWifiQueueScheduler>());
119 Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager();
120
122 protectionManager->SetWifiMac(mac);
123 fem->SetProtectionManager(protectionManager);
124
126 ackManager->SetWifiMac(mac);
127 fem->SetAckManager(ackManager);
128
129 return node;
130}
131
132void
134{
135 m_manager.SetTypeId("ns3::ParfWifiManager");
136 Ptr<Node> node = ConfigureNode();
137 Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice>(node->GetDevice(0));
138 Ptr<WifiRemoteStationManager> manager = dev->GetRemoteStationManager();
139
140 /*
141 * Configure thresholds for rate and power control.
142 */
143 manager->SetAttribute("AttemptThreshold", UintegerValue(15));
144 manager->SetAttribute("SuccessThreshold", UintegerValue(10));
145
146 /*
147 * Create a dummy packet to simulate transmission.
148 */
149 Mac48Address remoteAddress = Mac48Address::Allocate();
150 WifiMacHeader packetHeader;
151 packetHeader.SetAddr1(remoteAddress);
152 packetHeader.SetType(WIFI_MAC_DATA);
153 packetHeader.SetQosTid(0);
154 Ptr<Packet> packet = Create<Packet>(10);
155 Ptr<WifiMpdu> mpdu = Create<WifiMpdu>(packet, packetHeader);
156 WifiMode ackMode;
157
158 /*
159 * To initialize the manager we need to generate a transmission.
160 */
162 dev->Send(p, remoteAddress, 1);
163
164 //-----------------------------------------------------------------------------------------------------
165
166 /*
167 * Parf initiates with maximal rate and power.
168 */
169 WifiTxVector txVector =
170 manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
171 WifiMode mode = txVector.GetMode();
172 int power = (int)txVector.GetTxPowerLevel();
173
175 54000000,
176 "PARF: Initial data rate wrong");
177 NS_TEST_ASSERT_MSG_EQ(power, 17, "PARF: Initial power level wrong");
178
179 //-----------------------------------------------------------------------------------------------------
180
181 /*
182 * After 10 consecutive successful transmissions parf increase rate or decrease power.
183 * As we are at maximal rate, the power should be decreased. recoveryPower=true.
184 */
185 for (int i = 0; i < 10; i++)
186 {
187 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
188 }
189
190 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
191 mode = txVector.GetMode();
192 power = (int)txVector.GetTxPowerLevel();
193
195 54000000,
196 "PARF: Incorrect vale of data rate");
197 NS_TEST_ASSERT_MSG_EQ(power, 16, "PARF: Incorrect value of power level");
198
199 //-----------------------------------------------------------------------------------------------------
200
201 /*
202 * As we are using recovery power, one failure make power increase.
203 *
204 */
205 manager->ReportDataFailed(mpdu);
206
207 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
208 mode = txVector.GetMode();
209 power = (int)txVector.GetTxPowerLevel();
210
212 54000000,
213 "PARF: Incorrect vale of data rate");
214 NS_TEST_ASSERT_MSG_EQ(power, 17, "PARF: Incorrect value of power level");
215
216 //-----------------------------------------------------------------------------------------------------
217
218 /*
219 * After 15 transmissions attempts parf increase rate or decrease power.
220 * As we are at maximal rate, the power should be decreased. recoveryPower=true.
221 */
222 for (int i = 0; i < 7; i++)
223 {
224 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
225 manager->ReportDataFailed(mpdu);
226 }
227 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
228
229 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
230 mode = txVector.GetMode();
231 power = (int)txVector.GetTxPowerLevel();
232
234 54000000,
235 "PARF: Incorrect vale of data rate");
236 NS_TEST_ASSERT_MSG_EQ(power, 16, "PARF: Incorrect value of power level");
237
238 //-----------------------------------------------------------------------------------------------------
239
240 /*
241 * As we are using recovery power, one failure make power increase. recoveryPower=false.
242 */
243
244 manager->ReportDataFailed(mpdu);
245
246 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
247 mode = txVector.GetMode();
248 power = (int)txVector.GetTxPowerLevel();
249
251 54000000,
252 "PARF: Incorrect vale of data rate");
253 NS_TEST_ASSERT_MSG_EQ(power, 17, "PARF: Incorrect value of power level");
254
255 //-----------------------------------------------------------------------------------------------------
256
257 /*
258 * After two consecutive fails the rate is decreased or the power increased.
259 * As we are at maximal power, the rate should be decreased.
260 */
261 manager->ReportDataFailed(mpdu);
262 manager->ReportDataFailed(mpdu);
263
264 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
265 mode = txVector.GetMode();
266 power = (int)txVector.GetTxPowerLevel();
267
269 48000000,
270 "PARF: Incorrect vale of data rate");
271 NS_TEST_ASSERT_MSG_EQ(power, 17, "PARF: Incorrect value of power level");
272
273 //-----------------------------------------------------------------------------------------------------
274
275 /*
276 * After 10 consecutive successful transmissions parf increase rate or decrease power.
277 * As we are not at maximal rate, the rate is increased again. recoveryRate=true.
278 */
279 for (int i = 0; i < 10; i++)
280 {
281 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
282 }
283
284 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
285 mode = txVector.GetMode();
286 power = (int)txVector.GetTxPowerLevel();
287
289 54000000,
290 "PARF: Incorrect vale of data rate");
291 NS_TEST_ASSERT_MSG_EQ(power, 17, "PARF: Incorrect value of power level");
292
293 //-----------------------------------------------------------------------------------------------------
294
295 /*
296 * As we are using recovery rate, one failure make rate decrease. recoveryRate=false.
297 */
298
299 manager->ReportDataFailed(mpdu);
300
301 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
302 mode = txVector.GetMode();
303 power = (int)txVector.GetTxPowerLevel();
304
306 48000000,
307 "PARF: Incorrect vale of data rate");
308 NS_TEST_ASSERT_MSG_EQ(power, 17, "PARF: Incorrect value of power level");
309
310 //-----------------------------------------------------------------------------------------------------
311
312 /*
313 * After 10 consecutive successful transmissions parf increase rate or decrease power.
314 * As we are not at maximal rate, the rate is increased again. recoveryRate=true.
315 */
316 for (int i = 0; i < 10; i++)
317 {
318 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
319 }
320
321 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
322 mode = txVector.GetMode();
323 power = (int)txVector.GetTxPowerLevel();
324
326 54000000,
327 "PARF: Incorrect vale of data rate");
328 NS_TEST_ASSERT_MSG_EQ(power, 17, "PARF: Incorrect value of power level");
329
330 //-----------------------------------------------------------------------------------------------------
331
332 /*
333 * After 10 consecutive successful transmissions parf increase rate or decrease power.
334 * As we are at maximal rate, the power is decreased. recoveryRate=false, recoveryPower=true.
335 */
336 for (int i = 0; i < 10; i++)
337 {
338 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
339 }
340
341 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
342 mode = txVector.GetMode();
343 power = (int)txVector.GetTxPowerLevel();
344
346 54000000,
347 "PARF: Incorrect vale of data rate");
348 NS_TEST_ASSERT_MSG_EQ(power, 16, "PARF: Incorrect value of power level");
349
350 //-----------------------------------------------------------------------------------------------------
351
352 /*
353 * One successful transmissions after a power decrease make recoverPower=false.
354 * So we need two consecutive failures to increase power again.
355 */
356 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
357
358 for (int i = 0; i < 2; i++)
359 {
360 manager->ReportDataFailed(mpdu);
361 }
362
363 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
364 mode = txVector.GetMode();
365 power = (int)txVector.GetTxPowerLevel();
366
368 54000000,
369 "PARF: Incorrect vale of data rate");
370 NS_TEST_ASSERT_MSG_EQ(power, 17, "PARF: Incorrect value of power level");
371
373}
374
375void
377{
378 m_manager.SetTypeId("ns3::AparfWifiManager");
379 Ptr<Node> node = ConfigureNode();
380 Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice>(node->GetDevice(0));
381 Ptr<WifiRemoteStationManager> manager = dev->GetRemoteStationManager();
382
383 /*
384 * Configure thresholds for rate and power control.
385 */
386 manager->SetAttribute("SuccessThreshold1", UintegerValue(3));
387 manager->SetAttribute("SuccessThreshold2", UintegerValue(10));
388 manager->SetAttribute("FailThreshold", UintegerValue(1));
389 manager->SetAttribute("PowerThreshold", UintegerValue(10));
390
391 /*
392 * Create a dummy packet to simulate transmission.
393 */
394 Mac48Address remoteAddress = Mac48Address::Allocate();
395 WifiMacHeader packetHeader;
396 packetHeader.SetAddr1(remoteAddress);
397 packetHeader.SetType(WIFI_MAC_DATA);
398 packetHeader.SetQosTid(0);
399 Ptr<Packet> packet = Create<Packet>(10);
400 Ptr<WifiMpdu> mpdu = Create<WifiMpdu>(packet, packetHeader);
401 WifiMode ackMode;
402
403 /*
404 * To initialize the manager we need to generate a transmission.
405 */
407 dev->Send(p, remoteAddress, 1);
408
409 //-----------------------------------------------------------------------------------------------------
410
411 /*
412 * Aparf initiates with maximal rate and power.
413 */
414 WifiTxVector txVector =
415 manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
416 WifiMode mode = txVector.GetMode();
417 int power = (int)txVector.GetTxPowerLevel();
418
420 54000000,
421 "APARF: Initial data rate wrong");
422 NS_TEST_ASSERT_MSG_EQ(power, 17, "APARF: Initial power level wrong");
423
424 //-----------------------------------------------------------------------------------------------------
425
426 /*
427 * As Aparf starts in state High, after 3 consecutive successful transmissions aparf increase
428 * rate or decrease power. As we are at maximal rate, the power should be decreased. Change to
429 * state Spread.
430 */
431 for (int i = 0; i < 3; i++)
432 {
433 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
434 }
435
436 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
437 mode = txVector.GetMode();
438 power = (int)txVector.GetTxPowerLevel();
439
441 54000000,
442 "APARF: Incorrect vale of data rate");
443 NS_TEST_ASSERT_MSG_EQ(power, 16, "APARF: Incorrect value of power level");
444
445 //-----------------------------------------------------------------------------------------------------
446
447 /*
448 * One failure make the power to be increased again.
449 * Change to state Low.
450 */
451 manager->ReportDataFailed(mpdu);
452
453 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
454 mode = txVector.GetMode();
455 power = (int)txVector.GetTxPowerLevel();
456
458 54000000,
459 "APARF: Incorrect vale of data rate");
460 NS_TEST_ASSERT_MSG_EQ(power, 17, "APARF: Incorrect value of power level");
461
462 //-----------------------------------------------------------------------------------------------------
463
464 /*
465 * As we are in state Low we need 10 successful transmissions to increase rate or decrease
466 * power. As we are at maximal rate, the power should be decreased. Change to state Spread.
467 */
468 for (int i = 0; i < 10; i++)
469 {
470 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
471 }
472
473 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
474 mode = txVector.GetMode();
475 power = (int)txVector.GetTxPowerLevel();
476
478 54000000,
479 "APARF: Incorrect vale of data rate");
480 NS_TEST_ASSERT_MSG_EQ(power, 16, "APARF: Incorrect value of power level");
481
482 //-----------------------------------------------------------------------------------------------------
483
484 /*
485 * One more successful transmission make to change to state High.
486 * Two more successful transmissions make power decrease.
487 */
488
489 for (int i = 0; i < 3; i++)
490 {
491 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
492 }
493
494 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
495 mode = txVector.GetMode();
496 power = (int)txVector.GetTxPowerLevel();
497
499 54000000,
500 "APARF: Incorrect vale of data rate");
501 NS_TEST_ASSERT_MSG_EQ(power, 15, "APARF: Incorrect value of power level");
502
503 //-----------------------------------------------------------------------------------------------------
504
505 /*
506 * As we are in state High we need 3 successful transmissions to increase rate or decrease
507 * power. After 16*3 successful transmissions power is decreased to zero.
508 */
509 for (int i = 0; i < 16 * 3; i++)
510 {
511 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
512 }
513
514 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
515 mode = txVector.GetMode();
516 power = (int)txVector.GetTxPowerLevel();
517
519 54000000,
520 "APARF: Incorrect vale of data rate");
521 NS_TEST_ASSERT_MSG_EQ(power, 0, "APARF: Incorrect value of power level");
522
523 //-----------------------------------------------------------------------------------------------------
524
525 /*
526 * After one fail the rate is decreased or the power increased.
527 * As we are at minimal power, the power should be increased.
528 */
529 manager->ReportDataFailed(mpdu);
530
531 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
532 mode = txVector.GetMode();
533 power = (int)txVector.GetTxPowerLevel();
534
536 54000000,
537 "Incorrect vale of data rate");
538 NS_TEST_ASSERT_MSG_EQ(power, 1, "Incorrect value of power level");
539
540 //-----------------------------------------------------------------------------------------------------
541
542 /*
543 * After one fail the rate is decreased or the power increased.
544 * After 16 failed transmissions power is increase to 17.
545 */
546 for (int i = 0; i < 16; i++)
547 {
548 manager->ReportDataFailed(mpdu);
549 }
550
551 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
552 mode = txVector.GetMode();
553 power = (int)txVector.GetTxPowerLevel();
554
556 54000000,
557 "APARF: Incorrect vale of data rate");
558 NS_TEST_ASSERT_MSG_EQ(power, 17, "APARF: Incorrect value of power level");
559
560 //-----------------------------------------------------------------------------------------------------
561
562 /*
563 * After one fail the rate is decreased or the power increased.
564 * As we are at maximal power, the rate should be decreased.
565 * Set critical rate to 54 Mbps.
566 */
567 manager->ReportDataFailed(mpdu);
568
569 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
570 mode = txVector.GetMode();
571 power = (int)txVector.GetTxPowerLevel();
572
574 48000000,
575 "Incorrect vale of data rate");
576 NS_TEST_ASSERT_MSG_EQ(power, 17, "Incorrect value of power level");
577
578 //-----------------------------------------------------------------------------------------------------
579
580 /*
581 * As we are in state High we need 3 successful transmissions to increase rate or decrease
582 * power. As rate critical is set, after 3 successful transmissions power is decreased.
583 */
584 for (int i = 0; i < 3; i++)
585 {
586 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
587 }
588
589 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
590 mode = txVector.GetMode();
591 power = (int)txVector.GetTxPowerLevel();
592
594 48000000,
595 "APARF: Incorrect vale of data rate");
596 NS_TEST_ASSERT_MSG_EQ(power, 16, "APARF: Incorrect value of power level");
597
598 //-----------------------------------------------------------------------------------------------------
599
600 /*
601 * As we are in state High we need 3 successful transmissions to increase rate or decrease
602 * power. After 10 power changes critical rate is reset. So after 10*3 successful transmissions
603 * critical rate is set to 0. And 3 successful transmissions more will make power increase to
604 * maximum and rate increase to the critical rate.
605 */
606 for (int i = 0; i < 9 * 3; i++)
607 {
608 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
609 }
610
611 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
612 mode = txVector.GetMode();
613 power = (int)txVector.GetTxPowerLevel();
614
616 48000000,
617 "APARF: Incorrect vale of data rate");
618 NS_TEST_ASSERT_MSG_EQ(power, 7, "APARF: Incorrect value of power level");
619
620 for (int i = 0; i < 3; i++)
621 {
622 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
623 }
624
625 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
626 mode = txVector.GetMode();
627 power = (int)txVector.GetTxPowerLevel();
628
630 54000000,
631 "APARF: Incorrect vale of data rate");
632 NS_TEST_ASSERT_MSG_EQ(power, 17, "APARF: Incorrect value of power level");
633
635}
636
637void
639{
640 m_manager.SetTypeId("ns3::RrpaaWifiManager");
641 Ptr<Node> node = ConfigureNode();
642 Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice>(node->GetDevice(0));
643 Ptr<WifiRemoteStationManager> manager = dev->GetRemoteStationManager();
644
645 /*
646 * Configure constants for rate and power control.
647 */
648 manager->SetAttribute("Basic", BooleanValue(true));
649 manager->SetAttribute("Alpha", DoubleValue(1.25));
650 manager->SetAttribute("Beta", DoubleValue(2));
651 manager->SetAttribute("Tau", DoubleValue(0.015));
652 /*
653 * Constants for the Probabilistic Decision Table.
654 * We set both to 1 to avoid random behaviour in tests.
655 */
656 manager->SetAttribute("Gamma", DoubleValue(1));
657 manager->SetAttribute("Delta", DoubleValue(1));
658
659 /*
660 * Create a dummy packet to simulate transmission.
661 */
662 Mac48Address remoteAddress = Mac48Address::Allocate();
663 WifiMacHeader packetHeader;
664 packetHeader.SetAddr1(remoteAddress);
665 packetHeader.SetType(WIFI_MAC_DATA);
666 packetHeader.SetQosTid(0);
667 Ptr<Packet> packet = Create<Packet>(10);
668 Ptr<WifiMpdu> mpdu = Create<WifiMpdu>(packet, packetHeader);
669 WifiMode ackMode;
670
671 /*
672 * To initialize the manager we need to generate a transmission.
673 */
675 dev->Send(p, remoteAddress, 1);
676
677 /**
678 * This will be the thresholds table.
679 * The parameters of the table are:
680 * - Estimation Window Size (EWND)
681 * - Maximum Tolerable Loss Probability Threshold (MTL)
682 * - Opportunistic Rate Increase (and Power Decrease) Probability Threshold (ORI)
683 *
684 * We also calculate the needed success and failures to generate
685 * a rate or power change:
686 * Rate Increase or Power Decrease limits (RI-PD)
687 * Rate Decrease or Power Increase limits (RD-PI)
688 * Power Decrease limits (PD)
689 *
690 * Mode EWND MTL ORI RI-PD RD-PI PD
691 * succ fails succ fails
692 * OfdmRate6Mbps 8 1 0.19861 7 8 2
693 * OfdmRate9Mbps 11 0.397219 0.14556 10 5 7 2
694 * OfdmRate12Mbps 15 0.291121 0.189753 13 5 11 3
695 * OfdmRate18Mbps 21 0.379507 0.13624 19 8 14 3
696 * OfdmRate24Mbps 27 0.27248 0.174216 23 8 20 5
697 * OfdmRate36Mbps 37 0.348432 0.120773 33 13 25 5
698 * OfdmRate48Mbps 45 0.241546 0.0523952 43 11 35 3
699 * OfdmRate54Mbps 50 0.10479 0 50 6 45 5
700 *
701 */
702
703 //-----------------------------------------------------------------------------------------------------
704
705 /*
706 * RRPAA initiates with minimal rate and maximal power.
707 */
708 WifiTxVector txVector =
709 manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
710 WifiMode mode = txVector.GetMode();
711 int power = (int)txVector.GetTxPowerLevel();
712
714 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
715 6000000,
716 "RRPAA: Initial data rate wrong"); // 802.11a minimal rate is 6Mbps
717 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Initial power level wrong");
718
719 //-----------------------------------------------------------------------------------------------------
720
721 /*
722 * As RRPAA starts with the 6Mbps rate, 7 successful transmissions are needed for RRPAA to
723 * increase rate. 1/8 = 0.125
724 */
725
726 /**
727 * Test that 6 is not enough.
728 */
729 for (int i = 0; i < 6; i++)
730 {
731 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
732 }
733
734 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
735 mode = txVector.GetMode();
736 power = (int)txVector.GetTxPowerLevel();
737
739 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
740 6000000,
741 "RRPAA: Incorrect vale of data rate");
742 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
743
744 /**
745 * Test that 7 is enough.
746 */
747 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
748
749 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
750 mode = txVector.GetMode();
751 power = (int)txVector.GetTxPowerLevel();
752
754 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
755 9000000,
756 "RRPAA: Incorrect vale of data rate");
757 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
758
759 //-----------------------------------------------------------------------------------------------------
760
761 /*
762 * 5 failures are needed to make the rate decrease again.
763 * 5/11 = 0.45
764 */
765 for (int i = 0; i < 4; i++)
766 {
767 manager->ReportDataFailed(mpdu);
768 }
769
770 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
771 mode = txVector.GetMode();
772 power = (int)txVector.GetTxPowerLevel();
773
775 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
776 9000000,
777 "RRPAA: Incorrect vale of data rate");
778 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
779
780 manager->ReportDataFailed(mpdu);
781
782 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
783 mode = txVector.GetMode();
784 power = (int)txVector.GetTxPowerLevel();
785
787 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
788 6000000,
789 "RRPAA: Incorrect vale of data rate");
790 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
791
792 //-----------------------------------------------------------------------------------------------------
793
794 /**
795 * Increase rate until maximal rate.
796 */
797
798 for (int i = 0; i < 7; i++)
799 {
800 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
801 }
802
803 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
804 mode = txVector.GetMode();
805 power = (int)txVector.GetTxPowerLevel();
806
808 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
809 9000000,
810 "RRPAA: Incorrect vale of data rate");
811 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
812
813 for (int i = 0; i < 10; i++)
814 {
815 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
816 }
817
818 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
819 mode = txVector.GetMode();
820 power = (int)txVector.GetTxPowerLevel();
821
823 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
824 12000000,
825 "RRPAA: Incorrect vale of data rate");
826 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
827
828 for (int i = 0; i < 13; i++)
829 {
830 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
831 }
832
833 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
834 mode = txVector.GetMode();
835 power = (int)txVector.GetTxPowerLevel();
836
838 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
839 18000000,
840 "RRPAA: Incorrect vale of data rate");
841 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
842
843 for (int i = 0; i < 19; i++)
844 {
845 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
846 }
847
848 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
849 mode = txVector.GetMode();
850 power = (int)txVector.GetTxPowerLevel();
851
853 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
854 24000000,
855 "RRPAA: Incorrect vale of data rate");
856 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
857
858 for (int i = 0; i < 23; i++)
859 {
860 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
861 }
862
863 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
864 mode = txVector.GetMode();
865 power = (int)txVector.GetTxPowerLevel();
866
868 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
869 36000000,
870 "RRPAA: Incorrect vale of data rate");
871 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
872
873 for (int i = 0; i < 33; i++)
874 {
875 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
876 }
877
878 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
879 mode = txVector.GetMode();
880 power = (int)txVector.GetTxPowerLevel();
881
883 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
884 48000000,
885 "RRPAA: Incorrect vale of data rate");
886 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
887
888 for (int i = 0; i < 43; i++)
889 {
890 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
891 }
892
893 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
894 mode = txVector.GetMode();
895 power = (int)txVector.GetTxPowerLevel();
896
898 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
899 54000000,
900 "RRPAA: Incorrect vale of data rate");
901 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
902
903 //-----------------------------------------------------------------------------------------------------
904
905 /**
906 * Now we need more successful transmissions to make power decrease.
907 * As we are at maximal rate, the power is decreased when it is sure that the failures
908 * will not generate a rate decrease.
909 */
910
911 for (int i = 0; i < 49; i++)
912 {
913 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
914 }
915
916 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
917 mode = txVector.GetMode();
918 power = (int)txVector.GetTxPowerLevel();
919
921 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
922 54000000,
923 "RRPAA: Incorrect vale of data rate");
924 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
925
926 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
927
928 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
929 mode = txVector.GetMode();
930 power = (int)txVector.GetTxPowerLevel();
931
933 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
934 54000000,
935 "RRPAA: Incorrect vale of data rate");
936 NS_TEST_ASSERT_MSG_EQ(power, 16, "RRPAA: Incorrect value of power level");
937
938 //-----------------------------------------------------------------------------------------------------
939
940 /**
941 * As rate hasn't change the same amount of success are needed.
942 * After 16*45 successful transmissions power is decreased to zero.
943 */
944
945 for (int i = 0; i < 16 * 50; i++)
946 {
947 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
948 }
949
950 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
951 mode = txVector.GetMode();
952 power = (int)txVector.GetTxPowerLevel();
953
955 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
956 54000000,
957 "RRPAA: Incorrect vale of data rate");
958 NS_TEST_ASSERT_MSG_EQ(power, 0, "RRPAA: Incorrect value of power level");
959
960 //-----------------------------------------------------------------------------------------------------
961
962 /**
963 * After 6 failures the power should be increased.
964 */
965
966 for (int i = 0; i < 6; i++)
967 {
968 manager->ReportDataFailed(mpdu);
969 }
970
971 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
972 mode = txVector.GetMode();
973 power = (int)txVector.GetTxPowerLevel();
974
976 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
977 54000000,
978 "RRPAA: Incorrect vale of data rate");
979 NS_TEST_ASSERT_MSG_EQ(power, 1, "RRPAA: Incorrect value of power level");
980
981 //-----------------------------------------------------------------------------------------------------
982
983 /*
984 * After 16*6 failed transmissions power is increase to 17.
985 */
986
987 for (int i = 0; i < 16 * 6; i++)
988 {
989 manager->ReportDataFailed(mpdu);
990 }
991
992 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
993 mode = txVector.GetMode();
994 power = (int)txVector.GetTxPowerLevel();
995
997 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
998 54000000,
999 "RRPAA: Incorrect vale of data rate");
1000 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
1001
1002 //-----------------------------------------------------------------------------------------------------
1003
1004 /*
1005 * After 6 more failures the rate should be decreased.
1006 */
1007
1008 for (int i = 0; i < 6; i++)
1009 {
1010 manager->ReportDataFailed(mpdu);
1011 }
1012
1013 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
1014 mode = txVector.GetMode();
1015 power = (int)txVector.GetTxPowerLevel();
1016
1018 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
1019 48000000,
1020 "RRPAA: Incorrect vale of data rate");
1021 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
1022
1023 /*
1024 * Now 11 failures are needed to decrease rate again.
1025 */
1026
1027 for (int i = 0; i < 11; i++)
1028 {
1029 manager->ReportDataFailed(mpdu);
1030 }
1031
1032 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
1033 mode = txVector.GetMode();
1034 power = (int)txVector.GetTxPowerLevel();
1035
1037 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
1038 36000000,
1039 "RRPAA: Incorrect vale of data rate");
1040 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
1041
1042 //-----------------------------------------------------------------------------------------------------
1043
1044 /*
1045 * Test power decrement when loss probability is between MTL and ORI.
1046 * As we are at rate 36 Mbps we need at least 25 successful transmissions
1047 * and 5 failures.
1048 */
1049
1050 for (int i = 0; i < 25; i++)
1051 {
1052 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
1053 }
1054
1055 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
1056 mode = txVector.GetMode();
1057 power = (int)txVector.GetTxPowerLevel();
1058
1060 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
1061 36000000,
1062 "RRPAA: Incorrect vale of data rate");
1063 NS_TEST_ASSERT_MSG_EQ(power, 17, "RRPAA: Incorrect value of power level");
1064
1065 for (int i = 0; i < 5; i++)
1066 {
1067 manager->ReportDataFailed(mpdu);
1068 }
1069
1070 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
1071 mode = txVector.GetMode();
1072 power = (int)txVector.GetTxPowerLevel();
1073
1075 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
1076 36000000,
1077 "RRPAA: Incorrect vale of data rate");
1078 NS_TEST_ASSERT_MSG_EQ(power, 16, "RRPAA: Incorrect value of power level");
1079
1080 for (int i = 0; i < 5; i++)
1081 {
1082 manager->ReportDataFailed(mpdu);
1083 }
1084
1085 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
1086 mode = txVector.GetMode();
1087 power = (int)txVector.GetTxPowerLevel();
1088
1090 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
1091 36000000,
1092 "RRPAA: Incorrect vale of data rate");
1093 NS_TEST_ASSERT_MSG_EQ(power, 16, "RRPAA: Incorrect value of power level");
1094
1095 for (int i = 0; i < 25; i++)
1096 {
1097 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
1098 }
1099
1100 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
1101 mode = txVector.GetMode();
1102 power = (int)txVector.GetTxPowerLevel();
1103
1105 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
1106 36000000,
1107 "RRPAA: Incorrect vale of data rate");
1108 NS_TEST_ASSERT_MSG_EQ(power, 15, "RRPAA: Incorrect value of power level");
1109
1110 //-----------------------------------------------------------------------------------------------------
1111
1112 /*
1113 * Repeat the previous test until power 0 is reached.
1114 */
1115
1116 for (int i = 0; i < 16; i++)
1117 {
1118 for (int j = 0; j < 25; j++)
1119 {
1120 manager->ReportDataOk(mpdu, 0, ackMode, 0, txVector);
1121 }
1122
1123 for (int j = 0; j < 5; j++)
1124 {
1125 manager->ReportDataFailed(mpdu);
1126 }
1127 }
1128
1129 txVector = manager->GetDataTxVector(packetHeader, dev->GetPhy()->GetChannelWidth());
1130 mode = txVector.GetMode();
1131 power = (int)txVector.GetTxPowerLevel();
1132
1134 mode.GetDataRate(txVector.GetChannelWidth(), txVector.GetGuardInterval(), 1),
1135 36000000,
1136 "RRPAA: Incorrect vale of data rate");
1137 NS_TEST_ASSERT_MSG_EQ(power, 0, "RRPAA: Incorrect value of power level");
1138
1140
1143}
1144
1145void
1147{
1148 TestParf();
1149 TestAparf();
1150 TestRrpaa();
1151}
1152
1153/**
1154 * @ingroup wifi-test
1155 * @ingroup tests
1156 *
1157 * @brief Power Rate Adaptation Test Suite
1158 */
1160{
1161 public:
1163};
1164
1170
Power Rate Adaptation Test.
void TestParf()
Test parf function.
void TestAparf()
Test aparf function.
Ptr< Node > ConfigureNode()
Configure nde function.
void DoRun() override
Implementation to actually run this TestCase.
void TestRrpaa()
Test rrpaa function.
Power Rate Adaptation Test Suite.
AttributeValue implementation for Boolean.
Definition boolean.h:26
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
an EUI-48 address
static Mac48Address Allocate()
Allocate a new Mac48Address.
Instantiate subclasses of ns3::Object.
AttributeValue implementation for Pointer.
Definition pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
@ QUICK
Fast test.
Definition test.h:1055
TestCase(const TestCase &)=delete
Type
Type of test.
Definition test.h:1274
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:490
static constexpr auto UNIT
Definition test.h:1291
Hold an unsigned integer type.
Definition uinteger.h:34
Implements the IEEE 802.11 MAC header.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
virtual void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
represent a single transmission mode
Definition wifi-mode.h:38
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:110
hold a list of per-remote-station state.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
MHz_u GetChannelWidth() const
uint8_t GetTxPowerLevel() const
Time GetGuardInterval() const
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:439
#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.
Definition test.h:134
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1369
@ WIFI_STANDARD_80211a
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:585
double dBm_u
dBm weak type
Definition wifi-units.h:27
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
Definition wifi-utils.h:280
@ WIFI_MAC_DATA
static PowerRateAdaptationTestSuite g_powerRateAdaptationTestSuite
the test suite