A Discrete-Event Network Simulator
API
power-rate-adaptation-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Universidad de la República - Uruguay
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Matías Richart <mrichart@fing.edu.uy>
19  */
20 
21 #include "ns3/wifi-net-device.h"
22 #include "ns3/yans-wifi-channel.h"
23 #include "ns3/adhoc-wifi-mac.h"
24 #include "ns3/yans-wifi-phy.h"
25 #include "ns3/parf-wifi-manager.h"
26 #include "ns3/propagation-delay-model.h"
27 #include "ns3/propagation-loss-model.h"
28 #include "ns3/error-rate-model.h"
29 #include "ns3/yans-error-rate-model.h"
30 #include "ns3/constant-position-mobility-model.h"
31 #include "ns3/node.h"
32 #include "ns3/simulator.h"
33 #include "ns3/test.h"
34 #include "ns3/object-factory.h"
35 #include "ns3/dca-txop.h"
36 #include "ns3/mac-rx-middle.h"
37 #include "ns3/pointer.h"
38 #include "ns3/rng-seed-manager.h"
39 #include "ns3/edca-txop-n.h"
40 #include "ns3/config.h"
41 #include "ns3/boolean.h"
42 
43 using namespace ns3;
44 
46 {
47 public:
49 
50  virtual void DoRun (void);
51 private:
52  void TestParf ();
53  void TestAparf ();
54  Ptr<Node> ConfigureNode ();
55 
57 };
58 
60  : TestCase ("PowerRateAdaptation")
61 {
62 }
63 
66 {
67  /*
68  * Create channel model. Is is necessary to configure correctly the phy layer.
69  */
70  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
71 
72  /*
73  * Create mac layer. We use Adhoc because association is not needed to get supported rates.
74  */
75  Ptr<AdhocWifiMac> mac = CreateObject<AdhocWifiMac> ();
76  mac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
77 
78  /*
79  * Create mobility model. Is needed by the phy layer for transmission.
80  */
81  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
82 
83  /*
84  * Create and configure phy layer.
85  */
86  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
87  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
88  phy->SetChannel (channel);
89  phy->SetDevice (dev);
90  phy->SetMobility (mobility);
91  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
92 
93  /*
94  * Configure power control parameters.
95  */
96  phy->SetNTxPower (18);
97  phy->SetTxPowerStart (0);
98  phy->SetTxPowerEnd (17);
99 
100  /*
101  * Create manager.
102  */
104 
105  /*
106  * Create and configure node. Add mac and phy layer and the manager.
107  */
108  Ptr<Node> node = CreateObject<Node> ();
109  mac->SetAddress (Mac48Address::Allocate ());
110  dev->SetMac (mac);
111  dev->SetPhy (phy);
112  dev->SetRemoteStationManager (manager);
113  node->AddDevice (dev);
114 
115  return node;
116 }
117 
118 void
120 {
121  m_manager.SetTypeId ("ns3::ParfWifiManager");
122  Ptr<Node> node = ConfigureNode ();
123  Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice> (node->GetDevice (0));
125 
126  /*
127  * Configure thresholds for rate and power control.
128  */
129  manager->SetAttribute ("AttemptThreshold",UintegerValue (15));
130  manager->SetAttribute ("SuccessThreshold",UintegerValue (10));
131 
132  /*
133  * Create a dummy packet to simulate transmission.
134  */
135  Mac48Address remoteAddress = Mac48Address::Allocate ();
136  WifiMacHeader packetHeader;
137  packetHeader.SetTypeData ();
138  packetHeader.SetQosTid (0);
139  Ptr<Packet> packet = Create<Packet> (10);
140  WifiMode ackMode;
141 
142  /*
143  * To initialize the manager we need to generate a transmission.
144  */
145  Ptr<Packet> p = Create<Packet> ();
146  dev->Send (p, remoteAddress, 1);
147 
148  //-----------------------------------------------------------------------------------------------------
149 
150  /*
151  * Parf initiates with maximal rate and power.
152  */
153  WifiTxVector txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
154  WifiMode mode = txVector.GetMode ();
155  int power = (int) txVector.GetTxPowerLevel ();
156 
157  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "PARF: Initial data rate wrong");
158  NS_TEST_ASSERT_MSG_EQ (power, 17, "PARF: Initial power level wrong");
159 
160  //-----------------------------------------------------------------------------------------------------
161 
162  /*
163  * After 10 consecutive successful transmissions parf increase rate or decrease power.
164  * As we are at maximal rate, the power should be decreased. recoveryPower=true.
165  */
166  for (int i = 0; i < 10; i++)
167  {
168  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
169  }
170 
171  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
172  mode = txVector.GetMode ();
173  power = (int) txVector.GetTxPowerLevel ();
174 
175  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "PARF: Incorrect vale of data rate");
176  NS_TEST_ASSERT_MSG_EQ (power, 16, "PARF: Incorrect value of power level");
177 
178  //-----------------------------------------------------------------------------------------------------
179 
180  /*
181  * As we are using recovery power, one failure make power increase.
182  *
183  */
184  manager->ReportDataFailed (remoteAddress,&packetHeader);
185 
186  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
187  mode = txVector.GetMode ();
188  power = (int) txVector.GetTxPowerLevel ();
189 
190  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "PARF: Incorrect vale of data rate");
191  NS_TEST_ASSERT_MSG_EQ (power, 17, "PARF: Incorrect value of power level");
192 
193  //-----------------------------------------------------------------------------------------------------
194 
195  /*
196  * After 15 transmissions attempts parf increase rate or decrease power.
197  * As we are at maximal rate, the power should be decreased. recoveryPower=true.
198  */
199  for (int i = 0; i < 7; i++)
200  {
201  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
202  manager->ReportDataFailed (remoteAddress,&packetHeader);
203  }
204  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
205 
206  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
207  mode = txVector.GetMode ();
208  power = (int) txVector.GetTxPowerLevel ();
209 
210  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "PARF: Incorrect vale of data rate");
211  NS_TEST_ASSERT_MSG_EQ (power, 16, "PARF: Incorrect value of power level");
212 
213  //-----------------------------------------------------------------------------------------------------
214 
215  /*
216  * As we are using recovery power, one failure make power increase. recoveryPower=false.
217  */
218 
219  manager->ReportDataFailed (remoteAddress,&packetHeader);
220 
221  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
222  mode = txVector.GetMode ();
223  power = (int) txVector.GetTxPowerLevel ();
224 
225  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "PARF: Incorrect vale of data rate");
226  NS_TEST_ASSERT_MSG_EQ (power, 17, "PARF: Incorrect value of power level");
227 
228  //-----------------------------------------------------------------------------------------------------
229 
230  /*
231  * After two consecutive fails the rate is decreased or the power increased.
232  * As we are at maximal power, the rate should be decreased.
233  */
234  manager->ReportDataFailed (remoteAddress,&packetHeader);
235  manager->ReportDataFailed (remoteAddress,&packetHeader);
236 
237  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
238  mode = txVector.GetMode ();
239  power = (int) txVector.GetTxPowerLevel ();
240 
241  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 48000000, "PARF: Incorrect vale of data rate");
242  NS_TEST_ASSERT_MSG_EQ (power, 17, "PARF: Incorrect value of power level");
243 
244  //-----------------------------------------------------------------------------------------------------
245 
246  /*
247  * After 10 consecutive successful transmissions parf increase rate or decrease power.
248  * As we are not at maximal rate, the rate is increased again. recoveryRate=true.
249  */
250  for (int i = 0; i < 10; i++)
251  {
252  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
253  }
254 
255  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
256  mode = txVector.GetMode ();
257  power = (int) txVector.GetTxPowerLevel ();
258 
259  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "PARF: Incorrect vale of data rate");
260  NS_TEST_ASSERT_MSG_EQ (power, 17, "PARF: Incorrect value of power level");
261 
262  //-----------------------------------------------------------------------------------------------------
263 
264  /*
265  * As we are using recovery rate, one failure make rate decrease. recoveryRate=false.
266  */
267 
268  manager->ReportDataFailed (remoteAddress,&packetHeader);
269 
270  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
271  mode = txVector.GetMode ();
272  power = (int) txVector.GetTxPowerLevel ();
273 
274  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 48000000, "PARF: Incorrect vale of data rate");
275  NS_TEST_ASSERT_MSG_EQ (power, 17, "PARF: Incorrect value of power level");
276 
277  //-----------------------------------------------------------------------------------------------------
278 
279  /*
280  * After 10 consecutive successful transmissions parf increase rate or decrease power.
281  * As we are not at maximal rate, the rate is increased again. recoveryRate=true.
282  */
283  for (int i = 0; i < 10; i++)
284  {
285  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
286  }
287 
288  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
289  mode = txVector.GetMode ();
290  power = (int) txVector.GetTxPowerLevel ();
291 
292  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "PARF: Incorrect vale of data rate");
293  NS_TEST_ASSERT_MSG_EQ (power, 17, "PARF: Incorrect value of power level");
294 
295  //-----------------------------------------------------------------------------------------------------
296 
297  /*
298  * After 10 consecutive successful transmissions parf increase rate or decrease power.
299  * As we are at maximal rate, the power is decreased. recoveryRate=false, recoveryPower=true.
300  */
301  for (int i = 0; i < 10; i++)
302  {
303  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
304  }
305 
306  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
307  mode = txVector.GetMode ();
308  power = (int) txVector.GetTxPowerLevel ();
309 
310  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "PARF: Incorrect vale of data rate");
311  NS_TEST_ASSERT_MSG_EQ (power, 16, "PARF: Incorrect value of power level");
312 
313  //-----------------------------------------------------------------------------------------------------
314 
315  /*
316  * One successful transmissions after a power decrease make recoverPower=false.
317  * So we need two consecutive failures to increase power again.
318  */
319  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
320 
321  for (int i = 0; i < 2; i++)
322  {
323  manager->ReportDataFailed (remoteAddress,&packetHeader);
324  }
325 
326  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
327  mode = txVector.GetMode ();
328  power = (int) txVector.GetTxPowerLevel ();
329 
330  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "PARF: Incorrect vale of data rate");
331  NS_TEST_ASSERT_MSG_EQ (power, 17, "PARF: Incorrect value of power level");
332 
333  Simulator::Stop (Seconds (10.0));
334 
335  Simulator::Run ();
336  Simulator::Destroy ();
337 
338 }
339 
340 void
342 {
343  m_manager.SetTypeId ("ns3::AparfWifiManager");
344  Ptr<Node> node = ConfigureNode ();
345  Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice> (node->GetDevice (0));
347 
348  /*
349  * Configure thresholds for rate and power control.
350  */
351  manager->SetAttribute ("SuccessThreshold 1",UintegerValue (3));
352  manager->SetAttribute ("SuccessThreshold 2",UintegerValue (10));
353  manager->SetAttribute ("FailThreshold",UintegerValue (1));
354  manager->SetAttribute ("PowerThreshold",UintegerValue (10));
355 
356  /*
357  * Create a dummy packet to simulate transmission.
358  */
359  Mac48Address remoteAddress = Mac48Address::Allocate ();
360  WifiMacHeader packetHeader;
361  packetHeader.SetTypeData ();
362  packetHeader.SetQosTid (0);
363  Ptr<Packet> packet = Create<Packet> (10);
364  WifiMode ackMode;
365 
366  /*
367  * To initialize the manager we need to generate a transmission.
368  */
369  Ptr<Packet> p = Create<Packet> ();
370  dev->Send (p, remoteAddress, 1);
371 
372  //-----------------------------------------------------------------------------------------------------
373 
374  /*
375  * Aparf initiates with maximal rate and power.
376  */
377  WifiTxVector txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
378  WifiMode mode = txVector.GetMode ();
379  int power = (int) txVector.GetTxPowerLevel ();
380 
381  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Initial data rate wrong");
382  NS_TEST_ASSERT_MSG_EQ (power, 17, "APARF: Initial power level wrong");
383 
384  //-----------------------------------------------------------------------------------------------------
385 
386  /*
387  * As Aparf starts in state High, after 3 consecutive successful transmissions aparf increase rate or decrease power.
388  * As we are at maximal rate, the power should be decreased.
389  * Change to state Spread.
390  */
391  for (int i = 0; i < 3; i++)
392  {
393  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
394  }
395 
396  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
397  mode = txVector.GetMode ();
398  power = (int) txVector.GetTxPowerLevel ();
399 
400  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
401  NS_TEST_ASSERT_MSG_EQ (power, 16, "APARF: Incorrect value of power level");
402 
403  //-----------------------------------------------------------------------------------------------------
404 
405  /*
406  * One failure make the power to be increased again.
407  * Change to state Low.
408  */
409  manager->ReportDataFailed (remoteAddress,&packetHeader);
410 
411  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
412  mode = txVector.GetMode ();
413  power = (int) txVector.GetTxPowerLevel ();
414 
415  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
416  NS_TEST_ASSERT_MSG_EQ (power, 17, "APARF: Incorrect value of power level");
417 
418  //-----------------------------------------------------------------------------------------------------
419 
420  /*
421  * As we are in state Low we need 10 successful transmissions to increase rate or decrease power.
422  * As we are at maximal rate, the power should be decreased.
423  * Change to state Spread.
424  */
425  for (int i = 0; i < 10; i++)
426  {
427  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
428  }
429 
430  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
431  mode = txVector.GetMode ();
432  power = (int) txVector.GetTxPowerLevel ();
433 
434  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
435  NS_TEST_ASSERT_MSG_EQ (power, 16, "APARF: Incorrect value of power level");
436 
437  //-----------------------------------------------------------------------------------------------------
438 
439  /*
440  * One more successful transmission make to change to state High.
441  * Two more successful transmissions make power decrease.
442  */
443 
444  for (int i = 0; i < 3; i++)
445  {
446  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
447  }
448 
449  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
450  mode = txVector.GetMode ();
451  power = (int) txVector.GetTxPowerLevel ();
452 
453  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
454  NS_TEST_ASSERT_MSG_EQ (power, 15, "APARF: Incorrect value of power level");
455 
456  //-----------------------------------------------------------------------------------------------------
457 
458  /*
459  * As we are in state High we need 3 successful transmissions to increase rate or decrease power.
460  * After 16*3 successful transmissions power is decreased to zero.
461  */
462  for (int i = 0; i < 16 * 3; i++)
463  {
464  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
465  }
466 
467  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
468  mode = txVector.GetMode ();
469  power = (int) txVector.GetTxPowerLevel ();
470 
471  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
472  NS_TEST_ASSERT_MSG_EQ (power, 0, "APARF: Incorrect value of power level");
473 
474  //-----------------------------------------------------------------------------------------------------
475 
476  /*
477  * After one fail the rate is decreased or the power increased.
478  * As we are at minimal power, the power should be increased.
479  */
480  manager->ReportDataFailed (remoteAddress,&packetHeader);
481 
482  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
483  mode = txVector.GetMode ();
484  power = (int) txVector.GetTxPowerLevel ();
485 
486  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "Incorrect vale of data rate");
487  NS_TEST_ASSERT_MSG_EQ (power, 1, "Incorrect value of power level");
488 
489  //-----------------------------------------------------------------------------------------------------
490 
491  /*
492  * After one fail the rate is decreased or the power increased.
493  * After 16 failed transmissions power is increase to 17.
494  */
495  for (int i = 0; i < 16; i++)
496  {
497  manager->ReportDataFailed (remoteAddress,&packetHeader);
498  }
499 
500  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
501  mode = txVector.GetMode ();
502  power = (int) txVector.GetTxPowerLevel ();
503 
504  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
505  NS_TEST_ASSERT_MSG_EQ (power, 17, "APARF: Incorrect value of power level");
506 
507  //-----------------------------------------------------------------------------------------------------
508 
509  /*
510  * After one fail the rate is decreased or the power increased.
511  * As we are at maximal power, the rate should be decreased.
512  * Set critical rate to 54 Mbps.
513  */
514  manager->ReportDataFailed (remoteAddress,&packetHeader);
515 
516  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
517  mode = txVector.GetMode ();
518  power = (int) txVector.GetTxPowerLevel ();
519 
520  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 48000000, "Incorrect vale of data rate");
521  NS_TEST_ASSERT_MSG_EQ (power, 17, "Incorrect value of power level");
522 
523  //-----------------------------------------------------------------------------------------------------
524 
525  /*
526  * As we are in state High we need 3 successful transmissions to increase rate or decrease power.
527  * As rate critical is set, after 3 successful transmissions power is decreased.
528  */
529  for (int i = 0; i < 3; i++)
530  {
531  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
532  }
533 
534  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
535  mode = txVector.GetMode ();
536  power = (int) txVector.GetTxPowerLevel ();
537 
538  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 48000000, "APARF: Incorrect vale of data rate");
539  NS_TEST_ASSERT_MSG_EQ (power, 16, "APARF: Incorrect value of power level");
540 
541  //-----------------------------------------------------------------------------------------------------
542 
543  /*
544  * As we are in state High we need 3 successful transmissions to increase rate or decrease power.
545  * After 10 power changes critical rate is reseted.
546  * So after 10*3 successful transmissions critical rate is set to 0.
547  * And 3 successful transmissions more will make power increase to maximum and rate increase to the critical rate.
548  */
549  for (int i = 0; i < 9 * 3; i++)
550  {
551  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
552  }
553 
554  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
555  mode = txVector.GetMode ();
556  power = (int) txVector.GetTxPowerLevel ();
557 
558  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 48000000, "APARF: Incorrect vale of data rate");
559  NS_TEST_ASSERT_MSG_EQ (power, 7, "APARF: Incorrect value of power level");
560 
561  for (int i = 0; i < 3; i++)
562  {
563  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
564  }
565 
566  txVector = manager->GetDataTxVector (remoteAddress,&packetHeader,packet,packet->GetSize ());
567  mode = txVector.GetMode ();
568  power = (int) txVector.GetTxPowerLevel ();
569 
570  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
571  NS_TEST_ASSERT_MSG_EQ (power, 17, "APARF: Incorrect value of power level");
572 
573  Simulator::Stop (Seconds (10.0));
574 
575  Simulator::Run ();
576  Simulator::Destroy ();
577 
578 }
579 
580 void
582 {
583 
584  TestParf ();
585  TestAparf ();
586 }
587 
588 //-----------------------------------------------------------------------------
590 {
591 public:
593 };
594 
596  : TestSuite ("power-rate-adaptation-wifi", UNIT)
597 {
598  AddTestCase (new PowerRateAdaptationTest, TestCase::QUICK);
599 }
600 
tuple channel
Definition: third.py:85
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
A suite of tests to run.
Definition: test.h:1333
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
bool IsShortGuardInterval(void) const
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:786
encapsulates test code
Definition: test.h:1147
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
uint8_t GetTxPowerLevel(void) const
tuple mobility
Definition: third.py:101
tuple phy
Definition: third.py:86
Ptr< WifiRemoteStationManager > GetRemoteStationManager(void) const
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:297
static PowerRateAdaptationTestSuite g_powerRateAdaptationTestSuite
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Hold an unsigned integer type.
Definition: uinteger.h:44
#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:161
uint32_t GetChannelWidth(void) const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:135
tuple mac
Definition: third.py:92
hold a list of per-remote-station state.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
an EUI-48 address
Definition: mac48-address.h:43
uint64_t GetDataRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
Instantiate subclasses of ns3::Object.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:121
void SetTypeData(void)
Set Type/Subtype values for a data packet with no subtype equal to 0.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
virtual void DoRun(void)
Implementation to actually run this TestCase.
WifiMode GetMode(void) const
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:191
Implements the IEEE 802.11 MAC header.