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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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::Destroy ();
334 }
335 
336 void
338 {
339  m_manager.SetTypeId ("ns3::AparfWifiManager");
340  Ptr<Node> node = ConfigureNode ();
341  Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice> (node->GetDevice (0));
343 
344  /*
345  * Configure thresholds for rate and power control.
346  */
347  manager->SetAttribute ("SuccessThreshold1",UintegerValue (3));
348  manager->SetAttribute ("SuccessThreshold2",UintegerValue (10));
349  manager->SetAttribute ("FailThreshold",UintegerValue (1));
350  manager->SetAttribute ("PowerThreshold",UintegerValue (10));
351 
352  /*
353  * Create a dummy packet to simulate transmission.
354  */
355  Mac48Address remoteAddress = Mac48Address::Allocate ();
356  WifiMacHeader packetHeader;
357  packetHeader.SetTypeData ();
358  packetHeader.SetQosTid (0);
359  Ptr<Packet> packet = Create<Packet> (10);
360  WifiMode ackMode;
361 
362  /*
363  * To initialize the manager we need to generate a transmission.
364  */
365  Ptr<Packet> p = Create<Packet> ();
366  dev->Send (p, remoteAddress, 1);
367 
368  //-----------------------------------------------------------------------------------------------------
369 
370  /*
371  * Aparf initiates with maximal rate and power.
372  */
373  WifiTxVector txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
374  WifiMode mode = txVector.GetMode ();
375  int power = (int) txVector.GetTxPowerLevel ();
376 
377  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Initial data rate wrong");
378  NS_TEST_ASSERT_MSG_EQ (power, 17, "APARF: Initial power level wrong");
379 
380  //-----------------------------------------------------------------------------------------------------
381 
382  /*
383  * As Aparf starts in state High, after 3 consecutive successful transmissions aparf increase rate or decrease power.
384  * As we are at maximal rate, the power should be decreased.
385  * Change to state Spread.
386  */
387  for (int i = 0; i < 3; i++)
388  {
389  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
390  }
391 
392  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
393  mode = txVector.GetMode ();
394  power = (int) txVector.GetTxPowerLevel ();
395 
396  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
397  NS_TEST_ASSERT_MSG_EQ (power, 16, "APARF: Incorrect value of power level");
398 
399  //-----------------------------------------------------------------------------------------------------
400 
401  /*
402  * One failure make the power to be increased again.
403  * Change to state Low.
404  */
405  manager->ReportDataFailed (remoteAddress, &packetHeader);
406 
407  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
408  mode = txVector.GetMode ();
409  power = (int) txVector.GetTxPowerLevel ();
410 
411  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
412  NS_TEST_ASSERT_MSG_EQ (power, 17, "APARF: Incorrect value of power level");
413 
414  //-----------------------------------------------------------------------------------------------------
415 
416  /*
417  * As we are in state Low we need 10 successful transmissions to increase rate or decrease power.
418  * As we are at maximal rate, the power should be decreased.
419  * Change to state Spread.
420  */
421  for (int i = 0; i < 10; i++)
422  {
423  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
424  }
425 
426  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
427  mode = txVector.GetMode ();
428  power = (int) txVector.GetTxPowerLevel ();
429 
430  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
431  NS_TEST_ASSERT_MSG_EQ (power, 16, "APARF: Incorrect value of power level");
432 
433  //-----------------------------------------------------------------------------------------------------
434 
435  /*
436  * One more successful transmission make to change to state High.
437  * Two more successful transmissions make power decrease.
438  */
439 
440  for (int i = 0; i < 3; i++)
441  {
442  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
443  }
444 
445  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
446  mode = txVector.GetMode ();
447  power = (int) txVector.GetTxPowerLevel ();
448 
449  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
450  NS_TEST_ASSERT_MSG_EQ (power, 15, "APARF: Incorrect value of power level");
451 
452  //-----------------------------------------------------------------------------------------------------
453 
454  /*
455  * As we are in state High we need 3 successful transmissions to increase rate or decrease power.
456  * After 16*3 successful transmissions power is decreased to zero.
457  */
458  for (int i = 0; i < 16 * 3; i++)
459  {
460  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
461  }
462 
463  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
464  mode = txVector.GetMode ();
465  power = (int) txVector.GetTxPowerLevel ();
466 
467  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
468  NS_TEST_ASSERT_MSG_EQ (power, 0, "APARF: Incorrect value of power level");
469 
470  //-----------------------------------------------------------------------------------------------------
471 
472  /*
473  * After one fail the rate is decreased or the power increased.
474  * As we are at minimal power, the power should be increased.
475  */
476  manager->ReportDataFailed (remoteAddress,&packetHeader);
477 
478  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
479  mode = txVector.GetMode ();
480  power = (int) txVector.GetTxPowerLevel ();
481 
482  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "Incorrect vale of data rate");
483  NS_TEST_ASSERT_MSG_EQ (power, 1, "Incorrect value of power level");
484 
485  //-----------------------------------------------------------------------------------------------------
486 
487  /*
488  * After one fail the rate is decreased or the power increased.
489  * After 16 failed transmissions power is increase to 17.
490  */
491  for (int i = 0; i < 16; i++)
492  {
493  manager->ReportDataFailed (remoteAddress,&packetHeader);
494  }
495 
496  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
497  mode = txVector.GetMode ();
498  power = (int) txVector.GetTxPowerLevel ();
499 
500  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
501  NS_TEST_ASSERT_MSG_EQ (power, 17, "APARF: Incorrect value of power level");
502 
503  //-----------------------------------------------------------------------------------------------------
504 
505  /*
506  * After one fail the rate is decreased or the power increased.
507  * As we are at maximal power, the rate should be decreased.
508  * Set critical rate to 54 Mbps.
509  */
510  manager->ReportDataFailed (remoteAddress,&packetHeader);
511 
512  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
513  mode = txVector.GetMode ();
514  power = (int) txVector.GetTxPowerLevel ();
515 
516  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 48000000, "Incorrect vale of data rate");
517  NS_TEST_ASSERT_MSG_EQ (power, 17, "Incorrect value of power level");
518 
519  //-----------------------------------------------------------------------------------------------------
520 
521  /*
522  * As we are in state High we need 3 successful transmissions to increase rate or decrease power.
523  * As rate critical is set, after 3 successful transmissions power is decreased.
524  */
525  for (int i = 0; i < 3; i++)
526  {
527  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
528  }
529 
530  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
531  mode = txVector.GetMode ();
532  power = (int) txVector.GetTxPowerLevel ();
533 
534  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 48000000, "APARF: Incorrect vale of data rate");
535  NS_TEST_ASSERT_MSG_EQ (power, 16, "APARF: Incorrect value of power level");
536 
537  //-----------------------------------------------------------------------------------------------------
538 
539  /*
540  * As we are in state High we need 3 successful transmissions to increase rate or decrease power.
541  * After 10 power changes critical rate is reseted.
542  * So after 10*3 successful transmissions critical rate is set to 0.
543  * And 3 successful transmissions more will make power increase to maximum and rate increase to the critical rate.
544  */
545  for (int i = 0; i < 9 * 3; i++)
546  {
547  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
548  }
549 
550  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
551  mode = txVector.GetMode ();
552  power = (int) txVector.GetTxPowerLevel ();
553 
554  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 48000000, "APARF: Incorrect vale of data rate");
555  NS_TEST_ASSERT_MSG_EQ (power, 7, "APARF: Incorrect value of power level");
556 
557  for (int i = 0; i < 3; i++)
558  {
559  manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0);
560  }
561 
562  txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
563  mode = txVector.GetMode ();
564  power = (int) txVector.GetTxPowerLevel ();
565 
566  NS_TEST_ASSERT_MSG_EQ (mode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1), 54000000, "APARF: Incorrect vale of data rate");
567  NS_TEST_ASSERT_MSG_EQ (power, 17, "APARF: Incorrect value of power level");
568 
569  Simulator::Destroy ();
570 }
571 
572 void
574 {
575 
576  TestParf ();
577  TestAparf ();
578 }
579 
580 //-----------------------------------------------------------------------------
582 {
583 public:
585 };
586 
588  : TestSuite ("power-rate-adaptation-wifi", UNIT)
589 {
590  AddTestCase (new PowerRateAdaptationTest, TestCase::QUICK);
591 }
592 
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
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:99
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:298
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:142
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:109
Instantiate subclasses of ns3::Object.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:128
void SetTypeData(void)
Set Type/Subtype values for a data packet with no subtype equal to 0.
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.