A Discrete-Event Network Simulator
API
wifi-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  * 2010 NICTA
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Quincy Tse <quincy.tse@nicta.com.au>
21  * S├ębastien Deronne <sebastien.deronne@gmail.com>
22  */
23 
24 #include "ns3/string.h"
25 #include "ns3/yans-wifi-helper.h"
26 #include "ns3/mobility-helper.h"
27 #include "ns3/wifi-net-device.h"
28 #include "ns3/adhoc-wifi-mac.h"
29 #include "ns3/ap-wifi-mac.h"
30 #include "ns3/propagation-loss-model.h"
31 #include "ns3/yans-error-rate-model.h"
32 #include "ns3/constant-position-mobility-model.h"
33 #include "ns3/test.h"
34 #include "ns3/pointer.h"
35 #include "ns3/rng-seed-manager.h"
36 #include "ns3/config.h"
37 #include "ns3/error-model.h"
38 #include "ns3/socket.h"
39 #include "ns3/packet-socket-server.h"
40 #include "ns3/packet-socket-client.h"
41 #include "ns3/packet-socket-helper.h"
42 #include "ns3/spectrum-wifi-helper.h"
43 #include "ns3/multi-model-spectrum-channel.h"
44 #include "ns3/wifi-spectrum-signal-parameters.h"
45 #include "ns3/yans-wifi-phy.h"
46 #include "ns3/mgt-headers.h"
47 #include "ns3/ht-configuration.h"
48 #include "ns3/wifi-ppdu.h"
49 #include "ns3/wifi-psdu.h"
50 #include "ns3/waypoint-mobility-model.h"
51 
52 using namespace ns3;
53 
54 //Helper function to assign streams to random variables, to control
55 //randomness in the tests
56 static void
58 {
59  int64_t currentStream = stream;
60  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
61  if (rmac)
62  {
63  PointerValue ptr;
64  rmac->GetAttribute ("Txop", ptr);
65  Ptr<Txop> txop = ptr.Get<Txop> ();
66  currentStream += txop->AssignStreams (currentStream);
67 
68  rmac->GetAttribute ("VO_Txop", ptr);
69  Ptr<QosTxop> vo_txop = ptr.Get<QosTxop> ();
70  currentStream += vo_txop->AssignStreams (currentStream);
71 
72  rmac->GetAttribute ("VI_Txop", ptr);
73  Ptr<QosTxop> vi_txop = ptr.Get<QosTxop> ();
74  currentStream += vi_txop->AssignStreams (currentStream);
75 
76  rmac->GetAttribute ("BE_Txop", ptr);
77  Ptr<QosTxop> be_txop = ptr.Get<QosTxop> ();
78  currentStream += be_txop->AssignStreams (currentStream);
79 
80  rmac->GetAttribute ("BK_Txop", ptr);
81  Ptr<QosTxop> bk_txop = ptr.Get<QosTxop> ();
82  bk_txop->AssignStreams (currentStream);
83  }
84 }
85 
92 class WifiTest : public TestCase
93 {
94 public:
95  WifiTest ();
96 
97  virtual void DoRun (void);
98 
99 
100 private:
102  void RunOne (void);
108  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
114 
118 };
119 
121  : TestCase ("Wifi")
122 {
123 }
124 
125 void
127 {
128  Ptr<Packet> p = Create<Packet> ();
129  dev->Send (p, dev->GetBroadcast (), 1);
130 }
131 
132 void
134 {
135  Ptr<Node> node = CreateObject<Node> ();
136  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
137 
139  mac->SetDevice (dev);
140  mac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
141  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
142  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
143  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
144  phy->SetErrorRateModel (error);
145  phy->SetChannel (channel);
146  phy->SetDevice (dev);
147  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
149 
150  mobility->SetPosition (pos);
151  node->AggregateObject (mobility);
152  mac->SetAddress (Mac48Address::Allocate ());
153  dev->SetMac (mac);
154  dev->SetPhy (phy);
155  dev->SetRemoteStationManager (manager);
156  node->AddDevice (dev);
157 
158  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
159 }
160 
161 void
163 {
164  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
166  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
167  channel->SetPropagationDelayModel (propDelay);
168  channel->SetPropagationLossModel (propLoss);
169 
170  CreateOne (Vector (0.0, 0.0, 0.0), channel);
171  CreateOne (Vector (5.0, 0.0, 0.0), channel);
172  CreateOne (Vector (5.0, 0.0, 0.0), channel);
173 
174  Simulator::Stop (Seconds (10.0));
175 
176  Simulator::Run ();
177  Simulator::Destroy ();
178 }
179 
180 void
182 {
183  m_mac.SetTypeId ("ns3::AdhocWifiMac");
184  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
185 
186  m_manager.SetTypeId ("ns3::ArfWifiManager");
187  RunOne ();
188  m_manager.SetTypeId ("ns3::AarfWifiManager");
189  RunOne ();
190  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
191  RunOne ();
192  m_manager.SetTypeId ("ns3::OnoeWifiManager");
193  RunOne ();
194  m_manager.SetTypeId ("ns3::AmrrWifiManager");
195  RunOne ();
196  m_manager.SetTypeId ("ns3::IdealWifiManager");
197  RunOne ();
198 
199  m_mac.SetTypeId ("ns3::AdhocWifiMac");
200  RunOne ();
201  m_mac.SetTypeId ("ns3::ApWifiMac");
202  RunOne ();
203  m_mac.SetTypeId ("ns3::StaWifiMac");
204  RunOne ();
205 
206 
207  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
208  m_mac.SetTypeId ("ns3::AdhocWifiMac");
209  RunOne ();
210 }
211 
219 {
220 public:
221  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
222  {
223  }
224  virtual void DoRun (void)
225  {
226  //startingSeq=0, seqNum=2047
227  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
228  //startingSeq=0, seqNum=2048
229  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
230  //startingSeq=2048, seqNum=0
231  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
232  //startingSeq=4095, seqNum=0
233  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
234  //startingSeq=0, seqNum=4095
235  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
236  //startingSeq=4095 seqNum=2047
237  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
238  //startingSeq=2048 seqNum=4095
239  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
240  //startingSeq=2049 seqNum=0
241  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
242  }
243 };
244 
245 
250 {
251 public:
253 
254  virtual void DoRun (void);
255 
256 
257 private:
274  void SwitchCh (Ptr<WifiNetDevice> dev);
275 
279 };
280 
282  : TestCase ("InterferenceHelperSequence")
283 {
284 }
285 
286 void
288 {
289  Ptr<Packet> p = Create<Packet> (1000);
290  dev->Send (p, dev->GetBroadcast (), 1);
291 }
292 
293 void
295 {
296  Ptr<WifiPhy> p = dev->GetPhy ();
297  p->SetChannelNumber (1);
298 }
299 
300 Ptr<Node>
302 {
303  Ptr<Node> node = CreateObject<Node> ();
304  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
305 
307  mac->SetDevice (dev);
308  mac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
309  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
310  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
311  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
312  phy->SetErrorRateModel (error);
313  phy->SetChannel (channel);
314  phy->SetDevice (dev);
315  phy->SetMobility (mobility);
316  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
318 
319  mobility->SetPosition (pos);
320  node->AggregateObject (mobility);
321  mac->SetAddress (Mac48Address::Allocate ());
322  dev->SetMac (mac);
323  dev->SetPhy (phy);
324  dev->SetRemoteStationManager (manager);
325  node->AddDevice (dev);
326 
327  return node;
328 }
329 
330 void
332 {
333  m_mac.SetTypeId ("ns3::AdhocWifiMac");
334  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
335  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
336 
337  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
339  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
340  channel->SetPropagationDelayModel (propDelay);
341  channel->SetPropagationLossModel (propLoss);
342 
343  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
344  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
345  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
346 
347  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
348  propLoss->SetDefaultLoss (999);
349 
350  Simulator::Schedule (Seconds (1.0),
352  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
353 
354  Simulator::Schedule (Seconds (1.0000001),
356  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
357 
358  Simulator::Schedule (Seconds (5.0),
360  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
361 
362  Simulator::Schedule (Seconds (7.0),
364  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
365 
366  Simulator::Stop (Seconds (100.0));
367  Simulator::Run ();
368 
369  Simulator::Destroy ();
370 }
371 
372 
373 //-----------------------------------------------------------------------------
425 {
426 public:
428 
429  virtual void DoRun (void);
430 
431 
432 private:
438 
442 
445  unsigned int m_numSentPackets;
446 
452  void NotifyPhyTxBegin (Ptr<const Packet> p, double txPowerW);
453 };
454 
456  : TestCase ("Test case for DCF immediate access with broadcast frames")
457 {
458 }
459 
460 void
462 {
463  if (m_numSentPackets == 0)
464  {
467  }
468  else if (m_numSentPackets == 1)
469  {
471  }
472 }
473 
474 void
476 {
477  Ptr<Packet> p = Create<Packet> (1000);
478  dev->Send (p, dev->GetBroadcast (), 1);
479 }
480 
481 void
483 {
484  m_mac.SetTypeId ("ns3::AdhocWifiMac");
485  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
486  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
487 
488  //Assign a seed and run number, and later fix the assignment of streams to
489  //WiFi random variables, so that the first backoff used is one slot
490  RngSeedManager::SetSeed (1);
491  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
492 
493  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
495  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
496  channel->SetPropagationDelayModel (propDelay);
497  channel->SetPropagationLossModel (propLoss);
498 
499  Ptr<Node> txNode = CreateObject<Node> ();
500  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
501  Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
502  txMac->SetDevice (txDev);
503  txMac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
504  //Fix the stream assignment to the Dcf Txop objects (backoffs)
505  //The below stream assignment will result in the Txop object
506  //using a backoff value of zero for this test when the
507  //Txop::EndTxNoAck() calls to StartBackoffNow()
508  AssignWifiRandomStreams (txMac, 23);
509 
510  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
511  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
512  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
513  txPhy->SetErrorRateModel (txError);
514  txPhy->SetChannel (channel);
515  txPhy->SetDevice (txDev);
516  txPhy->SetMobility (txMobility);
517  txPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
518 
519  txPhy->TraceConnectWithoutContext ("PhyTxBegin", MakeCallback (&DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin, this));
520 
521  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
522  txNode->AggregateObject (txMobility);
523  txMac->SetAddress (Mac48Address::Allocate ());
524  txDev->SetMac (txMac);
525  txDev->SetPhy (txPhy);
526  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
527  txNode->AddDevice (txDev);
528 
531  m_numSentPackets = 0;
532 
533  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
534  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
535 
536  Simulator::Stop (Seconds (2.0));
537  Simulator::Run ();
538  Simulator::Destroy ();
539 
540  // First packet is transmitted a DIFS after the packet is queued. A DIFS
541  // is 2 slots (2 * 9 = 18 us) plus a SIFS (16 us), i.e., 34 us
542  Time expectedFirstTransmissionTime = Seconds (1.0) + MicroSeconds (34);
543 
544  //First packet has 1408 us of transmit time. Slot time is 9 us.
545  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
546  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
547  //1451 us after the first one.
548  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
549  Time expectedSecondTransmissionTime = expectedFirstTransmissionTime + MicroSeconds (expectedWait1);
550  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, expectedFirstTransmissionTime, "The first transmission time not correct!");
551 
552  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
553 }
554 
555 
556 //-----------------------------------------------------------------------------
569 class Bug730TestCase : public TestCase
570 {
571 public:
572  Bug730TestCase ();
573  virtual ~Bug730TestCase ();
574 
575  virtual void DoRun (void);
576 
577 
578 private:
579  uint32_t m_received;
580 
587  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
588 
589 };
590 
592  : TestCase ("Test case for Bug 730"),
593  m_received (0)
594 {
595 }
596 
598 {
599 }
600 
601 void
602 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
603 {
604  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
605  {
606  m_received++;
607  }
608 }
609 
610 
611 void
613 {
614  m_received = 0;
615 
616  NodeContainer wifiStaNode;
617  wifiStaNode.Create (1);
618 
620  wifiApNode.Create (1);
621 
622  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
623  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
624  phy.SetChannel (channel.Create ());
625 
627  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
628  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
629  "DataMode", StringValue ("DsssRate1Mbps"),
630  "ControlMode", StringValue ("DsssRate1Mbps"));
631 
633  Ssid ssid = Ssid ("ns-3-ssid");
634  mac.SetType ("ns3::StaWifiMac",
635  "Ssid", SsidValue (ssid),
636  "ActiveProbing", BooleanValue (false));
637 
639  staDevices = wifi.Install (phy, mac, wifiStaNode);
640 
641  mac.SetType ("ns3::ApWifiMac",
642  "Ssid", SsidValue (ssid),
643  "BeaconGeneration", BooleanValue (true));
644 
646  apDevices = wifi.Install (phy, mac, wifiApNode);
647 
649  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
650 
651  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
652  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
653  mobility.SetPositionAllocator (positionAlloc);
654 
655  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
656  mobility.Install (wifiApNode);
657  mobility.Install (wifiStaNode);
658 
659  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
660  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
661 
662  PacketSocketAddress socket;
663  socket.SetSingleDevice (sta_device->GetIfIndex ());
664  socket.SetPhysicalAddress (ap_device->GetAddress ());
665  socket.SetProtocol (1);
666 
667  // give packet socket powers to nodes.
668  PacketSocketHelper packetSocket;
669  packetSocket.Install (wifiStaNode);
670  packetSocket.Install (wifiApNode);
671 
672  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
673  client->SetAttribute ("PacketSize", UintegerValue (1460));
674  client->SetRemote (socket);
675  wifiStaNode.Get (0)->AddApplication (client);
676  client->SetStartTime (Seconds (1));
677  client->SetStopTime (Seconds (51.0));
678 
679  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
680  server->SetLocal (socket);
681  wifiApNode.Get (0)->AddApplication (server);
682  server->SetStartTime (Seconds (0.0));
683  server->SetStopTime (Seconds (52.0));
684 
685  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
686 
687  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
688 
689  Simulator::Stop (Seconds (55));
690  Simulator::Run ();
691 
692  Simulator::Destroy ();
693 
694  bool result = (m_received > 0);
695  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
696 }
697 
698 //-----------------------------------------------------------------------------
707 {
708 public:
710  virtual ~QosFragmentationTestCase ();
711 
712  virtual void DoRun (void);
713 
714 
715 private:
716  uint32_t m_received;
717  uint32_t m_fragments;
718 
725  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
726 
733  void Transmit (std::string context, Ptr<const Packet> p, double power);
734 };
735 
737  : TestCase ("Test case for fragmentation with QoS stations"),
738  m_received (0),
739  m_fragments (0)
740 {
741 }
742 
744 {
745 }
746 
747 void
748 QosFragmentationTestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
749 {
750  if (p->GetSize () == 1400)
751  {
752  m_received++;
753  }
754 }
755 
756 void
757 QosFragmentationTestCase::Transmit (std::string context, Ptr<const Packet> p, double power)
758 {
759  WifiMacHeader hdr;
760  p->PeekHeader (hdr);
761  if (hdr.IsQosData ())
762  {
763  NS_TEST_EXPECT_MSG_LT_OR_EQ (p->GetSize (), 400, "Unexpected fragment size");
764  m_fragments++;
765  }
766 }
767 
768 void
770 {
771  NodeContainer wifiStaNode;
772  wifiStaNode.Create (1);
773 
775  wifiApNode.Create (1);
776 
777  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
778  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
779  phy.SetChannel (channel.Create ());
780 
782  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
783  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
784  "DataMode", StringValue ("HtMcs7"));
785 
787  Ssid ssid = Ssid ("ns-3-ssid");
788  mac.SetType ("ns3::StaWifiMac",
789  "Ssid", SsidValue (ssid),
790  "ActiveProbing", BooleanValue (false));
791 
793  staDevices = wifi.Install (phy, mac, wifiStaNode);
794 
795  mac.SetType ("ns3::ApWifiMac",
796  "Ssid", SsidValue (ssid),
797  "BeaconGeneration", BooleanValue (true));
798 
800  apDevices = wifi.Install (phy, mac, wifiApNode);
801 
803  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
804 
805  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
806  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
807  mobility.SetPositionAllocator (positionAlloc);
808 
809  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
810  mobility.Install (wifiApNode);
811  mobility.Install (wifiStaNode);
812 
813  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
814  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
815 
816  // set the TXOP limit on BE AC
817  Ptr<RegularWifiMac> sta_mac = DynamicCast<RegularWifiMac> (sta_device->GetMac ());
818  NS_ASSERT (sta_mac);
819  PointerValue ptr;
820  sta_mac->GetAttribute ("BE_Txop", ptr);
821  ptr.Get<QosTxop> ()->SetTxopLimit (MicroSeconds (3008));
822 
823  PacketSocketAddress socket;
824  socket.SetSingleDevice (sta_device->GetIfIndex ());
825  socket.SetPhysicalAddress (ap_device->GetAddress ());
826  socket.SetProtocol (1);
827 
828  // give packet socket powers to nodes.
829  PacketSocketHelper packetSocket;
830  packetSocket.Install (wifiStaNode);
831  packetSocket.Install (wifiApNode);
832 
833  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
834  client->SetAttribute ("PacketSize", UintegerValue (1400));
835  client->SetAttribute ("MaxPackets", UintegerValue (1));
836  client->SetRemote (socket);
837  wifiStaNode.Get (0)->AddApplication (client);
838  client->SetStartTime (Seconds (1));
839  client->SetStopTime (Seconds (3.0));
840 
841  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
842  server->SetLocal (socket);
843  wifiApNode.Get (0)->AddApplication (server);
844  server->SetStartTime (Seconds (0.0));
845  server->SetStopTime (Seconds (4.0));
846 
847  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&QosFragmentationTestCase::Receive, this));
848 
849  Config::Set ("/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("400"));
850  Config::Connect ("/NodeList/0/DeviceList/0/Phy/PhyTxBegin", MakeCallback (&QosFragmentationTestCase::Transmit, this));
851 
852  Simulator::Stop (Seconds (5));
853  Simulator::Run ();
854 
855  Simulator::Destroy ();
856 
857  NS_TEST_ASSERT_MSG_EQ (m_received, 1, "Unexpected number of received packets");
858  NS_TEST_ASSERT_MSG_EQ (m_fragments, 4, "Unexpected number of transmitted fragments");
859 }
860 
868 {
869 public:
871 
872  virtual void DoRun (void);
873 
874 
875 private:
882 
883 };
884 
886  : TestCase ("Test case for setting WifiPhy channel and frequency")
887 {
888 }
889 
892 {
893  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
894  Ptr<WifiPhy> wp = wnd->GetPhy ();
895  return wp->GetObject<YansWifiPhy> ();
896 }
897 
898 void
900 {
901  NodeContainer wifiStaNode;
902  wifiStaNode.Create (1);
904  wifiApNode.Create (1);
905 
906  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
907  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
908  phy.SetChannel (channel.Create ());
909 
910  // Configure and declare other generic components of this example
911  Ssid ssid;
912  ssid = Ssid ("wifi-phy-configuration");
913  WifiMacHelper macSta;
914  macSta.SetType ("ns3::StaWifiMac",
915  "Ssid", SsidValue (ssid),
916  "ActiveProbing", BooleanValue (false));
917  NetDeviceContainer staDevice;
918  Ptr<YansWifiPhy> phySta;
919 
920  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
921  {
922  // case 0
923  // Default configuration, without WifiHelper::SetStandard or WifiHelper
924  phySta = CreateObject<YansWifiPhy> ();
925  // The default results in an invalid configuration of channel 0,
926  // width 20, and frequency 0 MHz
927  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "default configuration");
928  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
929  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 0, "default configuration");
930  }
931  {
932  // case 1
934  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
935  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
936  phySta = GetYansWifiPhyPtr (staDevice);
937  // We expect channel 36, width 20, frequency 5180
938  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
939  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
940  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
941  }
942  {
943  // case 2
945  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
946  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
947  phySta = GetYansWifiPhyPtr (staDevice);
948  // We expect channel 1, width 22, frequency 2412
949  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
950  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
951  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
952  }
953  {
954  // case 3
956  wifi.SetStandard (WIFI_PHY_STANDARD_80211g);
957  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
958  phySta = GetYansWifiPhyPtr (staDevice);
959  // We expect channel 1, width 20, frequency 2412
960  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
961  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
962  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
963  }
964  {
965  // case 4
967  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
968  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
969  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
970  phySta = GetYansWifiPhyPtr (staDevice);
971  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
972  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
973  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
974  }
975  {
976  // case 5
978  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
980  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
981  phySta = GetYansWifiPhyPtr (staDevice);
982  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
983  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
984  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
985  }
986  {
987  // case 6
989  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
990  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
991  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
992  phySta = GetYansWifiPhyPtr (staDevice);
993  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
994  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
995  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
996  }
997  {
998  // case 7
1000  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1001  wifi.SetStandard (WIFI_PHY_STANDARD_80211_10MHZ);
1002  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1003  phySta = GetYansWifiPhyPtr (staDevice);
1004  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11 10Mhz configuration");
1005  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11 10Mhz configuration");
1006  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 10Mhz configuration");
1007  }
1008  {
1009  // case 8
1010  WifiHelper wifi;
1011  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1012  wifi.SetStandard (WIFI_PHY_STANDARD_80211_5MHZ);
1013  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1014  phySta = GetYansWifiPhyPtr (staDevice);
1015  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5Mhz configuration");
1016  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11 5Mhz configuration");
1017  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 5Mhz configuration");
1018  }
1019  {
1020  // case 9
1021  WifiHelper wifi;
1022  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1023  wifi.SetStandard (WIFI_PHY_STANDARD_holland);
1024  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1025  phySta = GetYansWifiPhyPtr (staDevice);
1026  // We expect channel 36, width 20, frequency 5180
1027  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
1028  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
1029  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
1030  }
1031  {
1032  // case 10
1033  WifiHelper wifi;
1034  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1035  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1036  phy.Set ("ChannelNumber", UintegerValue (44));
1037  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1038  phySta = GetYansWifiPhyPtr (staDevice);
1039  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1040  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1041  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1042  }
1043  {
1044  // case 11
1045  WifiHelper wifi;
1046  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1047  phy.Set ("ChannelNumber", UintegerValue (44));
1048  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1049  phySta = GetYansWifiPhyPtr (staDevice);
1050  // Post-install reconfiguration to channel number 40
1051  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber", UintegerValue (40));
1052  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1053  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1054  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1055  }
1056  {
1057  // case 12
1058  WifiHelper wifi;
1059  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1060  phy.Set ("ChannelNumber", UintegerValue (44));
1061  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1062  phySta = GetYansWifiPhyPtr (staDevice);
1063  // Post-install reconfiguration to channel width 40 MHz
1064  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
1065  // Although channel 44 is configured originally for 20 MHz, we
1066  // allow it to be used for 40 MHz here
1067  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1068  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1069  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1070  }
1071  {
1072  // case 13
1073  WifiHelper wifi;
1074  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1075  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1076  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1077  phySta = GetYansWifiPhyPtr (staDevice);
1078  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
1079  // Post-install reconfiguration to channel width 40 MHz
1080  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
1081  // Although channel 44 is configured originally for 20 MHz, we
1082  // allow it to be used for 40 MHz here
1083  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1084  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1085  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1086  }
1087  {
1088  // case 14
1089  WifiHelper wifi;
1090  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1091  // Test that setting Frequency to a non-standard value will zero the
1092  // channel number
1093  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1094  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1095  phySta = GetYansWifiPhyPtr (staDevice);
1096  phySta->SetAttribute ("Frequency", UintegerValue (5281));
1097  // We expect channel number to be zero since frequency doesn't match
1098  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1099  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1100  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5281, "802.11 5GHz configuration");
1101  }
1102  {
1103  // case 15:
1104  WifiHelper wifi;
1105  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1106  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1107  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1108  phySta = GetYansWifiPhyPtr (staDevice);
1109  // Test that setting Frequency to a standard value will set the
1110  // channel number correctly
1111  phySta->SetAttribute ("Frequency", UintegerValue (5500));
1112  // We expect channel number to be 100 due to frequency 5500
1113  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
1114  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1115  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
1116  }
1117  {
1118  // case 16:
1119  WifiHelper wifi;
1120  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1121  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1122  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1123  phySta = GetYansWifiPhyPtr (staDevice);
1124  // This case will error exit due to invalid channel number unless
1125  // we provide the DefineChannelNumber() below
1126  phySta->DefineChannelNumber (99, WIFI_PHY_STANDARD_80211n_5GHZ, 5185, 40);
1127  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
1128  }
1129  {
1130  // case 17:
1131  WifiHelper wifi;
1132  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1133  // Test how channel number behaves when frequency is non-standard
1134  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1135  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1136  phySta = GetYansWifiPhyPtr (staDevice);
1137  phySta->SetAttribute ("Frequency", UintegerValue (5181));
1138  // We expect channel number to be 0 due to unknown center frequency 5181
1139  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1140  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1141  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5181, "802.11 5GHz configuration");
1142  phySta->SetAttribute ("Frequency", UintegerValue (5180));
1143  // We expect channel number to be 36 due to known center frequency 5180
1144  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1145  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1146  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1147  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1148  // We expect channel number to be 0 due to unknown center frequency 5179
1149  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1150  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1151  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1152  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1153  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1154  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1155  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1156  }
1157  {
1158  // case 18:
1159  WifiHelper wifi;
1160  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1161  // Set both channel and frequency to consistent values
1162  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1163  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1164  phySta = GetYansWifiPhyPtr (staDevice);
1165  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1166  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
1167  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1168  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1169  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1170  // Set both channel and frequency to inconsistent values
1171  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1172  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1173  // We expect channel number to be 36
1174  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1175  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1176  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1177  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1178  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1179  // We expect channel number to be 40
1180  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1181  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1182  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1183  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1184  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1185  // We expect channel number to be 36
1186  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1187  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1188  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1189  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1190  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1191  // We expect channel number to be 0
1192  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1193  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1194  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1195  }
1196 
1197  Simulator::Destroy ();
1198 }
1199 
1200 //-----------------------------------------------------------------------------
1209 {
1210 public:
1211  Bug2222TestCase ();
1212  virtual ~Bug2222TestCase ();
1213 
1214  virtual void DoRun (void);
1215 
1216 
1217 private:
1219 
1221  void PopulateArpCache ();
1227  void TxDataFailedTrace (std::string context, Mac48Address adress);
1228 };
1229 
1231  : TestCase ("Test case for Bug 2222"),
1232  m_countInternalCollisions (0)
1233 {
1234 }
1235 
1237 {
1238 }
1239 
1240 void
1242 {
1243  //Indicate the long retry counter has been increased in the wifi remote station manager
1245 }
1246 
1247 void
1249 {
1251 
1252  //Generate same backoff for AC_VI and AC_VO
1253  //The below combination will work
1254  RngSeedManager::SetSeed (1);
1255  RngSeedManager::SetRun (16);
1256  int64_t streamNumber = 100;
1257 
1258  NodeContainer wifiNodes;
1259  wifiNodes.Create (2);
1260 
1261  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1262  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1263  phy.SetChannel (channel.Create ());
1264 
1265  WifiHelper wifi;
1266  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1267  "DataMode", StringValue ("OfdmRate54Mbps"),
1268  "ControlMode", StringValue ("OfdmRate24Mbps"));
1270  Ssid ssid = Ssid ("ns-3-ssid");
1271  mac.SetType ("ns3::AdhocWifiMac",
1272  "QosSupported", BooleanValue (true));
1273 
1274  NetDeviceContainer wifiDevices;
1275  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1276 
1277  // Assign fixed streams to random variables in use
1278  wifi.AssignStreams (wifiDevices, streamNumber);
1279 
1281  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1282 
1283  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1284  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1285  mobility.SetPositionAllocator (positionAlloc);
1286 
1287  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1288  mobility.Install (wifiNodes);
1289 
1290  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1291  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1292 
1293  PacketSocketAddress socket;
1294  socket.SetSingleDevice (device1->GetIfIndex ());
1295  socket.SetPhysicalAddress (device2->GetAddress ());
1296  socket.SetProtocol (1);
1297 
1298  PacketSocketHelper packetSocket;
1299  packetSocket.Install (wifiNodes);
1300 
1301  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1302  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1303  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1304  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1305  clientLowPriority->SetRemote (socket);
1306  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1307  clientLowPriority->SetStartTime (Seconds (0.0));
1308  clientLowPriority->SetStopTime (Seconds (1.0));
1309 
1310  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1311  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1312  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1313  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1314  clientHighPriority->SetRemote (socket);
1315  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1316  clientHighPriority->SetStartTime (Seconds (0.0));
1317  clientHighPriority->SetStopTime (Seconds (1.0));
1318 
1319  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1320  server->SetLocal (socket);
1321  wifiNodes.Get (1)->AddApplication (server);
1322  server->SetStartTime (Seconds (0.0));
1323  server->SetStopTime (Seconds (1.0));
1324 
1325  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1326 
1327  Simulator::Stop (Seconds (1.0));
1328  Simulator::Run ();
1329  Simulator::Destroy ();
1330 
1331  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1332 }
1333 
1334 //-----------------------------------------------------------------------------
1348 {
1349 public:
1350  Bug2843TestCase ();
1351  virtual ~Bug2843TestCase ();
1352  virtual void DoRun (void);
1353 
1354 private:
1358  typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1359  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1360 
1367  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1374  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1375 
1376  uint16_t m_channelWidth;
1377 };
1378 
1380  : TestCase ("Test case for Bug 2843"),
1381  m_channelWidth (20)
1382 {
1383 }
1384 
1386 {
1387 }
1388 
1389 void
1391 {
1392  // Extract starting frequency and number of subbands
1393  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1394  std::size_t numBands = c->GetNumBands ();
1395  double startingFreq = c->Begin ()->fl;
1396 
1397  // Get channel bandwidth and modulation class
1398  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1399 
1400  Ptr<WifiPpdu> ppdu = Copy (wifiTxParams->ppdu);
1401  WifiTxVector txVector = ppdu->GetTxVector ();
1402  m_channelWidth = txVector.GetChannelWidth ();
1403  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1404 
1405  // Build a tuple and check if seen before (if so store it)
1406  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, m_channelWidth, numBands, modulationClass);
1407  bool found = false;
1408  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1409  {
1410  if (*it == tupleForCurrentTx)
1411  {
1412  found = true;
1413  }
1414  }
1415  if (!found)
1416  {
1417  m_distinctTuples.push_back (tupleForCurrentTx);
1418  }
1419 }
1420 
1421 void
1422 Bug2843TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1423  Address& destination) const
1424 {
1425  for (uint8_t i = 0; i < numPackets; i++)
1426  {
1427  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1428  sourceDevice->Send (pkt, destination, 0);
1429  }
1430 }
1431 
1432 void
1434 {
1435  uint16_t channelWidth = 40; // at least 40 MHz expected here
1436 
1437  NodeContainer wifiStaNode;
1438  wifiStaNode.Create (1);
1439 
1441  wifiApNode.Create (1);
1442 
1443  SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default ();
1444  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1445  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1446  lossModel->SetFrequency (5.180e9);
1447  spectrumChannel->AddPropagationLossModel (lossModel);
1448 
1450  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1451  spectrumChannel->SetPropagationDelayModel (delayModel);
1452 
1453  spectrumPhy.SetChannel (spectrumChannel);
1454  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1455  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1456  spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
1457  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1458  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1459 
1460  WifiHelper wifi;
1461  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
1462  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1463  "DataMode", StringValue ("VhtMcs8"),
1464  "ControlMode", StringValue ("VhtMcs8"),
1465  "RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1466 
1468  mac.SetType ("ns3::StaWifiMac");
1469  NetDeviceContainer staDevice;
1470  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1471 
1472  mac.SetType ("ns3::ApWifiMac");
1473  NetDeviceContainer apDevice;
1474  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1475 
1477  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1478  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1479  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1480  mobility.SetPositionAllocator (positionAlloc);
1481 
1482  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1483  mobility.Install (wifiApNode);
1484  mobility.Install (wifiStaNode);
1485 
1486  // Send two 5 packet-bursts
1487  Simulator::Schedule (Seconds (0.5), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1488  Simulator::Schedule (Seconds (0.6), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1489 
1490  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2843TestCase::StoreDistinctTuple, this));
1491 
1492  Simulator::Stop (Seconds (0.8));
1493  Simulator::Run ();
1494 
1495  Simulator::Destroy ();
1496 
1497  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1498  std::size_t numberTuples = m_distinctTuples.size ();
1499  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1500  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");
1501  // Note that the first tuple should the one initiated by the beacon, i.e. non-HT OFDM (20 MHz)
1502  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1503  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)");
1504  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1505  // Second tuple
1506  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1507  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)");
1508  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1509 }
1510 
1511 //-----------------------------------------------------------------------------
1524 {
1525 public:
1526  Bug2831TestCase ();
1527  virtual ~Bug2831TestCase ();
1528  virtual void DoRun (void);
1529 
1530 private:
1534  void ChangeSupportedChannelWidth (void);
1540  void RxCallback (std::string context, Ptr<const Packet> p);
1541 
1544 
1549 };
1550 
1552  : TestCase ("Test case for Bug 2831"),
1553  m_reassocReqCount (0),
1554  m_reassocRespCount (0),
1555  m_countOperationalChannelWidth20 (0),
1556  m_countOperationalChannelWidth40 (0)
1557 {
1558 }
1559 
1561 {
1562 }
1563 
1564 void
1566 {
1567  m_apPhy->SetChannelNumber (38);
1568  m_apPhy->SetChannelWidth (40);
1569  m_staPhy->SetChannelNumber (38);
1570  m_staPhy->SetChannelWidth (40);
1571 }
1572 
1573 void
1575 {
1576  Ptr<Packet> packet = p->Copy ();
1577  WifiMacHeader hdr;
1578  packet->RemoveHeader (hdr);
1579  if (hdr.IsReassocReq ())
1580  {
1582  }
1583  else if (hdr.IsReassocResp ())
1584  {
1586  }
1587  else if (hdr.IsBeacon ())
1588  {
1589  MgtBeaconHeader beacon;
1590  packet->RemoveHeader (beacon);
1591  HtOperation htOperation = beacon.GetHtOperation ();
1592  if (htOperation.GetStaChannelWidth () > 0)
1593  {
1595  }
1596  else
1597  {
1599  }
1600  }
1601 }
1602 
1603 void
1605 {
1606  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1607  ObjectFactory propDelay;
1608  propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1609  Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1610  Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel> ();
1611  channel->SetPropagationDelayModel (propagationDelay);
1612  channel->SetPropagationLossModel (propagationLoss);
1613 
1614  Ptr<Node> apNode = CreateObject<Node> ();
1615  Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1616  Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration> ();
1617  apDev->SetHtConfiguration (apHtConfiguration);
1619  mac.SetTypeId ("ns3::ApWifiMac");
1620  mac.Set ("EnableBeaconJitter", BooleanValue (false));
1621  Ptr<WifiMac> apMac = mac.Create<WifiMac> ();
1622  apMac->SetDevice (apDev);
1624 
1625  Ptr<Node> staNode = CreateObject<Node> ();
1626  Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> ();
1627  Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration> ();
1628  staDev->SetHtConfiguration (staHtConfiguration);
1629  mac.SetTypeId ("ns3::StaWifiMac");
1630  Ptr<WifiMac> staMac = mac.Create<WifiMac> ();
1631  staMac->SetDevice (staDev);
1633 
1634  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
1635  apMobility->SetPosition (Vector (0.0, 0.0, 0.0));
1636  apNode->AggregateObject (apMobility);
1637 
1638  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
1639  m_apPhy = CreateObject<YansWifiPhy> ();
1640  m_apPhy->SetErrorRateModel (error);
1642  m_apPhy->SetMobility (apMobility);
1643  m_apPhy->SetDevice (apDev);
1645  m_apPhy->SetChannelNumber (36);
1646  m_apPhy->SetChannelWidth (20);
1647 
1648  Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel> ();
1649  staMobility->SetPosition (Vector (1.0, 0.0, 0.0));
1650  staNode->AggregateObject (staMobility);
1651 
1652  m_staPhy = CreateObject<YansWifiPhy> ();
1653  m_staPhy->SetErrorRateModel (error);
1655  m_staPhy->SetMobility (staMobility);
1656  m_staPhy->SetDevice (apDev);
1658  m_staPhy->SetChannelNumber (36);
1659  m_staPhy->SetChannelWidth (20);
1660 
1661  apMac->SetAddress (Mac48Address::Allocate ());
1662  apDev->SetMac (apMac);
1663  apDev->SetPhy (m_apPhy);
1664  ObjectFactory manager;
1665  manager.SetTypeId ("ns3::ConstantRateWifiManager");
1666  apDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1667  apNode->AddDevice (apDev);
1668 
1669  staMac->SetAddress (Mac48Address::Allocate ());
1670  staDev->SetMac (staMac);
1671  staDev->SetPhy (m_staPhy);
1672  staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1673  staNode->AddDevice (staDev);
1674 
1675  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this));
1676 
1677  Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1678 
1679  Simulator::Stop (Seconds (3.0));
1680  Simulator::Run ();
1681  Simulator::Destroy ();
1682 
1683  NS_TEST_ASSERT_MSG_EQ (m_reassocReqCount, 1, "Reassociation request not received");
1684  NS_TEST_ASSERT_MSG_EQ (m_reassocRespCount, 1, "Reassociation response not received");
1685  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operational channel width before channel change");
1686  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operational channel width after channel change");
1687 }
1688 
1689 //-----------------------------------------------------------------------------
1706 {
1707 public:
1709  virtual ~StaWifiMacScanningTestCase ();
1710  virtual void DoRun (void);
1711 
1712 private:
1718  void AssocCallback (std::string context, Mac48Address bssid);
1723  void TurnBeaconGenerationOn (Ptr<Node> apNode);
1728  void TurnApOff (Ptr<Node> apNode);
1735  NodeContainer Setup (bool nearestApBeaconGeneration, bool staActiveProbe);
1736 
1738 };
1739 
1741  : TestCase ("Test case for StaWifiMac scanning capability")
1742 {
1743 }
1744 
1746 {
1747 }
1748 
1749 void
1751 {
1752  m_associatedApBssid = bssid;
1753 }
1754 
1755 void
1757 {
1758  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1759  Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac> (netDevice->GetMac ());
1760  mac->SetAttribute ("BeaconGeneration", BooleanValue (true));
1761 }
1762 
1763 void
1765 {
1766  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1767  Ptr<WifiPhy> phy = netDevice->GetPhy ();
1768  phy->SetOffMode ();
1769 }
1770 
1772 StaWifiMacScanningTestCase::Setup (bool nearestApBeaconGeneration, bool staActiveProbe)
1773 {
1774  NodeContainer apNodes;
1775  apNodes.Create (2);
1776 
1777  Ptr<Node> apNodeNearest = CreateObject<Node> ();
1778  Ptr<Node> staNode = CreateObject<Node> ();
1779 
1780  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1781  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1782  phy.SetChannel (channel.Create ());
1783 
1784  WifiHelper wifi;
1785  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_2_4GHZ);
1786  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
1787 
1789  NetDeviceContainer apDevice, apDeviceNearest;
1790  mac.SetType ("ns3::ApWifiMac",
1791  "BeaconGeneration", BooleanValue (true));
1792  apDevice = wifi.Install (phy, mac, apNodes);
1793  mac.SetType ("ns3::ApWifiMac",
1794  "BeaconGeneration", BooleanValue (nearestApBeaconGeneration));
1795  apDeviceNearest = wifi.Install (phy, mac, apNodeNearest);
1796 
1797  NetDeviceContainer staDevice;
1798  mac.SetType ("ns3::StaWifiMac",
1799  "ActiveProbing", BooleanValue (staActiveProbe));
1800  staDevice = wifi.Install (phy, mac, staNode);
1801 
1803  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1804  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Furthest AP
1805  positionAlloc->Add (Vector (10.0, 0.0, 0.0)); // Second nearest AP
1806  positionAlloc->Add (Vector (5.0, 5.0, 0.0)); // Nearest AP
1807  positionAlloc->Add (Vector (6.0, 5.0, 0.0)); // STA
1808  mobility.SetPositionAllocator (positionAlloc);
1809 
1810  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1811  mobility.Install (apNodes);
1812  mobility.Install (apNodeNearest);
1813  mobility.Install (staNode);
1814 
1815  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc", MakeCallback (&StaWifiMacScanningTestCase::AssocCallback, this));
1816 
1817  NodeContainer allNodes = NodeContainer (apNodes, apNodeNearest, staNode);
1818  return allNodes;
1819 }
1820 
1821 void
1823 {
1824  {
1825  RngSeedManager::SetSeed (1);
1826  RngSeedManager::SetRun (1);
1827 
1828  NodeContainer nodes = Setup (false, false);
1829  Ptr<Node> nearestAp = nodes.Get (2);
1830  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1831 
1832  Simulator::Schedule (Seconds (0.05), &StaWifiMacScanningTestCase::TurnBeaconGenerationOn, this, nearestAp);
1833 
1834  Simulator::Stop (Seconds (0.2));
1835  Simulator::Run ();
1836  Simulator::Destroy ();
1837 
1838  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1839  }
1841  {
1842  RngSeedManager::SetSeed (1);
1843  RngSeedManager::SetRun (1);
1844 
1845  NodeContainer nodes = Setup (true, true);
1846  Ptr<Node> nearestAp = nodes.Get (2);
1847  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1848 
1849  Simulator::Stop (Seconds (0.2));
1850  Simulator::Run ();
1851  Simulator::Destroy ();
1852 
1853  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1854  }
1856  {
1857  RngSeedManager::SetSeed (1);
1858  RngSeedManager::SetRun (1);
1859 
1860  NodeContainer nodes = Setup (true, false);
1861  Ptr<Node> nearestAp = nodes.Get (2);
1862  Mac48Address secondNearestApAddr = DynamicCast<WifiNetDevice> (nodes.Get (1)->GetDevice (0))->GetMac ()->GetAddress ();
1863 
1864  Simulator::Schedule (Seconds (0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
1865 
1866  Simulator::Stop (Seconds (1.5));
1867  Simulator::Run ();
1868  Simulator::Destroy ();
1869 
1870  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, secondNearestApAddr, "STA is associated to the wrong AP");
1871  }
1872 }
1873 
1874 //-----------------------------------------------------------------------------
1898 {
1899 public:
1900  Bug2470TestCase ();
1901  virtual ~Bug2470TestCase ();
1902  virtual void DoRun (void);
1903 
1904 private:
1913  void AddbaStateChangedCallback (std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
1923  void RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise);
1930  void RxErrorCallback (std::string context, Ptr<const Packet> p, double snr);
1937  void SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1943  void RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel);
1944 
1953 };
1954 
1956  : TestCase ("Test case for Bug 2470"),
1957  m_receivedNormalMpduCount (0),
1958  m_receivedAmpduCount (0),
1959  m_failedActionCount (0),
1960  m_addbaEstablishedCount (0),
1961  m_addbaPendingCount (0),
1962  m_addbaRejectedCount (0),
1963  m_addbaNoReplyCount (0),
1964  m_addbaResetCount (0)
1965 {
1966 }
1967 
1969 {
1970 }
1971 
1972 void
1974 {
1975  switch (state)
1976  {
1977  case OriginatorBlockAckAgreement::ESTABLISHED:
1979  break;
1980  case OriginatorBlockAckAgreement::PENDING:
1982  break;
1983  case OriginatorBlockAckAgreement::REJECTED:
1985  break;
1986  case OriginatorBlockAckAgreement::NO_REPLY:
1988  break;
1989  case OriginatorBlockAckAgreement::RESET:
1991  break;
1992  }
1993 }
1994 
1995 void
1996 Bug2470TestCase::RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise)
1997 {
1998  Ptr<Packet> packet = p->Copy ();
1999  if (aMpdu.type != MpduType::NORMAL_MPDU)
2000  {
2002  }
2003  else
2004  {
2005  WifiMacHeader hdr;
2006  packet->RemoveHeader (hdr);
2007  if (hdr.IsData ())
2008  {
2010  }
2011  }
2012 }
2013 
2014 void
2015 Bug2470TestCase::RxErrorCallback (std::string context, Ptr<const Packet> p, double snr)
2016 {
2017  Ptr<Packet> packet = p->Copy ();
2018  WifiMacHeader hdr;
2019  packet->RemoveHeader (hdr);
2020  if (hdr.IsAction ())
2021  {
2023  }
2024 }
2025 
2026 void
2027 Bug2470TestCase::SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice,
2028  Address& destination) const
2029 {
2030  for (uint32_t i = 0; i < numPackets; i++)
2031  {
2032  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2033  sourceDevice->Send (pkt, destination, 0);
2034  }
2035 }
2036 
2037 void
2039 {
2040  RngSeedManager::SetSeed (1);
2041  RngSeedManager::SetRun (1);
2042  int64_t streamNumber = 200;
2043 
2044  NodeContainer wifiApNode, wifiStaNode;
2045  wifiApNode.Create (1);
2046  wifiStaNode.Create (1);
2047 
2048  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2049  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2050  phy.SetChannel (channel.Create ());
2051 
2052  WifiHelper wifi;
2053  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
2054  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2055  "DataMode", StringValue ("HtMcs7"),
2056  "ControlMode", StringValue ("HtMcs7"));
2057 
2059  NetDeviceContainer apDevice;
2060  phy.Set ("PostReceptionErrorModel", apErrorModel);
2061  mac.SetType ("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue (false));
2062  apDevice = wifi.Install (phy, mac, wifiApNode);
2063 
2064  NetDeviceContainer staDevice;
2065  phy.Set ("PostReceptionErrorModel", staErrorModel);
2066  mac.SetType ("ns3::StaWifiMac");
2067  staDevice = wifi.Install (phy, mac, wifiStaNode);
2068 
2069  // Assign fixed streams to random variables in use
2070  wifi.AssignStreams (apDevice, streamNumber);
2071  wifi.AssignStreams (staDevice, streamNumber);
2072 
2074  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2075  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2076  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2077  mobility.SetPositionAllocator (positionAlloc);
2078 
2079  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2080  mobility.Install (wifiApNode);
2081  mobility.Install (wifiStaNode);
2082 
2083  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this));
2084  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&Bug2470TestCase::RxErrorCallback, this));
2085  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this));
2086 
2087  Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2088  Simulator::Schedule (Seconds (0.5) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2089  Simulator::Schedule (Seconds (0.8), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2090  Simulator::Schedule (Seconds (0.8) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2091 
2092  Simulator::Stop (Seconds (1.0));
2093  Simulator::Run ();
2094  Simulator::Destroy ();
2095 }
2096 
2097 void
2099 {
2100  // Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel
2101  // instead of ListErrorModel since packet UID is incremented between simulations. But
2102  // problem may occur because of random stream, therefore we suppress usage of RNG as
2103  // much as possible (i.e., removing beacon jitter).
2104  Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel> ();
2105  std::list<uint32_t> blackList;
2106  // Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2107  blackList.push_back (8);
2108  blackList.push_back (9);
2109  blackList.push_back (10);
2110  blackList.push_back (11);
2111  blackList.push_back (12);
2112  blackList.push_back (13);
2113  staPem->SetList (blackList);
2114 
2115  {
2116  RunSubtest (PointerValue (), PointerValue (staPem));
2117  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 6, "ADDBA request packets are not failed");
2118  // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by normal
2119  // MPDU because of failed ADDBA handshake. For the second set, the first packet should be sent by
2120  // normal MPDU, and the rest with A-MPDU. In total we expect to receive 2 normal MPDU packets and
2121  // 8 A-MPDU packets.
2122  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 2, "Receiving incorrect number of normal MPDU packet on subtest 1");
2123  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 8, "Receiving incorrect number of A-MPDU packet on subtest 1");
2124 
2125  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 1");
2126  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2127  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2128  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 0, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2129  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2130  }
2131 
2134  m_failedActionCount = 0;
2136  m_addbaPendingCount = 0;
2138  m_addbaNoReplyCount = 0;
2139  m_addbaResetCount = 0;
2140 
2141  Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel> ();
2142  blackList.clear ();
2143  // Block ADDBA request 3 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2144  blackList.push_back (4);
2145  blackList.push_back (5);
2146  blackList.push_back (6);
2147  apPem->SetList (blackList);
2148 
2149  {
2150  RunSubtest (PointerValue (apPem), PointerValue ());
2151  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 3, "ADDBA response packets are not failed");
2152  // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU packets.
2153  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 6, "Receiving incorrect number of normal MPDU packet on subtest 2");
2154  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 4, "Receiving incorrect number of A-MPDU packet on subtest 2");
2155 
2156  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 2");
2157  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2158  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2159  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 1, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2160  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2161  }
2162 
2163  // TODO: In the second test set, it does not go to reset state since ADDBA response is received after timeout (NO_REPLY)
2164  // but before it does not enter RESET state. More tests should be written to verify all possible scenarios.
2165 }
2166 
2167 
2168 //-----------------------------------------------------------------------------
2184 {
2185 public:
2186  Issue40TestCase ();
2187  virtual ~Issue40TestCase ();
2188  virtual void DoRun (void);
2189 
2190 private:
2195  void RunOne (bool useAmpdu);
2196 
2202  void RxSuccessCallback (std::string context, Ptr<const Packet> p);
2209  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination);
2215  void TxFinalDataFailedCallback (std::string context, Mac48Address address);
2216 
2217  uint16_t m_rxCount;
2218  uint16_t m_txCount;
2220 };
2221 
2223  : TestCase ("Test case for issue #40"),
2224  m_rxCount (0),
2225  m_txCount (0),
2226  m_txMacFinalDataFailedCount (0)
2227 {
2228 }
2229 
2231 {
2232 }
2233 
2234 void
2236 {
2237  m_rxCount++;
2238 }
2239 
2240 void
2241 Issue40TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination)
2242 {
2243  for (uint8_t i = 0; i < numPackets; i++)
2244  {
2245  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2246  sourceDevice->Send (pkt, destination, 0);
2247  m_txCount++;
2248  }
2249 }
2250 
2251 void
2253 {
2255 }
2256 
2257 void
2259 {
2260  m_rxCount = 0;
2261  m_txCount = 0;
2263 
2264  RngSeedManager::SetSeed (1);
2265  RngSeedManager::SetRun (1);
2266  int64_t streamNumber = 100;
2267 
2268  NodeContainer wifiApNode, wifiStaNode;
2269  wifiApNode.Create (1);
2270  wifiStaNode.Create (1);
2271 
2272  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2273  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2274  phy.SetChannel (channel.Create ());
2275 
2276  WifiHelper wifi;
2277  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
2278  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2279 
2281  NetDeviceContainer apDevice;
2282  mac.SetType ("ns3::ApWifiMac");
2283  apDevice = wifi.Install (phy, mac, wifiApNode);
2284 
2285  NetDeviceContainer staDevice;
2286  mac.SetType ("ns3::StaWifiMac");
2287  staDevice = wifi.Install (phy, mac, wifiStaNode);
2288 
2289  // Assign fixed streams to random variables in use
2290  wifi.AssignStreams (apDevice, streamNumber);
2291  wifi.AssignStreams (staDevice, streamNumber);
2292 
2294  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2295  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2296  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
2297  mobility.SetPositionAllocator (positionAlloc);
2298 
2299  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2300  mobility.Install (wifiApNode);
2301 
2302  mobility.SetMobilityModel("ns3::WaypointMobilityModel");
2303  mobility.Install (wifiStaNode);
2304 
2305  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxFinalDataFailed", MakeCallback (&Issue40TestCase::TxFinalDataFailedCallback, this));
2306  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/MacRx", MakeCallback (&Issue40TestCase::RxSuccessCallback, this));
2307 
2308  Ptr<WaypointMobilityModel> staWaypointMobility = DynamicCast<WaypointMobilityModel>(wifiStaNode.Get(0)->GetObject<MobilityModel>());
2309  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.0), Vector (10.0, 0.0, 0.0)));
2310  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.5), Vector (50.0, 0.0, 0.0)));
2311 
2312  if (useAmpdu)
2313  {
2314  // 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
2315  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevice.Get (0));
2316  Ptr<RegularWifiMac> ap_mac = DynamicCast<RegularWifiMac> (ap_device->GetMac ());
2317  NS_ASSERT (ap_mac);
2318  PointerValue ptr;
2319  ap_mac->GetAttribute ("BE_Txop", ptr);
2320  ptr.Get<QosTxop> ()->SetAttribute ("UseExplicitBarAfterMissedBlockAck", BooleanValue (false));
2321  }
2322 
2323  // Transmit a first data packet before the station moves: it should be sent with a high modulation and successfully received
2324  Simulator::Schedule (Seconds (0.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2325 
2326  // 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
2327  Simulator::Schedule (Seconds (2.0), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2328 
2329  // 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
2330  Simulator::Schedule (Seconds (2.1), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2331  Simulator::Schedule (Seconds (2.2), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2332  Simulator::Schedule (Seconds (2.3), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2333  Simulator::Schedule (Seconds (2.4), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2334  Simulator::Schedule (Seconds (2.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2335 
2336  Simulator::Stop (Seconds (3.0));
2337  Simulator::Run ();
2338 
2339  NS_TEST_ASSERT_MSG_EQ (m_txCount, (useAmpdu ? 14 : 7), "Incorrect number of transmitted packets");
2340  NS_TEST_ASSERT_MSG_EQ (m_rxCount, (useAmpdu ? 12 : 6), "Incorrect number of successfully received packets");
2341  NS_TEST_ASSERT_MSG_EQ (m_txMacFinalDataFailedCount, 1, "Incorrect number of dropped TX packets");
2342 
2343  Simulator::Destroy ();
2344 }
2345 
2346 void
2348 {
2349  //Test without A-MPDU
2350  RunOne (false);
2351 
2352  //Test with A-MPDU
2353  RunOne (true);
2354 }
2355 
2356 //-----------------------------------------------------------------------------
2370 {
2371 public:
2372  Issue169TestCase ();
2373  virtual ~Issue169TestCase ();
2374  virtual void DoRun (void);
2375 
2376 private:
2384  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority);
2385 
2393  void TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW);
2394 };
2395 
2397  : TestCase ("Test case for issue #169")
2398 {
2399 }
2400 
2402 {
2403 }
2404 
2405 void
2406 Issue169TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority)
2407 {
2408  SocketPriorityTag priorityTag;
2409  priorityTag.SetPriority (priority);
2410  for (uint8_t i = 0; i < numPackets; i++)
2411  {
2412  Ptr<Packet> packet = Create<Packet> (1000); // 1000 dummy bytes of data
2413  packet->AddPacketTag (priorityTag);
2414  sourceDevice->Send (packet, destination, 0);
2415  }
2416 }
2417 
2418 void
2419 Issue169TestCase::TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW)
2420 {
2421  if (psdu->GetSize () >= 1000)
2422  {
2423  NS_TEST_ASSERT_MSG_EQ (txVector.GetMode ().GetModulationClass (), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Ideal rate manager selected incorrect modulation class");
2424  }
2425 }
2426 
2427 void
2429 {
2430  RngSeedManager::SetSeed (1);
2431  RngSeedManager::SetRun (1);
2432  int64_t streamNumber = 100;
2433 
2434  NodeContainer wifiApNode, wifiStaNode;
2435  wifiApNode.Create (1);
2436  wifiStaNode.Create (1);
2437 
2438  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2439  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2440  phy.SetChannel (channel.Create ());
2441 
2442  WifiHelper wifi;
2443  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
2444  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2445 
2447  NetDeviceContainer apDevice;
2448  mac.SetType ("ns3::ApWifiMac");
2449  apDevice = wifi.Install (phy, mac, wifiApNode);
2450 
2451  NetDeviceContainer staDevice;
2452  mac.SetType ("ns3::StaWifiMac");
2453  staDevice = wifi.Install (phy, mac, wifiStaNode);
2454 
2455  // Assign fixed streams to random variables in use
2456  wifi.AssignStreams (apDevice, streamNumber);
2457  wifi.AssignStreams (staDevice, streamNumber);
2458 
2460  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2461  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2462  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2463  mobility.SetPositionAllocator (positionAlloc);
2464 
2465  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2466  mobility.Install (wifiApNode);
2467  mobility.Install (wifiStaNode);
2468 
2469  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&Issue169TestCase::TxCallback, this));
2470 
2471  //Send best-effort packet (i.e. priority 0)
2472  Simulator::Schedule (Seconds (0.5), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 0);
2473 
2474  //Send non best-effort (voice) packet (i.e. priority 6)
2475  Simulator::Schedule (Seconds (1.0), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 6);
2476 
2477  Simulator::Stop (Seconds (2.0));
2478  Simulator::Run ();
2479 
2480  Simulator::Destroy ();
2481 }
2482 
2483 
2484 //-----------------------------------------------------------------------------
2500 {
2501 public:
2504  virtual void DoRun (void);
2505 
2506 private:
2511  void ChangeChannelWidth (uint16_t channelWidth);
2512 
2518  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2519 
2527  void TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW);
2528 
2533  void CheckLastSelectedMode (WifiMode expectedMode);
2534 
2536 };
2537 
2539  : TestCase ("Test case for use of channel bonding with Ideal rate manager")
2540 {
2541 }
2542 
2544 {
2545 }
2546 
2547 void
2549 {
2550  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", UintegerValue (channelWidth));
2551 }
2552 
2553 void
2555 {
2556  Ptr<Packet> packet = Create<Packet> (1000);
2557  sourceDevice->Send (packet, destination, 0);
2558 }
2559 
2560 void
2561 IdealRateManagerChannelWidthTest::TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW)
2562 {
2563  if (psdu->GetSize () >= 1000)
2564  {
2565  m_txMode = txVector.GetMode ();
2566  }
2567 }
2568 
2569 void
2571 {
2572  NS_TEST_ASSERT_MSG_EQ (m_txMode, expectedMode, "Last selected WifiMode " << m_txMode << " does not match expected WifiMode " << expectedMode);
2573 }
2574 
2575 void
2577 {
2578  RngSeedManager::SetSeed (1);
2579  RngSeedManager::SetRun (1);
2580  int64_t streamNumber = 100;
2581 
2582  NodeContainer wifiApNode, wifiStaNode;
2583  wifiApNode.Create (1);
2584  wifiStaNode.Create (1);
2585 
2586  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2587  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2588  phy.SetChannel (channel.Create ());
2589 
2590  WifiHelper wifi;
2591  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
2592  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2593 
2595  NetDeviceContainer apDevice;
2596  mac.SetType ("ns3::ApWifiMac");
2597  apDevice = wifi.Install (phy, mac, wifiApNode);
2598 
2599  NetDeviceContainer staDevice;
2600  mac.SetType ("ns3::StaWifiMac");
2601  staDevice = wifi.Install (phy, mac, wifiStaNode);
2602 
2603  // Assign fixed streams to random variables in use
2604  wifi.AssignStreams (apDevice, streamNumber);
2605  wifi.AssignStreams (staDevice, streamNumber);
2606 
2608  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2609  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2610  positionAlloc->Add (Vector (50.0, 0.0, 0.0));
2611  mobility.SetPositionAllocator (positionAlloc);
2612 
2613  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2614  mobility.Install (wifiApNode);
2615  mobility.Install (wifiStaNode);
2616 
2617  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerChannelWidthTest::TxCallback, this));
2618 
2619  //Set channel width to 80 MHz & send packet
2620  Simulator::Schedule (Seconds (0.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 80);
2621  Simulator::Schedule (Seconds (1.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2622  //Selected rate should be VHT-MCS 0
2623  Simulator::Schedule (Seconds (1.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs0 ());
2624 
2625  //Set channel width to 20 MHz & send packet
2626  Simulator::Schedule (Seconds (1.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 20);
2627  Simulator::Schedule (Seconds (2.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2628  //Selected rate should be VHT-MCS 2 since SNR should be 6 dB higher than previously
2629  Simulator::Schedule (Seconds (2.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2630 
2631  //Set channel width to 40 MHz & send packet
2632  Simulator::Schedule (Seconds (2.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 40);
2633  Simulator::Schedule (Seconds (3.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2634  //Selected rate should be VHT-MCS 1 since SNR should be 3 dB lower than previously
2635  Simulator::Schedule (Seconds (3.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2636 
2637  Simulator::Stop (Seconds (3.2));
2638  Simulator::Run ();
2639 
2640  Simulator::Destroy ();
2641 }
2642 
2643 
2644 //-----------------------------------------------------------------------------
2653 {
2654 public:
2656  virtual ~IdealRateManagerMimoTest ();
2657  virtual void DoRun (void);
2658 
2659 private:
2665  void SetApMimoSettings (uint8_t antennas, uint8_t maxStreams);
2671  void SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams);
2677  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2678 
2686  void TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW);
2687 
2692  void CheckLastSelectedMode (WifiMode expectedMode);
2697  void CheckLastSelectedNss (uint8_t expectedNss);
2698 
2700 };
2701 
2703  : TestCase ("Test case for use of imbalanced MIMO settings with Ideal rate manager")
2704 {
2705 }
2706 
2708 {
2709 }
2710 
2711 void
2712 IdealRateManagerMimoTest::SetApMimoSettings (uint8_t antennas, uint8_t maxStreams)
2713 {
2714  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2715  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2716  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2717 }
2718 
2719 void
2720 IdealRateManagerMimoTest::SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams)
2721 {
2722  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2723  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2724  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2725 }
2726 
2727 void
2729 {
2730  Ptr<Packet> packet = Create<Packet> (1000);
2731  sourceDevice->Send (packet, destination, 0);
2732 }
2733 
2734 void
2735 IdealRateManagerMimoTest::TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW)
2736 {
2737  if (psdu->GetSize () >= 1000)
2738  {
2739  m_txVector = txVector;
2740  }
2741 }
2742 
2743 void
2745 {
2746  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetNss (), expectedNss, "Last selected Nss " << m_txVector.GetNss () << " does not match expected Nss " << expectedNss);
2747 }
2748 
2749 void
2751 {
2752  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetMode (), expectedMode, "Last selected WifiMode " << m_txVector.GetMode () << " does not match expected WifiMode " << expectedMode);
2753 }
2754 
2755 void
2757 {
2758  RngSeedManager::SetSeed (1);
2759  RngSeedManager::SetRun (1);
2760  int64_t streamNumber = 100;
2761 
2762  NodeContainer wifiApNode, wifiStaNode;
2763  wifiApNode.Create (1);
2764  wifiStaNode.Create (1);
2765 
2766  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2767  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2768  phy.SetChannel (channel.Create ());
2769 
2770  WifiHelper wifi;
2771  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
2772  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2773 
2775  NetDeviceContainer apDevice;
2776  mac.SetType ("ns3::ApWifiMac");
2777  apDevice = wifi.Install (phy, mac, wifiApNode);
2778 
2779  NetDeviceContainer staDevice;
2780  mac.SetType ("ns3::StaWifiMac");
2781  staDevice = wifi.Install (phy, mac, wifiStaNode);
2782 
2783  // Assign fixed streams to random variables in use
2784  wifi.AssignStreams (apDevice, streamNumber);
2785  wifi.AssignStreams (staDevice, streamNumber);
2786 
2788  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2789  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2790  positionAlloc->Add (Vector (40.0, 0.0, 0.0));
2791  mobility.SetPositionAllocator (positionAlloc);
2792 
2793  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2794  mobility.Install (wifiApNode);
2795  mobility.Install (wifiStaNode);
2796 
2797  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerMimoTest::TxCallback, this));
2798 
2799 
2800  // TX: 1 antenna
2801  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2802  // RX: 1 antenna
2803  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2804  // Send packets (2 times to get one feedback)
2805  Simulator::Schedule (Seconds (1.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2806  Simulator::Schedule (Seconds (1.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2807  // Selected NSS should be 1 since both TX and RX support a single antenna
2808  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2809  // Selected rate should be VHT-MCS1 because of settings and distance between TX and RX
2810  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2811 
2812 
2813  // TX: 1 antenna
2814  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2815  // RX: 2 antennas, but only supports 1 spatial stream
2816  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2817  // Send packets (2 times to get one feedback)
2818  Simulator::Schedule (Seconds (2.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2819  Simulator::Schedule (Seconds (2.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2820  // Selected NSS should be 1 since both TX and RX support a single antenna
2821  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2822  // Selected rate should be increased to VHT-MCS2 because of RX diversity resulting in SNR improvement of about 3dB
2823  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2824 
2825 
2826  // TX: 1 antenna
2827  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2828  // RX: 2 antennas, and supports 2 spatial streams
2829  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2830  // Send packets (2 times to get one feedback)
2831  Simulator::Schedule (Seconds (3.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2832  Simulator::Schedule (Seconds (3.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2833  // Selected NSS should be 1 since TX supports a single antenna
2834  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2835  // Selected rate should be as previously
2836  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2837 
2838 
2839  // TX: 2 antennas, but only supports 1 spatial stream
2840  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2841  // RX: 1 antenna
2842  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2843  // Send packets (2 times to get one feedback)
2844  Simulator::Schedule (Seconds (4.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2845  Simulator::Schedule (Seconds (4.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2846  // Selected NSS should be 1 since both TX and RX support a single antenna
2847  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2848  // Selected rate should be VHT-MCS1 because we do no longer have diversity in this scenario (more antennas at TX does not result in SNR improvement in AWGN channel)
2849  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2850 
2851 
2852  // TX: 2 antennas, but only supports 1 spatial stream
2853  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2854  // RX: 2 antennas, but only supports 1 spatial stream
2855  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2856  // Send packets (2 times to get one feedback)
2857  Simulator::Schedule (Seconds (5.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2858  Simulator::Schedule (Seconds (5.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2859  // Selected NSS should be 1 since both TX and RX support a single antenna
2860  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2861  // Selected rate should be increased to VHT-MCS2 because of RX diversity resulting in SNR improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN channel)
2862  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2863 
2864 
2865  // TX: 2 antennas, but only supports 1 spatial stream
2866  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2867  // RX: 2 antennas, and supports 2 spatial streams
2868  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2869  // Send packets (2 times to get one feedback)
2870  Simulator::Schedule (Seconds (6.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2871  Simulator::Schedule (Seconds (6.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2872  // Selected NSS should be 1 since TX supports a single antenna
2873  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2874  // Selected rate should be as previously
2875  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2876 
2877 
2878  // TX: 2 antennas, and supports 2 spatial streams
2879  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2880  // RX: 1 antenna
2881  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2882  // Send packets (2 times to get one feedback)
2883  Simulator::Schedule (Seconds (7.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2884  Simulator::Schedule (Seconds (7.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2885  // Selected NSS should be 1 since RX supports a single antenna
2886  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2887  // Selected rate should be VHT-MCS1 because we do no longer have diversity in this scenario (more antennas at TX does not result in SNR improvement in AWGN channel)
2888  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2889 
2890 
2891  // TX: 2 antennas, and supports 2 spatial streams
2892  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2893  // RX: 2 antennas, but only supports 1 spatial stream
2894  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2895  // Send packets (2 times to get one feedback)
2896  Simulator::Schedule (Seconds (8.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2897  Simulator::Schedule (Seconds (8.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2898  // Selected NSS should be 1 since RX supports a single antenna
2899  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2900  // Selected rate should be increased to VHT-MCS2 because of RX diversity resulting in SNR improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN channel)
2901  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2902 
2903 
2904  // TX: 2 antennas, and supports 2 spatial streams
2905  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2906  // RX: 2 antennas, and supports 2 spatial streams
2907  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2908  // Send packets (2 times to get one feedback)
2909  Simulator::Schedule (Seconds (9.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2910  Simulator::Schedule (Seconds (9.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2911  // Selected NSS should be 2 since both TX and RX support 2 antennas
2912  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 2);
2913  // 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
2914  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2915 
2916 
2917  // Verify we can go back to initial situation
2918  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2919  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2920  Simulator::Schedule (Seconds (10.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2921  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2922  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2923 
2924  Simulator::Stop (Seconds (10.2));
2925  Simulator::Run ();
2926  Simulator::Destroy ();
2927 }
2928 
2935 class WifiTestSuite : public TestSuite
2936 {
2937 public:
2938  WifiTestSuite ();
2939 };
2940 
2942  : TestSuite ("wifi-devices", UNIT)
2943 {
2944  AddTestCase (new WifiTest, TestCase::QUICK);
2945  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
2946  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
2947  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
2948  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
2949  AddTestCase (new QosFragmentationTestCase, TestCase::QUICK);
2950  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
2951  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
2952  AddTestCase (new Bug2843TestCase, TestCase::QUICK); //Bug 2843
2953  AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
2954  AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399
2955  AddTestCase (new Bug2470TestCase, TestCase::QUICK); //Bug 2470
2956  AddTestCase (new Issue40TestCase, TestCase::QUICK); //Issue #40
2957  AddTestCase (new Issue169TestCase, TestCase::QUICK); //Issue #169
2958  AddTestCase (new IdealRateManagerChannelWidthTest, TestCase::QUICK);
2959  AddTestCase (new IdealRateManagerMimoTest, TestCase::QUICK);
2960 }
2961 
ERP-OFDM PHY (Clause 19, Section 19.5)
MpduInfo structure.
Definition: wifi-phy.h:124
void TxCallback(std::string context, Ptr< const WifiPsdu > psdu, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2561
size_t GetNumBands() const
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void RunOne(void)
Run one function.
Definition: wifi-test.cc:162
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:143
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:159
uint8_t m_countOperationalChannelWidth20
count number of beacon frames announcing a 20 MHz operating channel width
Definition: wifi-test.cc:1547
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void AddbaStateChangedCallback(std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
Callback when ADDBA state changed.
Definition: wifi-test.cc:1973
virtual ~Bug730TestCase()
Definition: wifi-test.cc:597
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
OFDM PHY for the 5 GHz band (Clause 17 with 5 MHz channel bandwidth)
void PopulateArpCache()
Populate ARP cache function.
virtual ~QosFragmentationTestCase()
Definition: wifi-test.cc:743
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint16_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1273
void Transmit(std::string context, Ptr< const Packet > p, double power)
Callback invoked when PHY transmits a packet.
Definition: wifi-test.cc:757
AttributeValue implementation for Boolean.
Definition: boolean.h:36
Ptr< T > Get(void) const
Definition: pointer.h:201
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
HT PHY for the 5 GHz band (clause 20)
void TxFinalDataFailedCallback(std::string context, Mac48Address address)
Transmit final data failed function.
Definition: wifi-test.cc:2252
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:602
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
void StoreDistinctTuple(std::string context, Ptr< SpectrumSignalParameters > txParams)
Stores the distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples that have been used during the testcase run.
Definition: wifi-test.cc:1390
Ptr< WifiPpdu > ppdu
The PPDU being transmitted.
Hold variables of type string.
Definition: string.h:41
Make sure that the ADDBA handshake process is protected.
Definition: wifi-test.cc:1897
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1604
Make it easy to create and manage PHY objects for the YANS model.
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:839
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1822
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
virtual ~IdealRateManagerMimoTest()
Definition: wifi-test.cc:2707
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:144
A suite of tests to run.
Definition: test.h:1343
void AddWaypoint(const Waypoint &waypoint)
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:92
an address for a packet socket
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2756
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
uint16_t m_receivedNormalMpduCount
Count received normal MPDU packets on STA.
Definition: wifi-test.cc:1945
uint16_t m_rxCount
Count number of successfully received data packets.
Definition: wifi-test.cc:2217
void RxCallback(std::string context, Ptr< const Packet > p)
Callback triggered when a packet is received by the PHYs.
Definition: wifi-test.cc:1574
uint16_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:1946
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:283
Make sure that Ideal rate manager is able to handle non best-effort traffic.
Definition: wifi-test.cc:2369
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:781
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:50
staDevices
Definition: third.py:103
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet. ...
Definition: qos-utils.cc:84
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:262
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1433
HT PHY for the 2.4 GHz band (clause 20)
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:1422
VHT PHY (Clause 22)
Definition: wifi-mode.h:60
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:218
encapsulates test code
Definition: test.h:1153
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
virtual void ConfigureStandard(WifiPhyStandard standard)=0
virtual ~StaWifiMacScanningTestCase()
Definition: wifi-test.cc:1745
uint8_t m_reassocReqCount
count number of reassociation requests
Definition: wifi-test.cc:1545
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:569
virtual ~Bug2843TestCase()
Definition: wifi-test.cc:1385
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1750
helps to create WifiNetDevice objects
Definition: wifi-helper.h:300
Mac48Address m_associatedApBssid
Associated AP&#39;s bssid.
Definition: wifi-test.cc:1737
Make sure that Ideal rate manager recovers when the station is moving away from the access point...
Definition: wifi-test.cc:2183
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
uint32_t GetIfIndex(void) const
Address GetAddress(void) const
void RxCallback(std::string context, Ptr< const Packet > p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise)
Callback when packet is received.
Definition: wifi-test.cc:1996
a polymophic address class
Definition: address.h:90
unsigned int m_numSentPackets
number of sent packets
Definition: wifi-test.cc:445
channel
Definition: third.py:92
void SendPackets(uint8_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination)
Triggers the arrival of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:2241
mobility
Definition: third.py:108
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
Definition: wifi-psdu.cc:260
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:441
phy
Definition: third.py:93
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:757
virtual ~Issue169TestCase()
Definition: wifi-test.cc:2401
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1508
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2570
uint16_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:1950
uint16_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:1948
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:2728
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1756
Keep track of the current position and velocity of an object.
void SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for STA node.
Definition: wifi-test.cc:2720
The MPDU is not part of an A-MPDU.
bool IsAction(void) const
Return true if the header is an Action header.
virtual ~Bug2470TestCase()
Definition: wifi-test.cc:1968
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:301
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1560
HE PHY for the 5 GHz band (clause 26)
nodes
Definition: first.py:32
Make sure that Wifi STA is correctly associating to the best AP (i.e., nearest from STA)...
Definition: wifi-test.cc:1705
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-mac.cc:82
Time m_firstTransmissionTime
first transmission time
Definition: wifi-test.cc:443
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:748
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
WifiMode m_txMode
Store the last selected mode to send data packet.
Definition: wifi-test.cc:2535
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: txop.cc:332
bool IsBeacon(void) const
Return true if the header is a Beacon header.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:46
uint32_t m_countInternalCollisions
count internal collisions
Definition: wifi-test.cc:1218
void SetChannel(Ptr< SpectrumChannel > channel)
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Definition: vector.h:297
ssid
Definition: third.py:100
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:482
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:166
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2098
holds a vector of ns3::NetDevice pointers
mac
Definition: third.py:99
indicates whether the socket has a priority set.
Definition: socket.h:1307
void RunOne(bool useAmpdu)
Run one function.
Definition: wifi-test.cc:2258
WifiMode GetMode(void) const
calculate a propagation delay.
Address GetBroadcast(void) const
Hold together all Wifi-related objects.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1248
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2576
wifiApNode
Definition: third.py:90
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:612
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1523
uint16_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:1952
virtual void SetAddress(Mac48Address address)=0
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:277
hold a list of per-remote-station state.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:463
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:915
uint32_t m_fragments
transmitted fragments
Definition: wifi-test.cc:717
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:2554
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:800
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:899
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
void SwitchCh(Ptr< WifiNetDevice > dev)
Switch channel function.
Definition: wifi-test.cc:294
Ptr< WifiPhy > GetPhy(void) const
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start.
Ptr< YansWifiPhy > m_staPhy
STA PHY.
Definition: wifi-test.cc:1543
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2750
void TxDataFailedTrace(std::string context, Mac48Address adress)
Transmit data failed function.
Definition: wifi-test.cc:1241
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:181
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void SetApMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for AP node.
Definition: wifi-test.cc:2712
Hold objects of type Ptr<T>.
Definition: pointer.h:36
bool IsData(void) const
Return true if the Type is DATA.
address
Definition: first.py:44
void NotifyPhyTxBegin(Ptr< const Packet > p, double txPowerW)
Notify Phy transmit begin.
Definition: wifi-test.cc:461
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:2962
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1488
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:48
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:116
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:224
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
uint32_t m_received
received packets
Definition: wifi-test.cc:716
void SetList(const std::list< uint32_t > &packetlist)
Definition: error-model.cc:520
uint16_t m_addbaPendingCount
Count number of times ADDBA state machine is in pending state.
Definition: wifi-test.cc:1949
an EUI-48 address
Definition: mac48-address.h:43
ObjectFactory m_manager
manager
Definition: wifi-test.cc:439
NodeContainer Setup(bool nearestApBeaconGeneration, bool staActiveProbe)
Setup test.
Definition: wifi-test.cc:1772
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1236
Ptr< const SpectrumModel > GetSpectrumModel() const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1606
manage and create wifi channel objects for the YANS model.
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:117
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:475
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1660
create MAC layers for a ns3::WifiNetDevice.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
State
Represents the state for this agreement.
void RxSuccessCallback(std::string context, Ptr< const Packet > p)
Callback when packet is successfully received.
Definition: wifi-test.cc:2235
uint8_t m_countOperationalChannelWidth40
count number of beacon frames announcing a 40 MHz operating channel width
Definition: wifi-test.cc:1548
void ChangeChannelWidth(uint16_t channelWidth)
Change the configured channel width for all nodes.
Definition: wifi-test.cc:2548
void SetErrorRateModel(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Definition: wifi-helper.cc:149
Test to validate that Ideal rate manager properly selects TXVECTOR in scenarios where MIMO is used...
Definition: wifi-test.cc:2652
void SetPosition(const Vector &position)
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
Make sure that the correct channel width and center frequency have been set for OFDM basic rate trans...
Definition: wifi-test.cc:1347
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:278
void RxErrorCallback(std::string context, Ptr< const Packet > p, double snr)
Callback when packet is dropped.
Definition: wifi-test.cc:2015
Wifi Test Suite.
Definition: wifi-test.cc:2935
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1208
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
std::tuple< double, uint16_t, uint32_t, WifiModulationClass > FreqWidthSubbandModulationTuple
A tuple of {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type}.
Definition: wifi-test.cc:1358
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:769
uint16_t m_txCount
Count number of transmitted data packets.
Definition: wifi-test.cc:2218
void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel)
Run subtest for this test suite.
Definition: wifi-test.cc:2038
wifi
Definition: third.py:96
uint8_t GetStaChannelWidth(void) const
Return the STA channel width.
Helper class used to assign positions and mobility models to nodes.
ObjectFactory m_manager
manager
Definition: wifi-test.cc:115
Instantiate subclasses of ns3::Object.
Ptr< WifiMac > GetMac(void) const
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
Definition: wifi-mode.h:36
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:863
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
static void AssignWifiRandomStreams(Ptr< WifiMac > mac, int64_t stream)
Definition: wifi-test.cc:57
SignalNoiseDbm structure.
Definition: wifi-phy.h:117
virtual void SetChannelWidth(uint16_t channelWidth)
Definition: wifi-phy.cc:1494
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1542
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
AttributeValue implementation for Ssid.
Definition: ssid.h:105
ObjectFactory m_manager
manager
Definition: wifi-test.cc:276
OFDM PHY (Clause 17)
Definition: wifi-mode.h:56
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:2027
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
uint32_t m_received
received
Definition: wifi-test.cc:579
void Add(Vector v)
Add a position to the list of positions.
void TxCallback(std::string context, Ptr< const WifiPsdu > psdu, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2419
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:287
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
apDevices
Definition: third.py:106
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2347
WifiTxVector m_txVector
Store the last TXVECTOR used to transmit Data.
Definition: wifi-test.cc:2699
Make sure that Ideal rate manager properly selects MCS based on the configured channel width...
Definition: wifi-test.cc:2499
void TurnApOff(Ptr< Node > apNode)
Turn the AP node off.
Definition: wifi-test.cc:1764
uint16_t m_txMacFinalDataFailedCount
Count number of unsuccessfully transmitted data packets.
Definition: wifi-test.cc:2219
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data...
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:126
void CheckLastSelectedNss(uint8_t expectedNss)
Check if the selected Nss is correct.
Definition: wifi-test.cc:2744
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
uint16_t m_addbaNoReplyCount
Count number of times ADDBA state machine is in no_reply state.
Definition: wifi-test.cc:1951
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2428
Wifi Test.
Definition: wifi-test.cc:92
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
virtual ~Issue40TestCase()
Definition: wifi-test.cc:2230
uint16_t GetChannelWidth(void) const
std::vector< FreqWidthSubbandModulationTuple > m_distinctTuples
vector of distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
Definition: wifi-test.cc:1359
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1368
Time m_secondTransmissionTime
second transmission time
Definition: wifi-test.cc:444
void ChangeSupportedChannelWidth(void)
Function called to change the supported channel width at runtime.
Definition: wifi-test.cc:1565
void SetPriority(uint8_t priority)
Set the tag&#39;s priority.
Definition: socket.cc:842
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
uint16_t m_failedActionCount
Count failed ADDBA request/response.
Definition: wifi-test.cc:1947
MpduType type
type
Definition: wifi-phy.h:126
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:891
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
void SendPackets(uint8_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination, uint8_t priority)
Triggers the transmission of a 1000 Byte-long data packet from the source device. ...
Definition: wifi-test.cc:2406
a (time, location) pair.
Definition: waypoint.h:35
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:223
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:69
#define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg)
Test that an actual value is less than or equal to a limit and report if not.
Definition: test.h:922
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition: ptr.h:536
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:847
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
uint8_t m_reassocRespCount
count number of reassociation responses
Definition: wifi-test.cc:1546
Implements the IEEE 802.11 MAC header.
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:133
uint8_t GetNss(void) const
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
void TxCallback(std::string context, Ptr< const WifiPsdu > psdu, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2735
Make sure that fragmentation works with QoS stations.
Definition: wifi-test.cc:706
uint16_t m_channelWidth
channel width (in MHz)
Definition: wifi-test.cc:1376
Set Channel Frequency Test.
Definition: wifi-test.cc:867
Make sure that when multiple broadcast packets are queued on the same device in a short succession...
Definition: wifi-test.cc:424
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:66
Make it easy to create and manage PHY objects for the spectrum model.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:331