A Discrete-Event Network Simulator
API
wifi-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  * 2010 NICTA
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Quincy Tse <quincy.tse@nicta.com.au>
21  * Sébastien Deronne <sebastien.deronne@gmail.com>
22  */
23 
24 #include "ns3/string.h"
25 #include "ns3/yans-wifi-helper.h"
26 #include "ns3/mobility-helper.h"
27 #include "ns3/wifi-net-device.h"
28 #include "ns3/adhoc-wifi-mac.h"
29 #include "ns3/ap-wifi-mac.h"
30 #include "ns3/propagation-loss-model.h"
31 #include "ns3/yans-error-rate-model.h"
32 #include "ns3/constant-position-mobility-model.h"
33 #include "ns3/test.h"
34 #include "ns3/pointer.h"
35 #include "ns3/rng-seed-manager.h"
36 #include "ns3/config.h"
37 #include "ns3/error-model.h"
38 #include "ns3/socket.h"
39 #include "ns3/packet-socket-server.h"
40 #include "ns3/packet-socket-client.h"
41 #include "ns3/packet-socket-helper.h"
42 #include "ns3/spectrum-wifi-helper.h"
43 #include "ns3/multi-model-spectrum-channel.h"
44 #include "ns3/wifi-spectrum-signal-parameters.h"
45 #include "ns3/yans-wifi-phy.h"
46 #include "ns3/mgt-headers.h"
47 #include "ns3/ht-configuration.h"
48 #include "ns3/wifi-ppdu.h"
49 #include "ns3/wifi-psdu.h"
50 #include "ns3/waypoint-mobility-model.h"
51 
52 using namespace ns3;
53 
54 //Helper function to assign streams to random variables, to control
55 //randomness in the tests
56 static void
58 {
59  int64_t currentStream = stream;
60  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
61  if (rmac)
62  {
63  PointerValue ptr;
64  rmac->GetAttribute ("Txop", ptr);
65  Ptr<Txop> txop = ptr.Get<Txop> ();
66  currentStream += txop->AssignStreams (currentStream);
67 
68  rmac->GetAttribute ("VO_Txop", ptr);
69  Ptr<QosTxop> vo_txop = ptr.Get<QosTxop> ();
70  currentStream += vo_txop->AssignStreams (currentStream);
71 
72  rmac->GetAttribute ("VI_Txop", ptr);
73  Ptr<QosTxop> vi_txop = ptr.Get<QosTxop> ();
74  currentStream += vi_txop->AssignStreams (currentStream);
75 
76  rmac->GetAttribute ("BE_Txop", ptr);
77  Ptr<QosTxop> be_txop = ptr.Get<QosTxop> ();
78  currentStream += be_txop->AssignStreams (currentStream);
79 
80  rmac->GetAttribute ("BK_Txop", ptr);
81  Ptr<QosTxop> bk_txop = ptr.Get<QosTxop> ();
82  bk_txop->AssignStreams (currentStream);
83  }
84 }
85 
92 class WifiTest : public TestCase
93 {
94 public:
95  WifiTest ();
96 
97  virtual void DoRun (void);
98 
99 
100 private:
102  void RunOne (void);
108  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
114 
118 };
119 
121  : TestCase ("Wifi")
122 {
123 }
124 
125 void
127 {
128  Ptr<Packet> p = Create<Packet> ();
129  dev->Send (p, dev->GetBroadcast (), 1);
130 }
131 
132 void
134 {
135  Ptr<Node> node = CreateObject<Node> ();
136  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
137 
139  mac->SetDevice (dev);
140  mac->ConfigureStandard (WIFI_STANDARD_80211a);
141  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
142  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
143  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
144  phy->SetErrorRateModel (error);
145  phy->SetChannel (channel);
146  phy->SetDevice (dev);
147  phy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
149 
150  mobility->SetPosition (pos);
151  node->AggregateObject (mobility);
152  mac->SetAddress (Mac48Address::Allocate ());
153  dev->SetMac (mac);
154  dev->SetPhy (phy);
155  dev->SetRemoteStationManager (manager);
156  node->AddDevice (dev);
157 
158  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
159 }
160 
161 void
163 {
164  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
166  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
167  channel->SetPropagationDelayModel (propDelay);
168  channel->SetPropagationLossModel (propLoss);
169 
170  CreateOne (Vector (0.0, 0.0, 0.0), channel);
171  CreateOne (Vector (5.0, 0.0, 0.0), channel);
172  CreateOne (Vector (5.0, 0.0, 0.0), channel);
173 
174  Simulator::Stop (Seconds (10.0));
175 
176  Simulator::Run ();
177  Simulator::Destroy ();
178 }
179 
180 void
182 {
183  m_mac.SetTypeId ("ns3::AdhocWifiMac");
184  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
185 
186  m_manager.SetTypeId ("ns3::ArfWifiManager");
187  RunOne ();
188  m_manager.SetTypeId ("ns3::AarfWifiManager");
189  RunOne ();
190  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
191  RunOne ();
192  m_manager.SetTypeId ("ns3::OnoeWifiManager");
193  RunOne ();
194  m_manager.SetTypeId ("ns3::AmrrWifiManager");
195  RunOne ();
196  m_manager.SetTypeId ("ns3::IdealWifiManager");
197  RunOne ();
198 
199  m_mac.SetTypeId ("ns3::AdhocWifiMac");
200  RunOne ();
201  m_mac.SetTypeId ("ns3::ApWifiMac");
202  RunOne ();
203  m_mac.SetTypeId ("ns3::StaWifiMac");
204  RunOne ();
205 
206 
207  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
208  m_mac.SetTypeId ("ns3::AdhocWifiMac");
209  RunOne ();
210 }
211 
219 {
220 public:
221  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
222  {
223  }
224  virtual void DoRun (void)
225  {
226  //startingSeq=0, seqNum=2047
227  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
228  //startingSeq=0, seqNum=2048
229  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
230  //startingSeq=2048, seqNum=0
231  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
232  //startingSeq=4095, seqNum=0
233  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
234  //startingSeq=0, seqNum=4095
235  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
236  //startingSeq=4095 seqNum=2047
237  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
238  //startingSeq=2048 seqNum=4095
239  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
240  //startingSeq=2049 seqNum=0
241  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
242  }
243 };
244 
245 
250 {
251 public:
253 
254  virtual void DoRun (void);
255 
256 
257 private:
274  void SwitchCh (Ptr<WifiNetDevice> dev);
275 
279 };
280 
282  : TestCase ("InterferenceHelperSequence")
283 {
284 }
285 
286 void
288 {
289  Ptr<Packet> p = Create<Packet> (1000);
290  dev->Send (p, dev->GetBroadcast (), 1);
291 }
292 
293 void
295 {
296  Ptr<WifiPhy> p = dev->GetPhy ();
297  p->SetChannelNumber (40);
298 }
299 
300 Ptr<Node>
302 {
303  Ptr<Node> node = CreateObject<Node> ();
304  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
305 
307  mac->SetDevice (dev);
308  mac->ConfigureStandard (WIFI_STANDARD_80211a);
309  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
310  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
311  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
312  phy->SetErrorRateModel (error);
313  phy->SetChannel (channel);
314  phy->SetDevice (dev);
315  phy->SetMobility (mobility);
316  phy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
318 
319  mobility->SetPosition (pos);
320  node->AggregateObject (mobility);
321  mac->SetAddress (Mac48Address::Allocate ());
322  dev->SetMac (mac);
323  dev->SetPhy (phy);
324  dev->SetRemoteStationManager (manager);
325  node->AddDevice (dev);
326 
327  return node;
328 }
329 
330 void
332 {
333  m_mac.SetTypeId ("ns3::AdhocWifiMac");
334  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
335  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
336 
337  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
339  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
340  channel->SetPropagationDelayModel (propDelay);
341  channel->SetPropagationLossModel (propLoss);
342 
343  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
344  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
345  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
346 
347  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
348  propLoss->SetDefaultLoss (999);
349 
350  Simulator::Schedule (Seconds (1.0),
352  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
353 
354  Simulator::Schedule (Seconds (1.0000001),
356  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
357 
358  Simulator::Schedule (Seconds (5.0),
360  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
361 
362  Simulator::Schedule (Seconds (7.0),
364  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
365 
366  Simulator::Stop (Seconds (100.0));
367  Simulator::Run ();
368 
369  Simulator::Destroy ();
370 }
371 
372 //-----------------------------------------------------------------------------
424 {
425 public:
427 
428  virtual void DoRun (void);
429 
430 
431 private:
437 
441 
444  unsigned int m_numSentPackets;
445 
451  void NotifyPhyTxBegin (Ptr<const Packet> p, double txPowerW);
452 };
453 
455  : TestCase ("Test case for DCF immediate access with broadcast frames")
456 {
457 }
458 
459 void
461 {
462  if (m_numSentPackets == 0)
463  {
466  }
467  else if (m_numSentPackets == 1)
468  {
470  }
471 }
472 
473 void
475 {
476  Ptr<Packet> p = Create<Packet> (1000);
477  dev->Send (p, dev->GetBroadcast (), 1);
478 }
479 
480 void
482 {
483  m_mac.SetTypeId ("ns3::AdhocWifiMac");
484  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
485  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
486 
487  //Assign a seed and run number, and later fix the assignment of streams to
488  //WiFi random variables, so that the first backoff used is one slot
489  RngSeedManager::SetSeed (1);
490  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
491 
492  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
494  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
495  channel->SetPropagationDelayModel (propDelay);
496  channel->SetPropagationLossModel (propLoss);
497 
498  Ptr<Node> txNode = CreateObject<Node> ();
499  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
500  Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
501  txMac->SetDevice (txDev);
502  txMac->ConfigureStandard (WIFI_STANDARD_80211a);
503  //Fix the stream assignment to the Dcf Txop objects (backoffs)
504  //The below stream assignment will result in the Txop object
505  //using a backoff value of zero for this test when the
506  //Txop::EndTxNoAck() calls to StartBackoffNow()
507  AssignWifiRandomStreams (txMac, 23);
508 
509  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
510  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
511  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
512  txPhy->SetErrorRateModel (txError);
513  txPhy->SetChannel (channel);
514  txPhy->SetDevice (txDev);
515  txPhy->SetMobility (txMobility);
516  txPhy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
517 
518  txPhy->TraceConnectWithoutContext ("PhyTxBegin", MakeCallback (&DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin, this));
519 
520  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
521  txNode->AggregateObject (txMobility);
522  txMac->SetAddress (Mac48Address::Allocate ());
523  txDev->SetMac (txMac);
524  txDev->SetPhy (txPhy);
525  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
526  txNode->AddDevice (txDev);
527 
530  m_numSentPackets = 0;
531 
532  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
533  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
534 
535  Simulator::Stop (Seconds (2.0));
536  Simulator::Run ();
537  Simulator::Destroy ();
538 
539  // First packet is transmitted a DIFS after the packet is queued. A DIFS
540  // is 2 slots (2 * 9 = 18 us) plus a SIFS (16 us), i.e., 34 us
541  Time expectedFirstTransmissionTime = Seconds (1.0) + MicroSeconds (34);
542 
543  //First packet has 1408 us of transmit time. Slot time is 9 us.
544  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
545  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
546  //1451 us after the first one.
547  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
548  Time expectedSecondTransmissionTime = expectedFirstTransmissionTime + MicroSeconds (expectedWait1);
549  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, expectedFirstTransmissionTime, "The first transmission time not correct!");
550 
551  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
552 }
553 
554 //-----------------------------------------------------------------------------
567 class Bug730TestCase : public TestCase
568 {
569 public:
570  Bug730TestCase ();
571  virtual ~Bug730TestCase ();
572 
573  virtual void DoRun (void);
574 
575 
576 private:
577  uint32_t m_received;
578 
585  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
586 
587 };
588 
590  : TestCase ("Test case for Bug 730"),
591  m_received (0)
592 {
593 }
594 
596 {
597 }
598 
599 void
600 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
601 {
602  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
603  {
604  m_received++;
605  }
606 }
607 
608 
609 void
611 {
612  m_received = 0;
613 
614  NodeContainer wifiStaNode;
615  wifiStaNode.Create (1);
616 
618  wifiApNode.Create (1);
619 
620  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
622  phy.SetChannel (channel.Create ());
623 
625  wifi.SetStandard (WIFI_STANDARD_80211b);
626  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
627  "DataMode", StringValue ("DsssRate1Mbps"),
628  "ControlMode", StringValue ("DsssRate1Mbps"));
629 
631  Ssid ssid = Ssid ("ns-3-ssid");
632  mac.SetType ("ns3::StaWifiMac",
633  "Ssid", SsidValue (ssid),
634  "ActiveProbing", BooleanValue (false));
635 
637  staDevices = wifi.Install (phy, mac, wifiStaNode);
638 
639  mac.SetType ("ns3::ApWifiMac",
640  "Ssid", SsidValue (ssid),
641  "BeaconGeneration", BooleanValue (true));
642 
644  apDevices = wifi.Install (phy, mac, wifiApNode);
645 
647  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
648 
649  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
650  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
651  mobility.SetPositionAllocator (positionAlloc);
652 
653  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
654  mobility.Install (wifiApNode);
655  mobility.Install (wifiStaNode);
656 
657  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
658  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
659 
660  PacketSocketAddress socket;
661  socket.SetSingleDevice (sta_device->GetIfIndex ());
662  socket.SetPhysicalAddress (ap_device->GetAddress ());
663  socket.SetProtocol (1);
664 
665  // give packet socket powers to nodes.
666  PacketSocketHelper packetSocket;
667  packetSocket.Install (wifiStaNode);
668  packetSocket.Install (wifiApNode);
669 
670  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
671  client->SetAttribute ("PacketSize", UintegerValue (1460));
672  client->SetRemote (socket);
673  wifiStaNode.Get (0)->AddApplication (client);
674  client->SetStartTime (Seconds (1));
675  client->SetStopTime (Seconds (51.0));
676 
677  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
678  server->SetLocal (socket);
679  wifiApNode.Get (0)->AddApplication (server);
680  server->SetStartTime (Seconds (0.0));
681  server->SetStopTime (Seconds (52.0));
682 
683  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
684 
685  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
686 
687  Simulator::Stop (Seconds (55));
688  Simulator::Run ();
689 
690  Simulator::Destroy ();
691 
692  bool result = (m_received > 0);
693  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
694 }
695 
696 //-----------------------------------------------------------------------------
705 {
706 public:
708  virtual ~QosFragmentationTestCase ();
709 
710  virtual void DoRun (void);
711 
712 
713 private:
714  uint32_t m_received;
715  uint32_t m_fragments;
716 
723  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
724 
731  void Transmit (std::string context, Ptr<const Packet> p, double power);
732 };
733 
735  : TestCase ("Test case for fragmentation with QoS stations"),
736  m_received (0),
737  m_fragments (0)
738 {
739 }
740 
742 {
743 }
744 
745 void
746 QosFragmentationTestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
747 {
748  if (p->GetSize () == 1400)
749  {
750  m_received++;
751  }
752 }
753 
754 void
755 QosFragmentationTestCase::Transmit (std::string context, Ptr<const Packet> p, double power)
756 {
757  WifiMacHeader hdr;
758  p->PeekHeader (hdr);
759  if (hdr.IsQosData ())
760  {
761  NS_TEST_EXPECT_MSG_LT_OR_EQ (p->GetSize (), 400, "Unexpected fragment size");
762  m_fragments++;
763  }
764 }
765 
766 void
768 {
769  NodeContainer wifiStaNode;
770  wifiStaNode.Create (1);
771 
773  wifiApNode.Create (1);
774 
775  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
777  phy.SetChannel (channel.Create ());
778 
780  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
781  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
782  "DataMode", StringValue ("HtMcs7"));
783 
785  Ssid ssid = Ssid ("ns-3-ssid");
786  mac.SetType ("ns3::StaWifiMac",
787  "Ssid", SsidValue (ssid),
788  "ActiveProbing", BooleanValue (false));
789 
791  staDevices = wifi.Install (phy, mac, wifiStaNode);
792 
793  mac.SetType ("ns3::ApWifiMac",
794  "Ssid", SsidValue (ssid),
795  "BeaconGeneration", BooleanValue (true));
796 
798  apDevices = wifi.Install (phy, mac, wifiApNode);
799 
801  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
802 
803  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
804  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
805  mobility.SetPositionAllocator (positionAlloc);
806 
807  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
808  mobility.Install (wifiApNode);
809  mobility.Install (wifiStaNode);
810 
811  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
812  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
813 
814  // set the TXOP limit on BE AC
815  Ptr<RegularWifiMac> sta_mac = DynamicCast<RegularWifiMac> (sta_device->GetMac ());
816  NS_ASSERT (sta_mac);
817  PointerValue ptr;
818  sta_mac->GetAttribute ("BE_Txop", ptr);
819  ptr.Get<QosTxop> ()->SetTxopLimit (MicroSeconds (3008));
820 
821  PacketSocketAddress socket;
822  socket.SetSingleDevice (sta_device->GetIfIndex ());
823  socket.SetPhysicalAddress (ap_device->GetAddress ());
824  socket.SetProtocol (1);
825 
826  // give packet socket powers to nodes.
827  PacketSocketHelper packetSocket;
828  packetSocket.Install (wifiStaNode);
829  packetSocket.Install (wifiApNode);
830 
831  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
832  client->SetAttribute ("PacketSize", UintegerValue (1400));
833  client->SetAttribute ("MaxPackets", UintegerValue (1));
834  client->SetRemote (socket);
835  wifiStaNode.Get (0)->AddApplication (client);
836  client->SetStartTime (Seconds (1));
837  client->SetStopTime (Seconds (3.0));
838 
839  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
840  server->SetLocal (socket);
841  wifiApNode.Get (0)->AddApplication (server);
842  server->SetStartTime (Seconds (0.0));
843  server->SetStopTime (Seconds (4.0));
844 
845  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&QosFragmentationTestCase::Receive, this));
846 
847  Config::Set ("/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("400"));
848  Config::Connect ("/NodeList/0/DeviceList/0/Phy/PhyTxBegin", MakeCallback (&QosFragmentationTestCase::Transmit, this));
849 
850  Simulator::Stop (Seconds (5));
851  Simulator::Run ();
852 
853  Simulator::Destroy ();
854 
855  NS_TEST_ASSERT_MSG_EQ (m_received, 1, "Unexpected number of received packets");
856  NS_TEST_ASSERT_MSG_EQ (m_fragments, 4, "Unexpected number of transmitted fragments");
857 }
858 
866 {
867 public:
869 
870  virtual void DoRun (void);
871 
872 
873 private:
880 
881 };
882 
884  : TestCase ("Test case for setting WifiPhy channel and frequency")
885 {
886 }
887 
890 {
891  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
892  Ptr<WifiPhy> wp = wnd->GetPhy ();
893  return wp->GetObject<YansWifiPhy> ();
894 }
895 
896 void
898 {
899  NodeContainer wifiStaNode;
900  wifiStaNode.Create (1);
902  wifiApNode.Create (1);
903 
904  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
906  phy.SetChannel (channel.Create ());
907 
908  // Configure and declare other generic components of this example
909  Ssid ssid;
910  ssid = Ssid ("wifi-phy-configuration");
911  WifiMacHelper macSta;
912  macSta.SetType ("ns3::StaWifiMac",
913  "Ssid", SsidValue (ssid),
914  "ActiveProbing", BooleanValue (false));
915  NetDeviceContainer staDevice;
916  Ptr<YansWifiPhy> phySta;
917 
918  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
919  {
920  // case 0:
921  // Default configuration, without WifiHelper::SetStandard or WifiHelper
922  phySta = CreateObject<YansWifiPhy> ();
923  // The default results in an invalid configuration of channel 0,
924  // width 20, and frequency 0 MHz
925  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "default configuration");
926  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
927  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 0, "default configuration");
928  }
929  {
930  // case 1:
932  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
933  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
934  phySta = GetYansWifiPhyPtr (staDevice);
935  // We expect channel 36, width 20, frequency 5180
936  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
937  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
938  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
939  }
940  {
941  // case 2:
943  wifi.SetStandard (WIFI_STANDARD_80211b);
944  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
945  phySta = GetYansWifiPhyPtr (staDevice);
946  // We expect channel 1, width 22, frequency 2412
947  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
948  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
949  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
950  }
951  {
952  // case 3:
954  wifi.SetStandard (WIFI_STANDARD_80211g);
955  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
956  phySta = GetYansWifiPhyPtr (staDevice);
957  // We expect channel 1, width 20, frequency 2412
958  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
959  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
960  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
961  }
962  {
963  // case 4:
965  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
966  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
967  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
968  phySta = GetYansWifiPhyPtr (staDevice);
969  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
970  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
971  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
972  }
973  {
974  // case 5:
976  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
977  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
978  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
979  phySta = GetYansWifiPhyPtr (staDevice);
980  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
981  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
982  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
983  }
984  {
985  // case 6:
987  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
988  wifi.SetStandard (WIFI_STANDARD_80211ac);
989  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
990  phySta = GetYansWifiPhyPtr (staDevice);
991  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
992  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
993  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
994  }
995  {
996  // case 7:
998  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
999  wifi.SetStandard (WIFI_STANDARD_80211ax_2_4GHZ);
1000  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1001  phySta = GetYansWifiPhyPtr (staDevice);
1002  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11ax-2.4GHz configuration");
1003  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11ax-2.4GHz configuration");
1004  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11ax-2.4GHz configuration");
1005  }
1006  {
1007  // case 8:
1008  WifiHelper wifi;
1009  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1010  wifi.SetStandard (WIFI_STANDARD_80211ax_5GHZ);
1011  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1012  phySta = GetYansWifiPhyPtr (staDevice);
1013  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ax-5GHz configuration");
1014  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-5GHz configuration");
1015  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ax-5GHz configuration");
1016  }
1017  {
1018  // case 9:
1019  WifiHelper wifi;
1020  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1021  wifi.SetStandard (WIFI_STANDARD_80211ax_6GHZ);
1022  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1023  phySta = GetYansWifiPhyPtr (staDevice);
1024  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 7, "802.11ax-6GHz configuration");
1025  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-6GHz configuration");
1026  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5975, "802.11ax-6GHz configuration");
1027  }
1028  {
1029  // case 10:
1030  WifiHelper wifi;
1031  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1032  wifi.SetStandard (WIFI_STANDARD_80211p);
1033  phy.Set ("ChannelWidth", UintegerValue (10));
1034  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1035  phySta = GetYansWifiPhyPtr (staDevice);
1036  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11p 10Mhz configuration");
1037  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11p 10Mhz configuration");
1038  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 10Mhz configuration");
1039  }
1040  {
1041  // case 11:
1042  WifiHelper wifi;
1043  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1044  wifi.SetStandard (WIFI_STANDARD_80211p);
1045  phy.Set ("ChannelWidth", UintegerValue (5));
1046  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1047  phySta = GetYansWifiPhyPtr (staDevice);
1048  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 171, "802.11p 5Mhz configuration");
1049  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11p 5Mhz configuration");
1050  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 5Mhz configuration");
1051  }
1052  {
1053  // case 12:
1054  WifiHelper wifi;
1055  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1056  wifi.SetStandard (WIFI_STANDARD_holland);
1057  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1058  phySta = GetYansWifiPhyPtr (staDevice);
1059  // We expect channel 36, width 20, frequency 5180
1060  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
1061  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
1062  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
1063  }
1064  {
1065  // case 13:
1066  WifiHelper wifi;
1067  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1068  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1069  phy.Set ("ChannelNumber", UintegerValue (44));
1070  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1071  phySta = GetYansWifiPhyPtr (staDevice);
1072  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1073  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1074  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1075  }
1076  {
1077  // case 14:
1078  WifiHelper wifi;
1079  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1080  phy.Set ("ChannelNumber", UintegerValue (44));
1081  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1082  phySta = GetYansWifiPhyPtr (staDevice);
1083  // Post-install reconfiguration to channel number 40
1084  std::ostringstream path;
1085  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber";
1086  Config::Set (path.str(), UintegerValue (40));
1087  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1088  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1089  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1090  }
1091  {
1092  // case 15:
1093  WifiHelper wifi;
1094  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1095  phy.Set ("ChannelNumber", UintegerValue (44));
1096  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1097  phySta = GetYansWifiPhyPtr (staDevice);
1098  // Post-install reconfiguration to channel width 40 MHz
1099  std::ostringstream path;
1100  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth";
1101  Config::Set (path.str(), UintegerValue (40));
1102  // Although channel 44 is configured originally for 20 MHz, we
1103  // allow it to be used for 40 MHz here
1104  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1105  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1106  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1107  }
1108  {
1109  // case 16:
1110  WifiHelper wifi;
1111  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1112  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1113  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1114  phySta = GetYansWifiPhyPtr (staDevice);
1115  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
1116  // Post-install reconfiguration to channel width 40 MHz
1117  std::ostringstream path;
1118  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth";
1119  Config::Set (path.str(), UintegerValue (40));
1120  // Although channel 44 is configured originally for 20 MHz, we
1121  // allow it to be used for 40 MHz here
1122  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1123  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1124  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1125  }
1126  {
1127  // case 17:
1128  WifiHelper wifi;
1129  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1130  // Test that setting Frequency to a non-standard value will zero the
1131  // channel number
1132  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1133  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1134  phySta = GetYansWifiPhyPtr (staDevice);
1135  phySta->SetAttribute ("Frequency", UintegerValue (5281));
1136  // We expect channel number to be zero since frequency doesn't match
1137  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1138  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1139  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5281, "802.11 5GHz configuration");
1140  }
1141  {
1142  // case 18:
1143  WifiHelper wifi;
1144  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1145  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1146  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1147  phySta = GetYansWifiPhyPtr (staDevice);
1148  // Test that setting Frequency to a standard value will set the
1149  // channel number correctly
1150  phySta->SetAttribute ("Frequency", UintegerValue (5500));
1151  // We expect channel number to be 100 due to frequency 5500
1152  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
1153  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1154  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
1155  }
1156  {
1157  // case 19:
1158  WifiHelper wifi;
1159  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1160  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1161  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1162  phySta = GetYansWifiPhyPtr (staDevice);
1163  // This case will error exit due to invalid channel number unless
1164  // we provide the DefineChannelNumber() below
1166  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
1167  }
1168  {
1169  // case 20:
1170  WifiHelper wifi;
1171  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1172  // Test how channel number behaves when frequency is non-standard
1173  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1174  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1175  phySta = GetYansWifiPhyPtr (staDevice);
1176  phySta->SetAttribute ("Frequency", UintegerValue (5181));
1177  // We expect channel number to be 0 due to unknown center frequency 5181
1178  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1179  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1180  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5181, "802.11 5GHz configuration");
1181  phySta->SetAttribute ("Frequency", UintegerValue (5180));
1182  // We expect channel number to be 36 due to known center frequency 5180
1183  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1184  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1185  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1186  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1187  // We expect channel number to be 0 due to unknown center frequency 5179
1188  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1189  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1190  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1191  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1192  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1193  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1194  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1195  }
1196  {
1197  // case 21:
1198  WifiHelper wifi;
1199  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1200  // Set both channel and frequency to consistent values
1201  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1202  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1203  phySta = GetYansWifiPhyPtr (staDevice);
1204  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1205  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
1206  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1207  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1208  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1209  // Set both channel and frequency to inconsistent values
1210  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1211  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1212  // We expect channel number to be 36
1213  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1214  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1215  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1216  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1217  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1218  // We expect channel number to be 40
1219  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1220  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1221  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1222  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1223  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1224  // We expect channel number to be 36
1225  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1226  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1227  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1228  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1229  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1230  // We expect channel number to be 0
1231  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1232  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1233  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1234  }
1235 
1236  Simulator::Destroy ();
1237 }
1238 
1239 //-----------------------------------------------------------------------------
1248 {
1249 public:
1250  Bug2222TestCase ();
1251  virtual ~Bug2222TestCase ();
1252 
1253  virtual void DoRun (void);
1254 
1255 
1256 private:
1258 
1264  void TxDataFailedTrace (std::string context, Mac48Address adress);
1265 };
1266 
1268  : TestCase ("Test case for Bug 2222"),
1269  m_countInternalCollisions (0)
1270 {
1271 }
1272 
1274 {
1275 }
1276 
1277 void
1279 {
1280  //Indicate the long retry counter has been increased in the wifi remote station manager
1282 }
1283 
1284 void
1286 {
1288 
1289  //Generate same backoff for AC_VI and AC_VO
1290  //The below combination will work
1291  RngSeedManager::SetSeed (1);
1292  RngSeedManager::SetRun (16);
1293  int64_t streamNumber = 100;
1294 
1295  NodeContainer wifiNodes;
1296  wifiNodes.Create (2);
1297 
1298  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1300  phy.SetChannel (channel.Create ());
1301 
1302  WifiHelper wifi;
1303  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1304  "DataMode", StringValue ("OfdmRate54Mbps"),
1305  "ControlMode", StringValue ("OfdmRate24Mbps"));
1307  Ssid ssid = Ssid ("ns-3-ssid");
1308  mac.SetType ("ns3::AdhocWifiMac",
1309  "QosSupported", BooleanValue (true));
1310 
1311  NetDeviceContainer wifiDevices;
1312  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1313 
1314  // Assign fixed streams to random variables in use
1315  wifi.AssignStreams (wifiDevices, streamNumber);
1316 
1318  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1319 
1320  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1321  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1322  mobility.SetPositionAllocator (positionAlloc);
1323 
1324  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1325  mobility.Install (wifiNodes);
1326 
1327  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1328  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1329 
1330  PacketSocketAddress socket;
1331  socket.SetSingleDevice (device1->GetIfIndex ());
1332  socket.SetPhysicalAddress (device2->GetAddress ());
1333  socket.SetProtocol (1);
1334 
1335  PacketSocketHelper packetSocket;
1336  packetSocket.Install (wifiNodes);
1337 
1338  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1339  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1340  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1341  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1342  clientLowPriority->SetRemote (socket);
1343  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1344  clientLowPriority->SetStartTime (Seconds (0.0));
1345  clientLowPriority->SetStopTime (Seconds (1.0));
1346 
1347  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1348  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1349  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1350  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1351  clientHighPriority->SetRemote (socket);
1352  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1353  clientHighPriority->SetStartTime (Seconds (0.0));
1354  clientHighPriority->SetStopTime (Seconds (1.0));
1355 
1356  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1357  server->SetLocal (socket);
1358  wifiNodes.Get (1)->AddApplication (server);
1359  server->SetStartTime (Seconds (0.0));
1360  server->SetStopTime (Seconds (1.0));
1361 
1362  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1363 
1364  Simulator::Stop (Seconds (1.0));
1365  Simulator::Run ();
1366  Simulator::Destroy ();
1367 
1368  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1369 }
1370 
1371 //-----------------------------------------------------------------------------
1385 {
1386 public:
1387  Bug2843TestCase ();
1388  virtual ~Bug2843TestCase ();
1389  virtual void DoRun (void);
1390 
1391 private:
1395  typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1396  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1397 
1404  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1411  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1412 
1413  uint16_t m_channelWidth;
1414 };
1415 
1417  : TestCase ("Test case for Bug 2843"),
1418  m_channelWidth (20)
1419 {
1420 }
1421 
1423 {
1424 }
1425 
1426 void
1428 {
1429  // Extract starting frequency and number of subbands
1430  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1431  std::size_t numBands = c->GetNumBands ();
1432  double startingFreq = c->Begin ()->fl;
1433 
1434  // Get channel bandwidth and modulation class
1435  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1436 
1437  Ptr<WifiPpdu> ppdu = Copy (wifiTxParams->ppdu);
1438  WifiTxVector txVector = ppdu->GetTxVector ();
1439  m_channelWidth = txVector.GetChannelWidth ();
1440  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1441 
1442  // Build a tuple and check if seen before (if so store it)
1443  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, m_channelWidth, numBands, modulationClass);
1444  bool found = false;
1445  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1446  {
1447  if (*it == tupleForCurrentTx)
1448  {
1449  found = true;
1450  }
1451  }
1452  if (!found)
1453  {
1454  m_distinctTuples.push_back (tupleForCurrentTx);
1455  }
1456 }
1457 
1458 void
1459 Bug2843TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1460  Address& destination) const
1461 {
1462  for (uint8_t i = 0; i < numPackets; i++)
1463  {
1464  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1465  sourceDevice->Send (pkt, destination, 0);
1466  }
1467 }
1468 
1469 void
1471 {
1472  uint16_t channelWidth = 40; // at least 40 MHz expected here
1473 
1474  NodeContainer wifiStaNode;
1475  wifiStaNode.Create (1);
1476 
1478  wifiApNode.Create (1);
1479 
1480  SpectrumWifiPhyHelper spectrumPhy;
1481  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1482  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1483  lossModel->SetFrequency (5.180e9);
1484  spectrumChannel->AddPropagationLossModel (lossModel);
1485 
1487  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1488  spectrumChannel->SetPropagationDelayModel (delayModel);
1489 
1490  spectrumPhy.SetChannel (spectrumChannel);
1491  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1492  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1493  spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
1494  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1495  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1496 
1497  WifiHelper wifi;
1498  wifi.SetStandard (WIFI_STANDARD_80211ac);
1499  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1500  "DataMode", StringValue ("VhtMcs8"),
1501  "ControlMode", StringValue ("VhtMcs8"),
1502  "RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1503 
1505  mac.SetType ("ns3::StaWifiMac");
1506  NetDeviceContainer staDevice;
1507  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1508 
1509  mac.SetType ("ns3::ApWifiMac");
1510  NetDeviceContainer apDevice;
1511  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1512 
1514  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1515  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1516  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1517  mobility.SetPositionAllocator (positionAlloc);
1518 
1519  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1520  mobility.Install (wifiApNode);
1521  mobility.Install (wifiStaNode);
1522 
1523  // Send two 5 packet-bursts
1524  Simulator::Schedule (Seconds (0.5), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1525  Simulator::Schedule (Seconds (0.6), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1526 
1527  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2843TestCase::StoreDistinctTuple, this));
1528 
1529  Simulator::Stop (Seconds (0.8));
1530  Simulator::Run ();
1531 
1532  Simulator::Destroy ();
1533 
1534  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1535  std::size_t numberTuples = m_distinctTuples.size ();
1536  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1537  NS_TEST_ASSERT_MSG_EQ (std::get<0> (m_distinctTuples[0]) - 20e6, std::get<0> (m_distinctTuples[1]), "The starting frequency of the first tuple should be shifted 20 MHz to the right wrt second tuple");
1538  // Note that the first tuple should the one initiated by the beacon, i.e. non-HT OFDM (20 MHz)
1539  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1540  NS_TEST_ASSERT_MSG_EQ (std::get<2> (m_distinctTuples[0]), 193, "First tuple should have 193 subbands (64+DC, 20MHz+DC, inband and 64*2 out-of-band, 20MHz on each side)");
1541  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1542  // Second tuple
1543  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1544  NS_TEST_ASSERT_MSG_EQ (std::get<2> (m_distinctTuples[1]), 385, "Second tuple should have 385 subbands (128+DC, 40MHz+DC, inband and 128*2 out-of-band, 40MHz on each side)");
1545  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1546 }
1547 
1548 //-----------------------------------------------------------------------------
1561 {
1562 public:
1563  Bug2831TestCase ();
1564  virtual ~Bug2831TestCase ();
1565  virtual void DoRun (void);
1566 
1567 private:
1571  void ChangeSupportedChannelWidth (void);
1578  void RxCallback (std::string context, Ptr<const Packet> p, RxPowerWattPerChannelBand rxPowersW);
1579 
1582 
1587 };
1588 
1590  : TestCase ("Test case for Bug 2831"),
1591  m_reassocReqCount (0),
1592  m_reassocRespCount (0),
1593  m_countOperationalChannelWidth20 (0),
1594  m_countOperationalChannelWidth40 (0)
1595 {
1596 }
1597 
1599 {
1600 }
1601 
1602 void
1604 {
1605  m_apPhy->SetChannelNumber (38);
1606  m_apPhy->SetChannelWidth (40);
1607  m_staPhy->SetChannelNumber (38);
1608  m_staPhy->SetChannelWidth (40);
1609 }
1610 
1611 void
1613 {
1614  Ptr<Packet> packet = p->Copy ();
1615  WifiMacHeader hdr;
1616  packet->RemoveHeader (hdr);
1617  if (hdr.IsReassocReq ())
1618  {
1620  }
1621  else if (hdr.IsReassocResp ())
1622  {
1624  }
1625  else if (hdr.IsBeacon ())
1626  {
1627  MgtBeaconHeader beacon;
1628  packet->RemoveHeader (beacon);
1629  HtOperation htOperation = beacon.GetHtOperation ();
1630  if (htOperation.GetStaChannelWidth () > 0)
1631  {
1633  }
1634  else
1635  {
1637  }
1638  }
1639 }
1640 
1641 void
1643 {
1644  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1645  ObjectFactory propDelay;
1646  propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1647  Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1648  Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel> ();
1649  channel->SetPropagationDelayModel (propagationDelay);
1650  channel->SetPropagationLossModel (propagationLoss);
1651 
1652  Ptr<Node> apNode = CreateObject<Node> ();
1653  Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1654  Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration> ();
1655  apDev->SetHtConfiguration (apHtConfiguration);
1657  mac.SetTypeId ("ns3::ApWifiMac");
1658  mac.Set ("EnableBeaconJitter", BooleanValue (false));
1659  Ptr<WifiMac> apMac = mac.Create<WifiMac> ();
1660  apMac->SetDevice (apDev);
1662 
1663  Ptr<Node> staNode = CreateObject<Node> ();
1664  Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> ();
1665  Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration> ();
1666  staDev->SetHtConfiguration (staHtConfiguration);
1667  mac.SetTypeId ("ns3::StaWifiMac");
1668  Ptr<WifiMac> staMac = mac.Create<WifiMac> ();
1669  staMac->SetDevice (staDev);
1671 
1672  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
1673  apMobility->SetPosition (Vector (0.0, 0.0, 0.0));
1674  apNode->AggregateObject (apMobility);
1675 
1676  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
1677  m_apPhy = CreateObject<YansWifiPhy> ();
1678  m_apPhy->SetErrorRateModel (error);
1680  m_apPhy->SetMobility (apMobility);
1681  m_apPhy->SetDevice (apDev);
1683  m_apPhy->SetChannelNumber (36);
1684  m_apPhy->SetChannelWidth (20);
1685 
1686  Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel> ();
1687  staMobility->SetPosition (Vector (1.0, 0.0, 0.0));
1688  staNode->AggregateObject (staMobility);
1689 
1690  m_staPhy = CreateObject<YansWifiPhy> ();
1691  m_staPhy->SetErrorRateModel (error);
1693  m_staPhy->SetMobility (staMobility);
1694  m_staPhy->SetDevice (apDev);
1696  m_staPhy->SetChannelNumber (36);
1697  m_staPhy->SetChannelWidth (20);
1698 
1699  apMac->SetAddress (Mac48Address::Allocate ());
1700  apDev->SetMac (apMac);
1701  apDev->SetPhy (m_apPhy);
1702  ObjectFactory manager;
1703  manager.SetTypeId ("ns3::ConstantRateWifiManager");
1704  apDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1705  apNode->AddDevice (apDev);
1706 
1707  staMac->SetAddress (Mac48Address::Allocate ());
1708  staDev->SetMac (staMac);
1709  staDev->SetPhy (m_staPhy);
1710  staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1711  staNode->AddDevice (staDev);
1712 
1713  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this));
1714 
1715  Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1716 
1717  Simulator::Stop (Seconds (3.0));
1718  Simulator::Run ();
1719  Simulator::Destroy ();
1720 
1721  NS_TEST_ASSERT_MSG_EQ (m_reassocReqCount, 1, "Reassociation request not received");
1722  NS_TEST_ASSERT_MSG_EQ (m_reassocRespCount, 1, "Reassociation response not received");
1723  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operational channel width before channel change");
1724  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operational channel width after channel change");
1725 }
1726 
1727 //-----------------------------------------------------------------------------
1744 {
1745 public:
1747  virtual ~StaWifiMacScanningTestCase ();
1748  virtual void DoRun (void);
1749 
1750 private:
1756  void AssocCallback (std::string context, Mac48Address bssid);
1761  void TurnBeaconGenerationOn (Ptr<Node> apNode);
1766  void TurnApOff (Ptr<Node> apNode);
1773  NodeContainer Setup (bool nearestApBeaconGeneration, bool staActiveProbe);
1774 
1776 };
1777 
1779  : TestCase ("Test case for StaWifiMac scanning capability")
1780 {
1781 }
1782 
1784 {
1785 }
1786 
1787 void
1789 {
1790  m_associatedApBssid = bssid;
1791 }
1792 
1793 void
1795 {
1796  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1797  Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac> (netDevice->GetMac ());
1798  mac->SetAttribute ("BeaconGeneration", BooleanValue (true));
1799 }
1800 
1801 void
1803 {
1804  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1805  Ptr<WifiPhy> phy = netDevice->GetPhy ();
1806  phy->SetOffMode ();
1807 }
1808 
1810 StaWifiMacScanningTestCase::Setup (bool nearestApBeaconGeneration, bool staActiveProbe)
1811 {
1812  RngSeedManager::SetSeed (1);
1813  RngSeedManager::SetRun (1);
1814  int64_t streamNumber = 1;
1815 
1816  NodeContainer apNodes;
1817  apNodes.Create (2);
1818 
1819  Ptr<Node> apNodeNearest = CreateObject<Node> ();
1820  Ptr<Node> staNode = CreateObject<Node> ();
1821 
1823  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1824  phy.SetChannel (channel.Create ());
1825 
1826  WifiHelper wifi;
1827  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
1828  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
1829 
1831  NetDeviceContainer apDevice, apDeviceNearest;
1832  mac.SetType ("ns3::ApWifiMac",
1833  "BeaconGeneration", BooleanValue (true));
1834  apDevice = wifi.Install (phy, mac, apNodes);
1835  mac.SetType ("ns3::ApWifiMac",
1836  "BeaconGeneration", BooleanValue (nearestApBeaconGeneration));
1837  apDeviceNearest = wifi.Install (phy, mac, apNodeNearest);
1838 
1839  NetDeviceContainer staDevice;
1840  mac.SetType ("ns3::StaWifiMac",
1841  "ActiveProbing", BooleanValue (staActiveProbe));
1842  staDevice = wifi.Install (phy, mac, staNode);
1843 
1844  // Assign fixed streams to random variables in use
1845  wifi.AssignStreams (apDevice, streamNumber);
1846  wifi.AssignStreams (apDeviceNearest, streamNumber + 1);
1847  wifi.AssignStreams (staDevice, streamNumber + 2);
1848 
1850  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1851  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Furthest AP
1852  positionAlloc->Add (Vector (10.0, 0.0, 0.0)); // Second nearest AP
1853  positionAlloc->Add (Vector (5.0, 5.0, 0.0)); // Nearest AP
1854  positionAlloc->Add (Vector (6.0, 5.0, 0.0)); // STA
1855  mobility.SetPositionAllocator (positionAlloc);
1856 
1857  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1858  mobility.Install (apNodes);
1859  mobility.Install (apNodeNearest);
1860  mobility.Install (staNode);
1861 
1862  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc", MakeCallback (&StaWifiMacScanningTestCase::AssocCallback, this));
1863 
1864  NodeContainer allNodes = NodeContainer (apNodes, apNodeNearest, staNode);
1865  return allNodes;
1866 }
1867 
1868 void
1870 {
1871  {
1872  NodeContainer nodes = Setup (false, false);
1873  Ptr<Node> nearestAp = nodes.Get (2);
1874  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1875 
1876  Simulator::Schedule (Seconds (0.05), &StaWifiMacScanningTestCase::TurnBeaconGenerationOn, this, nearestAp);
1877 
1878  Simulator::Stop (Seconds (0.2));
1879  Simulator::Run ();
1880  Simulator::Destroy ();
1881 
1882  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1883  }
1885  {
1886  NodeContainer nodes = Setup (true, true);
1887  Ptr<Node> nearestAp = nodes.Get (2);
1888  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1889 
1890  Simulator::Stop (Seconds (0.2));
1891  Simulator::Run ();
1892  Simulator::Destroy ();
1893 
1894  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1895  }
1897  {
1898  NodeContainer nodes = Setup (true, false);
1899  Ptr<Node> nearestAp = nodes.Get (2);
1900  Mac48Address secondNearestApAddr = DynamicCast<WifiNetDevice> (nodes.Get (1)->GetDevice (0))->GetMac ()->GetAddress ();
1901 
1902  Simulator::Schedule (Seconds (0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
1903 
1904  Simulator::Stop (Seconds (1.5));
1905  Simulator::Run ();
1906  Simulator::Destroy ();
1907 
1908  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, secondNearestApAddr, "STA is associated to the wrong AP");
1909  }
1910 }
1911 
1912 //-----------------------------------------------------------------------------
1936 {
1937 public:
1938  Bug2470TestCase ();
1939  virtual ~Bug2470TestCase ();
1940  virtual void DoRun (void);
1941 
1942 private:
1951  void AddbaStateChangedCallback (std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
1962  void RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId);
1969  void RxErrorCallback (std::string context, Ptr<const Packet> p, double snr);
1976  void SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1982  void RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel);
1983 
1992 };
1993 
1995  : TestCase ("Test case for Bug 2470"),
1996  m_receivedNormalMpduCount (0),
1997  m_receivedAmpduCount (0),
1998  m_failedActionCount (0),
1999  m_addbaEstablishedCount (0),
2000  m_addbaPendingCount (0),
2001  m_addbaRejectedCount (0),
2002  m_addbaNoReplyCount (0),
2003  m_addbaResetCount (0)
2004 {
2005 }
2006 
2008 {
2009 }
2010 
2011 void
2013 {
2014  switch (state)
2015  {
2016  case OriginatorBlockAckAgreement::ESTABLISHED:
2018  break;
2019  case OriginatorBlockAckAgreement::PENDING:
2021  break;
2022  case OriginatorBlockAckAgreement::REJECTED:
2024  break;
2025  case OriginatorBlockAckAgreement::NO_REPLY:
2027  break;
2028  case OriginatorBlockAckAgreement::RESET:
2030  break;
2031  }
2032 }
2033 
2034 void
2035 Bug2470TestCase::RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
2036 {
2037  Ptr<Packet> packet = p->Copy ();
2038  if (aMpdu.type != MpduType::NORMAL_MPDU)
2039  {
2041  }
2042  else
2043  {
2044  WifiMacHeader hdr;
2045  packet->RemoveHeader (hdr);
2046  if (hdr.IsData ())
2047  {
2049  }
2050  }
2051 }
2052 
2053 void
2054 Bug2470TestCase::RxErrorCallback (std::string context, Ptr<const Packet> p, double snr)
2055 {
2056  Ptr<Packet> packet = p->Copy ();
2057  WifiMacHeader hdr;
2058  packet->RemoveHeader (hdr);
2059  if (hdr.IsAction ())
2060  {
2062  }
2063 }
2064 
2065 void
2066 Bug2470TestCase::SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice,
2067  Address& destination) const
2068 {
2069  for (uint32_t i = 0; i < numPackets; i++)
2070  {
2071  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2072  sourceDevice->Send (pkt, destination, 0);
2073  }
2074 }
2075 
2076 void
2078 {
2079  RngSeedManager::SetSeed (1);
2080  RngSeedManager::SetRun (1);
2081  int64_t streamNumber = 200;
2082 
2083  NodeContainer wifiApNode, wifiStaNode;
2084  wifiApNode.Create (1);
2085  wifiStaNode.Create (1);
2086 
2088  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2089  phy.SetChannel (channel.Create ());
2090 
2091  WifiHelper wifi;
2092  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
2093  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2094  "DataMode", StringValue ("HtMcs7"),
2095  "ControlMode", StringValue ("HtMcs7"));
2096 
2098  NetDeviceContainer apDevice;
2099  phy.Set ("PostReceptionErrorModel", apErrorModel);
2100  mac.SetType ("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue (false));
2101  apDevice = wifi.Install (phy, mac, wifiApNode);
2102 
2103  NetDeviceContainer staDevice;
2104  phy.Set ("PostReceptionErrorModel", staErrorModel);
2105  mac.SetType ("ns3::StaWifiMac");
2106  staDevice = wifi.Install (phy, mac, wifiStaNode);
2107 
2108  // Assign fixed streams to random variables in use
2109  wifi.AssignStreams (apDevice, streamNumber);
2110  wifi.AssignStreams (staDevice, streamNumber);
2111 
2113  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2114  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2115  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2116  mobility.SetPositionAllocator (positionAlloc);
2117 
2118  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2119  mobility.Install (wifiApNode);
2120  mobility.Install (wifiStaNode);
2121 
2122  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this));
2123  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&Bug2470TestCase::RxErrorCallback, this));
2124  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this));
2125 
2126  Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2127  Simulator::Schedule (Seconds (0.5) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2128  Simulator::Schedule (Seconds (0.8), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2129  Simulator::Schedule (Seconds (0.8) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2130 
2131  Simulator::Stop (Seconds (1.0));
2132  Simulator::Run ();
2133  Simulator::Destroy ();
2134 }
2135 
2136 void
2138 {
2139  // Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel
2140  // instead of ListErrorModel since packet UID is incremented between simulations. But
2141  // problem may occur because of random stream, therefore we suppress usage of RNG as
2142  // much as possible (i.e., removing beacon jitter).
2143  Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel> ();
2144  std::list<uint32_t> blackList;
2145  // Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2146  blackList.push_back (8);
2147  blackList.push_back (9);
2148  blackList.push_back (10);
2149  blackList.push_back (11);
2150  blackList.push_back (12);
2151  blackList.push_back (13);
2152  staPem->SetList (blackList);
2153 
2154  {
2155  RunSubtest (PointerValue (), PointerValue (staPem));
2156  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 6, "ADDBA request packets are not failed");
2157  // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by normal
2158  // MPDU because of failed ADDBA handshake. For the second set, the first packet should be sent by
2159  // normal MPDU, and the rest with A-MPDU. In total we expect to receive 2 normal MPDU packets and
2160  // 8 A-MPDU packets.
2161  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 2, "Receiving incorrect number of normal MPDU packet on subtest 1");
2162  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 8, "Receiving incorrect number of A-MPDU packet on subtest 1");
2163 
2164  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 1");
2165  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2166  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2167  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 0, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2168  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2169  }
2170 
2173  m_failedActionCount = 0;
2175  m_addbaPendingCount = 0;
2177  m_addbaNoReplyCount = 0;
2178  m_addbaResetCount = 0;
2179 
2180  Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel> ();
2181  blackList.clear ();
2182  // Block ADDBA request 3 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2183  blackList.push_back (4);
2184  blackList.push_back (5);
2185  blackList.push_back (6);
2186  apPem->SetList (blackList);
2187 
2188  {
2189  RunSubtest (PointerValue (apPem), PointerValue ());
2190  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 3, "ADDBA response packets are not failed");
2191  // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU packets.
2192  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 6, "Receiving incorrect number of normal MPDU packet on subtest 2");
2193  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 4, "Receiving incorrect number of A-MPDU packet on subtest 2");
2194 
2195  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 2");
2196  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2197  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2198  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 1, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2199  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2200  }
2201 
2202  // TODO: In the second test set, it does not go to reset state since ADDBA response is received after timeout (NO_REPLY)
2203  // but before it does not enter RESET state. More tests should be written to verify all possible scenarios.
2204 }
2205 
2206 //-----------------------------------------------------------------------------
2222 {
2223 public:
2224  Issue40TestCase ();
2225  virtual ~Issue40TestCase ();
2226  virtual void DoRun (void);
2227 
2228 private:
2233  void RunOne (bool useAmpdu);
2234 
2240  void RxSuccessCallback (std::string context, Ptr<const Packet> p);
2247  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination);
2253  void TxFinalDataFailedCallback (std::string context, Mac48Address address);
2254 
2255  uint16_t m_rxCount;
2256  uint16_t m_txCount;
2258 };
2259 
2261  : TestCase ("Test case for issue #40"),
2262  m_rxCount (0),
2263  m_txCount (0),
2264  m_txMacFinalDataFailedCount (0)
2265 {
2266 }
2267 
2269 {
2270 }
2271 
2272 void
2274 {
2275  m_rxCount++;
2276 }
2277 
2278 void
2279 Issue40TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination)
2280 {
2281  for (uint8_t i = 0; i < numPackets; i++)
2282  {
2283  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2284  sourceDevice->Send (pkt, destination, 0);
2285  m_txCount++;
2286  }
2287 }
2288 
2289 void
2291 {
2293 }
2294 
2295 void
2297 {
2298  m_rxCount = 0;
2299  m_txCount = 0;
2301 
2302  RngSeedManager::SetSeed (1);
2303  RngSeedManager::SetRun (1);
2304  int64_t streamNumber = 100;
2305 
2306  NodeContainer wifiApNode, wifiStaNode;
2307  wifiApNode.Create (1);
2308  wifiStaNode.Create (1);
2309 
2311  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2312  phy.SetChannel (channel.Create ());
2313 
2314  WifiHelper wifi;
2315  wifi.SetStandard (WIFI_STANDARD_80211ac);
2316  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2317 
2319  NetDeviceContainer apDevice;
2320  mac.SetType ("ns3::ApWifiMac");
2321  apDevice = wifi.Install (phy, mac, wifiApNode);
2322 
2323  NetDeviceContainer staDevice;
2324  mac.SetType ("ns3::StaWifiMac");
2325  staDevice = wifi.Install (phy, mac, wifiStaNode);
2326 
2327  // Assign fixed streams to random variables in use
2328  wifi.AssignStreams (apDevice, streamNumber);
2329  wifi.AssignStreams (staDevice, streamNumber);
2330 
2332  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2333  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2334  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
2335  mobility.SetPositionAllocator (positionAlloc);
2336 
2337  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2338  mobility.Install (wifiApNode);
2339 
2340  mobility.SetMobilityModel("ns3::WaypointMobilityModel");
2341  mobility.Install (wifiStaNode);
2342 
2343  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxFinalDataFailed", MakeCallback (&Issue40TestCase::TxFinalDataFailedCallback, this));
2344  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/MacRx", MakeCallback (&Issue40TestCase::RxSuccessCallback, this));
2345 
2346  Ptr<WaypointMobilityModel> staWaypointMobility = DynamicCast<WaypointMobilityModel>(wifiStaNode.Get(0)->GetObject<MobilityModel>());
2347  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.0), Vector (10.0, 0.0, 0.0)));
2348  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.5), Vector (50.0, 0.0, 0.0)));
2349 
2350  if (useAmpdu)
2351  {
2352  // Disable use of BAR that are sent with the lowest modulation so that we can also reproduce the problem with A-MPDU, i.e. the lack of feedback about SNR change
2353  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevice.Get (0));
2354  Ptr<RegularWifiMac> ap_mac = DynamicCast<RegularWifiMac> (ap_device->GetMac ());
2355  NS_ASSERT (ap_mac);
2356  PointerValue ptr;
2357  ap_mac->GetAttribute ("BE_Txop", ptr);
2358  ptr.Get<QosTxop> ()->SetAttribute ("UseExplicitBarAfterMissedBlockAck", BooleanValue (false));
2359  }
2360 
2361  // Transmit a first data packet before the station moves: it should be sent with a high modulation and successfully received
2362  Simulator::Schedule (Seconds (0.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2363 
2364  // Transmit a second data packet once the station is away from the access point: it should be sent with the same high modulation and be unsuccessfully received
2365  Simulator::Schedule (Seconds (2.0), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2366 
2367  // Keep on transmitting data packets while the station is away from the access point: it should be sent with a lower modulation and be successfully received
2368  Simulator::Schedule (Seconds (2.1), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2369  Simulator::Schedule (Seconds (2.2), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2370  Simulator::Schedule (Seconds (2.3), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2371  Simulator::Schedule (Seconds (2.4), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2372  Simulator::Schedule (Seconds (2.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2373 
2374  Simulator::Stop (Seconds (3.0));
2375  Simulator::Run ();
2376 
2377  NS_TEST_ASSERT_MSG_EQ (m_txCount, (useAmpdu ? 14 : 7), "Incorrect number of transmitted packets");
2378  NS_TEST_ASSERT_MSG_EQ (m_rxCount, (useAmpdu ? 12 : 6), "Incorrect number of successfully received packets");
2379  NS_TEST_ASSERT_MSG_EQ (m_txMacFinalDataFailedCount, 1, "Incorrect number of dropped TX packets");
2380 
2381  Simulator::Destroy ();
2382 }
2383 
2384 void
2386 {
2387  //Test without A-MPDU
2388  RunOne (false);
2389 
2390  //Test with A-MPDU
2391  RunOne (true);
2392 }
2393 
2394 //-----------------------------------------------------------------------------
2408 {
2409 public:
2410  Issue169TestCase ();
2411  virtual ~Issue169TestCase ();
2412  virtual void DoRun (void);
2413 
2414 private:
2422  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority);
2423 
2431  void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW);
2432 };
2433 
2435  : TestCase ("Test case for issue #169")
2436 {
2437 }
2438 
2440 {
2441 }
2442 
2443 void
2444 Issue169TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority)
2445 {
2446  SocketPriorityTag priorityTag;
2447  priorityTag.SetPriority (priority);
2448  for (uint8_t i = 0; i < numPackets; i++)
2449  {
2450  Ptr<Packet> packet = Create<Packet> (1000); // 1000 dummy bytes of data
2451  packet->AddPacketTag (priorityTag);
2452  sourceDevice->Send (packet, destination, 0);
2453  }
2454 }
2455 
2456 void
2457 Issue169TestCase::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
2458 {
2459  if (psdus.begin()->second->GetSize () >= 1000)
2460  {
2461  NS_TEST_ASSERT_MSG_EQ (txVector.GetMode ().GetModulationClass (), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Ideal rate manager selected incorrect modulation class");
2462  }
2463 }
2464 
2465 void
2467 {
2468  RngSeedManager::SetSeed (1);
2469  RngSeedManager::SetRun (1);
2470  int64_t streamNumber = 100;
2471 
2472  NodeContainer wifiApNode, wifiStaNode;
2473  wifiApNode.Create (1);
2474  wifiStaNode.Create (1);
2475 
2477  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2478  phy.SetChannel (channel.Create ());
2479 
2480  WifiHelper wifi;
2481  wifi.SetStandard (WIFI_STANDARD_80211ac);
2482  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2483 
2485  NetDeviceContainer apDevice;
2486  mac.SetType ("ns3::ApWifiMac");
2487  apDevice = wifi.Install (phy, mac, wifiApNode);
2488 
2489  NetDeviceContainer staDevice;
2490  mac.SetType ("ns3::StaWifiMac");
2491  staDevice = wifi.Install (phy, mac, wifiStaNode);
2492 
2493  // Assign fixed streams to random variables in use
2494  wifi.AssignStreams (apDevice, streamNumber);
2495  wifi.AssignStreams (staDevice, streamNumber);
2496 
2498  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2499  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2500  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2501  mobility.SetPositionAllocator (positionAlloc);
2502 
2503  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2504  mobility.Install (wifiApNode);
2505  mobility.Install (wifiStaNode);
2506 
2507  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&Issue169TestCase::TxCallback, this));
2508 
2509  //Send best-effort packet (i.e. priority 0)
2510  Simulator::Schedule (Seconds (0.5), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 0);
2511 
2512  //Send non best-effort (voice) packet (i.e. priority 6)
2513  Simulator::Schedule (Seconds (1.0), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 6);
2514 
2515  Simulator::Stop (Seconds (2.0));
2516  Simulator::Run ();
2517 
2518  Simulator::Destroy ();
2519 }
2520 
2521 
2522 //-----------------------------------------------------------------------------
2538 {
2539 public:
2542  virtual void DoRun (void);
2543 
2544 private:
2549  void ChangeChannelWidth (uint16_t channelWidth);
2550 
2556  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2557 
2565  void TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW);
2566 
2571  void CheckLastSelectedMode (WifiMode expectedMode);
2572 
2574 };
2575 
2577  : TestCase ("Test case for use of channel bonding with Ideal rate manager")
2578 {
2579 }
2580 
2582 {
2583 }
2584 
2585 void
2587 {
2588  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", UintegerValue (channelWidth));
2589 }
2590 
2591 void
2593 {
2594  Ptr<Packet> packet = Create<Packet> (1000);
2595  sourceDevice->Send (packet, destination, 0);
2596 }
2597 
2598 void
2599 IdealRateManagerChannelWidthTest::TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
2600 {
2601  if (psduMap.begin ()->second->GetSize () >= 1000)
2602  {
2603  m_txMode = txVector.GetMode ();
2604  }
2605 }
2606 
2607 void
2609 {
2610  NS_TEST_ASSERT_MSG_EQ (m_txMode, expectedMode, "Last selected WifiMode " << m_txMode << " does not match expected WifiMode " << expectedMode);
2611 }
2612 
2613 void
2615 {
2616  RngSeedManager::SetSeed (1);
2617  RngSeedManager::SetRun (1);
2618  int64_t streamNumber = 100;
2619 
2620  NodeContainer wifiApNode, wifiStaNode;
2621  wifiApNode.Create (1);
2622  wifiStaNode.Create (1);
2623 
2625  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2626  phy.SetChannel (channel.Create ());
2627 
2628  WifiHelper wifi;
2629  wifi.SetStandard (WIFI_STANDARD_80211ac);
2630  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2631 
2633  NetDeviceContainer apDevice;
2634  mac.SetType ("ns3::ApWifiMac");
2635  apDevice = wifi.Install (phy, mac, wifiApNode);
2636 
2637  NetDeviceContainer staDevice;
2638  mac.SetType ("ns3::StaWifiMac");
2639  staDevice = wifi.Install (phy, mac, wifiStaNode);
2640 
2641  // Assign fixed streams to random variables in use
2642  wifi.AssignStreams (apDevice, streamNumber);
2643  wifi.AssignStreams (staDevice, streamNumber);
2644 
2646  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2647  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2648  positionAlloc->Add (Vector (50.0, 0.0, 0.0));
2649  mobility.SetPositionAllocator (positionAlloc);
2650 
2651  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2652  mobility.Install (wifiApNode);
2653  mobility.Install (wifiStaNode);
2654 
2655  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerChannelWidthTest::TxCallback, this));
2656 
2657  //Set channel width to 80 MHz & send packet
2658  Simulator::Schedule (Seconds (0.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 80);
2659  Simulator::Schedule (Seconds (1.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2660  //Selected rate should be VHT-MCS 1
2661  Simulator::Schedule (Seconds (1.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2662 
2663  //Set channel width to 20 MHz & send packet
2664  Simulator::Schedule (Seconds (1.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 20);
2665  Simulator::Schedule (Seconds (2.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2666  //Selected rate should be VHT-MCS 3 since SNR should be 6 dB higher than previously
2667  Simulator::Schedule (Seconds (2.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2668 
2669  //Set channel width to 40 MHz & send packet
2670  Simulator::Schedule (Seconds (2.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 40);
2671  Simulator::Schedule (Seconds (3.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2672  //Selected rate should be VHT-MCS 2 since SNR should be 3 dB lower than previously
2673  Simulator::Schedule (Seconds (3.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2674 
2675  Simulator::Stop (Seconds (3.2));
2676  Simulator::Run ();
2677 
2678  Simulator::Destroy ();
2679 }
2680 
2681 
2682 //-----------------------------------------------------------------------------
2691 {
2692 public:
2694  virtual ~IdealRateManagerMimoTest ();
2695  virtual void DoRun (void);
2696 
2697 private:
2703  void SetApMimoSettings (uint8_t antennas, uint8_t maxStreams);
2709  void SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams);
2715  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2716 
2724  void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW);
2725 
2730  void CheckLastSelectedMode (WifiMode expectedMode);
2735  void CheckLastSelectedNss (uint8_t expectedNss);
2736 
2738 };
2739 
2741  : TestCase ("Test case for use of imbalanced MIMO settings with Ideal rate manager")
2742 {
2743 }
2744 
2746 {
2747 }
2748 
2749 void
2750 IdealRateManagerMimoTest::SetApMimoSettings (uint8_t antennas, uint8_t maxStreams)
2751 {
2752  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2753  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2754  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2755 }
2756 
2757 void
2758 IdealRateManagerMimoTest::SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams)
2759 {
2760  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2761  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2762  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2763 }
2764 
2765 void
2767 {
2768  Ptr<Packet> packet = Create<Packet> (1000);
2769  sourceDevice->Send (packet, destination, 0);
2770 }
2771 
2772 void
2773 IdealRateManagerMimoTest::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
2774 {
2775  if (psdus.begin ()->second->GetSize () >= 1000)
2776  {
2777  m_txVector = txVector;
2778  }
2779 }
2780 
2781 void
2783 {
2784  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetNss (), expectedNss, "Last selected Nss " << m_txVector.GetNss () << " does not match expected Nss " << expectedNss);
2785 }
2786 
2787 void
2789 {
2790  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetMode (), expectedMode, "Last selected WifiMode " << m_txVector.GetMode () << " does not match expected WifiMode " << expectedMode);
2791 }
2792 
2793 void
2795 {
2796  RngSeedManager::SetSeed (1);
2797  RngSeedManager::SetRun (1);
2798  int64_t streamNumber = 100;
2799 
2800  NodeContainer wifiApNode, wifiStaNode;
2801  wifiApNode.Create (1);
2802  wifiStaNode.Create (1);
2803 
2805  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2806  phy.SetChannel (channel.Create ());
2807 
2808  WifiHelper wifi;
2809  wifi.SetStandard (WIFI_STANDARD_80211ac);
2810  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2811 
2813  NetDeviceContainer apDevice;
2814  mac.SetType ("ns3::ApWifiMac");
2815  apDevice = wifi.Install (phy, mac, wifiApNode);
2816 
2817  NetDeviceContainer staDevice;
2818  mac.SetType ("ns3::StaWifiMac");
2819  staDevice = wifi.Install (phy, mac, wifiStaNode);
2820 
2821  // Assign fixed streams to random variables in use
2822  wifi.AssignStreams (apDevice, streamNumber);
2823  wifi.AssignStreams (staDevice, streamNumber);
2824 
2826  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2827  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2828  positionAlloc->Add (Vector (40.0, 0.0, 0.0));
2829  mobility.SetPositionAllocator (positionAlloc);
2830 
2831  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2832  mobility.Install (wifiApNode);
2833  mobility.Install (wifiStaNode);
2834 
2835  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerMimoTest::TxCallback, this));
2836 
2837 
2838  // TX: 1 antenna
2839  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2840  // RX: 1 antenna
2841  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2842  // Send packets (2 times to get one feedback)
2843  Simulator::Schedule (Seconds (1.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2844  Simulator::Schedule (Seconds (1.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2845  // Selected NSS should be 1 since both TX and RX support a single antenna
2846  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2847  // Selected rate should be VHT-MCS 2 because of settings and distance between TX and RX
2848  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2849 
2850 
2851  // TX: 1 antenna
2852  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2853  // RX: 2 antennas, but only supports 1 spatial stream
2854  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2855  // Send packets (2 times to get one feedback)
2856  Simulator::Schedule (Seconds (2.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2857  Simulator::Schedule (Seconds (2.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2858  // Selected NSS should be 1 since both TX and RX support a single antenna
2859  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2860  // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB
2861  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2862 
2863 
2864  // TX: 1 antenna
2865  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2866  // RX: 2 antennas, and supports 2 spatial streams
2867  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2868  // Send packets (2 times to get one feedback)
2869  Simulator::Schedule (Seconds (3.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2870  Simulator::Schedule (Seconds (3.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2871  // Selected NSS should be 1 since TX supports a single antenna
2872  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2873  // Selected rate should be as previously
2874  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2875 
2876 
2877  // TX: 2 antennas, but only supports 1 spatial stream
2878  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2879  // RX: 1 antenna
2880  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2881  // Send packets (2 times to get one feedback)
2882  Simulator::Schedule (Seconds (4.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2883  Simulator::Schedule (Seconds (4.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2884  // Selected NSS should be 1 since both TX and RX support a single antenna
2885  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2886  // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario (more antennas at TX does not result in SNR improvement in AWGN channel)
2887  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2888 
2889 
2890  // TX: 2 antennas, but only supports 1 spatial stream
2891  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2892  // RX: 2 antennas, but only supports 1 spatial stream
2893  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2894  // Send packets (2 times to get one feedback)
2895  Simulator::Schedule (Seconds (5.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2896  Simulator::Schedule (Seconds (5.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2897  // Selected NSS should be 1 since both TX and RX support a single antenna
2898  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2899  // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN channel)
2900  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2901 
2902 
2903  // TX: 2 antennas, but only supports 1 spatial stream
2904  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2905  // RX: 2 antennas, and supports 2 spatial streams
2906  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2907  // Send packets (2 times to get one feedback)
2908  Simulator::Schedule (Seconds (6.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2909  Simulator::Schedule (Seconds (6.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2910  // Selected NSS should be 1 since TX supports a single antenna
2911  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2912  // Selected rate should be as previously
2913  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2914 
2915 
2916  // TX: 2 antennas, and supports 2 spatial streams
2917  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2918  // RX: 1 antenna
2919  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2920  // Send packets (2 times to get one feedback)
2921  Simulator::Schedule (Seconds (7.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2922  Simulator::Schedule (Seconds (7.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2923  // Selected NSS should be 1 since RX supports a single antenna
2924  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2925  // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario (more antennas at TX does not result in SNR improvement in AWGN channel)
2926  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2927 
2928 
2929  // TX: 2 antennas, and supports 2 spatial streams
2930  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2931  // RX: 2 antennas, but only supports 1 spatial stream
2932  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2933  // Send packets (2 times to get one feedback)
2934  Simulator::Schedule (Seconds (8.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2935  Simulator::Schedule (Seconds (8.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2936  // Selected NSS should be 1 since RX supports a single antenna
2937  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2938  // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN channel)
2939  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2940 
2941 
2942  // TX: 2 antennas, and supports 2 spatial streams
2943  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2944  // RX: 2 antennas, and supports 2 spatial streams
2945  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2946  // Send packets (2 times to get one feedback)
2947  Simulator::Schedule (Seconds (9.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2948  Simulator::Schedule (Seconds (9.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2949  // Selected NSS should be 2 since both TX and RX support 2 antennas
2950  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 2);
2951  // Selecte rate should be the same as without diversity, as it uses 2 spatial streams so there is no more benefits from diversity in AWGN channels
2952  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2953 
2954 
2955  // Verify we can go back to initial situation
2956  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2957  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2958  Simulator::Schedule (Seconds (10.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2959  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2960  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2961 
2962  Simulator::Stop (Seconds (10.2));
2963  Simulator::Run ();
2964  Simulator::Destroy ();
2965 }
2966 
2967 //-----------------------------------------------------------------------------
2975 {
2976 public:
2978 
2979 private:
2989  bool CheckDataRate (HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate);
2990  virtual void DoRun (void);
2991 };
2992 
2994  : TestCase ("Check data rates for different RU types.")
2995 {
2996 }
2997 
2998 bool
2999 HeRuMcsDataRateTestCase::CheckDataRate (HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate)
3000 {
3001  uint16_t approxWidth = HeRu::GetBandwidth (ruType);
3002  WifiMode mode (mcs);
3003  uint64_t dataRate = round (mode.GetDataRate (approxWidth, guardInterval, nss) / 100000.0);
3004  NS_ABORT_MSG_IF (dataRate > 65535, "Rate is way too high");
3005  if (static_cast<uint16_t> (dataRate) != expectedDataRate)
3006  {
3007  std::cerr << "RU=" << ruType
3008  << " mode=" << mode
3009  << " Nss=" << +nss
3010  << " guardInterval=" << guardInterval
3011  << " expected=" << expectedDataRate << " x100kbps"
3012  << " computed=" << static_cast<uint16_t> (dataRate) << " x100kbps"
3013  << std::endl;
3014  return false;
3015  }
3016  return true;
3017 }
3018 
3019 void
3021 {
3022  bool retval = true;
3023 
3024  //26-tone RU, browse over all MCSs, GIs and Nss's (up to 4, current max)
3025  retval = retval
3026  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs0", 1, 800, 9)
3027  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs1", 1, 1600, 17)
3028  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs2", 1, 3200, 23)
3029  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs3", 1, 3200, 30)
3030  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs4", 2, 1600, 100)
3031  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs5", 3, 1600, 200)
3032  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs6", 4, 1600, 300)
3033  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs7", 4, 3200, 300)
3034  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs8", 4, 1600, 400)
3035  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs9", 4, 3200, 400)
3036  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs10", 4, 1600, 500)
3037  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs11", 4, 3200, 500);
3038 
3039  NS_TEST_EXPECT_MSG_EQ (retval, true, "26-tone RU data rate verification for different MCSs, GIs, and Nss's failed");
3040 
3041  //Check other RU sizes
3042  retval = retval
3043  && CheckDataRate ( HeRu::RU_52_TONE, "HeMcs2", 1, 1600, 50)
3044  && CheckDataRate ( HeRu::RU_106_TONE, "HeMcs9", 1, 800, 500)
3045  && CheckDataRate ( HeRu::RU_242_TONE, "HeMcs5", 1, 1600, 650)
3046  && CheckDataRate ( HeRu::RU_484_TONE, "HeMcs3", 1, 1600, 650)
3047  && CheckDataRate ( HeRu::RU_996_TONE, "HeMcs5", 1, 3200, 2450)
3048  && CheckDataRate (HeRu::RU_2x996_TONE, "HeMcs3", 1, 3200, 2450);
3049 
3050  NS_TEST_EXPECT_MSG_EQ (retval, true, "Data rate verification for RUs above 52-tone RU (included) failed");
3051 }
3052 
3059 class WifiTestSuite : public TestSuite
3060 {
3061 public:
3062  WifiTestSuite ();
3063 };
3064 
3066  : TestSuite ("wifi-devices", UNIT)
3067 {
3068  AddTestCase (new WifiTest, TestCase::QUICK);
3069  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
3070  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
3071  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
3072  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
3073  AddTestCase (new QosFragmentationTestCase, TestCase::QUICK);
3074  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
3075  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
3076  AddTestCase (new Bug2843TestCase, TestCase::QUICK); //Bug 2843
3077  AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
3078  AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399
3079  AddTestCase (new Bug2470TestCase, TestCase::QUICK); //Bug 2470
3080  AddTestCase (new Issue40TestCase, TestCase::QUICK); //Issue #40
3081  AddTestCase (new Issue169TestCase, TestCase::QUICK); //Issue #169
3082  AddTestCase (new IdealRateManagerChannelWidthTest, TestCase::QUICK);
3083  AddTestCase (new IdealRateManagerMimoTest, TestCase::QUICK);
3084  AddTestCase (new HeRuMcsDataRateTestCase, TestCase::QUICK);
3085 }
3086 
MpduInfo structure.
Definition: wifi-phy.h:126
size_t GetNumBands() const
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void RunOne(void)
Run one function.
Definition: wifi-test.cc:162
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:143
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:159
uint8_t m_countOperationalChannelWidth20
count number of beacon frames announcing a 20 MHz operating channel width
Definition: wifi-test.cc:1585
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
void AddbaStateChangedCallback(std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
Callback when ADDBA state changed.
Definition: wifi-test.cc:2012
virtual ~Bug730TestCase()
Definition: wifi-test.cc:595
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
virtual ~QosFragmentationTestCase()
Definition: wifi-test.cc:741
void Transmit(std::string context, Ptr< const Packet > p, double power)
Callback invoked when PHY transmits a packet.
Definition: wifi-test.cc:755
AttributeValue implementation for Boolean.
Definition: boolean.h:36
Ptr< T > Get(void) const
Definition: pointer.h:201
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
void TxFinalDataFailedCallback(std::string context, Mac48Address address)
Transmit final data failed function.
Definition: wifi-test.cc:2290
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:600
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
void StoreDistinctTuple(std::string context, Ptr< SpectrumSignalParameters > txParams)
Stores the distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples that have been used during the testcase run.
Definition: wifi-test.cc:1427
Ptr< WifiPpdu > ppdu
The PPDU being transmitted.
Hold variables of type string.
Definition: string.h:41
Make sure that the ADDBA handshake process is protected.
Definition: wifi-test.cc:1935
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1642
Make it easy to create and manage PHY objects for the YANS model.
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:839
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1869
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
virtual ~IdealRateManagerMimoTest()
Definition: wifi-test.cc:2745
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:144
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Definition: wifi-ppdu.h:33
void RxCallback(std::string context, Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
Callback triggered when a packet is received by the PHYs.
Definition: wifi-test.cc:1612
A suite of tests to run.
Definition: test.h:1343
void AddWaypoint(const Waypoint &waypoint)
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1373
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:92
an address for a packet socket
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2794
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
uint16_t m_receivedNormalMpduCount
Count received normal MPDU packets on STA.
Definition: wifi-test.cc:1984
uint16_t m_rxCount
Count number of successfully received data packets.
Definition: wifi-test.cc:2255
uint16_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:1985
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:283
Make sure that Ideal rate manager is able to handle non best-effort traffic.
Definition: wifi-test.cc:2407
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:765
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:50
staDevices
Definition: third.py:103
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet. ...
Definition: qos-utils.cc:84
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:262
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1470
void SendPacketBurst(uint8_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination) const
Triggers the arrival of a burst of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:1459
VHT PHY (Clause 22)
Definition: wifi-mode.h:62
The 5 GHz band.
Definition: wifi-phy-band.h:35
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:218
encapsulates test code
Definition: test.h:1153
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
virtual ~StaWifiMacScanningTestCase()
Definition: wifi-test.cc:1783
uint8_t m_reassocReqCount
count number of reassociation requests
Definition: wifi-test.cc:1583
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:567
virtual ~Bug2843TestCase()
Definition: wifi-test.cc:1422
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1788
virtual void ConfigureStandard(WifiStandard standard)=0
helps to create WifiNetDevice objects
Definition: wifi-helper.h:326
Mac48Address m_associatedApBssid
Associated AP&#39;s bssid.
Definition: wifi-test.cc:1775
Make sure that Ideal rate manager recovers when the station is moving away from the access point...
Definition: wifi-test.cc:2221
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
bool CheckDataRate(HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate)
Compare the data rate computed for the provided combination with standard defined one...
Definition: wifi-test.cc:2999
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
uint32_t GetIfIndex(void) const
Address GetAddress(void) const
a polymophic address class
Definition: address.h:90
unsigned int m_numSentPackets
number of sent packets
Definition: wifi-test.cc:444
channel
Definition: third.py:92
void SendPackets(uint8_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination)
Triggers the arrival of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:2279
mobility
Definition: third.py:108
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:440
phy
Definition: third.py:93
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:753
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...
virtual ~Issue169TestCase()
Definition: wifi-test.cc:2439
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1516
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2608
uint16_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:1989
uint16_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:1987
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
Triggers the transmission of a 1000 Byte-long data packet from the source device. ...
Definition: wifi-test.cc:2766
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1794
Keep track of the current position and velocity of an object.
void SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for STA node.
Definition: wifi-test.cc:2758
void RxCallback(std::string context, Ptr< const Packet > p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
Callback when packet is received.
Definition: wifi-test.cc:2035
The MPDU is not part of an A-MPDU.
bool IsAction(void) const
Return true if the header is an Action header.
virtual ~Bug2470TestCase()
Definition: wifi-test.cc:2007
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:301
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1598
nodes
Definition: first.py:32
Make sure that Wifi STA is correctly associating to the best AP (i.e., nearest from STA)...
Definition: wifi-test.cc:1743
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-mac.cc:82
Time m_firstTransmissionTime
first transmission time
Definition: wifi-test.cc:442
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:746
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
WifiMode m_txMode
Store the last selected mode to send data packet.
Definition: wifi-test.cc:2573
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: txop.cc:332
bool IsBeacon(void) const
Return true if the header is a Beacon header.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:46
uint32_t m_countInternalCollisions
count internal collisions
Definition: wifi-test.cc:1257
void SetChannel(Ptr< SpectrumChannel > channel)
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Definition: vector.h:297
ssid
Definition: third.py:100
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:481
#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:166
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2137
holds a vector of ns3::NetDevice pointers
mac
Definition: third.py:99
indicates whether the socket has a priority set.
Definition: socket.h:1307
void RunOne(bool useAmpdu)
Run one function.
Definition: wifi-test.cc:2296
calculate a propagation delay.
Address GetBroadcast(void) const
Hold together all Wifi-related objects.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1285
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2614
wifiApNode
Definition: third.py:90
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:610
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1560
uint16_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:1991
virtual void SetAddress(Mac48Address address)=0
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:277
hold a list of per-remote-station state.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:480
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:918
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3020
uint32_t m_fragments
transmitted fragments
Definition: wifi-test.cc:715
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
Triggers the transmission of a 1000 Byte-long data packet from the source device. ...
Definition: wifi-test.cc:2592
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:784
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:897
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
void SwitchCh(Ptr< WifiNetDevice > dev)
Switch channel function.
Definition: wifi-test.cc:294
Ptr< WifiPhy > GetPhy(void) const
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start.
Ptr< YansWifiPhy > m_staPhy
STA PHY.
Definition: wifi-test.cc:1581
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2788
void TxDataFailedTrace(std::string context, Mac48Address adress)
Transmit data failed function.
Definition: wifi-test.cc:1278
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:181
OFDM PHY (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void SetApMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for AP node.
Definition: wifi-test.cc:2750
Hold objects of type Ptr<T>.
Definition: pointer.h:36
bool IsData(void) const
Return true if the Type is DATA.
address
Definition: first.py:44
void NotifyPhyTxBegin(Ptr< const Packet > p, double txPowerW)
Notify Phy transmit begin.
Definition: wifi-test.cc:460
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:3087
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1496
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:48
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:116
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2773
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:224
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
uint32_t m_received
received packets
Definition: wifi-test.cc:714
void SetList(const std::list< uint32_t > &packetlist)
Definition: error-model.cc:520
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:41
uint16_t m_addbaPendingCount
Count number of times ADDBA state machine is in pending state.
Definition: wifi-test.cc:1988
an EUI-48 address
Definition: mac48-address.h:43
ObjectFactory m_manager
manager
Definition: wifi-test.cc:438
NodeContainer Setup(bool nearestApBeaconGeneration, bool staActiveProbe)
Setup test.
Definition: wifi-test.cc:1810
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1273
Ptr< const SpectrumModel > GetSpectrumModel() const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1614
manage and create wifi channel objects for the YANS model.
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:117
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:474
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1667
create MAC layers for a ns3::WifiNetDevice.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
State
Represents the state for this agreement.
void RxSuccessCallback(std::string context, Ptr< const Packet > p)
Callback when packet is successfully received.
Definition: wifi-test.cc:2273
uint8_t m_countOperationalChannelWidth40
count number of beacon frames announcing a 40 MHz operating channel width
Definition: wifi-test.cc:1586
void ChangeChannelWidth(uint16_t channelWidth)
Change the configured channel width for all nodes.
Definition: wifi-test.cc:2586
void SetErrorRateModel(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Definition: wifi-helper.cc:149
Test to validate that Ideal rate manager properly selects TXVECTOR in scenarios where MIMO is used...
Definition: wifi-test.cc:2690
void TxCallback(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2599
void SetPosition(const Vector &position)
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
Make sure that the correct channel width and center frequency have been set for OFDM basic rate trans...
Definition: wifi-test.cc:1384
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:278
void RxErrorCallback(std::string context, Ptr< const Packet > p, double snr)
Callback when packet is dropped.
Definition: wifi-test.cc:2054
Wifi Test Suite.
Definition: wifi-test.cc:3059
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1247
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
std::tuple< double, uint16_t, uint32_t, WifiModulationClass > FreqWidthSubbandModulationTuple
A tuple of {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type}.
Definition: wifi-test.cc:1395
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:767
uint16_t m_txCount
Count number of transmitted data packets.
Definition: wifi-test.cc:2256
void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel)
Run subtest for this test suite.
Definition: wifi-test.cc:2077
wifi
Definition: third.py:96
uint8_t GetStaChannelWidth(void) const
Return the STA channel width.
Helper class used to assign positions and mobility models to nodes.
ObjectFactory m_manager
manager
Definition: wifi-test.cc:115
Instantiate subclasses of ns3::Object.
Ptr< WifiMac > GetMac(void) const
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
Definition: wifi-mode.h:38
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:956
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2457
static void AssignWifiRandomStreams(Ptr< WifiMac > mac, int64_t stream)
Definition: wifi-test.cc:57
SignalNoiseDbm structure.
Definition: wifi-phy.h:119
virtual void SetChannelWidth(uint16_t channelWidth)
Definition: wifi-phy.cc:1502
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1580
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
AttributeValue implementation for Ssid.
Definition: ssid.h:105
ObjectFactory m_manager
manager
Definition: wifi-test.cc:276
OFDM PHY (Clause 17)
Definition: wifi-mode.h:58
void SendPacketBurst(uint32_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination) const
Triggers the arrival of a burst of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:2066
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
uint32_t m_received
received
Definition: wifi-test.cc:577
void Add(Vector v)
Add a position to the list of positions.
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:287
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
apDevices
Definition: third.py:106
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Data rate verification test for MCSs of different RU sizes.
Definition: wifi-test.cc:2974
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2385
WifiTxVector m_txVector
Store the last TXVECTOR used to transmit Data.
Definition: wifi-test.cc:2737
Make sure that Ideal rate manager properly selects MCS based on the configured channel width...
Definition: wifi-test.cc:2537
void TurnApOff(Ptr< Node > apNode)
Turn the AP node off.
Definition: wifi-test.cc:1802
uint16_t m_txMacFinalDataFailedCount
Count number of unsuccessfully transmitted data packets.
Definition: wifi-test.cc:2257
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data...
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:126
void CheckLastSelectedNss(uint8_t expectedNss)
Check if the selected Nss is correct.
Definition: wifi-test.cc:2782
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
uint16_t m_addbaNoReplyCount
Count number of times ADDBA state machine is in no_reply state.
Definition: wifi-test.cc:1990
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2466
Wifi Test.
Definition: wifi-test.cc:92
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
virtual ~Issue40TestCase()
Definition: wifi-test.cc:2268
uint16_t GetChannelWidth(void) const
std::vector< FreqWidthSubbandModulationTuple > m_distinctTuples
vector of distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
Definition: wifi-test.cc:1396
Time m_secondTransmissionTime
second transmission time
Definition: wifi-test.cc:443
void ChangeSupportedChannelWidth(void)
Function called to change the supported channel width at runtime.
Definition: wifi-test.cc:1603
void SetPriority(uint8_t priority)
Set the tag&#39;s priority.
Definition: socket.cc:842
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
uint16_t m_failedActionCount
Count failed ADDBA request/response.
Definition: wifi-test.cc:1986
MpduType type
type
Definition: wifi-phy.h:128
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:889
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
void SendPackets(uint8_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination, uint8_t priority)
Triggers the transmission of a 1000 Byte-long data packet from the source device. ...
Definition: wifi-test.cc:2444
a (time, location) pair.
Definition: waypoint.h:35
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:223
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:69
#define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg)
Test that an actual value is less than or equal to a limit and report if not.
Definition: test.h:922
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition: ptr.h:536
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:847
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
uint8_t m_reassocRespCount
count number of reassociation responses
Definition: wifi-test.cc:1584
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:127
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Implements the IEEE 802.11 MAC header.
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:133
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Make sure that fragmentation works with QoS stations.
Definition: wifi-test.cc:704
uint16_t m_channelWidth
channel width (in MHz)
Definition: wifi-test.cc:1413
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyBand band, WifiPhyStandard standard, uint16_t frequency, uint16_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1278
Set Channel Frequency Test.
Definition: wifi-test.cc:865
Make sure that when multiple broadcast packets are queued on the same device in a short succession...
Definition: wifi-test.cc:423
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:66
Make it easy to create and manage PHY objects for the spectrum model.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:331