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/vht-phy.h"
51 #include "ns3/waypoint-mobility-model.h"
52 #include "ns3/frame-exchange-manager.h"
53 #include "ns3/wifi-default-protection-manager.h"
54 #include "ns3/wifi-default-ack-manager.h"
55 
56 using namespace ns3;
57 
58 //Helper function to assign streams to random variables, to control
59 //randomness in the tests
60 static void
62 {
63  int64_t currentStream = stream;
64  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
65  if (rmac)
66  {
67  PointerValue ptr;
68  if (!rmac->GetQosSupported ())
69  {
70  rmac->GetAttribute ("Txop", ptr);
71  Ptr<Txop> txop = ptr.Get<Txop> ();
72  currentStream += txop->AssignStreams (currentStream);
73  }
74  else
75  {
76  rmac->GetAttribute ("VO_Txop", ptr);
77  Ptr<QosTxop> vo_txop = ptr.Get<QosTxop> ();
78  currentStream += vo_txop->AssignStreams (currentStream);
79 
80  rmac->GetAttribute ("VI_Txop", ptr);
81  Ptr<QosTxop> vi_txop = ptr.Get<QosTxop> ();
82  currentStream += vi_txop->AssignStreams (currentStream);
83 
84  rmac->GetAttribute ("BE_Txop", ptr);
85  Ptr<QosTxop> be_txop = ptr.Get<QosTxop> ();
86  currentStream += be_txop->AssignStreams (currentStream);
87 
88  rmac->GetAttribute ("BK_Txop", ptr);
89  Ptr<QosTxop> bk_txop = ptr.Get<QosTxop> ();
90  bk_txop->AssignStreams (currentStream);
91  }
92  }
93 }
94 
101 class WifiTest : public TestCase
102 {
103 public:
104  WifiTest ();
105 
106  void DoRun (void) override;
107 
108 
109 private:
111  void RunOne (void);
117  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
123 
127 };
128 
130  : TestCase ("Wifi")
131 {
132 }
133 
134 void
136 {
137  Ptr<Packet> p = Create<Packet> ();
138  dev->Send (p, dev->GetBroadcast (), 1);
139 }
140 
141 void
143 {
144  Ptr<Node> node = CreateObject<Node> ();
145  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
146 
148  mac->SetDevice (dev);
149  mac->SetAddress (Mac48Address::Allocate ());
150  mac->ConfigureStandard (WIFI_STANDARD_80211a);
151  Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager ();
152  Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
153  protectionManager->SetWifiMac (mac);
154  fem->SetProtectionManager (protectionManager);
155  Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
156  ackManager->SetWifiMac (mac);
157  fem->SetAckManager (ackManager);
158 
159  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
160  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
161  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
162  phy->SetErrorRateModel (error);
163  phy->SetChannel (channel);
164  phy->SetDevice (dev);
165  phy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
167 
168  mobility->SetPosition (pos);
169  node->AggregateObject (mobility);
170  dev->SetMac (mac);
171  dev->SetPhy (phy);
172  dev->SetRemoteStationManager (manager);
173  node->AddDevice (dev);
174 
175  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
176 }
177 
178 void
180 {
181  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
183  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
184  channel->SetPropagationDelayModel (propDelay);
185  channel->SetPropagationLossModel (propLoss);
186 
187  CreateOne (Vector (0.0, 0.0, 0.0), channel);
188  CreateOne (Vector (5.0, 0.0, 0.0), channel);
189  CreateOne (Vector (5.0, 0.0, 0.0), channel);
190 
191  Simulator::Stop (Seconds (10.0));
192 
193  Simulator::Run ();
194  Simulator::Destroy ();
195 }
196 
197 void
199 {
200  m_mac.SetTypeId ("ns3::AdhocWifiMac");
201  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
202 
203  m_manager.SetTypeId ("ns3::ArfWifiManager");
204  RunOne ();
205  m_manager.SetTypeId ("ns3::AarfWifiManager");
206  RunOne ();
207  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
208  RunOne ();
209  m_manager.SetTypeId ("ns3::OnoeWifiManager");
210  RunOne ();
211  m_manager.SetTypeId ("ns3::AmrrWifiManager");
212  RunOne ();
213  m_manager.SetTypeId ("ns3::IdealWifiManager");
214  RunOne ();
215 
216  m_mac.SetTypeId ("ns3::AdhocWifiMac");
217  RunOne ();
218  m_mac.SetTypeId ("ns3::ApWifiMac");
219  RunOne ();
220  m_mac.SetTypeId ("ns3::StaWifiMac");
221  RunOne ();
222 
223 
224  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
225  m_mac.SetTypeId ("ns3::AdhocWifiMac");
226  RunOne ();
227 }
228 
236 {
237 public:
238  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
239  {
240  }
241  void DoRun (void) override
242  {
243  //startingSeq=0, seqNum=2047
244  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
245  //startingSeq=0, seqNum=2048
246  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
247  //startingSeq=2048, seqNum=0
248  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
249  //startingSeq=4095, seqNum=0
250  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
251  //startingSeq=0, seqNum=4095
252  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
253  //startingSeq=4095 seqNum=2047
254  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
255  //startingSeq=2048 seqNum=4095
256  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
257  //startingSeq=2049 seqNum=0
258  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
259  }
260 };
261 
262 
267 {
268 public:
270 
271  void DoRun (void) override;
272 
273 
274 private:
291  void SwitchCh (Ptr<WifiNetDevice> dev);
292 
296 };
297 
299  : TestCase ("InterferenceHelperSequence")
300 {
301 }
302 
303 void
305 {
306  Ptr<Packet> p = Create<Packet> (1000);
307  dev->Send (p, dev->GetBroadcast (), 1);
308 }
309 
310 void
312 {
313  Ptr<WifiPhy> p = dev->GetPhy ();
314  p->SetChannelNumber (40);
315 }
316 
317 Ptr<Node>
319 {
320  Ptr<Node> node = CreateObject<Node> ();
321  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
322 
324  mac->SetDevice (dev);
325  mac->SetAddress (Mac48Address::Allocate ());
326  mac->ConfigureStandard (WIFI_STANDARD_80211a);
327  Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager ();
328  Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
329  protectionManager->SetWifiMac (mac);
330  fem->SetProtectionManager (protectionManager);
331  Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
332  ackManager->SetWifiMac (mac);
333  fem->SetAckManager (ackManager);
334 
335  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
336  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
337  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
338  phy->SetErrorRateModel (error);
339  phy->SetChannel (channel);
340  phy->SetDevice (dev);
341  phy->SetMobility (mobility);
342  phy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
344 
345  mobility->SetPosition (pos);
346  node->AggregateObject (mobility);
347  dev->SetMac (mac);
348  dev->SetPhy (phy);
349  dev->SetRemoteStationManager (manager);
350  node->AddDevice (dev);
351 
352  return node;
353 }
354 
355 void
357 {
358  m_mac.SetTypeId ("ns3::AdhocWifiMac");
359  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
360  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
361 
362  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
364  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
365  channel->SetPropagationDelayModel (propDelay);
366  channel->SetPropagationLossModel (propLoss);
367 
368  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
369  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
370  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
371 
372  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
373  propLoss->SetDefaultLoss (999);
374 
375  Simulator::Schedule (Seconds (1.0),
377  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
378 
379  Simulator::Schedule (Seconds (1.0000001),
381  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
382 
383  Simulator::Schedule (Seconds (5.0),
385  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
386 
387  Simulator::Schedule (Seconds (7.0),
389  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
390 
391  Simulator::Stop (Seconds (100.0));
392  Simulator::Run ();
393 
394  Simulator::Destroy ();
395 }
396 
397 //-----------------------------------------------------------------------------
449 {
450 public:
452 
453  void DoRun (void) override;
454 
455 
456 private:
462 
466 
469  unsigned int m_numSentPackets;
470 
476  void NotifyPhyTxBegin (Ptr<const Packet> p, double txPowerW);
477 };
478 
480  : TestCase ("Test case for DCF immediate access with broadcast frames")
481 {
482 }
483 
484 void
486 {
487  if (m_numSentPackets == 0)
488  {
491  }
492  else if (m_numSentPackets == 1)
493  {
495  }
496 }
497 
498 void
500 {
501  Ptr<Packet> p = Create<Packet> (1000);
502  dev->Send (p, dev->GetBroadcast (), 1);
503 }
504 
505 void
507 {
508  m_mac.SetTypeId ("ns3::AdhocWifiMac");
509  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
510  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
511 
512  //Assign a seed and run number, and later fix the assignment of streams to
513  //WiFi random variables, so that the first backoff used is one slot
514  RngSeedManager::SetSeed (1);
515  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
516 
517  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
519  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
520  channel->SetPropagationDelayModel (propDelay);
521  channel->SetPropagationLossModel (propLoss);
522 
523  Ptr<Node> txNode = CreateObject<Node> ();
524  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
526  txMac->SetDevice (txDev);
529  Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
530  protectionManager->SetWifiMac (txMac);
531  fem->SetProtectionManager (protectionManager);
532  Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
533  ackManager->SetWifiMac (txMac);
534  fem->SetAckManager (ackManager);
535 
536 
537  //Fix the stream assignment to the Dcf Txop objects (backoffs)
538  //The below stream assignment will result in the Txop object
539  //using a backoff value of zero for this test when the
540  //Txop::EndTxNoAck() calls to StartBackoffNow()
541  AssignWifiRandomStreams (txMac, 23);
542 
543  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
544  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
545  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
546  txPhy->SetErrorRateModel (txError);
547  txPhy->SetChannel (channel);
548  txPhy->SetDevice (txDev);
549  txPhy->SetMobility (txMobility);
551 
553 
554  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
555  txNode->AggregateObject (txMobility);
556  txMac->SetAddress (Mac48Address::Allocate ());
557  txDev->SetMac (txMac);
558  txDev->SetPhy (txPhy);
560  txNode->AddDevice (txDev);
561 
564  m_numSentPackets = 0;
565 
566  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
567  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
568 
569  Simulator::Stop (Seconds (2.0));
570  Simulator::Run ();
571  Simulator::Destroy ();
572 
573  // First packet is transmitted a DIFS after the packet is queued. A DIFS
574  // is 2 slots (2 * 9 = 18 us) plus a SIFS (16 us), i.e., 34 us
575  Time expectedFirstTransmissionTime = Seconds (1.0) + MicroSeconds (34);
576 
577  //First packet has 1408 us of transmit time. Slot time is 9 us.
578  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
579  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
580  //1451 us after the first one.
581  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
582  Time expectedSecondTransmissionTime = expectedFirstTransmissionTime + MicroSeconds (expectedWait1);
583  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, expectedFirstTransmissionTime, "The first transmission time not correct!");
584 
585  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
586 }
587 
588 //-----------------------------------------------------------------------------
601 class Bug730TestCase : public TestCase
602 {
603 public:
604  Bug730TestCase ();
605  virtual ~Bug730TestCase ();
606 
607  void DoRun (void) override;
608 
609 
610 private:
611  uint32_t m_received;
612 
619  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
620 
621 };
622 
624  : TestCase ("Test case for Bug 730"),
625  m_received (0)
626 {
627 }
628 
630 {
631 }
632 
633 void
634 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
635 {
636  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
637  {
638  m_received++;
639  }
640 }
641 
642 
643 void
645 {
646  m_received = 0;
647 
648  NodeContainer wifiStaNode;
649  wifiStaNode.Create (1);
650 
652  wifiApNode.Create (1);
653 
654  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
656  phy.SetChannel (channel.Create ());
657 
659  wifi.SetStandard (WIFI_STANDARD_80211b);
660  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
661  "DataMode", StringValue ("DsssRate1Mbps"),
662  "ControlMode", StringValue ("DsssRate1Mbps"));
663 
665  Ssid ssid = Ssid ("ns-3-ssid");
666  mac.SetType ("ns3::StaWifiMac",
667  "Ssid", SsidValue (ssid),
668  "ActiveProbing", BooleanValue (false));
669 
671  staDevices = wifi.Install (phy, mac, wifiStaNode);
672 
673  mac.SetType ("ns3::ApWifiMac",
674  "Ssid", SsidValue (ssid),
675  "BeaconGeneration", BooleanValue (true));
676 
678  apDevices = wifi.Install (phy, mac, wifiApNode);
679 
681  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
682 
683  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
684  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
685  mobility.SetPositionAllocator (positionAlloc);
686 
687  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
688  mobility.Install (wifiApNode);
689  mobility.Install (wifiStaNode);
690 
691  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
692  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
693 
694  PacketSocketAddress socket;
695  socket.SetSingleDevice (sta_device->GetIfIndex ());
696  socket.SetPhysicalAddress (ap_device->GetAddress ());
697  socket.SetProtocol (1);
698 
699  // give packet socket powers to nodes.
700  PacketSocketHelper packetSocket;
701  packetSocket.Install (wifiStaNode);
702  packetSocket.Install (wifiApNode);
703 
704  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
705  client->SetAttribute ("PacketSize", UintegerValue (1460));
706  client->SetRemote (socket);
707  wifiStaNode.Get (0)->AddApplication (client);
708  client->SetStartTime (Seconds (1));
709  client->SetStopTime (Seconds (51.0));
710 
711  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
712  server->SetLocal (socket);
713  wifiApNode.Get (0)->AddApplication (server);
714  server->SetStartTime (Seconds (0.0));
715  server->SetStopTime (Seconds (52.0));
716 
717  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
718 
719  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
720 
721  Simulator::Stop (Seconds (55));
722  Simulator::Run ();
723 
724  Simulator::Destroy ();
725 
726  bool result = (m_received > 0);
727  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
728 }
729 
730 //-----------------------------------------------------------------------------
739 {
740 public:
742  virtual ~QosFragmentationTestCase ();
743 
744  void DoRun (void) override;
745 
746 
747 private:
748  uint32_t m_received;
749  uint32_t m_fragments;
750 
757  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
758 
765  void Transmit (std::string context, Ptr<const Packet> p, double power);
766 };
767 
769  : TestCase ("Test case for fragmentation with QoS stations"),
770  m_received (0),
771  m_fragments (0)
772 {
773 }
774 
776 {
777 }
778 
779 void
780 QosFragmentationTestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
781 {
782  if (p->GetSize () == 1400)
783  {
784  m_received++;
785  }
786 }
787 
788 void
789 QosFragmentationTestCase::Transmit (std::string context, Ptr<const Packet> p, double power)
790 {
791  WifiMacHeader hdr;
792  p->PeekHeader (hdr);
793  if (hdr.IsQosData ())
794  {
795  NS_TEST_EXPECT_MSG_LT_OR_EQ (p->GetSize (), 400, "Unexpected fragment size");
796  m_fragments++;
797  }
798 }
799 
800 void
802 {
803  NodeContainer wifiStaNode;
804  wifiStaNode.Create (1);
805 
807  wifiApNode.Create (1);
808 
809  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
811  phy.SetChannel (channel.Create ());
812 
814  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
815  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
816  "DataMode", StringValue ("HtMcs7"));
817 
819  Ssid ssid = Ssid ("ns-3-ssid");
820  mac.SetType ("ns3::StaWifiMac",
821  "Ssid", SsidValue (ssid),
822  "ActiveProbing", BooleanValue (false));
823 
825  staDevices = wifi.Install (phy, mac, wifiStaNode);
826 
827  mac.SetType ("ns3::ApWifiMac",
828  "Ssid", SsidValue (ssid),
829  "BeaconGeneration", BooleanValue (true));
830 
832  apDevices = wifi.Install (phy, mac, wifiApNode);
833 
835  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
836 
837  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
838  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
839  mobility.SetPositionAllocator (positionAlloc);
840 
841  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
842  mobility.Install (wifiApNode);
843  mobility.Install (wifiStaNode);
844 
845  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
846  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
847 
848  // set the TXOP limit on BE AC
849  Ptr<RegularWifiMac> sta_mac = DynamicCast<RegularWifiMac> (sta_device->GetMac ());
850  NS_ASSERT (sta_mac);
851  PointerValue ptr;
852  sta_mac->GetAttribute ("BE_Txop", ptr);
853  ptr.Get<QosTxop> ()->SetTxopLimit (MicroSeconds (3008));
854 
855  PacketSocketAddress socket;
856  socket.SetSingleDevice (sta_device->GetIfIndex ());
857  socket.SetPhysicalAddress (ap_device->GetAddress ());
858  socket.SetProtocol (1);
859 
860  // give packet socket powers to nodes.
861  PacketSocketHelper packetSocket;
862  packetSocket.Install (wifiStaNode);
863  packetSocket.Install (wifiApNode);
864 
865  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
866  client->SetAttribute ("PacketSize", UintegerValue (1400));
867  client->SetAttribute ("MaxPackets", UintegerValue (1));
868  client->SetRemote (socket);
869  wifiStaNode.Get (0)->AddApplication (client);
870  client->SetStartTime (Seconds (1));
871  client->SetStopTime (Seconds (3.0));
872 
873  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
874  server->SetLocal (socket);
875  wifiApNode.Get (0)->AddApplication (server);
876  server->SetStartTime (Seconds (0.0));
877  server->SetStopTime (Seconds (4.0));
878 
879  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&QosFragmentationTestCase::Receive, this));
880 
881  Config::Set ("/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("400"));
882  Config::Connect ("/NodeList/0/DeviceList/0/Phy/PhyTxBegin", MakeCallback (&QosFragmentationTestCase::Transmit, this));
883 
884  Simulator::Stop (Seconds (5));
885  Simulator::Run ();
886 
887  Simulator::Destroy ();
888 
889  NS_TEST_ASSERT_MSG_EQ (m_received, 1, "Unexpected number of received packets");
890  NS_TEST_ASSERT_MSG_EQ (m_fragments, 4, "Unexpected number of transmitted fragments");
891 }
892 
900 {
901 public:
903 
904  void DoRun (void) override;
905 
906 
907 private:
914 
915 };
916 
918  : TestCase ("Test case for setting WifiPhy channel and frequency")
919 {
920 }
921 
924 {
925  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
926  Ptr<WifiPhy> wp = wnd->GetPhy ();
927  return wp->GetObject<YansWifiPhy> ();
928 }
929 
930 void
932 {
933  NodeContainer wifiStaNode;
934  wifiStaNode.Create (1);
936  wifiApNode.Create (1);
937 
938  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
940  phy.SetChannel (channel.Create ());
941 
942  // Configure and declare other generic components of this example
943  Ssid ssid;
944  ssid = Ssid ("wifi-phy-configuration");
945  WifiMacHelper macSta;
946  macSta.SetType ("ns3::StaWifiMac",
947  "Ssid", SsidValue (ssid),
948  "ActiveProbing", BooleanValue (false));
949  NetDeviceContainer staDevice;
950  Ptr<YansWifiPhy> phySta;
951 
952  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
953  {
954  // case 0:
955  // Default configuration, without WifiHelper::SetStandard or WifiHelper
956  phySta = CreateObject<YansWifiPhy> ();
957  // The default results in an invalid configuration
958  NS_TEST_ASSERT_MSG_EQ (phySta->GetOperatingChannel ().IsSet (), false, "default configuration");
959  }
960  {
961  // case 1:
963  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
964  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
965  phySta = GetYansWifiPhyPtr (staDevice);
966  // We expect channel 36, width 20, frequency 5180
967  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
968  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
969  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
970  }
971  {
972  // case 2:
974  wifi.SetStandard (WIFI_STANDARD_80211b);
975  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
976  phySta = GetYansWifiPhyPtr (staDevice);
977  // We expect channel 1, width 22, frequency 2412
978  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
979  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
980  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
981  }
982  {
983  // case 3:
985  wifi.SetStandard (WIFI_STANDARD_80211g);
986  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
987  phySta = GetYansWifiPhyPtr (staDevice);
988  // We expect channel 1, width 20, frequency 2412
989  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
990  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
991  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
992  }
993  {
994  // case 4:
996  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
997  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
998  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
999  phySta = GetYansWifiPhyPtr (staDevice);
1000  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
1001  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
1002  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
1003  }
1004  {
1005  // case 5:
1006  WifiHelper wifi;
1007  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1008  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
1009  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1010  phySta = GetYansWifiPhyPtr (staDevice);
1011  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
1012  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
1013  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
1014  }
1015  {
1016  // case 6:
1017  WifiHelper wifi;
1018  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1019  wifi.SetStandard (WIFI_STANDARD_80211ac);
1020  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1021  phySta = GetYansWifiPhyPtr (staDevice);
1022  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
1023  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
1024  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
1025  }
1026  {
1027  // case 7:
1028  WifiHelper wifi;
1029  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1030  wifi.SetStandard (WIFI_STANDARD_80211ax_2_4GHZ);
1031  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1032  phySta = GetYansWifiPhyPtr (staDevice);
1033  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11ax-2.4GHz configuration");
1034  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11ax-2.4GHz configuration");
1035  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11ax-2.4GHz configuration");
1036  }
1037  {
1038  // case 8:
1039  WifiHelper wifi;
1040  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1041  wifi.SetStandard (WIFI_STANDARD_80211ax_5GHZ);
1042  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1043  phySta = GetYansWifiPhyPtr (staDevice);
1044  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ax-5GHz configuration");
1045  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-5GHz configuration");
1046  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ax-5GHz configuration");
1047  }
1048  {
1049  // case 9:
1050  WifiHelper wifi;
1051  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1052  wifi.SetStandard (WIFI_STANDARD_80211ax_6GHZ);
1053  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1054  phySta = GetYansWifiPhyPtr (staDevice);
1055  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 7, "802.11ax-6GHz configuration");
1056  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-6GHz configuration");
1057  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5975, "802.11ax-6GHz configuration");
1058  }
1059  {
1060  // case 10:
1061  WifiHelper wifi;
1062  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1063  wifi.SetStandard (WIFI_STANDARD_80211p);
1064  phy.Set ("ChannelWidth", UintegerValue (10));
1065  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1066  phySta = GetYansWifiPhyPtr (staDevice);
1067  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11p 10Mhz configuration");
1068  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11p 10Mhz configuration");
1069  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 10Mhz configuration");
1070  }
1071  {
1072  // case 11:
1073  WifiHelper wifi;
1074  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1075  wifi.SetStandard (WIFI_STANDARD_80211p);
1076  phy.Set ("ChannelWidth", UintegerValue (5));
1077  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1078  phySta = GetYansWifiPhyPtr (staDevice);
1079  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 171, "802.11p 5Mhz configuration");
1080  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11p 5Mhz configuration");
1081  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 5Mhz configuration");
1082  }
1083  {
1084  // case 12:
1085  WifiHelper wifi;
1086  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1087  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1088  phy.Set ("ChannelWidth", UintegerValue (20)); // reset value after previous case
1089  phy.Set ("ChannelNumber", UintegerValue (44));
1090  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1091  phySta = GetYansWifiPhyPtr (staDevice);
1092  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1093  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1094  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1095  }
1096  {
1097  // case 13:
1098  WifiHelper wifi;
1099  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1100  phy.Set ("ChannelNumber", UintegerValue (44));
1101  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1102  phySta = GetYansWifiPhyPtr (staDevice);
1103  // Post-install reconfiguration to channel number 40
1104  std::ostringstream path;
1105  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber";
1106  Config::Set (path.str(), UintegerValue (40));
1107  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1108  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1109  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1110  }
1111  {
1112  // case 14:
1113  WifiHelper wifi;
1114  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1115  phy.Set ("ChannelNumber", UintegerValue (44));
1116  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1117  phySta = GetYansWifiPhyPtr (staDevice);
1118  // Post-install reconfiguration to a 40 MHz channel
1119  std::ostringstream path;
1120  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber";
1121  Config::Set (path.str(), UintegerValue (46));
1122  // Although channel 44 is configured originally for 20 MHz, we
1123  // allow it to be used for 40 MHz here
1124  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 46, "802.11 5GHz configuration");
1125  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1126  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5230, "802.11 5GHz configuration");
1127  }
1128  {
1129  // case 15:
1130  WifiHelper wifi;
1131  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1132  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1133  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1134  phySta = GetYansWifiPhyPtr (staDevice);
1135  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
1136  // Post-install reconfiguration to a 40 MHz channel
1137  std::ostringstream path;
1138  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber";
1139  Config::Set (path.str(), UintegerValue (46));
1140  // Although channel 44 is configured originally for 20 MHz, we
1141  // allow it to be used for 40 MHz here
1142  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 46, "802.11 5GHz configuration");
1143  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1144  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5230, "802.11 5GHz configuration");
1145  }
1146  {
1147  // case 16:
1148  WifiHelper wifi;
1149  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1150  // Test that setting Frequency to a non-standard value will throw an exception
1151  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1152  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1153  phySta = GetYansWifiPhyPtr (staDevice);
1154  bool exceptionThrown = false;
1155  try
1156  {
1157  phySta->SetAttribute ("Frequency", UintegerValue (5281));
1158  }
1159  catch (const std::runtime_error&)
1160  {
1161  exceptionThrown = true;
1162  }
1163  // We expect that an exception is thrown
1164  NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1165  }
1166  {
1167  // case 17:
1168  WifiHelper wifi;
1169  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1170  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1171  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1172  phySta = GetYansWifiPhyPtr (staDevice);
1173  // Test that setting Frequency to a standard value will set the
1174  // channel number correctly
1175  phySta->SetAttribute ("Frequency", UintegerValue (5500));
1176  // We expect channel number to be 100 due to frequency 5500
1177  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
1178  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1179  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
1180  }
1181  {
1182  // case 18:
1183  // Set a wrong channel after initialization
1184  WifiHelper wifi;
1185  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1186  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1187  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1188  phySta = GetYansWifiPhyPtr (staDevice);
1189  bool exceptionThrown = false;
1190  try
1191  {
1192  phySta->SetOperatingChannel (99, 5185, 40);
1193  }
1194  catch (const std::runtime_error&)
1195  {
1196  exceptionThrown = true;
1197  }
1198  // We expect that an exception is thrown
1199  NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1200  }
1201  {
1202  // case 19:
1203  WifiHelper wifi;
1204  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1205  // Test how channel number behaves when frequency is non-standard
1206  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1207  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1208  phySta = GetYansWifiPhyPtr (staDevice);
1209  bool exceptionThrown = false;
1210  try
1211  {
1212  phySta->SetAttribute ("Frequency", UintegerValue (5181));
1213  }
1214  catch (const std::runtime_error&)
1215  {
1216  exceptionThrown = true;
1217  }
1218  // We expect that an exception is thrown due to unknown center frequency 5181
1219  NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1220  phySta->SetAttribute ("Frequency", UintegerValue (5180));
1221  // We expect channel number to be 36 due to known center frequency 5180
1222  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1223  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1224  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1225  exceptionThrown = false;
1226  try
1227  {
1228  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1229  }
1230  catch (const std::runtime_error&)
1231  {
1232  exceptionThrown = true;
1233  }
1234  // We expect that an exception is thrown due to unknown center frequency 5179
1235  NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1236  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1237  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1238  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1239  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1240  }
1241  {
1242  // case 20:
1243  WifiHelper wifi;
1244  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1245  // Set both channel and frequency to consistent values before initialization
1246  phy.Set ("Frequency", UintegerValue (5200));
1247  phy.Set ("ChannelNumber", UintegerValue (40));
1248  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1249  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1250  phySta = GetYansWifiPhyPtr (staDevice);
1251  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1252  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1253  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1254  // Set both channel and frequency to consistent values after initialization
1255  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1256  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1257  phySta = GetYansWifiPhyPtr (staDevice);
1258  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1259  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
1260  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1261  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1262  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1263  // Set both channel and frequency to inconsistent values
1264  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1265  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1266  // We expect channel number to be 36
1267  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1268  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1269  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1270  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1271  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1272  // We expect channel number to be 40
1273  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1274  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1275  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1276  bool exceptionThrown = false;
1277  try
1278  {
1279  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1280  }
1281  catch (const std::runtime_error&)
1282  {
1283  exceptionThrown = true;
1284  }
1285  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1286  // We expect channel number to be 36 and an exception to be thrown
1287  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1288  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1289  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1290  NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1291  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1292  exceptionThrown = false;
1293  try
1294  {
1295  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1296  }
1297  catch (const std::runtime_error&)
1298  {
1299  exceptionThrown = true;
1300  }
1301  // We expect channel number to be 36 and an exception to be thrown
1302  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1303  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1304  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1305  NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1306  }
1307 
1308  Simulator::Destroy ();
1309 }
1310 
1311 //-----------------------------------------------------------------------------
1320 {
1321 public:
1322  Bug2222TestCase ();
1323  virtual ~Bug2222TestCase ();
1324 
1325  void DoRun (void) override;
1326 
1327 
1328 private:
1330 
1336  void TxDataFailedTrace (std::string context, Mac48Address adr);
1337 };
1338 
1340  : TestCase ("Test case for Bug 2222"),
1341  m_countInternalCollisions (0)
1342 {
1343 }
1344 
1346 {
1347 }
1348 
1349 void
1351 {
1352  //Indicate the long retry counter has been increased in the wifi remote station manager
1354 }
1355 
1356 void
1358 {
1360 
1361  //Generate same backoff for AC_VI and AC_VO
1362  //The below combination will work
1363  RngSeedManager::SetSeed (1);
1364  RngSeedManager::SetRun (1);
1365  int64_t streamNumber = 100;
1366 
1367  NodeContainer wifiNodes;
1368  wifiNodes.Create (2);
1369 
1370  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1372  phy.SetChannel (channel.Create ());
1373 
1374  WifiHelper wifi;
1375  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1376  "DataMode", StringValue ("OfdmRate54Mbps"),
1377  "ControlMode", StringValue ("OfdmRate24Mbps"));
1379  Ssid ssid = Ssid ("ns-3-ssid");
1380  mac.SetType ("ns3::AdhocWifiMac",
1381  "QosSupported", BooleanValue (true));
1382 
1383  NetDeviceContainer wifiDevices;
1384  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1385 
1386  // Assign fixed streams to random variables in use
1387  wifi.AssignStreams (wifiDevices, streamNumber);
1388 
1390  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1391 
1392  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1393  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1394  mobility.SetPositionAllocator (positionAlloc);
1395 
1396  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1397  mobility.Install (wifiNodes);
1398 
1399  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1400  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1401 
1402  PacketSocketAddress socket;
1403  socket.SetSingleDevice (device1->GetIfIndex ());
1404  socket.SetPhysicalAddress (device2->GetAddress ());
1405  socket.SetProtocol (1);
1406 
1407  PacketSocketHelper packetSocket;
1408  packetSocket.Install (wifiNodes);
1409 
1410  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1411  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1412  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1413  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1414  clientLowPriority->SetRemote (socket);
1415  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1416  clientLowPriority->SetStartTime (Seconds (0.0));
1417  clientLowPriority->SetStopTime (Seconds (1.0));
1418 
1419  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1420  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1421  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1422  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1423  clientHighPriority->SetRemote (socket);
1424  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1425  clientHighPriority->SetStartTime (Seconds (0.0));
1426  clientHighPriority->SetStopTime (Seconds (1.0));
1427 
1428  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1429  server->SetLocal (socket);
1430  wifiNodes.Get (1)->AddApplication (server);
1431  server->SetStartTime (Seconds (0.0));
1432  server->SetStopTime (Seconds (1.0));
1433 
1434  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1435 
1436  Simulator::Stop (Seconds (1.0));
1437  Simulator::Run ();
1438  Simulator::Destroy ();
1439 
1440  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1441 }
1442 
1443 //-----------------------------------------------------------------------------
1457 {
1458 public:
1459  Bug2843TestCase ();
1460  virtual ~Bug2843TestCase ();
1461  void DoRun (void) override;
1462 
1463 private:
1467  typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1468  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1469 
1476  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1483  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1484 
1485  uint16_t m_channelWidth;
1486 };
1487 
1489  : TestCase ("Test case for Bug 2843"),
1490  m_channelWidth (20)
1491 {
1492 }
1493 
1495 {
1496 }
1497 
1498 void
1500 {
1501  // Extract starting frequency and number of subbands
1502  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1503  std::size_t numBands = c->GetNumBands ();
1504  double startingFreq = c->Begin ()->fl;
1505 
1506  // Get channel bandwidth and modulation class
1507  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1508 
1509  Ptr<WifiPpdu> ppdu = wifiTxParams->ppdu->Copy ();
1510  WifiTxVector txVector = ppdu->GetTxVector ();
1511  m_channelWidth = txVector.GetChannelWidth ();
1512  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1513 
1514  // Build a tuple and check if seen before (if so store it)
1515  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, m_channelWidth, numBands, modulationClass);
1516  bool found = false;
1517  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1518  {
1519  if (*it == tupleForCurrentTx)
1520  {
1521  found = true;
1522  }
1523  }
1524  if (!found)
1525  {
1526  m_distinctTuples.push_back (tupleForCurrentTx);
1527  }
1528 }
1529 
1530 void
1531 Bug2843TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1532  Address& destination) const
1533 {
1534  for (uint8_t i = 0; i < numPackets; i++)
1535  {
1536  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1537  sourceDevice->Send (pkt, destination, 0);
1538  }
1539 }
1540 
1541 void
1543 {
1544  uint16_t channelWidth = 40; // at least 40 MHz expected here
1545 
1546  NodeContainer wifiStaNode;
1547  wifiStaNode.Create (1);
1548 
1550  wifiApNode.Create (1);
1551 
1552  SpectrumWifiPhyHelper spectrumPhy;
1553  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1554  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1555  lossModel->SetFrequency (5.190e9);
1556  spectrumChannel->AddPropagationLossModel (lossModel);
1557 
1559  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1560  spectrumChannel->SetPropagationDelayModel (delayModel);
1561 
1562  spectrumPhy.SetChannel (spectrumChannel);
1563  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1564  spectrumPhy.Set ("Frequency", UintegerValue (5190));
1565  spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
1566  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1567  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1568 
1569  WifiHelper wifi;
1570  wifi.SetStandard (WIFI_STANDARD_80211ac);
1571  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1572  "DataMode", StringValue ("VhtMcs8"),
1573  "ControlMode", StringValue ("VhtMcs8"),
1574  "RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1575 
1577  mac.SetType ("ns3::StaWifiMac");
1578  NetDeviceContainer staDevice;
1579  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1580 
1581  mac.SetType ("ns3::ApWifiMac");
1582  NetDeviceContainer apDevice;
1583  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1584 
1586  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1587  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1588  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1589  mobility.SetPositionAllocator (positionAlloc);
1590 
1591  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1592  mobility.Install (wifiApNode);
1593  mobility.Install (wifiStaNode);
1594 
1595  // Send two 5 packet-bursts
1596  Simulator::Schedule (Seconds (0.5), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1597  Simulator::Schedule (Seconds (0.6), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1598 
1599  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2843TestCase::StoreDistinctTuple, this));
1600 
1601  Simulator::Stop (Seconds (0.8));
1602  Simulator::Run ();
1603 
1604  Simulator::Destroy ();
1605 
1606  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1607  std::size_t numberTuples = m_distinctTuples.size ();
1608  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1609  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");
1610  // Note that the first tuple should the one initiated by the beacon, i.e. non-HT OFDM (20 MHz)
1611  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1612  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)");
1613  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1614  // Second tuple
1615  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1616  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)");
1617  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1618 }
1619 
1620 //-----------------------------------------------------------------------------
1633 {
1634 public:
1635  Bug2831TestCase ();
1636  virtual ~Bug2831TestCase ();
1637  void DoRun (void) override;
1638 
1639 private:
1643  void ChangeSupportedChannelWidth (void);
1650  void RxCallback (std::string context, Ptr<const Packet> p, RxPowerWattPerChannelBand rxPowersW);
1651 
1654 
1659 };
1660 
1662  : TestCase ("Test case for Bug 2831"),
1663  m_reassocReqCount (0),
1664  m_reassocRespCount (0),
1665  m_countOperationalChannelWidth20 (0),
1666  m_countOperationalChannelWidth40 (0)
1667 {
1668 }
1669 
1671 {
1672 }
1673 
1674 void
1676 {
1677  m_apPhy->SetChannelNumber (38);
1678  m_apPhy->SetChannelWidth (40);
1679  m_staPhy->SetChannelNumber (38);
1680  m_staPhy->SetChannelWidth (40);
1681 }
1682 
1683 void
1685 {
1686  Ptr<Packet> packet = p->Copy ();
1687  WifiMacHeader hdr;
1688  packet->RemoveHeader (hdr);
1689  if (hdr.IsReassocReq ())
1690  {
1692  }
1693  else if (hdr.IsReassocResp ())
1694  {
1696  }
1697  else if (hdr.IsBeacon ())
1698  {
1699  MgtBeaconHeader beacon;
1700  packet->RemoveHeader (beacon);
1701  HtOperation htOperation = beacon.GetHtOperation ();
1702  if (htOperation.GetStaChannelWidth () > 0)
1703  {
1705  }
1706  else
1707  {
1709  }
1710  }
1711 }
1712 
1713 void
1715 {
1716  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1717  ObjectFactory propDelay;
1718  propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1719  Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1720  Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel> ();
1721  channel->SetPropagationDelayModel (propagationDelay);
1722  channel->SetPropagationLossModel (propagationLoss);
1723 
1724  Ptr<Node> apNode = CreateObject<Node> ();
1725  Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1726  Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration> ();
1727  apDev->SetHtConfiguration (apHtConfiguration);
1729  mac.SetTypeId ("ns3::ApWifiMac");
1730  mac.Set ("EnableBeaconJitter", BooleanValue (false));
1731  mac.Set ("QosSupported", BooleanValue (true));
1732  Ptr<RegularWifiMac> apMac = mac.Create<RegularWifiMac> ();
1733  apMac->SetDevice (apDev);
1734  apMac->SetAddress (Mac48Address::Allocate ());
1737  Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
1738  protectionManager->SetWifiMac (apMac);
1739  fem->SetProtectionManager (protectionManager);
1740  Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
1741  ackManager->SetWifiMac (apMac);
1742  fem->SetAckManager (ackManager);
1743 
1744  Ptr<Node> staNode = CreateObject<Node> ();
1745  Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> ();
1746  Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration> ();
1747  staDev->SetHtConfiguration (staHtConfiguration);
1748  mac.SetTypeId ("ns3::StaWifiMac");
1749  Ptr<RegularWifiMac> staMac = mac.Create<RegularWifiMac> ();
1750  staMac->SetDevice (staDev);
1751  staMac->SetAddress (Mac48Address::Allocate ());
1753  fem = staMac->GetFrameExchangeManager ();
1754  protectionManager = CreateObject<WifiDefaultProtectionManager> ();
1755  protectionManager->SetWifiMac (staMac);
1756  fem->SetProtectionManager (protectionManager);
1757  ackManager = CreateObject<WifiDefaultAckManager> ();
1758  ackManager->SetWifiMac (staMac);
1759  fem->SetAckManager (ackManager);
1760 
1761  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
1762  apMobility->SetPosition (Vector (0.0, 0.0, 0.0));
1763  apNode->AggregateObject (apMobility);
1764 
1765  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
1766  m_apPhy = CreateObject<YansWifiPhy> ();
1767  m_apPhy->SetErrorRateModel (error);
1769  m_apPhy->SetMobility (apMobility);
1770  m_apPhy->SetDevice (apDev);
1772  m_apPhy->SetChannelNumber (36);
1773  m_apPhy->SetChannelWidth (20);
1774 
1775  Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel> ();
1776  staMobility->SetPosition (Vector (1.0, 0.0, 0.0));
1777  staNode->AggregateObject (staMobility);
1778 
1779  m_staPhy = CreateObject<YansWifiPhy> ();
1780  m_staPhy->SetErrorRateModel (error);
1782  m_staPhy->SetMobility (staMobility);
1783  m_staPhy->SetDevice (apDev);
1785  m_staPhy->SetChannelNumber (36);
1786  m_staPhy->SetChannelWidth (20);
1787 
1788  apDev->SetMac (apMac);
1789  apDev->SetPhy (m_apPhy);
1790  ObjectFactory manager;
1791  manager.SetTypeId ("ns3::ConstantRateWifiManager");
1793  apNode->AddDevice (apDev);
1794 
1795  staDev->SetMac (staMac);
1796  staDev->SetPhy (m_staPhy);
1798  staNode->AddDevice (staDev);
1799 
1800  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this));
1801 
1802  Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1803 
1804  Simulator::Stop (Seconds (3.0));
1805  Simulator::Run ();
1806  Simulator::Destroy ();
1807 
1808  NS_TEST_ASSERT_MSG_EQ (m_reassocReqCount, 1, "Reassociation request not received");
1809  NS_TEST_ASSERT_MSG_EQ (m_reassocRespCount, 1, "Reassociation response not received");
1810  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operational channel width before channel change");
1811  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operational channel width after channel change");
1812 }
1813 
1814 //-----------------------------------------------------------------------------
1831 {
1832 public:
1834  virtual ~StaWifiMacScanningTestCase ();
1835  void DoRun (void) override;
1836 
1837 private:
1843  void AssocCallback (std::string context, Mac48Address bssid);
1848  void TurnBeaconGenerationOn (Ptr<Node> apNode);
1853  void TurnApOff (Ptr<Node> apNode);
1860  NodeContainer Setup (bool nearestApBeaconGeneration, bool staActiveProbe);
1861 
1863 };
1864 
1866  : TestCase ("Test case for StaWifiMac scanning capability")
1867 {
1868 }
1869 
1871 {
1872 }
1873 
1874 void
1876 {
1877  m_associatedApBssid = bssid;
1878 }
1879 
1880 void
1882 {
1883  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1884  Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac> (netDevice->GetMac ());
1885  mac->SetAttribute ("BeaconGeneration", BooleanValue (true));
1886 }
1887 
1888 void
1890 {
1891  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1892  Ptr<WifiPhy> phy = netDevice->GetPhy ();
1893  phy->SetOffMode ();
1894 }
1895 
1897 StaWifiMacScanningTestCase::Setup (bool nearestApBeaconGeneration, bool staActiveProbe)
1898 {
1899  RngSeedManager::SetSeed (1);
1900  RngSeedManager::SetRun (1);
1901  int64_t streamNumber = 1;
1902 
1903  NodeContainer apNodes;
1904  apNodes.Create (2);
1905 
1906  Ptr<Node> apNodeNearest = CreateObject<Node> ();
1907  Ptr<Node> staNode = CreateObject<Node> ();
1908 
1910  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1911  phy.SetChannel (channel.Create ());
1912 
1913  WifiHelper wifi;
1914  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
1915  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
1916 
1918  NetDeviceContainer apDevice, apDeviceNearest;
1919  mac.SetType ("ns3::ApWifiMac",
1920  "BeaconGeneration", BooleanValue (true));
1921  apDevice = wifi.Install (phy, mac, apNodes);
1922  mac.SetType ("ns3::ApWifiMac",
1923  "BeaconGeneration", BooleanValue (nearestApBeaconGeneration));
1924  apDeviceNearest = wifi.Install (phy, mac, apNodeNearest);
1925 
1926  NetDeviceContainer staDevice;
1927  mac.SetType ("ns3::StaWifiMac",
1928  "ActiveProbing", BooleanValue (staActiveProbe));
1929  staDevice = wifi.Install (phy, mac, staNode);
1930 
1931  // Assign fixed streams to random variables in use
1932  wifi.AssignStreams (apDevice, streamNumber);
1933  wifi.AssignStreams (apDeviceNearest, streamNumber + 1);
1934  wifi.AssignStreams (staDevice, streamNumber + 2);
1935 
1937  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1938  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Furthest AP
1939  positionAlloc->Add (Vector (10.0, 0.0, 0.0)); // Second nearest AP
1940  positionAlloc->Add (Vector (5.0, 5.0, 0.0)); // Nearest AP
1941  positionAlloc->Add (Vector (6.0, 5.0, 0.0)); // STA
1942  mobility.SetPositionAllocator (positionAlloc);
1943 
1944  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1945  mobility.Install (apNodes);
1946  mobility.Install (apNodeNearest);
1947  mobility.Install (staNode);
1948 
1949  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc", MakeCallback (&StaWifiMacScanningTestCase::AssocCallback, this));
1950 
1951  NodeContainer allNodes = NodeContainer (apNodes, apNodeNearest, staNode);
1952  return allNodes;
1953 }
1954 
1955 void
1957 {
1958  {
1959  NodeContainer nodes = Setup (false, false);
1960  Ptr<Node> nearestAp = nodes.Get (2);
1961  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1962 
1963  Simulator::Schedule (Seconds (0.05), &StaWifiMacScanningTestCase::TurnBeaconGenerationOn, this, nearestAp);
1964 
1965  Simulator::Stop (Seconds (0.2));
1966  Simulator::Run ();
1967  Simulator::Destroy ();
1968 
1969  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1970  }
1972  {
1973  NodeContainer nodes = Setup (true, true);
1974  Ptr<Node> nearestAp = nodes.Get (2);
1975  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1976 
1977  Simulator::Stop (Seconds (0.2));
1978  Simulator::Run ();
1979  Simulator::Destroy ();
1980 
1981  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1982  }
1984  {
1985  NodeContainer nodes = Setup (true, false);
1986  Ptr<Node> nearestAp = nodes.Get (2);
1987  Mac48Address secondNearestApAddr = DynamicCast<WifiNetDevice> (nodes.Get (1)->GetDevice (0))->GetMac ()->GetAddress ();
1988 
1989  Simulator::Schedule (Seconds (0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
1990 
1991  Simulator::Stop (Seconds (1.5));
1992  Simulator::Run ();
1993  Simulator::Destroy ();
1994 
1995  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, secondNearestApAddr, "STA is associated to the wrong AP");
1996  }
1997 }
1998 
1999 //-----------------------------------------------------------------------------
2023 {
2024 public:
2025  Bug2470TestCase ();
2026  virtual ~Bug2470TestCase ();
2027  void DoRun (void) override;
2028 
2029 private:
2038  void AddbaStateChangedCallback (std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
2049  void RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId);
2056  void RxErrorCallback (std::string context, Ptr<const Packet> p, double snr);
2063  void SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
2069  void RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel);
2070 
2079 };
2080 
2082  : TestCase ("Test case for Bug 2470"),
2083  m_receivedNormalMpduCount (0),
2084  m_receivedAmpduCount (0),
2085  m_failedActionCount (0),
2086  m_addbaEstablishedCount (0),
2087  m_addbaPendingCount (0),
2088  m_addbaRejectedCount (0),
2089  m_addbaNoReplyCount (0),
2090  m_addbaResetCount (0)
2091 {
2092 }
2093 
2095 {
2096 }
2097 
2098 void
2100 {
2101  switch (state)
2102  {
2103  case OriginatorBlockAckAgreement::ESTABLISHED:
2105  break;
2106  case OriginatorBlockAckAgreement::PENDING:
2108  break;
2109  case OriginatorBlockAckAgreement::REJECTED:
2111  break;
2112  case OriginatorBlockAckAgreement::NO_REPLY:
2114  break;
2115  case OriginatorBlockAckAgreement::RESET:
2117  break;
2118  }
2119 }
2120 
2121 void
2122 Bug2470TestCase::RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
2123 {
2124  Ptr<Packet> packet = p->Copy ();
2125  if (aMpdu.type != MpduType::NORMAL_MPDU)
2126  {
2128  }
2129  else
2130  {
2131  WifiMacHeader hdr;
2132  packet->RemoveHeader (hdr);
2133  if (hdr.IsData ())
2134  {
2136  }
2137  }
2138 }
2139 
2140 void
2141 Bug2470TestCase::RxErrorCallback (std::string context, Ptr<const Packet> p, double snr)
2142 {
2143  Ptr<Packet> packet = p->Copy ();
2144  WifiMacHeader hdr;
2145  packet->RemoveHeader (hdr);
2146  if (hdr.IsAction ())
2147  {
2149  }
2150 }
2151 
2152 void
2153 Bug2470TestCase::SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice,
2154  Address& destination) const
2155 {
2156  for (uint32_t i = 0; i < numPackets; i++)
2157  {
2158  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2159  sourceDevice->Send (pkt, destination, 0);
2160  }
2161 }
2162 
2163 void
2165 {
2166  RngSeedManager::SetSeed (1);
2167  RngSeedManager::SetRun (1);
2168  int64_t streamNumber = 200;
2169 
2170  NodeContainer wifiApNode, wifiStaNode;
2171  wifiApNode.Create (1);
2172  wifiStaNode.Create (1);
2173 
2175  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2176  phy.SetChannel (channel.Create ());
2177 
2178  WifiHelper wifi;
2179  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
2180  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2181  "DataMode", StringValue ("HtMcs7"),
2182  "ControlMode", StringValue ("HtMcs7"));
2183 
2185  NetDeviceContainer apDevice;
2186  phy.Set ("PostReceptionErrorModel", apErrorModel);
2187  mac.SetType ("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue (false));
2188  apDevice = wifi.Install (phy, mac, wifiApNode);
2189 
2190  NetDeviceContainer staDevice;
2191  phy.Set ("PostReceptionErrorModel", staErrorModel);
2192  mac.SetType ("ns3::StaWifiMac");
2193  staDevice = wifi.Install (phy, mac, wifiStaNode);
2194 
2195  // Assign fixed streams to random variables in use
2196  wifi.AssignStreams (apDevice, streamNumber);
2197  wifi.AssignStreams (staDevice, streamNumber);
2198 
2200  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2201  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2202  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2203  mobility.SetPositionAllocator (positionAlloc);
2204 
2205  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2206  mobility.Install (wifiApNode);
2207  mobility.Install (wifiStaNode);
2208 
2209  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this));
2210  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&Bug2470TestCase::RxErrorCallback, this));
2211  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this));
2212 
2213  Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2214  Simulator::Schedule (Seconds (0.5) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2215  Simulator::Schedule (Seconds (0.8), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2216  Simulator::Schedule (Seconds (0.8) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2217 
2218  Simulator::Stop (Seconds (1.0));
2219  Simulator::Run ();
2220  Simulator::Destroy ();
2221 }
2222 
2223 void
2225 {
2226  // Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel
2227  // instead of ListErrorModel since packet UID is incremented between simulations. But
2228  // problem may occur because of random stream, therefore we suppress usage of RNG as
2229  // much as possible (i.e., removing beacon jitter).
2230  Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel> ();
2231  std::list<uint32_t> blackList;
2232  // Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2233  blackList.push_back (9);
2234  blackList.push_back (10);
2235  blackList.push_back (11);
2236  blackList.push_back (12);
2237  blackList.push_back (13);
2238  blackList.push_back (14);
2239  staPem->SetList (blackList);
2240 
2241  {
2242  RunSubtest (PointerValue (), PointerValue (staPem));
2243  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 6, "ADDBA request packets are not failed");
2244  // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by normal
2245  // MPDU because of failed ADDBA handshake. For the second set, the first packet should be sent by
2246  // normal MPDU, and the rest with A-MPDU. In total we expect to receive 2 normal MPDU packets and
2247  // 8 A-MPDU packets.
2248  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 2, "Receiving incorrect number of normal MPDU packet on subtest 1");
2249  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 8, "Receiving incorrect number of A-MPDU packet on subtest 1");
2250 
2251  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 1");
2252  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2253  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2254  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 0, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2255  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2256  }
2257 
2260  m_failedActionCount = 0;
2262  m_addbaPendingCount = 0;
2264  m_addbaNoReplyCount = 0;
2265  m_addbaResetCount = 0;
2266 
2267  Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel> ();
2268  blackList.clear ();
2269  // Block ADDBA request 4 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2270  blackList.push_back (5);
2271  blackList.push_back (6);
2272  blackList.push_back (7);
2273  blackList.push_back (9);
2274  apPem->SetList (blackList);
2275 
2276  {
2277  RunSubtest (PointerValue (apPem), PointerValue ());
2278  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 4, "ADDBA response packets are not failed");
2279  // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU packets.
2280  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 6, "Receiving incorrect number of normal MPDU packet on subtest 2");
2281  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 4, "Receiving incorrect number of A-MPDU packet on subtest 2");
2282 
2283  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 2");
2284  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2285  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2286  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 1, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2287  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2288  }
2289 
2290  // TODO: In the second test set, it does not go to reset state since ADDBA response is received after timeout (NO_REPLY)
2291  // but before it does not enter RESET state. More tests should be written to verify all possible scenarios.
2292 }
2293 
2294 //-----------------------------------------------------------------------------
2310 {
2311 public:
2312  Issue40TestCase ();
2313  virtual ~Issue40TestCase ();
2314  void DoRun (void) override;
2315 
2316 private:
2321  void RunOne (bool useAmpdu);
2322 
2328  void RxSuccessCallback (std::string context, Ptr<const Packet> p);
2335  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination);
2341  void TxFinalDataFailedCallback (std::string context, Mac48Address address);
2342 
2343  uint16_t m_rxCount;
2344  uint16_t m_txCount;
2346 };
2347 
2349  : TestCase ("Test case for issue #40"),
2350  m_rxCount (0),
2351  m_txCount (0),
2352  m_txMacFinalDataFailedCount (0)
2353 {
2354 }
2355 
2357 {
2358 }
2359 
2360 void
2362 {
2363  m_rxCount++;
2364 }
2365 
2366 void
2367 Issue40TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination)
2368 {
2369  for (uint8_t i = 0; i < numPackets; i++)
2370  {
2371  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2372  sourceDevice->Send (pkt, destination, 0);
2373  m_txCount++;
2374  }
2375 }
2376 
2377 void
2379 {
2381 }
2382 
2383 void
2385 {
2386  m_rxCount = 0;
2387  m_txCount = 0;
2389 
2390  RngSeedManager::SetSeed (1);
2391  RngSeedManager::SetRun (1);
2392  int64_t streamNumber = 100;
2393 
2394  NodeContainer wifiApNode, wifiStaNode;
2395  wifiApNode.Create (1);
2396  wifiStaNode.Create (1);
2397 
2399  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2400  phy.SetChannel (channel.Create ());
2401 
2402  WifiHelper wifi;
2403  wifi.SetStandard (WIFI_STANDARD_80211ac);
2404  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2405 
2407  NetDeviceContainer apDevice;
2408  mac.SetType ("ns3::ApWifiMac");
2409  apDevice = wifi.Install (phy, mac, wifiApNode);
2410 
2411  NetDeviceContainer staDevice;
2412  mac.SetType ("ns3::StaWifiMac");
2413  staDevice = wifi.Install (phy, mac, wifiStaNode);
2414 
2415  // Assign fixed streams to random variables in use
2416  wifi.AssignStreams (apDevice, streamNumber);
2417  wifi.AssignStreams (staDevice, streamNumber);
2418 
2420  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2421  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2422  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
2423  mobility.SetPositionAllocator (positionAlloc);
2424 
2425  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2426  mobility.Install (wifiApNode);
2427 
2428  mobility.SetMobilityModel("ns3::WaypointMobilityModel");
2429  mobility.Install (wifiStaNode);
2430 
2431  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxFinalDataFailed", MakeCallback (&Issue40TestCase::TxFinalDataFailedCallback, this));
2432  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/MacRx", MakeCallback (&Issue40TestCase::RxSuccessCallback, this));
2433 
2434  Ptr<WaypointMobilityModel> staWaypointMobility = DynamicCast<WaypointMobilityModel>(wifiStaNode.Get(0)->GetObject<MobilityModel>());
2435  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.0), Vector (10.0, 0.0, 0.0)));
2436  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.5), Vector (50.0, 0.0, 0.0)));
2437 
2438  if (useAmpdu)
2439  {
2440  // 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
2441  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevice.Get (0));
2442  Ptr<RegularWifiMac> ap_mac = DynamicCast<RegularWifiMac> (ap_device->GetMac ());
2443  NS_ASSERT (ap_mac);
2444  PointerValue ptr;
2445  ap_mac->GetAttribute ("BE_Txop", ptr);
2446  ptr.Get<QosTxop> ()->SetAttribute ("UseExplicitBarAfterMissedBlockAck", BooleanValue (false));
2447  }
2448 
2449  // Transmit a first data packet before the station moves: it should be sent with a high modulation and successfully received
2450  Simulator::Schedule (Seconds (0.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2451 
2452  // 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
2453  Simulator::Schedule (Seconds (2.0), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2454 
2455  // 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
2456  Simulator::Schedule (Seconds (2.1), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2457  Simulator::Schedule (Seconds (2.2), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2458  Simulator::Schedule (Seconds (2.3), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2459  Simulator::Schedule (Seconds (2.4), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2460  Simulator::Schedule (Seconds (2.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2461 
2462  Simulator::Stop (Seconds (3.0));
2463  Simulator::Run ();
2464 
2465  NS_TEST_ASSERT_MSG_EQ (m_txCount, (useAmpdu ? 14 : 7), "Incorrect number of transmitted packets");
2466  NS_TEST_ASSERT_MSG_EQ (m_rxCount, (useAmpdu ? 12 : 6), "Incorrect number of successfully received packets");
2467  NS_TEST_ASSERT_MSG_EQ (m_txMacFinalDataFailedCount, 1, "Incorrect number of dropped TX packets");
2468 
2469  Simulator::Destroy ();
2470 }
2471 
2472 void
2474 {
2475  //Test without A-MPDU
2476  RunOne (false);
2477 
2478  //Test with A-MPDU
2479  RunOne (true);
2480 }
2481 
2482 //-----------------------------------------------------------------------------
2496 {
2497 public:
2498  Issue169TestCase ();
2499  virtual ~Issue169TestCase ();
2500  void DoRun (void) override;
2501 
2502 private:
2510  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority);
2511 
2519  void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW);
2520 };
2521 
2523  : TestCase ("Test case for issue #169")
2524 {
2525 }
2526 
2528 {
2529 }
2530 
2531 void
2532 Issue169TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority)
2533 {
2534  SocketPriorityTag priorityTag;
2535  priorityTag.SetPriority (priority);
2536  for (uint8_t i = 0; i < numPackets; i++)
2537  {
2538  Ptr<Packet> packet = Create<Packet> (1000); // 1000 dummy bytes of data
2539  packet->AddPacketTag (priorityTag);
2540  sourceDevice->Send (packet, destination, 0);
2541  }
2542 }
2543 
2544 void
2545 Issue169TestCase::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
2546 {
2547  if (psdus.begin()->second->GetSize () >= 1000)
2548  {
2549  NS_TEST_ASSERT_MSG_EQ (txVector.GetMode ().GetModulationClass (), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Ideal rate manager selected incorrect modulation class");
2550  }
2551 }
2552 
2553 void
2555 {
2556  RngSeedManager::SetSeed (1);
2557  RngSeedManager::SetRun (1);
2558  int64_t streamNumber = 100;
2559 
2560  NodeContainer wifiApNode, wifiStaNode;
2561  wifiApNode.Create (1);
2562  wifiStaNode.Create (1);
2563 
2565  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2566  phy.SetChannel (channel.Create ());
2567 
2568  WifiHelper wifi;
2569  wifi.SetStandard (WIFI_STANDARD_80211ac);
2570  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2571 
2573  NetDeviceContainer apDevice;
2574  mac.SetType ("ns3::ApWifiMac");
2575  apDevice = wifi.Install (phy, mac, wifiApNode);
2576 
2577  NetDeviceContainer staDevice;
2578  mac.SetType ("ns3::StaWifiMac");
2579  staDevice = wifi.Install (phy, mac, wifiStaNode);
2580 
2581  // Assign fixed streams to random variables in use
2582  wifi.AssignStreams (apDevice, streamNumber);
2583  wifi.AssignStreams (staDevice, streamNumber);
2584 
2586  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2587  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2588  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2589  mobility.SetPositionAllocator (positionAlloc);
2590 
2591  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2592  mobility.Install (wifiApNode);
2593  mobility.Install (wifiStaNode);
2594 
2595  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&Issue169TestCase::TxCallback, this));
2596 
2597  //Send best-effort packet (i.e. priority 0)
2598  Simulator::Schedule (Seconds (0.5), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 0);
2599 
2600  //Send non best-effort (voice) packet (i.e. priority 6)
2601  Simulator::Schedule (Seconds (1.0), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 6);
2602 
2603  Simulator::Stop (Seconds (2.0));
2604  Simulator::Run ();
2605 
2606  Simulator::Destroy ();
2607 }
2608 
2609 
2610 //-----------------------------------------------------------------------------
2626 {
2627 public:
2630  void DoRun (void) override;
2631 
2632 private:
2637  void ChangeChannelWidth (uint16_t channelWidth);
2638 
2644  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2645 
2653  void TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW);
2654 
2659  void CheckLastSelectedMode (WifiMode expectedMode);
2660 
2662 };
2663 
2665  : TestCase ("Test case for use of channel bonding with Ideal rate manager")
2666 {
2667 }
2668 
2670 {
2671 }
2672 
2673 void
2675 {
2676  uint16_t frequency;
2677  switch (channelWidth)
2678  {
2679  case 20:
2680  default:
2681  frequency = 5180;
2682  break;
2683  case 40:
2684  frequency = 5190;
2685  break;
2686  case 80:
2687  frequency = 5210;
2688  break;
2689  case 160:
2690  frequency = 5250;
2691  break;
2692  }
2693  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/Frequency", UintegerValue (frequency));
2694 }
2695 
2696 void
2698 {
2699  Ptr<Packet> packet = Create<Packet> (1000);
2700  sourceDevice->Send (packet, destination, 0);
2701 }
2702 
2703 void
2704 IdealRateManagerChannelWidthTest::TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
2705 {
2706  if (psduMap.begin ()->second->GetSize () >= 1000)
2707  {
2708  m_txMode = txVector.GetMode ();
2709  }
2710 }
2711 
2712 void
2714 {
2715  NS_TEST_ASSERT_MSG_EQ (m_txMode, expectedMode, "Last selected WifiMode " << m_txMode << " does not match expected WifiMode " << expectedMode);
2716 }
2717 
2718 void
2720 {
2721  RngSeedManager::SetSeed (1);
2722  RngSeedManager::SetRun (1);
2723  int64_t streamNumber = 100;
2724 
2725  NodeContainer wifiApNode, wifiStaNode;
2726  wifiApNode.Create (1);
2727  wifiStaNode.Create (1);
2728 
2730  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2731  phy.SetChannel (channel.Create ());
2732 
2733  WifiHelper wifi;
2734  wifi.SetStandard (WIFI_STANDARD_80211ac);
2735  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2736 
2738  NetDeviceContainer apDevice;
2739  mac.SetType ("ns3::ApWifiMac");
2740  apDevice = wifi.Install (phy, mac, wifiApNode);
2741 
2742  NetDeviceContainer staDevice;
2743  mac.SetType ("ns3::StaWifiMac");
2744  staDevice = wifi.Install (phy, mac, wifiStaNode);
2745 
2746  // Assign fixed streams to random variables in use
2747  wifi.AssignStreams (apDevice, streamNumber);
2748  wifi.AssignStreams (staDevice, streamNumber);
2749 
2751  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2752  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2753  positionAlloc->Add (Vector (50.0, 0.0, 0.0));
2754  mobility.SetPositionAllocator (positionAlloc);
2755 
2756  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2757  mobility.Install (wifiApNode);
2758  mobility.Install (wifiStaNode);
2759 
2760  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerChannelWidthTest::TxCallback, this));
2761 
2762  //Set channel width to 80 MHz & send packet
2763  Simulator::Schedule (Seconds (0.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 80);
2764  Simulator::Schedule (Seconds (1.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2765  //Selected rate should be VHT-MCS 1
2766  Simulator::Schedule (Seconds (1.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs1 ());
2767 
2768  //Set channel width to 20 MHz & send packet
2769  Simulator::Schedule (Seconds (1.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 20);
2770  Simulator::Schedule (Seconds (2.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2771  //Selected rate should be VHT-MCS 3 since SNR should be 6 dB higher than previously
2772  Simulator::Schedule (Seconds (2.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
2773 
2774  //Set channel width to 40 MHz & send packet
2775  Simulator::Schedule (Seconds (2.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 40);
2776  Simulator::Schedule (Seconds (3.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2777  //Selected rate should be VHT-MCS 2 since SNR should be 3 dB lower than previously
2778  Simulator::Schedule (Seconds (3.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
2779 
2780  Simulator::Stop (Seconds (3.2));
2781  Simulator::Run ();
2782 
2783  Simulator::Destroy ();
2784 }
2785 
2786 
2787 //-----------------------------------------------------------------------------
2796 {
2797 public:
2799  virtual ~IdealRateManagerMimoTest ();
2800  void DoRun (void) override;
2801 
2802 private:
2808  void SetApMimoSettings (uint8_t antennas, uint8_t maxStreams);
2814  void SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams);
2820  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2821 
2829  void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW);
2830 
2835  void CheckLastSelectedMode (WifiMode expectedMode);
2840  void CheckLastSelectedNss (uint8_t expectedNss);
2841 
2843 };
2844 
2846  : TestCase ("Test case for use of imbalanced MIMO settings with Ideal rate manager")
2847 {
2848 }
2849 
2851 {
2852 }
2853 
2854 void
2855 IdealRateManagerMimoTest::SetApMimoSettings (uint8_t antennas, uint8_t maxStreams)
2856 {
2857  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2858  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2859  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2860 }
2861 
2862 void
2863 IdealRateManagerMimoTest::SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams)
2864 {
2865  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2866  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2867  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2868 }
2869 
2870 void
2872 {
2873  Ptr<Packet> packet = Create<Packet> (1000);
2874  sourceDevice->Send (packet, destination, 0);
2875 }
2876 
2877 void
2878 IdealRateManagerMimoTest::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
2879 {
2880  if (psdus.begin ()->second->GetSize () >= 1000)
2881  {
2882  m_txVector = txVector;
2883  }
2884 }
2885 
2886 void
2888 {
2889  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetNss (), expectedNss, "Last selected Nss " << m_txVector.GetNss () << " does not match expected Nss " << expectedNss);
2890 }
2891 
2892 void
2894 {
2895  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetMode (), expectedMode, "Last selected WifiMode " << m_txVector.GetMode () << " does not match expected WifiMode " << expectedMode);
2896 }
2897 
2898 void
2900 {
2901  RngSeedManager::SetSeed (1);
2902  RngSeedManager::SetRun (1);
2903  int64_t streamNumber = 100;
2904 
2905  NodeContainer wifiApNode, wifiStaNode;
2906  wifiApNode.Create (1);
2907  wifiStaNode.Create (1);
2908 
2910  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2911  phy.SetChannel (channel.Create ());
2912 
2913  WifiHelper wifi;
2914  wifi.SetStandard (WIFI_STANDARD_80211ac);
2915  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2916 
2918  NetDeviceContainer apDevice;
2919  mac.SetType ("ns3::ApWifiMac");
2920  apDevice = wifi.Install (phy, mac, wifiApNode);
2921 
2922  NetDeviceContainer staDevice;
2923  mac.SetType ("ns3::StaWifiMac");
2924  staDevice = wifi.Install (phy, mac, wifiStaNode);
2925 
2926  // Assign fixed streams to random variables in use
2927  wifi.AssignStreams (apDevice, streamNumber);
2928  wifi.AssignStreams (staDevice, streamNumber);
2929 
2931  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2932  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2933  positionAlloc->Add (Vector (40.0, 0.0, 0.0));
2934  mobility.SetPositionAllocator (positionAlloc);
2935 
2936  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2937  mobility.Install (wifiApNode);
2938  mobility.Install (wifiStaNode);
2939 
2940  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerMimoTest::TxCallback, this));
2941 
2942 
2943  // TX: 1 antenna
2944  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2945  // RX: 1 antenna
2946  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2947  // Send packets (2 times to get one feedback)
2948  Simulator::Schedule (Seconds (1.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2949  Simulator::Schedule (Seconds (1.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2950  // Selected NSS should be 1 since both TX and RX support a single antenna
2951  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2952  // Selected rate should be VHT-MCS 2 because of settings and distance between TX and RX
2953  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
2954 
2955 
2956  // TX: 1 antenna
2957  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2958  // RX: 2 antennas, but only supports 1 spatial stream
2959  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2960  // Send packets (2 times to get one feedback)
2961  Simulator::Schedule (Seconds (2.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2962  Simulator::Schedule (Seconds (2.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2963  // Selected NSS should be 1 since both TX and RX support a single antenna
2964  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2965  // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB
2966  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
2967 
2968 
2969  // TX: 1 antenna
2970  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2971  // RX: 2 antennas, and supports 2 spatial streams
2972  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2973  // Send packets (2 times to get one feedback)
2974  Simulator::Schedule (Seconds (3.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2975  Simulator::Schedule (Seconds (3.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2976  // Selected NSS should be 1 since TX supports a single antenna
2977  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2978  // Selected rate should be as previously
2979  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
2980 
2981 
2982  // TX: 2 antennas, but only supports 1 spatial stream
2983  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2984  // RX: 1 antenna
2985  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2986  // Send packets (2 times to get one feedback)
2987  Simulator::Schedule (Seconds (4.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2988  Simulator::Schedule (Seconds (4.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2989  // Selected NSS should be 1 since both TX and RX support a single antenna
2990  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2991  // 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)
2992  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
2993 
2994 
2995  // TX: 2 antennas, but only supports 1 spatial stream
2996  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2997  // RX: 2 antennas, but only supports 1 spatial stream
2998  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2999  // Send packets (2 times to get one feedback)
3000  Simulator::Schedule (Seconds (5.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3001  Simulator::Schedule (Seconds (5.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3002  // Selected NSS should be 1 since both TX and RX support a single antenna
3003  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3004  // 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)
3005  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
3006 
3007 
3008  // TX: 2 antennas, but only supports 1 spatial stream
3009  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
3010  // RX: 2 antennas, and supports 2 spatial streams
3011  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
3012  // Send packets (2 times to get one feedback)
3013  Simulator::Schedule (Seconds (6.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3014  Simulator::Schedule (Seconds (6.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3015  // Selected NSS should be 1 since TX supports a single antenna
3016  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3017  // Selected rate should be as previously
3018  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
3019 
3020 
3021  // TX: 2 antennas, and supports 2 spatial streams
3022  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
3023  // RX: 1 antenna
3024  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
3025  // Send packets (2 times to get one feedback)
3026  Simulator::Schedule (Seconds (7.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3027  Simulator::Schedule (Seconds (7.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3028  // Selected NSS should be 1 since RX supports a single antenna
3029  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3030  // 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)
3031  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
3032 
3033 
3034  // TX: 2 antennas, and supports 2 spatial streams
3035  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
3036  // RX: 2 antennas, but only supports 1 spatial stream
3037  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
3038  // Send packets (2 times to get one feedback)
3039  Simulator::Schedule (Seconds (8.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3040  Simulator::Schedule (Seconds (8.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3041  // Selected NSS should be 1 since RX supports a single antenna
3042  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3043  // 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)
3044  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
3045 
3046 
3047  // TX: 2 antennas, and supports 2 spatial streams
3048  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
3049  // RX: 2 antennas, and supports 2 spatial streams
3050  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
3051  // Send packets (2 times to get one feedback)
3052  Simulator::Schedule (Seconds (9.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3053  Simulator::Schedule (Seconds (9.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3054  // Selected NSS should be 2 since both TX and RX support 2 antennas
3055  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 2);
3056  // 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
3057  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
3058 
3059 
3060  // Verify we can go back to initial situation
3061  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
3062  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
3063  Simulator::Schedule (Seconds (10.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3064  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3065  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
3066 
3067  Simulator::Stop (Seconds (10.2));
3068  Simulator::Run ();
3069  Simulator::Destroy ();
3070 }
3071 
3072 //-----------------------------------------------------------------------------
3080 {
3081 public:
3083 
3084 private:
3094  bool CheckDataRate (HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate);
3095  void DoRun (void) override;
3096 };
3097 
3099  : TestCase ("Check data rates for different RU types.")
3100 {
3101 }
3102 
3103 bool
3104 HeRuMcsDataRateTestCase::CheckDataRate (HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate)
3105 {
3106  uint16_t approxWidth = HeRu::GetBandwidth (ruType);
3107  WifiMode mode (mcs);
3108  uint64_t dataRate = round (mode.GetDataRate (approxWidth, guardInterval, nss) / 100000.0);
3109  NS_ABORT_MSG_IF (dataRate > 65535, "Rate is way too high");
3110  if (static_cast<uint16_t> (dataRate) != expectedDataRate)
3111  {
3112  std::cerr << "RU=" << ruType
3113  << " mode=" << mode
3114  << " Nss=" << +nss
3115  << " guardInterval=" << guardInterval
3116  << " expected=" << expectedDataRate << " x100kbps"
3117  << " computed=" << static_cast<uint16_t> (dataRate) << " x100kbps"
3118  << std::endl;
3119  return false;
3120  }
3121  return true;
3122 }
3123 
3124 void
3126 {
3127  bool retval = true;
3128 
3129  //26-tone RU, browse over all MCSs, GIs and Nss's (up to 4, current max)
3130  retval = retval
3131  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs0", 1, 800, 9)
3132  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs1", 1, 1600, 17)
3133  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs2", 1, 3200, 23)
3134  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs3", 1, 3200, 30)
3135  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs4", 2, 1600, 100)
3136  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs5", 3, 1600, 200)
3137  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs6", 4, 1600, 300)
3138  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs7", 4, 3200, 300)
3139  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs8", 4, 1600, 400)
3140  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs9", 4, 3200, 400)
3141  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs10", 4, 1600, 500)
3142  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs11", 4, 3200, 500);
3143 
3144  NS_TEST_EXPECT_MSG_EQ (retval, true, "26-tone RU data rate verification for different MCSs, GIs, and Nss's failed");
3145 
3146  //Check other RU sizes
3147  retval = retval
3148  && CheckDataRate ( HeRu::RU_52_TONE, "HeMcs2", 1, 1600, 50)
3149  && CheckDataRate ( HeRu::RU_106_TONE, "HeMcs9", 1, 800, 500)
3150  && CheckDataRate ( HeRu::RU_242_TONE, "HeMcs5", 1, 1600, 650)
3151  && CheckDataRate ( HeRu::RU_484_TONE, "HeMcs3", 1, 1600, 650)
3152  && CheckDataRate ( HeRu::RU_996_TONE, "HeMcs5", 1, 3200, 2450)
3153  && CheckDataRate (HeRu::RU_2x996_TONE, "HeMcs3", 1, 3200, 2450);
3154 
3155  NS_TEST_EXPECT_MSG_EQ (retval, true, "Data rate verification for RUs above 52-tone RU (included) failed");
3156 }
3157 
3164 class WifiTestSuite : public TestSuite
3165 {
3166 public:
3167  WifiTestSuite ();
3168 };
3169 
3171  : TestSuite ("wifi-devices", UNIT)
3172 {
3173  AddTestCase (new WifiTest, TestCase::QUICK);
3174  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
3175  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
3176  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
3177  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
3178  AddTestCase (new QosFragmentationTestCase, TestCase::QUICK);
3179  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
3180  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
3181  AddTestCase (new Bug2843TestCase, TestCase::QUICK); //Bug 2843
3182  AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
3183  AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399
3184  AddTestCase (new Bug2470TestCase, TestCase::QUICK); //Bug 2470
3185  AddTestCase (new Issue40TestCase, TestCase::QUICK); //Issue #40
3186  AddTestCase (new Issue169TestCase, TestCase::QUICK); //Issue #169
3187  AddTestCase (new IdealRateManagerChannelWidthTest, TestCase::QUICK);
3188  AddTestCase (new IdealRateManagerMimoTest, TestCase::QUICK);
3189  AddTestCase (new HeRuMcsDataRateTestCase, TestCase::QUICK);
3190 }
3191 
ns3::SpectrumChannel::SetPropagationDelayModel
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Definition: spectrum-channel.cc:139
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition: net-device-container.h:42
ns3::WIFI_STANDARD_80211n_5GHZ
@ WIFI_STANDARD_80211n_5GHZ
Definition: wifi-standards.h:132
Bug2470TestCase::m_addbaNoReplyCount
uint16_t m_addbaNoReplyCount
Count number of times ADDBA state machine is in no_reply state.
Definition: wifi-test.cc:2077
Bug730TestCase::~Bug730TestCase
virtual ~Bug730TestCase()
Definition: wifi-test.cc:629
ns3::SpectrumSignalParameters::psd
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
Definition: spectrum-signal-parameters.h:94
ns3::RegularWifiMac::GetFrameExchangeManager
Ptr< FrameExchangeManager > GetFrameExchangeManager(void) const
Get the Frame Exchange Manager.
Definition: regular-wifi-mac.cc:168
Bug2470TestCase::m_failedActionCount
uint16_t m_failedActionCount
Count failed ADDBA request/response.
Definition: wifi-test.cc:2073
ns3::YansWifiPhyHelper
Make it easy to create and manage PHY objects for the YANS model.
Definition: yans-wifi-helper.h:161
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
ns3::YansWifiPhy::SetChannel
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
Definition: yans-wifi-phy.cc:74
ns3::ListPositionAllocator::Add
void Add(Vector v)
Add a position to the list of positions.
Definition: position-allocator.cc:70
Bug2470TestCase
Make sure that the ADDBA handshake process is protected.
Definition: wifi-test.cc:2023
ns3::Config::Set
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:839
third.staDevices
staDevices
Definition: third.py:103
NS_ASSERT
#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
DcfImmediateAccessBroadcastTestCase
Make sure that when multiple broadcast packets are queued on the same device in a short succession,...
Definition: wifi-test.cc:449
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition: boolean.h:37
ns3::SpectrumChannel::AddPropagationLossModel
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
Definition: spectrum-channel.cc:117
ns3::Packet::PeekHeader
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
Issue40TestCase::Issue40TestCase
Issue40TestCase()
Definition: wifi-test.cc:2348
IdealRateManagerChannelWidthTest::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2719
IdealRateManagerMimoTest::~IdealRateManagerMimoTest
virtual ~IdealRateManagerMimoTest()
Definition: wifi-test.cc:2850
Bug2222TestCase
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1320
Bug2843TestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1542
Bug2831TestCase::m_reassocRespCount
uint16_t m_reassocRespCount
count number of reassociation responses
Definition: wifi-test.cc:1656
WifiTest::m_propDelay
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:126
ns3::WifiMacHeader::IsBeacon
bool IsBeacon(void) const
Return true if the header is a Beacon header.
Definition: wifi-mac-header.cc:705
ns3::WifiMacHeader::IsData
bool IsData(void) const
Return true if the Type is DATA.
Definition: wifi-mac-header.cc:558
ns3::Packet::GetSize
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
StaWifiMacScanningTestCase::TurnApOff
void TurnApOff(Ptr< Node > apNode)
Turn the AP node off.
Definition: wifi-test.cc:1889
ns3::NetDevice::GetAddress
virtual Address GetAddress(void) const =0
Bug2843TestCase::Bug2843TestCase
Bug2843TestCase()
Definition: wifi-test.cc:1488
ns3::WifiNetDevice::GetPhy
Ptr< WifiPhy > GetPhy(void) const
Definition: wifi-net-device.cc:207
Bug730TestCase::Receive
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:634
InterferenceHelperSequenceTest::m_propDelay
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:295
Issue169TestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2554
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::HtOperation::GetStaChannelWidth
uint8_t GetStaChannelWidth(void) const
Return the STA channel width.
Definition: ht-operation.cc:207
ns3::WifiNetDevice::SetMac
void SetMac(const Ptr< WifiMac > mac)
Definition: wifi-net-device.cc:180
ns3::WifiHelper
helps to create WifiNetDevice objects
Definition: wifi-helper.h:323
DcfImmediateAccessBroadcastTestCase::m_numSentPackets
unsigned int m_numSentPackets
number of sent packets
Definition: wifi-test.cc:469
ns3::FrameExchangeManager::SetAckManager
virtual void SetAckManager(Ptr< WifiAckManager > ackManager)
Set the Acknowledgment Manager to use.
Definition: frame-exchange-manager.cc:117
Bug2843TestCase::m_distinctTuples
std::vector< FreqWidthSubbandModulationTuple > m_distinctTuples
vector of distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel,...
Definition: wifi-test.cc:1468
StaWifiMacScanningTestCase::m_associatedApBssid
Mac48Address m_associatedApBssid
Associated AP's bssid.
Definition: wifi-test.cc:1862
Bug2831TestCase::~Bug2831TestCase
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1670
ns3::WifiPpdu::GetTxVector
WifiTxVector GetTxVector(void) const
Get the TXVECTOR used to send the PPDU.
Definition: wifi-ppdu.cc:63
ns3::WIFI_STANDARD_80211ax_2_4GHZ
@ WIFI_STANDARD_80211ax_2_4GHZ
Definition: wifi-standards.h:134
ns3::WIFI_STANDARD_80211g
@ WIFI_STANDARD_80211g
Definition: wifi-standards.h:129
ns3::MicroSeconds
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
DcfImmediateAccessBroadcastTestCase::m_propDelay
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:465
ns3::WIFI_STANDARD_80211p
@ WIFI_STANDARD_80211p
Definition: wifi-standards.h:130
StaWifiMacScanningTestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1956
Issue40TestCase::RxSuccessCallback
void RxSuccessCallback(std::string context, Ptr< const Packet > p)
Callback when packet is successfully received.
Definition: wifi-test.cc:2361
QosFragmentationTestCase::Receive
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:780
ns3::WIFI_PHY_BAND_5GHZ
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Definition: wifi-phy-band.h:37
Bug2843TestCase::FreqWidthSubbandModulationTuple
std::tuple< double, uint16_t, uint32_t, WifiModulationClass > FreqWidthSubbandModulationTuple
A tuple of {starting frequency, channelWidth, Number of subbands in SpectrumModel,...
Definition: wifi-test.cc:1467
Issue169TestCase::Issue169TestCase
Issue169TestCase()
Definition: wifi-test.cc:2522
ns3::PropagationDelayModel
calculate a propagation delay.
Definition: propagation-delay-model.h:38
ns3::WIFI_STANDARD_80211ax_5GHZ
@ WIFI_STANDARD_80211ax_5GHZ
Definition: wifi-standards.h:135
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
IdealRateManagerChannelWidthTest
Make sure that Ideal rate manager properly selects MCS based on the configured channel width.
Definition: wifi-test.cc:2626
Issue40TestCase::m_rxCount
uint16_t m_rxCount
Count number of successfully received data packets.
Definition: wifi-test.cc:2343
third.channel
channel
Definition: third.py:92
IdealRateManagerChannelWidthTest::CheckLastSelectedMode
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2713
ns3::MobilityModel::SetPosition
void SetPosition(const Vector &position)
Definition: mobility-model.cc:88
Bug2843TestCase::StoreDistinctTuple
void StoreDistinctTuple(std::string context, Ptr< SpectrumSignalParameters > txParams)
Stores the distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel,...
Definition: wifi-test.cc:1499
ns3::WifiPhy::GetChannelNumber
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1200
ns3::WifiMode::GetModulationClass
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:177
ns3::WifiPhy::GetFrequency
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1169
ns3::WifiProtectionManager::SetWifiMac
void SetWifiMac(Ptr< RegularWifiMac > mac)
Set the MAC which is using this Protection Manager.
Definition: wifi-protection-manager.cc:56
DcfImmediateAccessBroadcastTestCase::m_firstTransmissionTime
Time m_firstTransmissionTime
first transmission time
Definition: wifi-test.cc:467
ns3::WifiRemoteStationManager
hold a list of per-remote-station state.
Definition: wifi-remote-station-manager.h:121
ns3::PointerValue
Hold objects of type Ptr<T>.
Definition: pointer.h:37
ns3::WaypointMobilityModel::AddWaypoint
void AddWaypoint(const Waypoint &waypoint)
Definition: waypoint-mobility-model.cc:82
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::WifiPhyOperatingChannel::IsSet
bool IsSet(void) const
Return true if a valid channel has been set, false otherwise.
Definition: wifi-phy-operating-channel.cc:43
WifiTestSuite::WifiTestSuite
WifiTestSuite()
Definition: wifi-test.cc:3170
ns3::PacketSocketAddress
an address for a packet socket
Definition: packet-socket-address.h:39
ns3::SpectrumValue::GetSpectrumModel
Ptr< const SpectrumModel > GetSpectrumModel() const
Definition: spectrum-value.cc:62
ns3::ObjectBase::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
ns3::FrameExchangeManager::SetProtectionManager
virtual void SetProtectionManager(Ptr< WifiProtectionManager > protectionManager)
Set the Protection Manager to use.
Definition: frame-exchange-manager.cc:104
ns3::WIFI_MOD_CLASS_OFDM
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
Definition: wifi-phy-common.h:129
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::WifiNetDevice::GetAddress
Address GetAddress(void) const override
Definition: wifi-net-device.cc:243
InterferenceHelperSequenceTest::SendOnePacket
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:304
InterferenceHelperSequenceTest
See Bug 991
Definition: wifi-test.cc:267
third.mac
mac
Definition: third.py:99
IdealRateManagerMimoTest::SendPacket
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:2871
ns3::Txop::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: txop.cc:309
IdealRateManagerChannelWidthTest::m_txMode
WifiMode m_txMode
Store the last selected mode to send data packet.
Definition: wifi-test.cc:2661
ns3::WifiConstPsduMap
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition: he-frame-exchange-manager.h:43
Bug2470TestCase::SendPacketBurst
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:2153
ns3::PacketSocketClient::SetRemote
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Definition: packet-socket-client.cc:91
ns3::RegularWifiMac
base class for all MAC-level wifi objects.
Definition: regular-wifi-mac.h:52
ns3::WifiPhyHelper::SetErrorRateModel
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:146
Bug730TestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:644
ns3::WifiPhy::SetChannelWidth
virtual void SetChannelWidth(uint16_t channelWidth)
If the operating channel for this object has not been set yet, the given channel width is saved and w...
Definition: wifi-phy.cc:1206
ns3::RegularWifiMac::GetQosSupported
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: regular-wifi-mac.cc:638
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
SetChannelFrequencyTest::SetChannelFrequencyTest
SetChannelFrequencyTest()
Definition: wifi-test.cc:917
ns3::NodeContainer::Create
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Definition: node-container.cc:98
WifiTest::SendOnePacket
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:135
SendOnePacket
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
Send one packet.
Definition: lr-wpan-phy-test.cc:65
ns3::SsidValue
AttributeValue implementation for Ssid.
Definition: ssid.h:105
ns3::SignalNoiseDbm
SignalNoiseDbm structure.
Definition: phy-entity.h:53
ns3::Ssid
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
HeRuMcsDataRateTestCase::CheckDataRate
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:3104
Issue40TestCase
Make sure that Ideal rate manager recovers when the station is moving away from the access point.
Definition: wifi-test.cc:2310
Issue40TestCase::SendPackets
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:2367
first.nodes
nodes
Definition: first.py:32
ns3::WifiNetDevice
Hold together all Wifi-related objects.
Definition: wifi-net-device.h:54
ns3::WifiNetDevice::SetHtConfiguration
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
Definition: wifi-net-device.cc:450
InterferenceHelperSequenceTest::m_manager
ObjectFactory m_manager
manager
Definition: wifi-test.cc:293
IdealRateManagerMimoTest
Test to validate that Ideal rate manager properly selects TXVECTOR in scenarios where MIMO is used.
Definition: wifi-test.cc:2796
WifiTest
Wifi Test.
Definition: wifi-test.cc:102
WifiTest::WifiTest
WifiTest()
Definition: wifi-test.cc:129
ns3::TestCase
encapsulates test code
Definition: test.h:1154
third.apDevices
apDevices
Definition: third.py:106
WifiTest::RunOne
void RunOne(void)
Run one function.
Definition: wifi-test.cc:179
StaWifiMacScanningTestCase::AssocCallback
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1875
DcfImmediateAccessBroadcastTestCase::DcfImmediateAccessBroadcastTestCase
DcfImmediateAccessBroadcastTestCase()
Definition: wifi-test.cc:479
WifiTest::m_manager
ObjectFactory m_manager
manager
Definition: wifi-test.cc:124
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition: wifi-mac-header.h:85
ns3::Application::SetStopTime
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
ns3::PacketSocketHelper::Install
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Definition: packet-socket-helper.cc:37
third.wifi
wifi
Definition: third.py:96
Issue40TestCase::~Issue40TestCase
virtual ~Issue40TestCase()
Definition: wifi-test.cc:2356
ns3::SocketPriorityTag::SetPriority
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:842
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
IdealRateManagerMimoTest::SetStaMimoSettings
void SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for STA node.
Definition: wifi-test.cc:2863
ns3::WIFI_PHY_STANDARD_80211ax
@ WIFI_PHY_STANDARD_80211ax
HE PHY (clause 26)
Definition: wifi-standards.h:49
ns3::NORMAL_MPDU
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
Definition: wifi-mpdu-type.h:33
Bug2831TestCase::m_apPhy
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1652
IdealRateManagerMimoTest::IdealRateManagerMimoTest
IdealRateManagerMimoTest()
Definition: wifi-test.cc:2845
ns3::Application::SetStartTime
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:69
ns3::ReceiveListErrorModel::SetList
void SetList(const std::list< uint32_t > &packetlist)
Definition: error-model.cc:520
ns3::WifiMac::SetDevice
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-mac.cc:85
DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin
void NotifyPhyTxBegin(Ptr< const Packet > p, double txPowerW)
Notify Phy transmit begin.
Definition: wifi-test.cc:485
QosFragmentationTestCase
Make sure that fragmentation works with QoS stations.
Definition: wifi-test.cc:739
ns3::MpduInfo
MpduInfo structure.
Definition: phy-entity.h:60
ns3::WifiNetDevice::Send
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Definition: wifi-net-device.cc:319
HeRuMcsDataRateTestCase
Data rate verification test for MCSs of different RU sizes.
Definition: wifi-test.cc:3080
Bug2222TestCase::~Bug2222TestCase
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1345
Bug2831TestCase::ChangeSupportedChannelWidth
void ChangeSupportedChannelWidth(void)
Function called to change the supported channel width at runtime.
Definition: wifi-test.cc:1675
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
ns3::QosUtilsIsOldPacket
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:178
ns3::Address
a polymophic address class
Definition: address.h:91
Bug2843TestCase::m_channelWidth
uint16_t m_channelWidth
channel width (in MHz)
Definition: wifi-test.cc:1485
Bug2470TestCase::m_addbaPendingCount
uint16_t m_addbaPendingCount
Count number of times ADDBA state machine is in pending state.
Definition: wifi-test.cc:2075
ns3::ObjectBase::GetAttribute
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:223
ns3::RegularWifiMac::SetAddress
void SetAddress(Mac48Address address) override
Definition: regular-wifi-mac.cc:711
Issue40TestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2473
ns3::OriginatorBlockAckAgreement::State
State
Represents the state for this agreement.
Definition: originator-block-ack-agreement.h:102
DcfImmediateAccessBroadcastTestCase::m_manager
ObjectFactory m_manager
manager
Definition: wifi-test.cc:463
Bug2222TestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1357
ns3::FriisPropagationLossModel::SetFrequency
void SetFrequency(double frequency)
Definition: propagation-loss-model.cc:197
ns3::Node::AddApplication
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:159
QosFragmentationTestCase::QosFragmentationTestCase
QosFragmentationTestCase()
Definition: wifi-test.cc:768
ns3::WifiAckManager::SetWifiMac
void SetWifiMac(Ptr< RegularWifiMac > mac)
Set the MAC which is using this Acknowledgment Manager.
Definition: wifi-ack-manager.cc:57
QosFragmentationTestCase::m_received
uint32_t m_received
received packets
Definition: wifi-test.cc:748
ns3::WIFI_STANDARD_80211a
@ WIFI_STANDARD_80211a
Definition: wifi-standards.h:127
IdealRateManagerChannelWidthTest::SendPacket
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:2697
ns3::Packet::RemoveHeader
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
ns3::Node::GetDevice
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:144
ns3::ObjectFactory
Instantiate subclasses of ns3::Object.
Definition: object-factory.h:48
ns3::HeRu::RuType
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:42
ns3::Object::AggregateObject
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
ns3::WIFI_PHY_STANDARD_80211a
@ WIFI_PHY_STANDARD_80211a
OFDM PHY (Clause 17)
Definition: wifi-standards.h:37
Bug2470TestCase::RxErrorCallback
void RxErrorCallback(std::string context, Ptr< const Packet > p, double snr)
Callback when packet is dropped.
Definition: wifi-test.cc:2141
ns3::PointerValue::Get
Ptr< T > Get(void) const
Definition: pointer.h:201
Bug2470TestCase::m_addbaEstablishedCount
uint16_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:2074
Bug2831TestCase::m_countOperationalChannelWidth20
uint16_t m_countOperationalChannelWidth20
count number of beacon frames announcing a 20 MHz operating channel width
Definition: wifi-test.cc:1657
QosUtilsIsOldPacketTest
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:236
IdealRateManagerMimoTest::TxCallback
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2878
Issue40TestCase::m_txCount
uint16_t m_txCount
Count number of transmitted data packets.
Definition: wifi-test.cc:2344
QosFragmentationTestCase::m_fragments
uint32_t m_fragments
transmitted fragments
Definition: wifi-test.cc:749
ns3::WIFI_STANDARD_80211b
@ WIFI_STANDARD_80211b
Definition: wifi-standards.h:128
ns3::NodeContainer::Get
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Definition: node-container.cc:93
Issue169TestCase::TxCallback
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2545
ns3::WifiMacHeader::IsQosData
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
Definition: wifi-mac-header.cc:565
first.address
address
Definition: first.py:44
ns3::WifiSpectrumSignalParameters::ppdu
Ptr< WifiPpdu > ppdu
The PPDU being transmitted.
Definition: wifi-spectrum-signal-parameters.h:53
HeRuMcsDataRateTestCase::HeRuMcsDataRateTestCase
HeRuMcsDataRateTestCase()
Definition: wifi-test.cc:3098
NS_TEST_EXPECT_MSG_EQ
#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
Bug2470TestCase::RxCallback
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:2122
Issue169TestCase::~Issue169TestCase
virtual ~Issue169TestCase()
Definition: wifi-test.cc:2527
ns3::WifiPhy::GetOperatingChannel
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:1138
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::NetDevice::Send
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
third.wifiApNode
wifiApNode
Definition: third.py:90
NS_ABORT_MSG_IF
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
ns3::WIFI_STANDARD_80211ax_6GHZ
@ WIFI_STANDARD_80211ax_6GHZ
Definition: wifi-standards.h:136
ns3::Node::AddDevice
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
WifiTestSuite
Wifi Test Suite.
Definition: wifi-test.cc:3165
QosUtilsIsOldPacketTest::QosUtilsIsOldPacketTest
QosUtilsIsOldPacketTest()
Definition: wifi-test.cc:238
ns3::PacketSocketAddress::SetSingleDevice
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Definition: packet-socket-address.cc:46
Issue169TestCase
Make sure that Ideal rate manager is able to handle non best-effort traffic.
Definition: wifi-test.cc:2496
ns3::MgtBeaconHeader
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:862
ns3::WifiTxVector::GetChannelWidth
uint16_t GetChannelWidth(void) const
Definition: wifi-tx-vector.cc:154
Bug2843TestCase
Make sure that the correct channel width and center frequency have been set for OFDM basic rate trans...
Definition: wifi-test.cc:1457
ns3::PacketSocketHelper
Give ns3::PacketSocket powers to ns3::Node.
Definition: packet-socket-helper.h:32
IdealRateManagerMimoTest::CheckLastSelectedMode
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2893
Bug2470TestCase::~Bug2470TestCase
virtual ~Bug2470TestCase()
Definition: wifi-test.cc:2094
Issue40TestCase::TxFinalDataFailedCallback
void TxFinalDataFailedCallback(std::string context, Mac48Address address)
Transmit final data failed function.
Definition: wifi-test.cc:2378
ns3::WIFI_STANDARD_80211ac
@ WIFI_STANDARD_80211ac
Definition: wifi-standards.h:133
ns3::SpectrumModel::GetNumBands
size_t GetNumBands() const
Definition: spectrum-model.cc:100
ns3::QosTxop
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:72
Bug2222TestCase::TxDataFailedTrace
void TxDataFailedTrace(std::string context, Mac48Address adr)
Transmit data failed function.
Definition: wifi-test.cc:1350
ns3::WifiPhy::SetMobility
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:790
ns3::MakeCallback
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
WifiTest::CreateOne
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:142
ns3::WifiNetDevice::GetIfIndex
uint32_t GetIfIndex(void) const override
Definition: wifi-net-device.cc:225
AssignWifiRandomStreams
static void AssignWifiRandomStreams(Ptr< WifiMac > mac, int64_t stream)
Definition: wifi-test.cc:61
IdealRateManagerMimoTest::SetApMimoSettings
void SetApMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for AP node.
Definition: wifi-test.cc:2855
ns3::StringValue
Hold variables of type string.
Definition: string.h:41
SetChannelFrequencyTest::GetYansWifiPhyPtr
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:923
DcfImmediateAccessBroadcastTestCase::m_mac
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:464
ns3::Packet::AddPacketTag
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:956
test-ns3.result
result
Definition: test-ns3.py:576
QosFragmentationTestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:801
ns3::TestSuite
A suite of tests to run.
Definition: test.h:1344
Bug2831TestCase::m_staPhy
Ptr< YansWifiPhy > m_staPhy
STA PHY.
Definition: wifi-test.cc:1653
InterferenceHelperSequenceTest::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:356
IdealRateManagerChannelWidthTest::ChangeChannelWidth
void ChangeChannelWidth(uint16_t channelWidth)
Change the configured channel width for all nodes.
Definition: wifi-test.cc:2674
ns3::WifiMacHeader::IsReassocResp
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Definition: wifi-mac-header.cc:687
Bug2222TestCase::m_countInternalCollisions
uint32_t m_countInternalCollisions
count internal collisions
Definition: wifi-test.cc:1329
ns3::SocketPriorityTag
indicates whether the socket has a priority set.
Definition: socket.h:1309
NS_TEST_ASSERT_MSG_EQ
#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
ns3::Config::Connect
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
NS_TEST_EXPECT_MSG_LT_OR_EQ
#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
ns3::WifiTxVector::GetNss
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.
Definition: wifi-tx-vector.cc:172
Bug2831TestCase
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1633
ns3::RegularWifiMac::ConfigureStandard
void ConfigureStandard(WifiStandard standard) override
Definition: regular-wifi-mac.cc:1142
Bug2470TestCase::m_addbaResetCount
uint16_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:2078
ns3::Waypoint
a (time, location) pair.
Definition: waypoint.h:36
Issue169TestCase::SendPackets
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:2532
Bug2470TestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2224
StaWifiMacScanningTestCase::~StaWifiMacScanningTestCase
virtual ~StaWifiMacScanningTestCase()
Definition: wifi-test.cc:1870
IdealRateManagerChannelWidthTest::~IdealRateManagerChannelWidthTest
virtual ~IdealRateManagerChannelWidthTest()
Definition: wifi-test.cc:2669
Bug2470TestCase::m_receivedNormalMpduCount
uint16_t m_receivedNormalMpduCount
Count received normal MPDU packets on STA.
Definition: wifi-test.cc:2071
StaWifiMacScanningTestCase
Make sure that Wifi STA is correctly associating to the best AP (i.e., nearest from STA).
Definition: wifi-test.cc:1831
StaWifiMacScanningTestCase::TurnBeaconGenerationOn
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1881
IdealRateManagerChannelWidthTest::IdealRateManagerChannelWidthTest
IdealRateManagerChannelWidthTest()
Definition: wifi-test.cc:2664
DcfImmediateAccessBroadcastTestCase::m_secondTransmissionTime
Time m_secondTransmissionTime
second transmission time
Definition: wifi-test.cc:468
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::Packet::Copy
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
ns3::WifiNetDevice::SetRemoteStationManager
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
Definition: wifi-net-device.cc:194
ns3::WifiPhy::ConfigureStandardAndBand
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1070
ns3::Vector3D::Vector
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:324
ns3::PacketSocketAddress::SetPhysicalAddress
void SetPhysicalAddress(const Address address)
Set the destination address.
Definition: packet-socket-address.cc:53
Bug2831TestCase::Bug2831TestCase
Bug2831TestCase()
Definition: wifi-test.cc:1661
Bug2843TestCase::~Bug2843TestCase
virtual ~Bug2843TestCase()
Definition: wifi-test.cc:1494
third.ssid
ssid
Definition: third.py:100
ns3::WifiPhy::GetChannelWidth
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1234
StaWifiMacScanningTestCase::Setup
NodeContainer Setup(bool nearestApBeaconGeneration, bool staActiveProbe)
Setup test.
Definition: wifi-test.cc:1897
DcfImmediateAccessBroadcastTestCase::SendOnePacket
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:499
IdealRateManagerChannelWidthTest::TxCallback
void TxCallback(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2704
ns3::MobilityModel
Keep track of the current position and velocity of an object.
Definition: mobility-model.h:40
ns3::NodeContainer
keep track of a set of node pointers.
Definition: node-container.h:39
Bug2843TestCase::SendPacketBurst
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:1531
Bug2470TestCase::m_receivedAmpduCount
uint16_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:2072
Bug2470TestCase::RunSubtest
void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel)
Run subtest for this test suite.
Definition: wifi-test.cc:2164
ns3::WifiMacHelper::SetType
void SetType(std::string type, Args &&... args)
Definition: wifi-mac-helper.h:130
InterferenceHelperSequenceTest::InterferenceHelperSequenceTest
InterferenceHelperSequenceTest()
Definition: wifi-test.cc:298
Bug2831TestCase::m_reassocReqCount
uint16_t m_reassocReqCount
count number of reassociation requests
Definition: wifi-test.cc:1655
ns3::PacketSocketAddress::SetProtocol
void SetProtocol(uint16_t protocol)
Set the protocol.
Definition: packet-socket-address.cc:33
ns3::RxPowerWattPerChannelBand
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
QosUtilsIsOldPacketTest::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:241
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition: object-factory.cc:40
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
Bug730TestCase
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:602
g_wifiTestSuite
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:3192
ns3::YansWifiPhy
802.11 PHY layer model
Definition: yans-wifi-phy.h:48
Bug2470TestCase::m_addbaRejectedCount
uint16_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:2076
SetChannelFrequencyTest
Set Channel Frequency Test.
Definition: wifi-test.cc:900
IdealRateManagerMimoTest::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2899
ns3::YansWifiChannelHelper
manage and create wifi channel objects for the YANS model.
Definition: yans-wifi-helper.h:37
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Definition: object-factory.cc:98
Bug2831TestCase::m_countOperationalChannelWidth40
uint16_t m_countOperationalChannelWidth40
count number of beacon frames announcing a 40 MHz operating channel width
Definition: wifi-test.cc:1658
ns3::WifiMacHelper
create MAC layers for a ns3::WifiNetDevice.
Definition: wifi-mac-helper.h:48
ns3::MgtProbeResponseHeader::GetHtOperation
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:262
ns3::HtOperation
The HT Operation Information Element.
Definition: ht-operation.h:51
ns3::MpduInfo::type
MpduType type
type of MPDU
Definition: phy-entity.h:61
ns3::WIFI_STANDARD_80211n_2_4GHZ
@ WIFI_STANDARD_80211n_2_4GHZ
Definition: wifi-standards.h:131
ns3::ObjectBase::TraceConnectWithoutContext
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
ns3::WifiMacHeader::IsReassocReq
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
Definition: wifi-mac-header.cc:681
Bug730TestCase::Bug730TestCase
Bug730TestCase()
Definition: wifi-test.cc:623
ns3::WifiMode::GetDataRate
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:114
ns3::WIFI_MOD_CLASS_VHT
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
Definition: wifi-phy-common.h:131
Bug2831TestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1714
Bug2470TestCase::AddbaStateChangedCallback
void AddbaStateChangedCallback(std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
Callback when ADDBA state changed.
Definition: wifi-test.cc:2099
Bug2222TestCase::Bug2222TestCase
Bug2222TestCase()
Definition: wifi-test.cc:1339
ns3::SpectrumWifiPhyHelper::SetChannel
void SetChannel(Ptr< SpectrumChannel > channel)
Definition: spectrum-wifi-helper.cc:44
ns3::WifiPhy::SetChannelNumber
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1175
InterferenceHelperSequenceTest::CreateOne
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:318
StaWifiMacScanningTestCase::StaWifiMacScanningTestCase
StaWifiMacScanningTestCase()
Definition: wifi-test.cc:1865
IdealRateManagerMimoTest::m_txVector
WifiTxVector m_txVector
Store the last TXVECTOR used to transmit Data.
Definition: wifi-test.cc:2842
IdealRateManagerMimoTest::CheckLastSelectedNss
void CheckLastSelectedNss(uint8_t expectedNss)
Check if the selected Nss is correct.
Definition: wifi-test.cc:2887
QosFragmentationTestCase::Transmit
void Transmit(std::string context, Ptr< const Packet > p, double power)
Callback invoked when PHY transmits a packet.
Definition: wifi-test.cc:789
ns3::PacketSocketServer::SetLocal
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
Definition: packet-socket-server.cc:102
Bug2470TestCase::Bug2470TestCase
Bug2470TestCase()
Definition: wifi-test.cc:2081
Issue40TestCase::m_txMacFinalDataFailedCount
uint16_t m_txMacFinalDataFailedCount
Count number of unsuccessfully transmitted data packets.
Definition: wifi-test.cc:2345
ns3::WifiNetDevice::GetBroadcast
Address GetBroadcast(void) const override
Definition: wifi-net-device.cc:284
ns3::WifiPhy::SetDevice
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:778
Bug2831TestCase::RxCallback
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:1684
ns3::NetDeviceContainer::Get
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Definition: net-device-container.cc:62
ns3::WifiPhy::SetOperatingChannel
void SetOperatingChannel(uint8_t number, uint16_t frequency, uint16_t width)
Set the operating channel according to the specified parameters.
Definition: wifi-phy.cc:1257
ns3::NetDevice::GetIfIndex
virtual uint32_t GetIfIndex(void) const =0
ns3::WifiPhyHelper::Set
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:140
DcfImmediateAccessBroadcastTestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:506
WifiTest::m_mac
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:125
InterferenceHelperSequenceTest::m_mac
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:294
SetChannelFrequencyTest::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:931
ns3::WifiPhy::SetErrorRateModel
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:809
ns3::MobilityHelper
Helper class used to assign positions and mobility models to nodes.
Definition: mobility-helper.h:43
Issue40TestCase::RunOne
void RunOne(bool useAmpdu)
Run one function.
Definition: wifi-test.cc:2384
ns3::SpectrumWifiPhyHelper
Make it easy to create and manage PHY objects for the spectrum model.
Definition: spectrum-wifi-helper.h:38
Bug730TestCase::m_received
uint32_t m_received
received
Definition: wifi-test.cc:611
ns3::WifiTxVector::GetMode
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.
Definition: wifi-tx-vector.cc:112
third.mobility
mobility
Definition: third.py:108
ns3::WifiModulationClass
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
Definition: wifi-phy-common.h:122
ns3::WifiMacHeader::IsAction
bool IsAction(void) const
Return true if the header is an Action header.
Definition: wifi-mac-header.cc:729
ns3::WifiNetDevice::SetPhy
void SetPhy(const Ptr< WifiPhy > phy)
Definition: wifi-net-device.cc:187
third.phy
phy
Definition: third.py:93
HeRuMcsDataRateTestCase::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3125
ns3::SpectrumModel::Begin
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start.
Definition: spectrum-model.cc:88
ns3::WifiNetDevice::GetMac
Ptr< WifiMac > GetMac(void) const
Definition: wifi-net-device.cc:201
InterferenceHelperSequenceTest::SwitchCh
void SwitchCh(Ptr< WifiNetDevice > dev)
Switch channel function.
Definition: wifi-test.cc:311
QosFragmentationTestCase::~QosFragmentationTestCase
virtual ~QosFragmentationTestCase()
Definition: wifi-test.cc:775
WifiTest::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:198
ns3::Txop
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:65