A Discrete-Event Network Simulator
API
wifi-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  * 2010 NICTA
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Quincy Tse <quincy.tse@nicta.com.au>
21  * S├ębastien Deronne <sebastien.deronne@gmail.com>
22  */
23 
24 #include "ns3/string.h"
25 #include "ns3/yans-wifi-helper.h"
26 #include "ns3/mobility-helper.h"
27 #include "ns3/wifi-net-device.h"
28 #include "ns3/adhoc-wifi-mac.h"
29 #include "ns3/ap-wifi-mac.h"
30 #include "ns3/propagation-loss-model.h"
31 #include "ns3/yans-error-rate-model.h"
32 #include "ns3/constant-position-mobility-model.h"
33 #include "ns3/test.h"
34 #include "ns3/pointer.h"
35 #include "ns3/rng-seed-manager.h"
36 #include "ns3/config.h"
37 #include "ns3/error-model.h"
38 #include "ns3/socket.h"
39 #include "ns3/packet-socket-server.h"
40 #include "ns3/packet-socket-client.h"
41 #include "ns3/packet-socket-helper.h"
42 #include "ns3/spectrum-wifi-helper.h"
43 #include "ns3/multi-model-spectrum-channel.h"
44 #include "ns3/wifi-spectrum-signal-parameters.h"
45 #include "ns3/yans-wifi-phy.h"
46 #include "ns3/mgt-headers.h"
47 #include "ns3/ht-configuration.h"
48 #include "ns3/wifi-ppdu.h"
49 #include "ns3/wifi-psdu.h"
50 #include "ns3/waypoint-mobility-model.h"
51 
52 using namespace ns3;
53 
54 //Helper function to assign streams to random variables, to control
55 //randomness in the tests
56 static void
58 {
59  int64_t currentStream = stream;
60  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
61  if (rmac)
62  {
63  PointerValue ptr;
64  rmac->GetAttribute ("Txop", ptr);
65  Ptr<Txop> txop = ptr.Get<Txop> ();
66  currentStream += txop->AssignStreams (currentStream);
67 
68  rmac->GetAttribute ("VO_Txop", ptr);
69  Ptr<QosTxop> vo_txop = ptr.Get<QosTxop> ();
70  currentStream += vo_txop->AssignStreams (currentStream);
71 
72  rmac->GetAttribute ("VI_Txop", ptr);
73  Ptr<QosTxop> vi_txop = ptr.Get<QosTxop> ();
74  currentStream += vi_txop->AssignStreams (currentStream);
75 
76  rmac->GetAttribute ("BE_Txop", ptr);
77  Ptr<QosTxop> be_txop = ptr.Get<QosTxop> ();
78  currentStream += be_txop->AssignStreams (currentStream);
79 
80  rmac->GetAttribute ("BK_Txop", ptr);
81  Ptr<QosTxop> bk_txop = ptr.Get<QosTxop> ();
82  bk_txop->AssignStreams (currentStream);
83  }
84 }
85 
92 class WifiTest : public TestCase
93 {
94 public:
95  WifiTest ();
96 
97  virtual void DoRun (void);
98 
99 
100 private:
102  void RunOne (void);
108  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
114 
118 };
119 
121  : TestCase ("Wifi")
122 {
123 }
124 
125 void
127 {
128  Ptr<Packet> p = Create<Packet> ();
129  dev->Send (p, dev->GetBroadcast (), 1);
130 }
131 
132 void
134 {
135  Ptr<Node> node = CreateObject<Node> ();
136  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
137 
139  mac->SetDevice (dev);
140  mac->ConfigureStandard (WIFI_STANDARD_80211a);
141  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
142  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
143  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
144  phy->SetErrorRateModel (error);
145  phy->SetChannel (channel);
146  phy->SetDevice (dev);
147  phy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
149 
150  mobility->SetPosition (pos);
151  node->AggregateObject (mobility);
152  mac->SetAddress (Mac48Address::Allocate ());
153  dev->SetMac (mac);
154  dev->SetPhy (phy);
155  dev->SetRemoteStationManager (manager);
156  node->AddDevice (dev);
157 
158  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
159 }
160 
161 void
163 {
164  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
166  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
167  channel->SetPropagationDelayModel (propDelay);
168  channel->SetPropagationLossModel (propLoss);
169 
170  CreateOne (Vector (0.0, 0.0, 0.0), channel);
171  CreateOne (Vector (5.0, 0.0, 0.0), channel);
172  CreateOne (Vector (5.0, 0.0, 0.0), channel);
173 
174  Simulator::Stop (Seconds (10.0));
175 
176  Simulator::Run ();
177  Simulator::Destroy ();
178 }
179 
180 void
182 {
183  m_mac.SetTypeId ("ns3::AdhocWifiMac");
184  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
185 
186  m_manager.SetTypeId ("ns3::ArfWifiManager");
187  RunOne ();
188  m_manager.SetTypeId ("ns3::AarfWifiManager");
189  RunOne ();
190  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
191  RunOne ();
192  m_manager.SetTypeId ("ns3::OnoeWifiManager");
193  RunOne ();
194  m_manager.SetTypeId ("ns3::AmrrWifiManager");
195  RunOne ();
196  m_manager.SetTypeId ("ns3::IdealWifiManager");
197  RunOne ();
198 
199  m_mac.SetTypeId ("ns3::AdhocWifiMac");
200  RunOne ();
201  m_mac.SetTypeId ("ns3::ApWifiMac");
202  RunOne ();
203  m_mac.SetTypeId ("ns3::StaWifiMac");
204  RunOne ();
205 
206 
207  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
208  m_mac.SetTypeId ("ns3::AdhocWifiMac");
209  RunOne ();
210 }
211 
219 {
220 public:
221  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
222  {
223  }
224  virtual void DoRun (void)
225  {
226  //startingSeq=0, seqNum=2047
227  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
228  //startingSeq=0, seqNum=2048
229  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
230  //startingSeq=2048, seqNum=0
231  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
232  //startingSeq=4095, seqNum=0
233  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
234  //startingSeq=0, seqNum=4095
235  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
236  //startingSeq=4095 seqNum=2047
237  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
238  //startingSeq=2048 seqNum=4095
239  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
240  //startingSeq=2049 seqNum=0
241  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
242  }
243 };
244 
245 
250 {
251 public:
253 
254  virtual void DoRun (void);
255 
256 
257 private:
274  void SwitchCh (Ptr<WifiNetDevice> dev);
275 
279 };
280 
282  : TestCase ("InterferenceHelperSequence")
283 {
284 }
285 
286 void
288 {
289  Ptr<Packet> p = Create<Packet> (1000);
290  dev->Send (p, dev->GetBroadcast (), 1);
291 }
292 
293 void
295 {
296  Ptr<WifiPhy> p = dev->GetPhy ();
297  p->SetChannelNumber (40);
298 }
299 
300 Ptr<Node>
302 {
303  Ptr<Node> node = CreateObject<Node> ();
304  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
305 
307  mac->SetDevice (dev);
308  mac->ConfigureStandard (WIFI_STANDARD_80211a);
309  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
310  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
311  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
312  phy->SetErrorRateModel (error);
313  phy->SetChannel (channel);
314  phy->SetDevice (dev);
315  phy->SetMobility (mobility);
316  phy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
318 
319  mobility->SetPosition (pos);
320  node->AggregateObject (mobility);
321  mac->SetAddress (Mac48Address::Allocate ());
322  dev->SetMac (mac);
323  dev->SetPhy (phy);
324  dev->SetRemoteStationManager (manager);
325  node->AddDevice (dev);
326 
327  return node;
328 }
329 
330 void
332 {
333  m_mac.SetTypeId ("ns3::AdhocWifiMac");
334  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
335  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
336 
337  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
339  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
340  channel->SetPropagationDelayModel (propDelay);
341  channel->SetPropagationLossModel (propLoss);
342 
343  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
344  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
345  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
346 
347  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
348  propLoss->SetDefaultLoss (999);
349 
350  Simulator::Schedule (Seconds (1.0),
352  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
353 
354  Simulator::Schedule (Seconds (1.0000001),
356  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
357 
358  Simulator::Schedule (Seconds (5.0),
360  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
361 
362  Simulator::Schedule (Seconds (7.0),
364  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
365 
366  Simulator::Stop (Seconds (100.0));
367  Simulator::Run ();
368 
369  Simulator::Destroy ();
370 }
371 
372 
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_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->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
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_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_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_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_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_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");
979  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
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_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_STANDARD_80211ax_2_4GHZ);
1002  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1003  phySta = GetYansWifiPhyPtr (staDevice);
1004  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11ax-2.4GHz configuration");
1005  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11ax-2.4GHz configuration");
1006  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11ax-2.4GHz configuration");
1007  }
1008  {
1009  // case 8:
1010  WifiHelper wifi;
1011  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1012  wifi.SetStandard (WIFI_STANDARD_80211ax_5GHZ);
1013  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1014  phySta = GetYansWifiPhyPtr (staDevice);
1015  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ax-5GHz configuration");
1016  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-5GHz configuration");
1017  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ax-5GHz configuration");
1018  }
1019  {
1020  // case 9:
1021  WifiHelper wifi;
1022  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1023  wifi.SetStandard (WIFI_STANDARD_80211ax_6GHZ);
1024  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1025  phySta = GetYansWifiPhyPtr (staDevice);
1026  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 7, "802.11ax-6GHz configuration");
1027  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-6GHz configuration");
1028  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5975, "802.11ax-6GHz configuration");
1029  }
1030  {
1031  // case 10:
1032  WifiHelper wifi;
1033  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1034  wifi.SetStandard (WIFI_STANDARD_80211p);
1035  phy.Set ("ChannelWidth", UintegerValue (10));
1036  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1037  phySta = GetYansWifiPhyPtr (staDevice);
1038  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11p 10Mhz configuration");
1039  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11p 10Mhz configuration");
1040  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 10Mhz configuration");
1041  }
1042  {
1043  // case 11:
1044  WifiHelper wifi;
1045  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1046  wifi.SetStandard (WIFI_STANDARD_80211p);
1047  phy.Set ("ChannelWidth", UintegerValue (5));
1048  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1049  phySta = GetYansWifiPhyPtr (staDevice);
1050  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 171, "802.11p 5Mhz configuration");
1051  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11p 5Mhz configuration");
1052  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 5Mhz configuration");
1053  }
1054  {
1055  // case 12:
1056  WifiHelper wifi;
1057  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1058  wifi.SetStandard (WIFI_STANDARD_holland);
1059  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1060  phySta = GetYansWifiPhyPtr (staDevice);
1061  // We expect channel 36, width 20, frequency 5180
1062  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
1063  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
1064  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
1065  }
1066  {
1067  // case 13:
1068  WifiHelper wifi;
1069  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1070  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1071  phy.Set ("ChannelNumber", UintegerValue (44));
1072  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1073  phySta = GetYansWifiPhyPtr (staDevice);
1074  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1075  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1076  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1077  }
1078  {
1079  // case 14:
1080  WifiHelper wifi;
1081  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1082  phy.Set ("ChannelNumber", UintegerValue (44));
1083  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1084  phySta = GetYansWifiPhyPtr (staDevice);
1085  // Post-install reconfiguration to channel number 40
1086  std::ostringstream path;
1087  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber";
1088  Config::Set (path.str(), UintegerValue (40));
1089  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1090  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1091  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1092  }
1093  {
1094  // case 15:
1095  WifiHelper wifi;
1096  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1097  phy.Set ("ChannelNumber", UintegerValue (44));
1098  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1099  phySta = GetYansWifiPhyPtr (staDevice);
1100  // Post-install reconfiguration to channel width 40 MHz
1101  std::ostringstream path;
1102  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth";
1103  Config::Set (path.str(), UintegerValue (40));
1104  // Although channel 44 is configured originally for 20 MHz, we
1105  // allow it to be used for 40 MHz here
1106  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1107  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1108  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1109  }
1110  {
1111  // case 16:
1112  WifiHelper wifi;
1113  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1114  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1115  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1116  phySta = GetYansWifiPhyPtr (staDevice);
1117  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
1118  // Post-install reconfiguration to channel width 40 MHz
1119  std::ostringstream path;
1120  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth";
1121  Config::Set (path.str(), UintegerValue (40));
1122  // Although channel 44 is configured originally for 20 MHz, we
1123  // allow it to be used for 40 MHz here
1124  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1125  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1126  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1127  }
1128  {
1129  // case 17:
1130  WifiHelper wifi;
1131  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1132  // Test that setting Frequency to a non-standard value will zero the
1133  // channel number
1134  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1135  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1136  phySta = GetYansWifiPhyPtr (staDevice);
1137  phySta->SetAttribute ("Frequency", UintegerValue (5281));
1138  // We expect channel number to be zero since frequency doesn't match
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 (), 5281, "802.11 5GHz configuration");
1142  }
1143  {
1144  // case 18:
1145  WifiHelper wifi;
1146  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1147  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1148  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1149  phySta = GetYansWifiPhyPtr (staDevice);
1150  // Test that setting Frequency to a standard value will set the
1151  // channel number correctly
1152  phySta->SetAttribute ("Frequency", UintegerValue (5500));
1153  // We expect channel number to be 100 due to frequency 5500
1154  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
1155  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1156  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
1157  }
1158  {
1159  // case 19:
1160  WifiHelper wifi;
1161  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1162  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1163  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1164  phySta = GetYansWifiPhyPtr (staDevice);
1165  // This case will error exit due to invalid channel number unless
1166  // we provide the DefineChannelNumber() below
1168  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
1169  }
1170  {
1171  // case 20:
1172  WifiHelper wifi;
1173  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1174  // Test how channel number behaves when frequency is non-standard
1175  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1176  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1177  phySta = GetYansWifiPhyPtr (staDevice);
1178  phySta->SetAttribute ("Frequency", UintegerValue (5181));
1179  // We expect channel number to be 0 due to unknown center frequency 5181
1180  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "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 (), 5181, "802.11 5GHz configuration");
1183  phySta->SetAttribute ("Frequency", UintegerValue (5180));
1184  // We expect channel number to be 36 due to known center frequency 5180
1185  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1186  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1187  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1188  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1189  // We expect channel number to be 0 due to unknown center frequency 5179
1190  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1191  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1192  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1193  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1194  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1195  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1196  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1197  }
1198  {
1199  // case 21:
1200  WifiHelper wifi;
1201  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1202  // Set both channel and frequency to consistent values
1203  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1204  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1205  phySta = GetYansWifiPhyPtr (staDevice);
1206  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1207  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
1208  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1209  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1210  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1211  // Set both channel and frequency to inconsistent values
1212  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1213  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1214  // We expect channel number to be 36
1215  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1216  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1217  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1218  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1219  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1220  // We expect channel number to be 40
1221  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1222  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1223  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1224  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1225  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1226  // We expect channel number to be 36
1227  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1228  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1229  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1230  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1231  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1232  // We expect channel number to be 0
1233  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1234  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1235  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1236  }
1237 
1238  Simulator::Destroy ();
1239 }
1240 
1241 //-----------------------------------------------------------------------------
1250 {
1251 public:
1252  Bug2222TestCase ();
1253  virtual ~Bug2222TestCase ();
1254 
1255  virtual void DoRun (void);
1256 
1257 
1258 private:
1260 
1262  void PopulateArpCache ();
1268  void TxDataFailedTrace (std::string context, Mac48Address adress);
1269 };
1270 
1272  : TestCase ("Test case for Bug 2222"),
1273  m_countInternalCollisions (0)
1274 {
1275 }
1276 
1278 {
1279 }
1280 
1281 void
1283 {
1284  //Indicate the long retry counter has been increased in the wifi remote station manager
1286 }
1287 
1288 void
1290 {
1292 
1293  //Generate same backoff for AC_VI and AC_VO
1294  //The below combination will work
1295  RngSeedManager::SetSeed (1);
1296  RngSeedManager::SetRun (16);
1297  int64_t streamNumber = 100;
1298 
1299  NodeContainer wifiNodes;
1300  wifiNodes.Create (2);
1301 
1302  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1303  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1304  phy.SetChannel (channel.Create ());
1305 
1306  WifiHelper wifi;
1307  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1308  "DataMode", StringValue ("OfdmRate54Mbps"),
1309  "ControlMode", StringValue ("OfdmRate24Mbps"));
1311  Ssid ssid = Ssid ("ns-3-ssid");
1312  mac.SetType ("ns3::AdhocWifiMac",
1313  "QosSupported", BooleanValue (true));
1314 
1315  NetDeviceContainer wifiDevices;
1316  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1317 
1318  // Assign fixed streams to random variables in use
1319  wifi.AssignStreams (wifiDevices, streamNumber);
1320 
1322  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1323 
1324  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1325  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1326  mobility.SetPositionAllocator (positionAlloc);
1327 
1328  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1329  mobility.Install (wifiNodes);
1330 
1331  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1332  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1333 
1334  PacketSocketAddress socket;
1335  socket.SetSingleDevice (device1->GetIfIndex ());
1336  socket.SetPhysicalAddress (device2->GetAddress ());
1337  socket.SetProtocol (1);
1338 
1339  PacketSocketHelper packetSocket;
1340  packetSocket.Install (wifiNodes);
1341 
1342  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1343  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1344  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1345  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1346  clientLowPriority->SetRemote (socket);
1347  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1348  clientLowPriority->SetStartTime (Seconds (0.0));
1349  clientLowPriority->SetStopTime (Seconds (1.0));
1350 
1351  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1352  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1353  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1354  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1355  clientHighPriority->SetRemote (socket);
1356  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1357  clientHighPriority->SetStartTime (Seconds (0.0));
1358  clientHighPriority->SetStopTime (Seconds (1.0));
1359 
1360  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1361  server->SetLocal (socket);
1362  wifiNodes.Get (1)->AddApplication (server);
1363  server->SetStartTime (Seconds (0.0));
1364  server->SetStopTime (Seconds (1.0));
1365 
1366  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1367 
1368  Simulator::Stop (Seconds (1.0));
1369  Simulator::Run ();
1370  Simulator::Destroy ();
1371 
1372  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1373 }
1374 
1375 //-----------------------------------------------------------------------------
1389 {
1390 public:
1391  Bug2843TestCase ();
1392  virtual ~Bug2843TestCase ();
1393  virtual void DoRun (void);
1394 
1395 private:
1399  typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1400  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1401 
1408  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1415  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1416 
1417  uint16_t m_channelWidth;
1418 };
1419 
1421  : TestCase ("Test case for Bug 2843"),
1422  m_channelWidth (20)
1423 {
1424 }
1425 
1427 {
1428 }
1429 
1430 void
1432 {
1433  // Extract starting frequency and number of subbands
1434  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1435  std::size_t numBands = c->GetNumBands ();
1436  double startingFreq = c->Begin ()->fl;
1437 
1438  // Get channel bandwidth and modulation class
1439  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1440 
1441  Ptr<WifiPpdu> ppdu = Copy (wifiTxParams->ppdu);
1442  WifiTxVector txVector = ppdu->GetTxVector ();
1443  m_channelWidth = txVector.GetChannelWidth ();
1444  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1445 
1446  // Build a tuple and check if seen before (if so store it)
1447  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, m_channelWidth, numBands, modulationClass);
1448  bool found = false;
1449  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1450  {
1451  if (*it == tupleForCurrentTx)
1452  {
1453  found = true;
1454  }
1455  }
1456  if (!found)
1457  {
1458  m_distinctTuples.push_back (tupleForCurrentTx);
1459  }
1460 }
1461 
1462 void
1463 Bug2843TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1464  Address& destination) const
1465 {
1466  for (uint8_t i = 0; i < numPackets; i++)
1467  {
1468  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1469  sourceDevice->Send (pkt, destination, 0);
1470  }
1471 }
1472 
1473 void
1475 {
1476  uint16_t channelWidth = 40; // at least 40 MHz expected here
1477 
1478  NodeContainer wifiStaNode;
1479  wifiStaNode.Create (1);
1480 
1482  wifiApNode.Create (1);
1483 
1484  SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default ();
1485  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1486  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1487  lossModel->SetFrequency (5.180e9);
1488  spectrumChannel->AddPropagationLossModel (lossModel);
1489 
1491  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1492  spectrumChannel->SetPropagationDelayModel (delayModel);
1493 
1494  spectrumPhy.SetChannel (spectrumChannel);
1495  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1496  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1497  spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
1498  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1499  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1500 
1501  WifiHelper wifi;
1502  wifi.SetStandard (WIFI_STANDARD_80211ac);
1503  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1504  "DataMode", StringValue ("VhtMcs8"),
1505  "ControlMode", StringValue ("VhtMcs8"),
1506  "RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1507 
1509  mac.SetType ("ns3::StaWifiMac");
1510  NetDeviceContainer staDevice;
1511  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1512 
1513  mac.SetType ("ns3::ApWifiMac");
1514  NetDeviceContainer apDevice;
1515  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1516 
1518  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1519  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1520  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1521  mobility.SetPositionAllocator (positionAlloc);
1522 
1523  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1524  mobility.Install (wifiApNode);
1525  mobility.Install (wifiStaNode);
1526 
1527  // Send two 5 packet-bursts
1528  Simulator::Schedule (Seconds (0.5), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1529  Simulator::Schedule (Seconds (0.6), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1530 
1531  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2843TestCase::StoreDistinctTuple, this));
1532 
1533  Simulator::Stop (Seconds (0.8));
1534  Simulator::Run ();
1535 
1536  Simulator::Destroy ();
1537 
1538  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1539  std::size_t numberTuples = m_distinctTuples.size ();
1540  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1541  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");
1542  // Note that the first tuple should the one initiated by the beacon, i.e. non-HT OFDM (20 MHz)
1543  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1544  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)");
1545  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1546  // Second tuple
1547  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1548  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)");
1549  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1550 }
1551 
1552 //-----------------------------------------------------------------------------
1565 {
1566 public:
1567  Bug2831TestCase ();
1568  virtual ~Bug2831TestCase ();
1569  virtual void DoRun (void);
1570 
1571 private:
1575  void ChangeSupportedChannelWidth (void);
1581  void RxCallback (std::string context, Ptr<const Packet> p);
1582 
1585 
1590 };
1591 
1593  : TestCase ("Test case for Bug 2831"),
1594  m_reassocReqCount (0),
1595  m_reassocRespCount (0),
1596  m_countOperationalChannelWidth20 (0),
1597  m_countOperationalChannelWidth40 (0)
1598 {
1599 }
1600 
1602 {
1603 }
1604 
1605 void
1607 {
1608  m_apPhy->SetChannelNumber (38);
1609  m_apPhy->SetChannelWidth (40);
1610  m_staPhy->SetChannelNumber (38);
1611  m_staPhy->SetChannelWidth (40);
1612 }
1613 
1614 void
1616 {
1617  Ptr<Packet> packet = p->Copy ();
1618  WifiMacHeader hdr;
1619  packet->RemoveHeader (hdr);
1620  if (hdr.IsReassocReq ())
1621  {
1623  }
1624  else if (hdr.IsReassocResp ())
1625  {
1627  }
1628  else if (hdr.IsBeacon ())
1629  {
1630  MgtBeaconHeader beacon;
1631  packet->RemoveHeader (beacon);
1632  HtOperation htOperation = beacon.GetHtOperation ();
1633  if (htOperation.GetStaChannelWidth () > 0)
1634  {
1636  }
1637  else
1638  {
1640  }
1641  }
1642 }
1643 
1644 void
1646 {
1647  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1648  ObjectFactory propDelay;
1649  propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1650  Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1651  Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel> ();
1652  channel->SetPropagationDelayModel (propagationDelay);
1653  channel->SetPropagationLossModel (propagationLoss);
1654 
1655  Ptr<Node> apNode = CreateObject<Node> ();
1656  Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1657  Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration> ();
1658  apDev->SetHtConfiguration (apHtConfiguration);
1660  mac.SetTypeId ("ns3::ApWifiMac");
1661  mac.Set ("EnableBeaconJitter", BooleanValue (false));
1662  Ptr<WifiMac> apMac = mac.Create<WifiMac> ();
1663  apMac->SetDevice (apDev);
1665 
1666  Ptr<Node> staNode = CreateObject<Node> ();
1667  Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> ();
1668  Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration> ();
1669  staDev->SetHtConfiguration (staHtConfiguration);
1670  mac.SetTypeId ("ns3::StaWifiMac");
1671  Ptr<WifiMac> staMac = mac.Create<WifiMac> ();
1672  staMac->SetDevice (staDev);
1674 
1675  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
1676  apMobility->SetPosition (Vector (0.0, 0.0, 0.0));
1677  apNode->AggregateObject (apMobility);
1678 
1679  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
1680  m_apPhy = CreateObject<YansWifiPhy> ();
1681  m_apPhy->SetErrorRateModel (error);
1683  m_apPhy->SetMobility (apMobility);
1684  m_apPhy->SetDevice (apDev);
1686  m_apPhy->SetChannelNumber (36);
1687  m_apPhy->SetChannelWidth (20);
1688 
1689  Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel> ();
1690  staMobility->SetPosition (Vector (1.0, 0.0, 0.0));
1691  staNode->AggregateObject (staMobility);
1692 
1693  m_staPhy = CreateObject<YansWifiPhy> ();
1694  m_staPhy->SetErrorRateModel (error);
1696  m_staPhy->SetMobility (staMobility);
1697  m_staPhy->SetDevice (apDev);
1699  m_staPhy->SetChannelNumber (36);
1700  m_staPhy->SetChannelWidth (20);
1701 
1702  apMac->SetAddress (Mac48Address::Allocate ());
1703  apDev->SetMac (apMac);
1704  apDev->SetPhy (m_apPhy);
1705  ObjectFactory manager;
1706  manager.SetTypeId ("ns3::ConstantRateWifiManager");
1707  apDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1708  apNode->AddDevice (apDev);
1709 
1710  staMac->SetAddress (Mac48Address::Allocate ());
1711  staDev->SetMac (staMac);
1712  staDev->SetPhy (m_staPhy);
1713  staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1714  staNode->AddDevice (staDev);
1715 
1716  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this));
1717 
1718  Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1719 
1720  Simulator::Stop (Seconds (3.0));
1721  Simulator::Run ();
1722  Simulator::Destroy ();
1723 
1724  NS_TEST_ASSERT_MSG_EQ (m_reassocReqCount, 1, "Reassociation request not received");
1725  NS_TEST_ASSERT_MSG_EQ (m_reassocRespCount, 1, "Reassociation response not received");
1726  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operational channel width before channel change");
1727  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operational channel width after channel change");
1728 }
1729 
1730 //-----------------------------------------------------------------------------
1747 {
1748 public:
1750  virtual ~StaWifiMacScanningTestCase ();
1751  virtual void DoRun (void);
1752 
1753 private:
1759  void AssocCallback (std::string context, Mac48Address bssid);
1764  void TurnBeaconGenerationOn (Ptr<Node> apNode);
1769  void TurnApOff (Ptr<Node> apNode);
1776  NodeContainer Setup (bool nearestApBeaconGeneration, bool staActiveProbe);
1777 
1779 };
1780 
1782  : TestCase ("Test case for StaWifiMac scanning capability")
1783 {
1784 }
1785 
1787 {
1788 }
1789 
1790 void
1792 {
1793  m_associatedApBssid = bssid;
1794 }
1795 
1796 void
1798 {
1799  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1800  Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac> (netDevice->GetMac ());
1801  mac->SetAttribute ("BeaconGeneration", BooleanValue (true));
1802 }
1803 
1804 void
1806 {
1807  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1808  Ptr<WifiPhy> phy = netDevice->GetPhy ();
1809  phy->SetOffMode ();
1810 }
1811 
1813 StaWifiMacScanningTestCase::Setup (bool nearestApBeaconGeneration, bool staActiveProbe)
1814 {
1815  RngSeedManager::SetSeed (1);
1816  RngSeedManager::SetRun (1);
1817  int64_t streamNumber = 1;
1818 
1819  NodeContainer apNodes;
1820  apNodes.Create (2);
1821 
1822  Ptr<Node> apNodeNearest = CreateObject<Node> ();
1823  Ptr<Node> staNode = CreateObject<Node> ();
1824 
1825  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1826  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1827  phy.SetChannel (channel.Create ());
1828 
1829  WifiHelper wifi;
1830  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
1831  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
1832 
1834  NetDeviceContainer apDevice, apDeviceNearest;
1835  mac.SetType ("ns3::ApWifiMac",
1836  "BeaconGeneration", BooleanValue (true));
1837  apDevice = wifi.Install (phy, mac, apNodes);
1838  mac.SetType ("ns3::ApWifiMac",
1839  "BeaconGeneration", BooleanValue (nearestApBeaconGeneration));
1840  apDeviceNearest = wifi.Install (phy, mac, apNodeNearest);
1841 
1842  NetDeviceContainer staDevice;
1843  mac.SetType ("ns3::StaWifiMac",
1844  "ActiveProbing", BooleanValue (staActiveProbe));
1845  staDevice = wifi.Install (phy, mac, staNode);
1846 
1847  // Assign fixed streams to random variables in use
1848  wifi.AssignStreams (apDevice, streamNumber);
1849  wifi.AssignStreams (apDeviceNearest, streamNumber + 1);
1850  wifi.AssignStreams (staDevice, streamNumber + 2);
1851 
1853  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1854  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Furthest AP
1855  positionAlloc->Add (Vector (10.0, 0.0, 0.0)); // Second nearest AP
1856  positionAlloc->Add (Vector (5.0, 5.0, 0.0)); // Nearest AP
1857  positionAlloc->Add (Vector (6.0, 5.0, 0.0)); // STA
1858  mobility.SetPositionAllocator (positionAlloc);
1859 
1860  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1861  mobility.Install (apNodes);
1862  mobility.Install (apNodeNearest);
1863  mobility.Install (staNode);
1864 
1865  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc", MakeCallback (&StaWifiMacScanningTestCase::AssocCallback, this));
1866 
1867  NodeContainer allNodes = NodeContainer (apNodes, apNodeNearest, staNode);
1868  return allNodes;
1869 }
1870 
1871 void
1873 {
1874  {
1875  NodeContainer nodes = Setup (false, false);
1876  Ptr<Node> nearestAp = nodes.Get (2);
1877  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1878 
1879  Simulator::Schedule (Seconds (0.05), &StaWifiMacScanningTestCase::TurnBeaconGenerationOn, this, nearestAp);
1880 
1881  Simulator::Stop (Seconds (0.2));
1882  Simulator::Run ();
1883  Simulator::Destroy ();
1884 
1885  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1886  }
1888  {
1889  NodeContainer nodes = Setup (true, true);
1890  Ptr<Node> nearestAp = nodes.Get (2);
1891  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1892 
1893  Simulator::Stop (Seconds (0.2));
1894  Simulator::Run ();
1895  Simulator::Destroy ();
1896 
1897  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1898  }
1900  {
1901  NodeContainer nodes = Setup (true, false);
1902  Ptr<Node> nearestAp = nodes.Get (2);
1903  Mac48Address secondNearestApAddr = DynamicCast<WifiNetDevice> (nodes.Get (1)->GetDevice (0))->GetMac ()->GetAddress ();
1904 
1905  Simulator::Schedule (Seconds (0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
1906 
1907  Simulator::Stop (Seconds (1.5));
1908  Simulator::Run ();
1909  Simulator::Destroy ();
1910 
1911  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, secondNearestApAddr, "STA is associated to the wrong AP");
1912  }
1913 }
1914 
1915 //-----------------------------------------------------------------------------
1939 {
1940 public:
1941  Bug2470TestCase ();
1942  virtual ~Bug2470TestCase ();
1943  virtual void DoRun (void);
1944 
1945 private:
1954  void AddbaStateChangedCallback (std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
1964  void RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise);
1971  void RxErrorCallback (std::string context, Ptr<const Packet> p, double snr);
1978  void SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1984  void RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel);
1985 
1994 };
1995 
1997  : TestCase ("Test case for Bug 2470"),
1998  m_receivedNormalMpduCount (0),
1999  m_receivedAmpduCount (0),
2000  m_failedActionCount (0),
2001  m_addbaEstablishedCount (0),
2002  m_addbaPendingCount (0),
2003  m_addbaRejectedCount (0),
2004  m_addbaNoReplyCount (0),
2005  m_addbaResetCount (0)
2006 {
2007 }
2008 
2010 {
2011 }
2012 
2013 void
2015 {
2016  switch (state)
2017  {
2018  case OriginatorBlockAckAgreement::ESTABLISHED:
2020  break;
2021  case OriginatorBlockAckAgreement::PENDING:
2023  break;
2024  case OriginatorBlockAckAgreement::REJECTED:
2026  break;
2027  case OriginatorBlockAckAgreement::NO_REPLY:
2029  break;
2030  case OriginatorBlockAckAgreement::RESET:
2032  break;
2033  }
2034 }
2035 
2036 void
2037 Bug2470TestCase::RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise)
2038 {
2039  Ptr<Packet> packet = p->Copy ();
2040  if (aMpdu.type != MpduType::NORMAL_MPDU)
2041  {
2043  }
2044  else
2045  {
2046  WifiMacHeader hdr;
2047  packet->RemoveHeader (hdr);
2048  if (hdr.IsData ())
2049  {
2051  }
2052  }
2053 }
2054 
2055 void
2056 Bug2470TestCase::RxErrorCallback (std::string context, Ptr<const Packet> p, double snr)
2057 {
2058  Ptr<Packet> packet = p->Copy ();
2059  WifiMacHeader hdr;
2060  packet->RemoveHeader (hdr);
2061  if (hdr.IsAction ())
2062  {
2064  }
2065 }
2066 
2067 void
2068 Bug2470TestCase::SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice,
2069  Address& destination) const
2070 {
2071  for (uint32_t i = 0; i < numPackets; i++)
2072  {
2073  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2074  sourceDevice->Send (pkt, destination, 0);
2075  }
2076 }
2077 
2078 void
2080 {
2081  RngSeedManager::SetSeed (1);
2082  RngSeedManager::SetRun (1);
2083  int64_t streamNumber = 200;
2084 
2085  NodeContainer wifiApNode, wifiStaNode;
2086  wifiApNode.Create (1);
2087  wifiStaNode.Create (1);
2088 
2089  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2090  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2091  phy.SetChannel (channel.Create ());
2092 
2093  WifiHelper wifi;
2094  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
2095  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2096  "DataMode", StringValue ("HtMcs7"),
2097  "ControlMode", StringValue ("HtMcs7"));
2098 
2100  NetDeviceContainer apDevice;
2101  phy.Set ("PostReceptionErrorModel", apErrorModel);
2102  mac.SetType ("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue (false));
2103  apDevice = wifi.Install (phy, mac, wifiApNode);
2104 
2105  NetDeviceContainer staDevice;
2106  phy.Set ("PostReceptionErrorModel", staErrorModel);
2107  mac.SetType ("ns3::StaWifiMac");
2108  staDevice = wifi.Install (phy, mac, wifiStaNode);
2109 
2110  // Assign fixed streams to random variables in use
2111  wifi.AssignStreams (apDevice, streamNumber);
2112  wifi.AssignStreams (staDevice, streamNumber);
2113 
2115  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2116  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2117  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2118  mobility.SetPositionAllocator (positionAlloc);
2119 
2120  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2121  mobility.Install (wifiApNode);
2122  mobility.Install (wifiStaNode);
2123 
2124  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this));
2125  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&Bug2470TestCase::RxErrorCallback, this));
2126  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this));
2127 
2128  Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2129  Simulator::Schedule (Seconds (0.5) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2130  Simulator::Schedule (Seconds (0.8), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2131  Simulator::Schedule (Seconds (0.8) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2132 
2133  Simulator::Stop (Seconds (1.0));
2134  Simulator::Run ();
2135  Simulator::Destroy ();
2136 }
2137 
2138 void
2140 {
2141  // Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel
2142  // instead of ListErrorModel since packet UID is incremented between simulations. But
2143  // problem may occur because of random stream, therefore we suppress usage of RNG as
2144  // much as possible (i.e., removing beacon jitter).
2145  Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel> ();
2146  std::list<uint32_t> blackList;
2147  // Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2148  blackList.push_back (8);
2149  blackList.push_back (9);
2150  blackList.push_back (10);
2151  blackList.push_back (11);
2152  blackList.push_back (12);
2153  blackList.push_back (13);
2154  staPem->SetList (blackList);
2155 
2156  {
2157  RunSubtest (PointerValue (), PointerValue (staPem));
2158  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 6, "ADDBA request packets are not failed");
2159  // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by normal
2160  // MPDU because of failed ADDBA handshake. For the second set, the first packet should be sent by
2161  // normal MPDU, and the rest with A-MPDU. In total we expect to receive 2 normal MPDU packets and
2162  // 8 A-MPDU packets.
2163  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 2, "Receiving incorrect number of normal MPDU packet on subtest 1");
2164  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 8, "Receiving incorrect number of A-MPDU packet on subtest 1");
2165 
2166  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 1");
2167  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2168  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2169  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 0, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2170  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2171  }
2172 
2175  m_failedActionCount = 0;
2177  m_addbaPendingCount = 0;
2179  m_addbaNoReplyCount = 0;
2180  m_addbaResetCount = 0;
2181 
2182  Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel> ();
2183  blackList.clear ();
2184  // Block ADDBA request 3 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2185  blackList.push_back (4);
2186  blackList.push_back (5);
2187  blackList.push_back (6);
2188  apPem->SetList (blackList);
2189 
2190  {
2191  RunSubtest (PointerValue (apPem), PointerValue ());
2192  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 3, "ADDBA response packets are not failed");
2193  // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU packets.
2194  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 6, "Receiving incorrect number of normal MPDU packet on subtest 2");
2195  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 4, "Receiving incorrect number of A-MPDU packet on subtest 2");
2196 
2197  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 2");
2198  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2199  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2200  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 1, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2201  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2202  }
2203 
2204  // TODO: In the second test set, it does not go to reset state since ADDBA response is received after timeout (NO_REPLY)
2205  // but before it does not enter RESET state. More tests should be written to verify all possible scenarios.
2206 }
2207 
2208 
2209 //-----------------------------------------------------------------------------
2225 {
2226 public:
2227  Issue40TestCase ();
2228  virtual ~Issue40TestCase ();
2229  virtual void DoRun (void);
2230 
2231 private:
2236  void RunOne (bool useAmpdu);
2237 
2243  void RxSuccessCallback (std::string context, Ptr<const Packet> p);
2250  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination);
2256  void TxFinalDataFailedCallback (std::string context, Mac48Address address);
2257 
2258  uint16_t m_rxCount;
2259  uint16_t m_txCount;
2261 };
2262 
2264  : TestCase ("Test case for issue #40"),
2265  m_rxCount (0),
2266  m_txCount (0),
2267  m_txMacFinalDataFailedCount (0)
2268 {
2269 }
2270 
2272 {
2273 }
2274 
2275 void
2277 {
2278  m_rxCount++;
2279 }
2280 
2281 void
2282 Issue40TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination)
2283 {
2284  for (uint8_t i = 0; i < numPackets; i++)
2285  {
2286  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2287  sourceDevice->Send (pkt, destination, 0);
2288  m_txCount++;
2289  }
2290 }
2291 
2292 void
2294 {
2296 }
2297 
2298 void
2300 {
2301  m_rxCount = 0;
2302  m_txCount = 0;
2304 
2305  RngSeedManager::SetSeed (1);
2306  RngSeedManager::SetRun (1);
2307  int64_t streamNumber = 100;
2308 
2309  NodeContainer wifiApNode, wifiStaNode;
2310  wifiApNode.Create (1);
2311  wifiStaNode.Create (1);
2312 
2313  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2314  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2315  phy.SetChannel (channel.Create ());
2316 
2317  WifiHelper wifi;
2318  wifi.SetStandard (WIFI_STANDARD_80211ac);
2319  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2320 
2322  NetDeviceContainer apDevice;
2323  mac.SetType ("ns3::ApWifiMac");
2324  apDevice = wifi.Install (phy, mac, wifiApNode);
2325 
2326  NetDeviceContainer staDevice;
2327  mac.SetType ("ns3::StaWifiMac");
2328  staDevice = wifi.Install (phy, mac, wifiStaNode);
2329 
2330  // Assign fixed streams to random variables in use
2331  wifi.AssignStreams (apDevice, streamNumber);
2332  wifi.AssignStreams (staDevice, streamNumber);
2333 
2335  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2336  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2337  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
2338  mobility.SetPositionAllocator (positionAlloc);
2339 
2340  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2341  mobility.Install (wifiApNode);
2342 
2343  mobility.SetMobilityModel("ns3::WaypointMobilityModel");
2344  mobility.Install (wifiStaNode);
2345 
2346  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxFinalDataFailed", MakeCallback (&Issue40TestCase::TxFinalDataFailedCallback, this));
2347  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/MacRx", MakeCallback (&Issue40TestCase::RxSuccessCallback, this));
2348 
2349  Ptr<WaypointMobilityModel> staWaypointMobility = DynamicCast<WaypointMobilityModel>(wifiStaNode.Get(0)->GetObject<MobilityModel>());
2350  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.0), Vector (10.0, 0.0, 0.0)));
2351  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.5), Vector (50.0, 0.0, 0.0)));
2352 
2353  if (useAmpdu)
2354  {
2355  // 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
2356  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevice.Get (0));
2357  Ptr<RegularWifiMac> ap_mac = DynamicCast<RegularWifiMac> (ap_device->GetMac ());
2358  NS_ASSERT (ap_mac);
2359  PointerValue ptr;
2360  ap_mac->GetAttribute ("BE_Txop", ptr);
2361  ptr.Get<QosTxop> ()->SetAttribute ("UseExplicitBarAfterMissedBlockAck", BooleanValue (false));
2362  }
2363 
2364  // Transmit a first data packet before the station moves: it should be sent with a high modulation and successfully received
2365  Simulator::Schedule (Seconds (0.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2366 
2367  // 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
2368  Simulator::Schedule (Seconds (2.0), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2369 
2370  // 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
2371  Simulator::Schedule (Seconds (2.1), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2372  Simulator::Schedule (Seconds (2.2), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2373  Simulator::Schedule (Seconds (2.3), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2374  Simulator::Schedule (Seconds (2.4), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2375  Simulator::Schedule (Seconds (2.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2376 
2377  Simulator::Stop (Seconds (3.0));
2378  Simulator::Run ();
2379 
2380  NS_TEST_ASSERT_MSG_EQ (m_txCount, (useAmpdu ? 14 : 7), "Incorrect number of transmitted packets");
2381  NS_TEST_ASSERT_MSG_EQ (m_rxCount, (useAmpdu ? 12 : 6), "Incorrect number of successfully received packets");
2382  NS_TEST_ASSERT_MSG_EQ (m_txMacFinalDataFailedCount, 1, "Incorrect number of dropped TX packets");
2383 
2384  Simulator::Destroy ();
2385 }
2386 
2387 void
2389 {
2390  //Test without A-MPDU
2391  RunOne (false);
2392 
2393  //Test with A-MPDU
2394  RunOne (true);
2395 }
2396 
2397 //-----------------------------------------------------------------------------
2411 {
2412 public:
2413  Issue169TestCase ();
2414  virtual ~Issue169TestCase ();
2415  virtual void DoRun (void);
2416 
2417 private:
2425  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority);
2426 
2434  void TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW);
2435 };
2436 
2438  : TestCase ("Test case for issue #169")
2439 {
2440 }
2441 
2443 {
2444 }
2445 
2446 void
2447 Issue169TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority)
2448 {
2449  SocketPriorityTag priorityTag;
2450  priorityTag.SetPriority (priority);
2451  for (uint8_t i = 0; i < numPackets; i++)
2452  {
2453  Ptr<Packet> packet = Create<Packet> (1000); // 1000 dummy bytes of data
2454  packet->AddPacketTag (priorityTag);
2455  sourceDevice->Send (packet, destination, 0);
2456  }
2457 }
2458 
2459 void
2460 Issue169TestCase::TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW)
2461 {
2462  if (psdu->GetSize () >= 1000)
2463  {
2464  NS_TEST_ASSERT_MSG_EQ (txVector.GetMode ().GetModulationClass (), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Ideal rate manager selected incorrect modulation class");
2465  }
2466 }
2467 
2468 void
2470 {
2471  RngSeedManager::SetSeed (1);
2472  RngSeedManager::SetRun (1);
2473  int64_t streamNumber = 100;
2474 
2475  NodeContainer wifiApNode, wifiStaNode;
2476  wifiApNode.Create (1);
2477  wifiStaNode.Create (1);
2478 
2479  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2480  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2481  phy.SetChannel (channel.Create ());
2482 
2483  WifiHelper wifi;
2484  wifi.SetStandard (WIFI_STANDARD_80211ac);
2485  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2486 
2488  NetDeviceContainer apDevice;
2489  mac.SetType ("ns3::ApWifiMac");
2490  apDevice = wifi.Install (phy, mac, wifiApNode);
2491 
2492  NetDeviceContainer staDevice;
2493  mac.SetType ("ns3::StaWifiMac");
2494  staDevice = wifi.Install (phy, mac, wifiStaNode);
2495 
2496  // Assign fixed streams to random variables in use
2497  wifi.AssignStreams (apDevice, streamNumber);
2498  wifi.AssignStreams (staDevice, streamNumber);
2499 
2501  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2502  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2503  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2504  mobility.SetPositionAllocator (positionAlloc);
2505 
2506  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2507  mobility.Install (wifiApNode);
2508  mobility.Install (wifiStaNode);
2509 
2510  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&Issue169TestCase::TxCallback, this));
2511 
2512  //Send best-effort packet (i.e. priority 0)
2513  Simulator::Schedule (Seconds (0.5), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 0);
2514 
2515  //Send non best-effort (voice) packet (i.e. priority 6)
2516  Simulator::Schedule (Seconds (1.0), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 6);
2517 
2518  Simulator::Stop (Seconds (2.0));
2519  Simulator::Run ();
2520 
2521  Simulator::Destroy ();
2522 }
2523 
2524 
2525 //-----------------------------------------------------------------------------
2541 {
2542 public:
2545  virtual void DoRun (void);
2546 
2547 private:
2552  void ChangeChannelWidth (uint16_t channelWidth);
2553 
2559  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2560 
2568  void TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW);
2569 
2574  void CheckLastSelectedMode (WifiMode expectedMode);
2575 
2577 };
2578 
2580  : TestCase ("Test case for use of channel bonding with Ideal rate manager")
2581 {
2582 }
2583 
2585 {
2586 }
2587 
2588 void
2590 {
2591  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", UintegerValue (channelWidth));
2592 }
2593 
2594 void
2596 {
2597  Ptr<Packet> packet = Create<Packet> (1000);
2598  sourceDevice->Send (packet, destination, 0);
2599 }
2600 
2601 void
2602 IdealRateManagerChannelWidthTest::TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW)
2603 {
2604  if (psdu->GetSize () >= 1000)
2605  {
2606  m_txMode = txVector.GetMode ();
2607  }
2608 }
2609 
2610 void
2612 {
2613  NS_TEST_ASSERT_MSG_EQ (m_txMode, expectedMode, "Last selected WifiMode " << m_txMode << " does not match expected WifiMode " << expectedMode);
2614 }
2615 
2616 void
2618 {
2619  RngSeedManager::SetSeed (1);
2620  RngSeedManager::SetRun (1);
2621  int64_t streamNumber = 100;
2622 
2623  NodeContainer wifiApNode, wifiStaNode;
2624  wifiApNode.Create (1);
2625  wifiStaNode.Create (1);
2626 
2627  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2628  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2629  phy.SetChannel (channel.Create ());
2630 
2631  WifiHelper wifi;
2632  wifi.SetStandard (WIFI_STANDARD_80211ac);
2633  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2634 
2636  NetDeviceContainer apDevice;
2637  mac.SetType ("ns3::ApWifiMac");
2638  apDevice = wifi.Install (phy, mac, wifiApNode);
2639 
2640  NetDeviceContainer staDevice;
2641  mac.SetType ("ns3::StaWifiMac");
2642  staDevice = wifi.Install (phy, mac, wifiStaNode);
2643 
2644  // Assign fixed streams to random variables in use
2645  wifi.AssignStreams (apDevice, streamNumber);
2646  wifi.AssignStreams (staDevice, streamNumber);
2647 
2649  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2650  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2651  positionAlloc->Add (Vector (50.0, 0.0, 0.0));
2652  mobility.SetPositionAllocator (positionAlloc);
2653 
2654  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2655  mobility.Install (wifiApNode);
2656  mobility.Install (wifiStaNode);
2657 
2658  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerChannelWidthTest::TxCallback, this));
2659 
2660  //Set channel width to 80 MHz & send packet
2661  Simulator::Schedule (Seconds (0.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 80);
2662  Simulator::Schedule (Seconds (1.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2663  //Selected rate should be VHT-MCS 0
2664  Simulator::Schedule (Seconds (1.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs0 ());
2665 
2666  //Set channel width to 20 MHz & send packet
2667  Simulator::Schedule (Seconds (1.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 20);
2668  Simulator::Schedule (Seconds (2.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2669  //Selected rate should be VHT-MCS 2 since SNR should be 6 dB higher than previously
2670  Simulator::Schedule (Seconds (2.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2671 
2672  //Set channel width to 40 MHz & send packet
2673  Simulator::Schedule (Seconds (2.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 40);
2674  Simulator::Schedule (Seconds (3.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2675  //Selected rate should be VHT-MCS 1 since SNR should be 3 dB lower than previously
2676  Simulator::Schedule (Seconds (3.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2677 
2678  Simulator::Stop (Seconds (3.2));
2679  Simulator::Run ();
2680 
2681  Simulator::Destroy ();
2682 }
2683 
2684 
2685 //-----------------------------------------------------------------------------
2694 {
2695 public:
2697  virtual ~IdealRateManagerMimoTest ();
2698  virtual void DoRun (void);
2699 
2700 private:
2706  void SetApMimoSettings (uint8_t antennas, uint8_t maxStreams);
2712  void SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams);
2718  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2719 
2727  void TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW);
2728 
2733  void CheckLastSelectedMode (WifiMode expectedMode);
2738  void CheckLastSelectedNss (uint8_t expectedNss);
2739 
2741 };
2742 
2744  : TestCase ("Test case for use of imbalanced MIMO settings with Ideal rate manager")
2745 {
2746 }
2747 
2749 {
2750 }
2751 
2752 void
2753 IdealRateManagerMimoTest::SetApMimoSettings (uint8_t antennas, uint8_t maxStreams)
2754 {
2755  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2756  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2757  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2758 }
2759 
2760 void
2761 IdealRateManagerMimoTest::SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams)
2762 {
2763  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2764  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2765  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2766 }
2767 
2768 void
2770 {
2771  Ptr<Packet> packet = Create<Packet> (1000);
2772  sourceDevice->Send (packet, destination, 0);
2773 }
2774 
2775 void
2776 IdealRateManagerMimoTest::TxCallback (std::string context, Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW)
2777 {
2778  if (psdu->GetSize () >= 1000)
2779  {
2780  m_txVector = txVector;
2781  }
2782 }
2783 
2784 void
2786 {
2787  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetNss (), expectedNss, "Last selected Nss " << m_txVector.GetNss () << " does not match expected Nss " << expectedNss);
2788 }
2789 
2790 void
2792 {
2793  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetMode (), expectedMode, "Last selected WifiMode " << m_txVector.GetMode () << " does not match expected WifiMode " << expectedMode);
2794 }
2795 
2796 void
2798 {
2799  RngSeedManager::SetSeed (1);
2800  RngSeedManager::SetRun (1);
2801  int64_t streamNumber = 100;
2802 
2803  NodeContainer wifiApNode, wifiStaNode;
2804  wifiApNode.Create (1);
2805  wifiStaNode.Create (1);
2806 
2807  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2808  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2809  phy.SetChannel (channel.Create ());
2810 
2811  WifiHelper wifi;
2812  wifi.SetStandard (WIFI_STANDARD_80211ac);
2813  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2814 
2816  NetDeviceContainer apDevice;
2817  mac.SetType ("ns3::ApWifiMac");
2818  apDevice = wifi.Install (phy, mac, wifiApNode);
2819 
2820  NetDeviceContainer staDevice;
2821  mac.SetType ("ns3::StaWifiMac");
2822  staDevice = wifi.Install (phy, mac, wifiStaNode);
2823 
2824  // Assign fixed streams to random variables in use
2825  wifi.AssignStreams (apDevice, streamNumber);
2826  wifi.AssignStreams (staDevice, streamNumber);
2827 
2829  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2830  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2831  positionAlloc->Add (Vector (40.0, 0.0, 0.0));
2832  mobility.SetPositionAllocator (positionAlloc);
2833 
2834  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2835  mobility.Install (wifiApNode);
2836  mobility.Install (wifiStaNode);
2837 
2838  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerMimoTest::TxCallback, this));
2839 
2840 
2841  // TX: 1 antenna
2842  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2843  // RX: 1 antenna
2844  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2845  // Send packets (2 times to get one feedback)
2846  Simulator::Schedule (Seconds (1.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2847  Simulator::Schedule (Seconds (1.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2848  // Selected NSS should be 1 since both TX and RX support a single antenna
2849  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2850  // Selected rate should be VHT-MCS1 because of settings and distance between TX and RX
2851  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2852 
2853 
2854  // TX: 1 antenna
2855  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2856  // RX: 2 antennas, but only supports 1 spatial stream
2857  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2858  // Send packets (2 times to get one feedback)
2859  Simulator::Schedule (Seconds (2.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2860  Simulator::Schedule (Seconds (2.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2861  // Selected NSS should be 1 since both TX and RX support a single antenna
2862  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2863  // Selected rate should be increased to VHT-MCS2 because of RX diversity resulting in SNR improvement of about 3dB
2864  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2865 
2866 
2867  // TX: 1 antenna
2868  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2869  // RX: 2 antennas, and supports 2 spatial streams
2870  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2871  // Send packets (2 times to get one feedback)
2872  Simulator::Schedule (Seconds (3.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2873  Simulator::Schedule (Seconds (3.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2874  // Selected NSS should be 1 since TX supports a single antenna
2875  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2876  // Selected rate should be as previously
2877  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2878 
2879 
2880  // TX: 2 antennas, but only supports 1 spatial stream
2881  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2882  // RX: 1 antenna
2883  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2884  // Send packets (2 times to get one feedback)
2885  Simulator::Schedule (Seconds (4.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2886  Simulator::Schedule (Seconds (4.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2887  // Selected NSS should be 1 since both TX and RX support a single antenna
2888  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2889  // 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)
2890  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2891 
2892 
2893  // TX: 2 antennas, but only supports 1 spatial stream
2894  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2895  // RX: 2 antennas, but only supports 1 spatial stream
2896  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2897  // Send packets (2 times to get one feedback)
2898  Simulator::Schedule (Seconds (5.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2899  Simulator::Schedule (Seconds (5.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2900  // Selected NSS should be 1 since both TX and RX support a single antenna
2901  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2902  // 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)
2903  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2904 
2905 
2906  // TX: 2 antennas, but only supports 1 spatial stream
2907  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2908  // RX: 2 antennas, and supports 2 spatial streams
2909  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2910  // Send packets (2 times to get one feedback)
2911  Simulator::Schedule (Seconds (6.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2912  Simulator::Schedule (Seconds (6.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2913  // Selected NSS should be 1 since TX supports a single antenna
2914  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2915  // Selected rate should be as previously
2916  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2917 
2918 
2919  // TX: 2 antennas, and supports 2 spatial streams
2920  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2921  // RX: 1 antenna
2922  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2923  // Send packets (2 times to get one feedback)
2924  Simulator::Schedule (Seconds (7.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2925  Simulator::Schedule (Seconds (7.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2926  // Selected NSS should be 1 since RX supports a single antenna
2927  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2928  // 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)
2929  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2930 
2931 
2932  // TX: 2 antennas, and supports 2 spatial streams
2933  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2934  // RX: 2 antennas, but only supports 1 spatial stream
2935  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2936  // Send packets (2 times to get one feedback)
2937  Simulator::Schedule (Seconds (8.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2938  Simulator::Schedule (Seconds (8.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2939  // Selected NSS should be 1 since RX supports a single antenna
2940  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2941  // 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)
2942  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2943 
2944 
2945  // TX: 2 antennas, and supports 2 spatial streams
2946  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2947  // RX: 2 antennas, and supports 2 spatial streams
2948  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2949  // Send packets (2 times to get one feedback)
2950  Simulator::Schedule (Seconds (9.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2951  Simulator::Schedule (Seconds (9.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2952  // Selected NSS should be 2 since both TX and RX support 2 antennas
2953  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 2);
2954  // 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
2955  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2956 
2957 
2958  // Verify we can go back to initial situation
2959  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2960  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2961  Simulator::Schedule (Seconds (10.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2962  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2963  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2964 
2965  Simulator::Stop (Seconds (10.2));
2966  Simulator::Run ();
2967  Simulator::Destroy ();
2968 }
2969 
2976 class WifiTestSuite : public TestSuite
2977 {
2978 public:
2979  WifiTestSuite ();
2980 };
2981 
2983  : TestSuite ("wifi-devices", UNIT)
2984 {
2985  AddTestCase (new WifiTest, TestCase::QUICK);
2986  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
2987  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
2988  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
2989  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
2990  AddTestCase (new QosFragmentationTestCase, TestCase::QUICK);
2991  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
2992  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
2993  AddTestCase (new Bug2843TestCase, TestCase::QUICK); //Bug 2843
2994  AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
2995  AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399
2996  AddTestCase (new Bug2470TestCase, TestCase::QUICK); //Bug 2470
2997  AddTestCase (new Issue40TestCase, TestCase::QUICK); //Issue #40
2998  AddTestCase (new Issue169TestCase, TestCase::QUICK); //Issue #169
2999  AddTestCase (new IdealRateManagerChannelWidthTest, TestCase::QUICK);
3000  AddTestCase (new IdealRateManagerMimoTest, TestCase::QUICK);
3001 }
3002 
MpduInfo structure.
Definition: wifi-phy.h:123
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:2602
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:1588
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
void AddbaStateChangedCallback(std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
Callback when ADDBA state changed.
Definition: wifi-test.cc:2014
virtual ~Bug730TestCase()
Definition: wifi-test.cc:597
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
void PopulateArpCache()
Populate ARP cache function.
virtual ~QosFragmentationTestCase()
Definition: wifi-test.cc:743
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
void TxFinalDataFailedCallback(std::string context, Mac48Address address)
Transmit final data failed function.
Definition: wifi-test.cc:2293
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:1431
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:1938
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1645
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:1872
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
virtual ~IdealRateManagerMimoTest()
Definition: wifi-test.cc:2748
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)
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1372
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:2797
#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:1986
uint16_t m_rxCount
Count number of successfully received data packets.
Definition: wifi-test.cc:2258
void RxCallback(std::string context, Ptr< const Packet > p)
Callback triggered when a packet is received by the PHYs.
Definition: wifi-test.cc:1615
uint16_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:1987
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:2410
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:764
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:1474
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:1463
VHT PHY (Clause 22)
Definition: wifi-mode.h:60
The 5 GHz band.
Definition: wifi-phy-band.h:35
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:218
encapsulates test code
Definition: test.h:1153
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
virtual ~StaWifiMacScanningTestCase()
Definition: wifi-test.cc:1786
uint8_t m_reassocReqCount
count number of reassociation requests
Definition: wifi-test.cc:1586
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:1426
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1791
virtual void ConfigureStandard(WifiStandard standard)=0
helps to create WifiNetDevice objects
Definition: wifi-helper.h:317
Mac48Address m_associatedApBssid
Associated AP&#39;s bssid.
Definition: wifi-test.cc:1778
Make sure that Ideal rate manager recovers when the station is moving away from the access point...
Definition: wifi-test.cc:2224
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:2037
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:2282
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:752
virtual ~Issue169TestCase()
Definition: wifi-test.cc:2442
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1515
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2611
uint16_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:1991
uint16_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:1989
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:2769
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1797
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:2761
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:2009
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:301
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1601
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:1746
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:2576
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:1259
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:2139
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:2299
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:1289
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2617
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:1564
uint16_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:1993
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:918
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:2595
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:783
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:1584
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2791
void TxDataFailedTrace(std::string context, Mac48Address adress)
Transmit data failed function.
Definition: wifi-test.cc:1282
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:181
OFDM PHY (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void SetApMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for AP node.
Definition: wifi-test.cc:2753
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:3003
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1495
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
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:1990
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:1813
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1277
Ptr< const SpectrumModel > GetSpectrumModel() const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1613
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:1666
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:2276
uint8_t m_countOperationalChannelWidth40
count number of beacon frames announcing a 40 MHz operating channel width
Definition: wifi-test.cc:1589
void ChangeChannelWidth(uint16_t channelWidth)
Change the configured channel width for all nodes.
Definition: wifi-test.cc:2589
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:2693
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:1388
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:2056
Wifi Test Suite.
Definition: wifi-test.cc:2976
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1249
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:1399
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:2259
void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel)
Run subtest for this test suite.
Definition: wifi-test.cc:2079
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:116
virtual void SetChannelWidth(uint16_t channelWidth)
Definition: wifi-phy.cc:1501
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1583
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:1278
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:2068
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:2460
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:2388
WifiTxVector m_txVector
Store the last TXVECTOR used to transmit Data.
Definition: wifi-test.cc:2740
Make sure that Ideal rate manager properly selects MCS based on the configured channel width...
Definition: wifi-test.cc:2540
void TurnApOff(Ptr< Node > apNode)
Turn the AP node off.
Definition: wifi-test.cc:1805
uint16_t m_txMacFinalDataFailedCount
Count number of unsuccessfully transmitted data packets.
Definition: wifi-test.cc:2260
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:2785
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1294
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:1992
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2469
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:2271
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:1400
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:1606
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:1988
MpduType type
type
Definition: wifi-phy.h:125
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:2447
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:1587
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:2776
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:1417
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyBand band, WifiPhyStandard standard, uint16_t frequency, uint16_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1277
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