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 #include "ns3/frame-exchange-manager.h"
52 #include "ns3/wifi-default-protection-manager.h"
53 #include "ns3/wifi-default-ack-manager.h"
54 
55 using namespace ns3;
56 
57 //Helper function to assign streams to random variables, to control
58 //randomness in the tests
59 static void
61 {
62  int64_t currentStream = stream;
63  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
64  if (rmac)
65  {
66  PointerValue ptr;
67  rmac->GetAttribute ("Txop", ptr);
68  Ptr<Txop> txop = ptr.Get<Txop> ();
69  currentStream += txop->AssignStreams (currentStream);
70 
71  rmac->GetAttribute ("VO_Txop", ptr);
72  Ptr<QosTxop> vo_txop = ptr.Get<QosTxop> ();
73  currentStream += vo_txop->AssignStreams (currentStream);
74 
75  rmac->GetAttribute ("VI_Txop", ptr);
76  Ptr<QosTxop> vi_txop = ptr.Get<QosTxop> ();
77  currentStream += vi_txop->AssignStreams (currentStream);
78 
79  rmac->GetAttribute ("BE_Txop", ptr);
80  Ptr<QosTxop> be_txop = ptr.Get<QosTxop> ();
81  currentStream += be_txop->AssignStreams (currentStream);
82 
83  rmac->GetAttribute ("BK_Txop", ptr);
84  Ptr<QosTxop> bk_txop = ptr.Get<QosTxop> ();
85  bk_txop->AssignStreams (currentStream);
86  }
87 }
88 
95 class WifiTest : public TestCase
96 {
97 public:
98  WifiTest ();
99 
100  virtual void DoRun (void);
101 
102 
103 private:
105  void RunOne (void);
111  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
117 
121 };
122 
124  : TestCase ("Wifi")
125 {
126 }
127 
128 void
130 {
131  Ptr<Packet> p = Create<Packet> ();
132  dev->Send (p, dev->GetBroadcast (), 1);
133 }
134 
135 void
137 {
138  Ptr<Node> node = CreateObject<Node> ();
139  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
140 
142  mac->SetDevice (dev);
143  mac->SetAddress (Mac48Address::Allocate ());
144  mac->ConfigureStandard (WIFI_STANDARD_80211a);
145  Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager ();
146  Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
147  protectionManager->SetWifiMac (mac);
148  fem->SetProtectionManager (protectionManager);
149  Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
150  ackManager->SetWifiMac (mac);
151  fem->SetAckManager (ackManager);
152 
153  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
154  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
155  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
156  phy->SetErrorRateModel (error);
157  phy->SetChannel (channel);
158  phy->SetDevice (dev);
159  phy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
161 
162  mobility->SetPosition (pos);
163  node->AggregateObject (mobility);
164  dev->SetMac (mac);
165  dev->SetPhy (phy);
166  dev->SetRemoteStationManager (manager);
167  node->AddDevice (dev);
168 
169  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
170 }
171 
172 void
174 {
175  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
177  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
178  channel->SetPropagationDelayModel (propDelay);
179  channel->SetPropagationLossModel (propLoss);
180 
181  CreateOne (Vector (0.0, 0.0, 0.0), channel);
182  CreateOne (Vector (5.0, 0.0, 0.0), channel);
183  CreateOne (Vector (5.0, 0.0, 0.0), channel);
184 
185  Simulator::Stop (Seconds (10.0));
186 
187  Simulator::Run ();
188  Simulator::Destroy ();
189 }
190 
191 void
193 {
194  m_mac.SetTypeId ("ns3::AdhocWifiMac");
195  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
196 
197  m_manager.SetTypeId ("ns3::ArfWifiManager");
198  RunOne ();
199  m_manager.SetTypeId ("ns3::AarfWifiManager");
200  RunOne ();
201  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
202  RunOne ();
203  m_manager.SetTypeId ("ns3::OnoeWifiManager");
204  RunOne ();
205  m_manager.SetTypeId ("ns3::AmrrWifiManager");
206  RunOne ();
207  m_manager.SetTypeId ("ns3::IdealWifiManager");
208  RunOne ();
209 
210  m_mac.SetTypeId ("ns3::AdhocWifiMac");
211  RunOne ();
212  m_mac.SetTypeId ("ns3::ApWifiMac");
213  RunOne ();
214  m_mac.SetTypeId ("ns3::StaWifiMac");
215  RunOne ();
216 
217 
218  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
219  m_mac.SetTypeId ("ns3::AdhocWifiMac");
220  RunOne ();
221 }
222 
230 {
231 public:
232  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
233  {
234  }
235  virtual void DoRun (void)
236  {
237  //startingSeq=0, seqNum=2047
238  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
239  //startingSeq=0, seqNum=2048
240  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
241  //startingSeq=2048, seqNum=0
242  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
243  //startingSeq=4095, seqNum=0
244  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
245  //startingSeq=0, seqNum=4095
246  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
247  //startingSeq=4095 seqNum=2047
248  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
249  //startingSeq=2048 seqNum=4095
250  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
251  //startingSeq=2049 seqNum=0
252  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
253  }
254 };
255 
256 
261 {
262 public:
264 
265  virtual void DoRun (void);
266 
267 
268 private:
285  void SwitchCh (Ptr<WifiNetDevice> dev);
286 
290 };
291 
293  : TestCase ("InterferenceHelperSequence")
294 {
295 }
296 
297 void
299 {
300  Ptr<Packet> p = Create<Packet> (1000);
301  dev->Send (p, dev->GetBroadcast (), 1);
302 }
303 
304 void
306 {
307  Ptr<WifiPhy> p = dev->GetPhy ();
308  p->SetChannelNumber (40);
309 }
310 
311 Ptr<Node>
313 {
314  Ptr<Node> node = CreateObject<Node> ();
315  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
316 
318  mac->SetDevice (dev);
319  mac->SetAddress (Mac48Address::Allocate ());
320  mac->ConfigureStandard (WIFI_STANDARD_80211a);
321  Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager ();
322  Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
323  protectionManager->SetWifiMac (mac);
324  fem->SetProtectionManager (protectionManager);
325  Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
326  ackManager->SetWifiMac (mac);
327  fem->SetAckManager (ackManager);
328 
329  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
330  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
331  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
332  phy->SetErrorRateModel (error);
333  phy->SetChannel (channel);
334  phy->SetDevice (dev);
335  phy->SetMobility (mobility);
336  phy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
338 
339  mobility->SetPosition (pos);
340  node->AggregateObject (mobility);
341  dev->SetMac (mac);
342  dev->SetPhy (phy);
343  dev->SetRemoteStationManager (manager);
344  node->AddDevice (dev);
345 
346  return node;
347 }
348 
349 void
351 {
352  m_mac.SetTypeId ("ns3::AdhocWifiMac");
353  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
354  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
355 
356  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
358  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
359  channel->SetPropagationDelayModel (propDelay);
360  channel->SetPropagationLossModel (propLoss);
361 
362  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
363  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
364  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
365 
366  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
367  propLoss->SetDefaultLoss (999);
368 
369  Simulator::Schedule (Seconds (1.0),
371  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
372 
373  Simulator::Schedule (Seconds (1.0000001),
375  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
376 
377  Simulator::Schedule (Seconds (5.0),
379  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
380 
381  Simulator::Schedule (Seconds (7.0),
383  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
384 
385  Simulator::Stop (Seconds (100.0));
386  Simulator::Run ();
387 
388  Simulator::Destroy ();
389 }
390 
391 //-----------------------------------------------------------------------------
443 {
444 public:
446 
447  virtual void DoRun (void);
448 
449 
450 private:
456 
460 
463  unsigned int m_numSentPackets;
464 
470  void NotifyPhyTxBegin (Ptr<const Packet> p, double txPowerW);
471 };
472 
474  : TestCase ("Test case for DCF immediate access with broadcast frames")
475 {
476 }
477 
478 void
480 {
481  if (m_numSentPackets == 0)
482  {
485  }
486  else if (m_numSentPackets == 1)
487  {
489  }
490 }
491 
492 void
494 {
495  Ptr<Packet> p = Create<Packet> (1000);
496  dev->Send (p, dev->GetBroadcast (), 1);
497 }
498 
499 void
501 {
502  m_mac.SetTypeId ("ns3::AdhocWifiMac");
503  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
504  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
505 
506  //Assign a seed and run number, and later fix the assignment of streams to
507  //WiFi random variables, so that the first backoff used is one slot
508  RngSeedManager::SetSeed (1);
509  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
510 
511  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
513  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
514  channel->SetPropagationDelayModel (propDelay);
515  channel->SetPropagationLossModel (propLoss);
516 
517  Ptr<Node> txNode = CreateObject<Node> ();
518  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
520  txMac->SetDevice (txDev);
521  txMac->ConfigureStandard (WIFI_STANDARD_80211a);
522  Ptr<FrameExchangeManager> fem = txMac->GetFrameExchangeManager ();
523  Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
524  protectionManager->SetWifiMac (txMac);
525  fem->SetProtectionManager (protectionManager);
526  Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
527  ackManager->SetWifiMac (txMac);
528  fem->SetAckManager (ackManager);
529 
530 
531  //Fix the stream assignment to the Dcf Txop objects (backoffs)
532  //The below stream assignment will result in the Txop object
533  //using a backoff value of zero for this test when the
534  //Txop::EndTxNoAck() calls to StartBackoffNow()
535  AssignWifiRandomStreams (txMac, 23);
536 
537  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
538  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
539  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
540  txPhy->SetErrorRateModel (txError);
541  txPhy->SetChannel (channel);
542  txPhy->SetDevice (txDev);
543  txPhy->SetMobility (txMobility);
544  txPhy->ConfigureStandardAndBand (WIFI_PHY_STANDARD_80211a, WIFI_PHY_BAND_5GHZ);
545 
546  txPhy->TraceConnectWithoutContext ("PhyTxBegin", MakeCallback (&DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin, this));
547 
548  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
549  txNode->AggregateObject (txMobility);
550  txMac->SetAddress (Mac48Address::Allocate ());
551  txDev->SetMac (txMac);
552  txDev->SetPhy (txPhy);
553  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
554  txNode->AddDevice (txDev);
555 
558  m_numSentPackets = 0;
559 
560  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
561  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
562 
563  Simulator::Stop (Seconds (2.0));
564  Simulator::Run ();
565  Simulator::Destroy ();
566 
567  // First packet is transmitted a DIFS after the packet is queued. A DIFS
568  // is 2 slots (2 * 9 = 18 us) plus a SIFS (16 us), i.e., 34 us
569  Time expectedFirstTransmissionTime = Seconds (1.0) + MicroSeconds (34);
570 
571  //First packet has 1408 us of transmit time. Slot time is 9 us.
572  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
573  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
574  //1451 us after the first one.
575  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
576  Time expectedSecondTransmissionTime = expectedFirstTransmissionTime + MicroSeconds (expectedWait1);
577  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, expectedFirstTransmissionTime, "The first transmission time not correct!");
578 
579  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
580 }
581 
582 //-----------------------------------------------------------------------------
595 class Bug730TestCase : public TestCase
596 {
597 public:
598  Bug730TestCase ();
599  virtual ~Bug730TestCase ();
600 
601  virtual void DoRun (void);
602 
603 
604 private:
605  uint32_t m_received;
606 
613  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
614 
615 };
616 
618  : TestCase ("Test case for Bug 730"),
619  m_received (0)
620 {
621 }
622 
624 {
625 }
626 
627 void
628 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
629 {
630  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
631  {
632  m_received++;
633  }
634 }
635 
636 
637 void
639 {
640  m_received = 0;
641 
642  NodeContainer wifiStaNode;
643  wifiStaNode.Create (1);
644 
646  wifiApNode.Create (1);
647 
648  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
650  phy.SetChannel (channel.Create ());
651 
653  wifi.SetStandard (WIFI_STANDARD_80211b);
654  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
655  "DataMode", StringValue ("DsssRate1Mbps"),
656  "ControlMode", StringValue ("DsssRate1Mbps"));
657 
659  Ssid ssid = Ssid ("ns-3-ssid");
660  mac.SetType ("ns3::StaWifiMac",
661  "Ssid", SsidValue (ssid),
662  "ActiveProbing", BooleanValue (false));
663 
665  staDevices = wifi.Install (phy, mac, wifiStaNode);
666 
667  mac.SetType ("ns3::ApWifiMac",
668  "Ssid", SsidValue (ssid),
669  "BeaconGeneration", BooleanValue (true));
670 
672  apDevices = wifi.Install (phy, mac, wifiApNode);
673 
675  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
676 
677  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
678  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
679  mobility.SetPositionAllocator (positionAlloc);
680 
681  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
682  mobility.Install (wifiApNode);
683  mobility.Install (wifiStaNode);
684 
685  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
686  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
687 
688  PacketSocketAddress socket;
689  socket.SetSingleDevice (sta_device->GetIfIndex ());
690  socket.SetPhysicalAddress (ap_device->GetAddress ());
691  socket.SetProtocol (1);
692 
693  // give packet socket powers to nodes.
694  PacketSocketHelper packetSocket;
695  packetSocket.Install (wifiStaNode);
696  packetSocket.Install (wifiApNode);
697 
698  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
699  client->SetAttribute ("PacketSize", UintegerValue (1460));
700  client->SetRemote (socket);
701  wifiStaNode.Get (0)->AddApplication (client);
702  client->SetStartTime (Seconds (1));
703  client->SetStopTime (Seconds (51.0));
704 
705  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
706  server->SetLocal (socket);
707  wifiApNode.Get (0)->AddApplication (server);
708  server->SetStartTime (Seconds (0.0));
709  server->SetStopTime (Seconds (52.0));
710 
711  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
712 
713  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
714 
715  Simulator::Stop (Seconds (55));
716  Simulator::Run ();
717 
718  Simulator::Destroy ();
719 
720  bool result = (m_received > 0);
721  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
722 }
723 
724 //-----------------------------------------------------------------------------
733 {
734 public:
736  virtual ~QosFragmentationTestCase ();
737 
738  virtual void DoRun (void);
739 
740 
741 private:
742  uint32_t m_received;
743  uint32_t m_fragments;
744 
751  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
752 
759  void Transmit (std::string context, Ptr<const Packet> p, double power);
760 };
761 
763  : TestCase ("Test case for fragmentation with QoS stations"),
764  m_received (0),
765  m_fragments (0)
766 {
767 }
768 
770 {
771 }
772 
773 void
774 QosFragmentationTestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
775 {
776  if (p->GetSize () == 1400)
777  {
778  m_received++;
779  }
780 }
781 
782 void
783 QosFragmentationTestCase::Transmit (std::string context, Ptr<const Packet> p, double power)
784 {
785  WifiMacHeader hdr;
786  p->PeekHeader (hdr);
787  if (hdr.IsQosData ())
788  {
789  NS_TEST_EXPECT_MSG_LT_OR_EQ (p->GetSize (), 400, "Unexpected fragment size");
790  m_fragments++;
791  }
792 }
793 
794 void
796 {
797  NodeContainer wifiStaNode;
798  wifiStaNode.Create (1);
799 
801  wifiApNode.Create (1);
802 
803  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
805  phy.SetChannel (channel.Create ());
806 
808  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
809  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
810  "DataMode", StringValue ("HtMcs7"));
811 
813  Ssid ssid = Ssid ("ns-3-ssid");
814  mac.SetType ("ns3::StaWifiMac",
815  "Ssid", SsidValue (ssid),
816  "ActiveProbing", BooleanValue (false));
817 
819  staDevices = wifi.Install (phy, mac, wifiStaNode);
820 
821  mac.SetType ("ns3::ApWifiMac",
822  "Ssid", SsidValue (ssid),
823  "BeaconGeneration", BooleanValue (true));
824 
826  apDevices = wifi.Install (phy, mac, wifiApNode);
827 
829  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
830 
831  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
832  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
833  mobility.SetPositionAllocator (positionAlloc);
834 
835  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
836  mobility.Install (wifiApNode);
837  mobility.Install (wifiStaNode);
838 
839  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
840  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
841 
842  // set the TXOP limit on BE AC
843  Ptr<RegularWifiMac> sta_mac = DynamicCast<RegularWifiMac> (sta_device->GetMac ());
844  NS_ASSERT (sta_mac);
845  PointerValue ptr;
846  sta_mac->GetAttribute ("BE_Txop", ptr);
847  ptr.Get<QosTxop> ()->SetTxopLimit (MicroSeconds (3008));
848 
849  PacketSocketAddress socket;
850  socket.SetSingleDevice (sta_device->GetIfIndex ());
851  socket.SetPhysicalAddress (ap_device->GetAddress ());
852  socket.SetProtocol (1);
853 
854  // give packet socket powers to nodes.
855  PacketSocketHelper packetSocket;
856  packetSocket.Install (wifiStaNode);
857  packetSocket.Install (wifiApNode);
858 
859  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
860  client->SetAttribute ("PacketSize", UintegerValue (1400));
861  client->SetAttribute ("MaxPackets", UintegerValue (1));
862  client->SetRemote (socket);
863  wifiStaNode.Get (0)->AddApplication (client);
864  client->SetStartTime (Seconds (1));
865  client->SetStopTime (Seconds (3.0));
866 
867  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
868  server->SetLocal (socket);
869  wifiApNode.Get (0)->AddApplication (server);
870  server->SetStartTime (Seconds (0.0));
871  server->SetStopTime (Seconds (4.0));
872 
873  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&QosFragmentationTestCase::Receive, this));
874 
875  Config::Set ("/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("400"));
876  Config::Connect ("/NodeList/0/DeviceList/0/Phy/PhyTxBegin", MakeCallback (&QosFragmentationTestCase::Transmit, this));
877 
878  Simulator::Stop (Seconds (5));
879  Simulator::Run ();
880 
881  Simulator::Destroy ();
882 
883  NS_TEST_ASSERT_MSG_EQ (m_received, 1, "Unexpected number of received packets");
884  NS_TEST_ASSERT_MSG_EQ (m_fragments, 4, "Unexpected number of transmitted fragments");
885 }
886 
894 {
895 public:
897 
898  virtual void DoRun (void);
899 
900 
901 private:
908 
909 };
910 
912  : TestCase ("Test case for setting WifiPhy channel and frequency")
913 {
914 }
915 
918 {
919  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
920  Ptr<WifiPhy> wp = wnd->GetPhy ();
921  return wp->GetObject<YansWifiPhy> ();
922 }
923 
924 void
926 {
927  NodeContainer wifiStaNode;
928  wifiStaNode.Create (1);
930  wifiApNode.Create (1);
931 
932  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
934  phy.SetChannel (channel.Create ());
935 
936  // Configure and declare other generic components of this example
937  Ssid ssid;
938  ssid = Ssid ("wifi-phy-configuration");
939  WifiMacHelper macSta;
940  macSta.SetType ("ns3::StaWifiMac",
941  "Ssid", SsidValue (ssid),
942  "ActiveProbing", BooleanValue (false));
943  NetDeviceContainer staDevice;
944  Ptr<YansWifiPhy> phySta;
945 
946  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
947  {
948  // case 0:
949  // Default configuration, without WifiHelper::SetStandard or WifiHelper
950  phySta = CreateObject<YansWifiPhy> ();
951  // The default results in an invalid configuration of channel 0,
952  // width 20, and frequency 0 MHz
953  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "default configuration");
954  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
955  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 0, "default configuration");
956  }
957  {
958  // case 1:
960  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
961  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
962  phySta = GetYansWifiPhyPtr (staDevice);
963  // We expect channel 36, width 20, frequency 5180
964  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
965  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
966  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
967  }
968  {
969  // case 2:
971  wifi.SetStandard (WIFI_STANDARD_80211b);
972  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
973  phySta = GetYansWifiPhyPtr (staDevice);
974  // We expect channel 1, width 22, frequency 2412
975  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
976  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
977  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
978  }
979  {
980  // case 3:
982  wifi.SetStandard (WIFI_STANDARD_80211g);
983  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
984  phySta = GetYansWifiPhyPtr (staDevice);
985  // We expect channel 1, width 20, frequency 2412
986  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
987  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
988  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
989  }
990  {
991  // case 4:
993  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
994  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
995  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
996  phySta = GetYansWifiPhyPtr (staDevice);
997  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
998  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
999  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
1000  }
1001  {
1002  // case 5:
1003  WifiHelper wifi;
1004  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1005  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
1006  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1007  phySta = GetYansWifiPhyPtr (staDevice);
1008  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
1009  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
1010  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
1011  }
1012  {
1013  // case 6:
1014  WifiHelper wifi;
1015  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1016  wifi.SetStandard (WIFI_STANDARD_80211ac);
1017  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1018  phySta = GetYansWifiPhyPtr (staDevice);
1019  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
1020  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
1021  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
1022  }
1023  {
1024  // case 7:
1025  WifiHelper wifi;
1026  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1027  wifi.SetStandard (WIFI_STANDARD_80211ax_2_4GHZ);
1028  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1029  phySta = GetYansWifiPhyPtr (staDevice);
1030  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11ax-2.4GHz configuration");
1031  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11ax-2.4GHz configuration");
1032  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11ax-2.4GHz configuration");
1033  }
1034  {
1035  // case 8:
1036  WifiHelper wifi;
1037  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1038  wifi.SetStandard (WIFI_STANDARD_80211ax_5GHZ);
1039  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1040  phySta = GetYansWifiPhyPtr (staDevice);
1041  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ax-5GHz configuration");
1042  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-5GHz configuration");
1043  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ax-5GHz configuration");
1044  }
1045  {
1046  // case 9:
1047  WifiHelper wifi;
1048  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1049  wifi.SetStandard (WIFI_STANDARD_80211ax_6GHZ);
1050  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1051  phySta = GetYansWifiPhyPtr (staDevice);
1052  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 7, "802.11ax-6GHz configuration");
1053  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-6GHz configuration");
1054  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5975, "802.11ax-6GHz configuration");
1055  }
1056  {
1057  // case 10:
1058  WifiHelper wifi;
1059  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1060  wifi.SetStandard (WIFI_STANDARD_80211p);
1061  phy.Set ("ChannelWidth", UintegerValue (10));
1062  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1063  phySta = GetYansWifiPhyPtr (staDevice);
1064  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11p 10Mhz configuration");
1065  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11p 10Mhz configuration");
1066  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 10Mhz configuration");
1067  }
1068  {
1069  // case 11:
1070  WifiHelper wifi;
1071  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1072  wifi.SetStandard (WIFI_STANDARD_80211p);
1073  phy.Set ("ChannelWidth", UintegerValue (5));
1074  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1075  phySta = GetYansWifiPhyPtr (staDevice);
1076  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 171, "802.11p 5Mhz configuration");
1077  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11p 5Mhz configuration");
1078  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 5Mhz configuration");
1079  }
1080  {
1081  // case 12:
1082  WifiHelper wifi;
1083  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1084  wifi.SetStandard (WIFI_STANDARD_holland);
1085  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1086  phySta = GetYansWifiPhyPtr (staDevice);
1087  // We expect channel 36, width 20, frequency 5180
1088  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
1089  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
1090  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
1091  }
1092  {
1093  // case 13:
1094  WifiHelper wifi;
1095  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1096  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1097  phy.Set ("ChannelNumber", UintegerValue (44));
1098  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1099  phySta = GetYansWifiPhyPtr (staDevice);
1100  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1101  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1102  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1103  }
1104  {
1105  // case 14:
1106  WifiHelper wifi;
1107  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1108  phy.Set ("ChannelNumber", UintegerValue (44));
1109  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1110  phySta = GetYansWifiPhyPtr (staDevice);
1111  // Post-install reconfiguration to channel number 40
1112  std::ostringstream path;
1113  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber";
1114  Config::Set (path.str(), UintegerValue (40));
1115  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1116  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1117  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1118  }
1119  {
1120  // case 15:
1121  WifiHelper wifi;
1122  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1123  phy.Set ("ChannelNumber", UintegerValue (44));
1124  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1125  phySta = GetYansWifiPhyPtr (staDevice);
1126  // Post-install reconfiguration to channel width 40 MHz
1127  std::ostringstream path;
1128  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth";
1129  Config::Set (path.str(), UintegerValue (40));
1130  // Although channel 44 is configured originally for 20 MHz, we
1131  // allow it to be used for 40 MHz here
1132  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1133  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1134  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1135  }
1136  {
1137  // case 16:
1138  WifiHelper wifi;
1139  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1140  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1141  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1142  phySta = GetYansWifiPhyPtr (staDevice);
1143  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
1144  // Post-install reconfiguration to channel width 40 MHz
1145  std::ostringstream path;
1146  path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth";
1147  Config::Set (path.str(), UintegerValue (40));
1148  // Although channel 44 is configured originally for 20 MHz, we
1149  // allow it to be used for 40 MHz here
1150  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1151  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1152  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1153  }
1154  {
1155  // case 17:
1156  WifiHelper wifi;
1157  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1158  // Test that setting Frequency to a non-standard value will zero the
1159  // channel number
1160  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1161  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1162  phySta = GetYansWifiPhyPtr (staDevice);
1163  phySta->SetAttribute ("Frequency", UintegerValue (5281));
1164  // We expect channel number to be zero since frequency doesn't match
1165  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1166  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1167  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5281, "802.11 5GHz configuration");
1168  }
1169  {
1170  // case 18:
1171  WifiHelper wifi;
1172  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1173  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1174  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1175  phySta = GetYansWifiPhyPtr (staDevice);
1176  // Test that setting Frequency to a standard value will set the
1177  // channel number correctly
1178  phySta->SetAttribute ("Frequency", UintegerValue (5500));
1179  // We expect channel number to be 100 due to frequency 5500
1180  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "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 (), 5500, "802.11 5GHz configuration");
1183  }
1184  {
1185  // case 19:
1186  WifiHelper wifi;
1187  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1188  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1189  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1190  phySta = GetYansWifiPhyPtr (staDevice);
1191  // This case will error exit due to invalid channel number unless
1192  // we provide the DefineChannelNumber() below
1194  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
1195  }
1196  {
1197  // case 20:
1198  WifiHelper wifi;
1199  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1200  // Test how channel number behaves when frequency is non-standard
1201  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1202  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1203  phySta = GetYansWifiPhyPtr (staDevice);
1204  phySta->SetAttribute ("Frequency", UintegerValue (5181));
1205  // We expect channel number to be 0 due to unknown center frequency 5181
1206  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1207  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1208  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5181, "802.11 5GHz configuration");
1209  phySta->SetAttribute ("Frequency", UintegerValue (5180));
1210  // We expect channel number to be 36 due to known center frequency 5180
1211  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1212  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1213  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1214  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1215  // We expect channel number to be 0 due to unknown center frequency 5179
1216  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1217  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1218  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1219  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1220  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1221  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1222  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1223  }
1224  {
1225  // case 21:
1226  WifiHelper wifi;
1227  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1228  // Set both channel and frequency to consistent values
1229  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
1230  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1231  phySta = GetYansWifiPhyPtr (staDevice);
1232  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1233  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
1234  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1235  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1236  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1237  // Set both channel and frequency to inconsistent values
1238  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1239  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1240  // We expect channel number to be 36
1241  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1242  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1243  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1244  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1245  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1246  // We expect channel number to be 40
1247  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1248  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1249  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1250  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1251  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1252  // We expect channel number to be 36
1253  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1254  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1255  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1256  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1257  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1258  // We expect channel number to be 0
1259  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1260  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1261  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1262  }
1263 
1264  Simulator::Destroy ();
1265 }
1266 
1267 //-----------------------------------------------------------------------------
1276 {
1277 public:
1278  Bug2222TestCase ();
1279  virtual ~Bug2222TestCase ();
1280 
1281  virtual void DoRun (void);
1282 
1283 
1284 private:
1286 
1292  void TxDataFailedTrace (std::string context, Mac48Address adress);
1293 };
1294 
1296  : TestCase ("Test case for Bug 2222"),
1297  m_countInternalCollisions (0)
1298 {
1299 }
1300 
1302 {
1303 }
1304 
1305 void
1307 {
1308  //Indicate the long retry counter has been increased in the wifi remote station manager
1310 }
1311 
1312 void
1314 {
1316 
1317  //Generate same backoff for AC_VI and AC_VO
1318  //The below combination will work
1319  RngSeedManager::SetSeed (1);
1320  RngSeedManager::SetRun (16);
1321  int64_t streamNumber = 100;
1322 
1323  NodeContainer wifiNodes;
1324  wifiNodes.Create (2);
1325 
1326  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1328  phy.SetChannel (channel.Create ());
1329 
1330  WifiHelper wifi;
1331  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1332  "DataMode", StringValue ("OfdmRate54Mbps"),
1333  "ControlMode", StringValue ("OfdmRate24Mbps"));
1335  Ssid ssid = Ssid ("ns-3-ssid");
1336  mac.SetType ("ns3::AdhocWifiMac",
1337  "QosSupported", BooleanValue (true));
1338 
1339  NetDeviceContainer wifiDevices;
1340  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1341 
1342  // Assign fixed streams to random variables in use
1343  wifi.AssignStreams (wifiDevices, streamNumber);
1344 
1346  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1347 
1348  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1349  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1350  mobility.SetPositionAllocator (positionAlloc);
1351 
1352  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1353  mobility.Install (wifiNodes);
1354 
1355  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1356  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1357 
1358  PacketSocketAddress socket;
1359  socket.SetSingleDevice (device1->GetIfIndex ());
1360  socket.SetPhysicalAddress (device2->GetAddress ());
1361  socket.SetProtocol (1);
1362 
1363  PacketSocketHelper packetSocket;
1364  packetSocket.Install (wifiNodes);
1365 
1366  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1367  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1368  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1369  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1370  clientLowPriority->SetRemote (socket);
1371  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1372  clientLowPriority->SetStartTime (Seconds (0.0));
1373  clientLowPriority->SetStopTime (Seconds (1.0));
1374 
1375  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1376  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1377  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1378  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1379  clientHighPriority->SetRemote (socket);
1380  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1381  clientHighPriority->SetStartTime (Seconds (0.0));
1382  clientHighPriority->SetStopTime (Seconds (1.0));
1383 
1384  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1385  server->SetLocal (socket);
1386  wifiNodes.Get (1)->AddApplication (server);
1387  server->SetStartTime (Seconds (0.0));
1388  server->SetStopTime (Seconds (1.0));
1389 
1390  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1391 
1392  Simulator::Stop (Seconds (1.0));
1393  Simulator::Run ();
1394  Simulator::Destroy ();
1395 
1396  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1397 }
1398 
1399 //-----------------------------------------------------------------------------
1413 {
1414 public:
1415  Bug2843TestCase ();
1416  virtual ~Bug2843TestCase ();
1417  virtual void DoRun (void);
1418 
1419 private:
1423  typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1424  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1425 
1432  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1439  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1440 
1441  uint16_t m_channelWidth;
1442 };
1443 
1445  : TestCase ("Test case for Bug 2843"),
1446  m_channelWidth (20)
1447 {
1448 }
1449 
1451 {
1452 }
1453 
1454 void
1456 {
1457  // Extract starting frequency and number of subbands
1458  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1459  std::size_t numBands = c->GetNumBands ();
1460  double startingFreq = c->Begin ()->fl;
1461 
1462  // Get channel bandwidth and modulation class
1463  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1464 
1465  Ptr<WifiPpdu> ppdu = Copy (wifiTxParams->ppdu);
1466  WifiTxVector txVector = ppdu->GetTxVector ();
1467  m_channelWidth = txVector.GetChannelWidth ();
1468  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1469 
1470  // Build a tuple and check if seen before (if so store it)
1471  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, m_channelWidth, numBands, modulationClass);
1472  bool found = false;
1473  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1474  {
1475  if (*it == tupleForCurrentTx)
1476  {
1477  found = true;
1478  }
1479  }
1480  if (!found)
1481  {
1482  m_distinctTuples.push_back (tupleForCurrentTx);
1483  }
1484 }
1485 
1486 void
1487 Bug2843TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1488  Address& destination) const
1489 {
1490  for (uint8_t i = 0; i < numPackets; i++)
1491  {
1492  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1493  sourceDevice->Send (pkt, destination, 0);
1494  }
1495 }
1496 
1497 void
1499 {
1500  uint16_t channelWidth = 40; // at least 40 MHz expected here
1501 
1502  NodeContainer wifiStaNode;
1503  wifiStaNode.Create (1);
1504 
1506  wifiApNode.Create (1);
1507 
1508  SpectrumWifiPhyHelper spectrumPhy;
1509  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1510  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1511  lossModel->SetFrequency (5.180e9);
1512  spectrumChannel->AddPropagationLossModel (lossModel);
1513 
1515  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1516  spectrumChannel->SetPropagationDelayModel (delayModel);
1517 
1518  spectrumPhy.SetChannel (spectrumChannel);
1519  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1520  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1521  spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
1522  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1523  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1524 
1525  WifiHelper wifi;
1526  wifi.SetStandard (WIFI_STANDARD_80211ac);
1527  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1528  "DataMode", StringValue ("VhtMcs8"),
1529  "ControlMode", StringValue ("VhtMcs8"),
1530  "RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1531 
1533  mac.SetType ("ns3::StaWifiMac");
1534  NetDeviceContainer staDevice;
1535  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1536 
1537  mac.SetType ("ns3::ApWifiMac");
1538  NetDeviceContainer apDevice;
1539  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1540 
1542  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1543  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1544  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1545  mobility.SetPositionAllocator (positionAlloc);
1546 
1547  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1548  mobility.Install (wifiApNode);
1549  mobility.Install (wifiStaNode);
1550 
1551  // Send two 5 packet-bursts
1552  Simulator::Schedule (Seconds (0.5), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1553  Simulator::Schedule (Seconds (0.6), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1554 
1555  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2843TestCase::StoreDistinctTuple, this));
1556 
1557  Simulator::Stop (Seconds (0.8));
1558  Simulator::Run ();
1559 
1560  Simulator::Destroy ();
1561 
1562  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1563  std::size_t numberTuples = m_distinctTuples.size ();
1564  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1565  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");
1566  // Note that the first tuple should the one initiated by the beacon, i.e. non-HT OFDM (20 MHz)
1567  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1568  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)");
1569  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1570  // Second tuple
1571  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1572  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)");
1573  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1574 }
1575 
1576 //-----------------------------------------------------------------------------
1589 {
1590 public:
1591  Bug2831TestCase ();
1592  virtual ~Bug2831TestCase ();
1593  virtual void DoRun (void);
1594 
1595 private:
1599  void ChangeSupportedChannelWidth (void);
1606  void RxCallback (std::string context, Ptr<const Packet> p, RxPowerWattPerChannelBand rxPowersW);
1607 
1610 
1615 };
1616 
1618  : TestCase ("Test case for Bug 2831"),
1619  m_reassocReqCount (0),
1620  m_reassocRespCount (0),
1621  m_countOperationalChannelWidth20 (0),
1622  m_countOperationalChannelWidth40 (0)
1623 {
1624 }
1625 
1627 {
1628 }
1629 
1630 void
1632 {
1633  m_apPhy->SetChannelNumber (38);
1634  m_apPhy->SetChannelWidth (40);
1635  m_staPhy->SetChannelNumber (38);
1636  m_staPhy->SetChannelWidth (40);
1637 }
1638 
1639 void
1641 {
1642  Ptr<Packet> packet = p->Copy ();
1643  WifiMacHeader hdr;
1644  packet->RemoveHeader (hdr);
1645  if (hdr.IsReassocReq ())
1646  {
1648  }
1649  else if (hdr.IsReassocResp ())
1650  {
1652  }
1653  else if (hdr.IsBeacon ())
1654  {
1655  MgtBeaconHeader beacon;
1656  packet->RemoveHeader (beacon);
1657  HtOperation htOperation = beacon.GetHtOperation ();
1658  if (htOperation.GetStaChannelWidth () > 0)
1659  {
1661  }
1662  else
1663  {
1665  }
1666  }
1667 }
1668 
1669 void
1671 {
1672  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1673  ObjectFactory propDelay;
1674  propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1675  Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1676  Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel> ();
1677  channel->SetPropagationDelayModel (propagationDelay);
1678  channel->SetPropagationLossModel (propagationLoss);
1679 
1680  Ptr<Node> apNode = CreateObject<Node> ();
1681  Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1682  Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration> ();
1683  apDev->SetHtConfiguration (apHtConfiguration);
1685  mac.SetTypeId ("ns3::ApWifiMac");
1686  mac.Set ("EnableBeaconJitter", BooleanValue (false));
1687  Ptr<WifiMac> apMac = mac.Create<WifiMac> ();
1688  apMac->SetDevice (apDev);
1689  apMac->SetAddress (Mac48Address::Allocate ());
1691 
1692  Ptr<Node> staNode = CreateObject<Node> ();
1693  Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> ();
1694  Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration> ();
1695  staDev->SetHtConfiguration (staHtConfiguration);
1696  mac.SetTypeId ("ns3::StaWifiMac");
1697  Ptr<WifiMac> staMac = mac.Create<WifiMac> ();
1698  staMac->SetDevice (staDev);
1699  staMac->SetAddress (Mac48Address::Allocate ());
1701 
1702  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
1703  apMobility->SetPosition (Vector (0.0, 0.0, 0.0));
1704  apNode->AggregateObject (apMobility);
1705 
1706  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
1707  m_apPhy = CreateObject<YansWifiPhy> ();
1708  m_apPhy->SetErrorRateModel (error);
1710  m_apPhy->SetMobility (apMobility);
1711  m_apPhy->SetDevice (apDev);
1713  m_apPhy->SetChannelNumber (36);
1714  m_apPhy->SetChannelWidth (20);
1715 
1716  Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel> ();
1717  staMobility->SetPosition (Vector (1.0, 0.0, 0.0));
1718  staNode->AggregateObject (staMobility);
1719 
1720  m_staPhy = CreateObject<YansWifiPhy> ();
1721  m_staPhy->SetErrorRateModel (error);
1723  m_staPhy->SetMobility (staMobility);
1724  m_staPhy->SetDevice (apDev);
1726  m_staPhy->SetChannelNumber (36);
1727  m_staPhy->SetChannelWidth (20);
1728 
1729  apDev->SetMac (apMac);
1730  apDev->SetPhy (m_apPhy);
1731  ObjectFactory manager;
1732  manager.SetTypeId ("ns3::ConstantRateWifiManager");
1733  apDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1734  apNode->AddDevice (apDev);
1735 
1736  staDev->SetMac (staMac);
1737  staDev->SetPhy (m_staPhy);
1738  staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1739  staNode->AddDevice (staDev);
1740 
1741  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this));
1742 
1743  Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1744 
1745  Simulator::Stop (Seconds (3.0));
1746  Simulator::Run ();
1747  Simulator::Destroy ();
1748 
1749  NS_TEST_ASSERT_MSG_EQ (m_reassocReqCount, 1, "Reassociation request not received");
1750  NS_TEST_ASSERT_MSG_EQ (m_reassocRespCount, 1, "Reassociation response not received");
1751  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operational channel width before channel change");
1752  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operational channel width after channel change");
1753 }
1754 
1755 //-----------------------------------------------------------------------------
1772 {
1773 public:
1775  virtual ~StaWifiMacScanningTestCase ();
1776  virtual void DoRun (void);
1777 
1778 private:
1784  void AssocCallback (std::string context, Mac48Address bssid);
1789  void TurnBeaconGenerationOn (Ptr<Node> apNode);
1794  void TurnApOff (Ptr<Node> apNode);
1801  NodeContainer Setup (bool nearestApBeaconGeneration, bool staActiveProbe);
1802 
1804 };
1805 
1807  : TestCase ("Test case for StaWifiMac scanning capability")
1808 {
1809 }
1810 
1812 {
1813 }
1814 
1815 void
1817 {
1818  m_associatedApBssid = bssid;
1819 }
1820 
1821 void
1823 {
1824  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1825  Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac> (netDevice->GetMac ());
1826  mac->SetAttribute ("BeaconGeneration", BooleanValue (true));
1827 }
1828 
1829 void
1831 {
1832  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1833  Ptr<WifiPhy> phy = netDevice->GetPhy ();
1834  phy->SetOffMode ();
1835 }
1836 
1838 StaWifiMacScanningTestCase::Setup (bool nearestApBeaconGeneration, bool staActiveProbe)
1839 {
1840  RngSeedManager::SetSeed (1);
1841  RngSeedManager::SetRun (1);
1842  int64_t streamNumber = 1;
1843 
1844  NodeContainer apNodes;
1845  apNodes.Create (2);
1846 
1847  Ptr<Node> apNodeNearest = CreateObject<Node> ();
1848  Ptr<Node> staNode = CreateObject<Node> ();
1849 
1851  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1852  phy.SetChannel (channel.Create ());
1853 
1854  WifiHelper wifi;
1855  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
1856  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
1857 
1859  NetDeviceContainer apDevice, apDeviceNearest;
1860  mac.SetType ("ns3::ApWifiMac",
1861  "BeaconGeneration", BooleanValue (true));
1862  apDevice = wifi.Install (phy, mac, apNodes);
1863  mac.SetType ("ns3::ApWifiMac",
1864  "BeaconGeneration", BooleanValue (nearestApBeaconGeneration));
1865  apDeviceNearest = wifi.Install (phy, mac, apNodeNearest);
1866 
1867  NetDeviceContainer staDevice;
1868  mac.SetType ("ns3::StaWifiMac",
1869  "ActiveProbing", BooleanValue (staActiveProbe));
1870  staDevice = wifi.Install (phy, mac, staNode);
1871 
1872  // Assign fixed streams to random variables in use
1873  wifi.AssignStreams (apDevice, streamNumber);
1874  wifi.AssignStreams (apDeviceNearest, streamNumber + 1);
1875  wifi.AssignStreams (staDevice, streamNumber + 2);
1876 
1878  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1879  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Furthest AP
1880  positionAlloc->Add (Vector (10.0, 0.0, 0.0)); // Second nearest AP
1881  positionAlloc->Add (Vector (5.0, 5.0, 0.0)); // Nearest AP
1882  positionAlloc->Add (Vector (6.0, 5.0, 0.0)); // STA
1883  mobility.SetPositionAllocator (positionAlloc);
1884 
1885  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1886  mobility.Install (apNodes);
1887  mobility.Install (apNodeNearest);
1888  mobility.Install (staNode);
1889 
1890  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc", MakeCallback (&StaWifiMacScanningTestCase::AssocCallback, this));
1891 
1892  NodeContainer allNodes = NodeContainer (apNodes, apNodeNearest, staNode);
1893  return allNodes;
1894 }
1895 
1896 void
1898 {
1899  {
1900  NodeContainer nodes = Setup (false, false);
1901  Ptr<Node> nearestAp = nodes.Get (2);
1902  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1903 
1904  Simulator::Schedule (Seconds (0.05), &StaWifiMacScanningTestCase::TurnBeaconGenerationOn, this, nearestAp);
1905 
1906  Simulator::Stop (Seconds (0.2));
1907  Simulator::Run ();
1908  Simulator::Destroy ();
1909 
1910  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1911  }
1913  {
1914  NodeContainer nodes = Setup (true, true);
1915  Ptr<Node> nearestAp = nodes.Get (2);
1916  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1917 
1918  Simulator::Stop (Seconds (0.2));
1919  Simulator::Run ();
1920  Simulator::Destroy ();
1921 
1922  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1923  }
1925  {
1926  NodeContainer nodes = Setup (true, false);
1927  Ptr<Node> nearestAp = nodes.Get (2);
1928  Mac48Address secondNearestApAddr = DynamicCast<WifiNetDevice> (nodes.Get (1)->GetDevice (0))->GetMac ()->GetAddress ();
1929 
1930  Simulator::Schedule (Seconds (0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
1931 
1932  Simulator::Stop (Seconds (1.5));
1933  Simulator::Run ();
1934  Simulator::Destroy ();
1935 
1936  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, secondNearestApAddr, "STA is associated to the wrong AP");
1937  }
1938 }
1939 
1940 //-----------------------------------------------------------------------------
1964 {
1965 public:
1966  Bug2470TestCase ();
1967  virtual ~Bug2470TestCase ();
1968  virtual void DoRun (void);
1969 
1970 private:
1979  void AddbaStateChangedCallback (std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
1990  void RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId);
1997  void RxErrorCallback (std::string context, Ptr<const Packet> p, double snr);
2004  void SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
2010  void RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel);
2011 
2020 };
2021 
2023  : TestCase ("Test case for Bug 2470"),
2024  m_receivedNormalMpduCount (0),
2025  m_receivedAmpduCount (0),
2026  m_failedActionCount (0),
2027  m_addbaEstablishedCount (0),
2028  m_addbaPendingCount (0),
2029  m_addbaRejectedCount (0),
2030  m_addbaNoReplyCount (0),
2031  m_addbaResetCount (0)
2032 {
2033 }
2034 
2036 {
2037 }
2038 
2039 void
2041 {
2042  switch (state)
2043  {
2044  case OriginatorBlockAckAgreement::ESTABLISHED:
2046  break;
2047  case OriginatorBlockAckAgreement::PENDING:
2049  break;
2050  case OriginatorBlockAckAgreement::REJECTED:
2052  break;
2053  case OriginatorBlockAckAgreement::NO_REPLY:
2055  break;
2056  case OriginatorBlockAckAgreement::RESET:
2058  break;
2059  }
2060 }
2061 
2062 void
2063 Bug2470TestCase::RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
2064 {
2065  Ptr<Packet> packet = p->Copy ();
2066  if (aMpdu.type != MpduType::NORMAL_MPDU)
2067  {
2069  }
2070  else
2071  {
2072  WifiMacHeader hdr;
2073  packet->RemoveHeader (hdr);
2074  if (hdr.IsData ())
2075  {
2077  }
2078  }
2079 }
2080 
2081 void
2082 Bug2470TestCase::RxErrorCallback (std::string context, Ptr<const Packet> p, double snr)
2083 {
2084  Ptr<Packet> packet = p->Copy ();
2085  WifiMacHeader hdr;
2086  packet->RemoveHeader (hdr);
2087  if (hdr.IsAction ())
2088  {
2090  }
2091 }
2092 
2093 void
2094 Bug2470TestCase::SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice,
2095  Address& destination) const
2096 {
2097  for (uint32_t i = 0; i < numPackets; i++)
2098  {
2099  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2100  sourceDevice->Send (pkt, destination, 0);
2101  }
2102 }
2103 
2104 void
2106 {
2107  RngSeedManager::SetSeed (1);
2108  RngSeedManager::SetRun (1);
2109  int64_t streamNumber = 200;
2110 
2111  NodeContainer wifiApNode, wifiStaNode;
2112  wifiApNode.Create (1);
2113  wifiStaNode.Create (1);
2114 
2116  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2117  phy.SetChannel (channel.Create ());
2118 
2119  WifiHelper wifi;
2120  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
2121  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2122  "DataMode", StringValue ("HtMcs7"),
2123  "ControlMode", StringValue ("HtMcs7"));
2124 
2126  NetDeviceContainer apDevice;
2127  phy.Set ("PostReceptionErrorModel", apErrorModel);
2128  mac.SetType ("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue (false));
2129  apDevice = wifi.Install (phy, mac, wifiApNode);
2130 
2131  NetDeviceContainer staDevice;
2132  phy.Set ("PostReceptionErrorModel", staErrorModel);
2133  mac.SetType ("ns3::StaWifiMac");
2134  staDevice = wifi.Install (phy, mac, wifiStaNode);
2135 
2136  // Assign fixed streams to random variables in use
2137  wifi.AssignStreams (apDevice, streamNumber);
2138  wifi.AssignStreams (staDevice, streamNumber);
2139 
2141  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2142  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2143  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2144  mobility.SetPositionAllocator (positionAlloc);
2145 
2146  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2147  mobility.Install (wifiApNode);
2148  mobility.Install (wifiStaNode);
2149 
2150  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this));
2151  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&Bug2470TestCase::RxErrorCallback, this));
2152  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this));
2153 
2154  Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2155  Simulator::Schedule (Seconds (0.5) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2156  Simulator::Schedule (Seconds (0.8), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2157  Simulator::Schedule (Seconds (0.8) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2158 
2159  Simulator::Stop (Seconds (1.0));
2160  Simulator::Run ();
2161  Simulator::Destroy ();
2162 }
2163 
2164 void
2166 {
2167  // Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel
2168  // instead of ListErrorModel since packet UID is incremented between simulations. But
2169  // problem may occur because of random stream, therefore we suppress usage of RNG as
2170  // much as possible (i.e., removing beacon jitter).
2171  Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel> ();
2172  std::list<uint32_t> blackList;
2173  // Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2174  blackList.push_back (8);
2175  blackList.push_back (9);
2176  blackList.push_back (10);
2177  blackList.push_back (11);
2178  blackList.push_back (12);
2179  blackList.push_back (13);
2180  staPem->SetList (blackList);
2181 
2182  {
2183  RunSubtest (PointerValue (), PointerValue (staPem));
2184  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 6, "ADDBA request packets are not failed");
2185  // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by normal
2186  // MPDU because of failed ADDBA handshake. For the second set, the first packet should be sent by
2187  // normal MPDU, and the rest with A-MPDU. In total we expect to receive 2 normal MPDU packets and
2188  // 8 A-MPDU packets.
2189  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 2, "Receiving incorrect number of normal MPDU packet on subtest 1");
2190  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 8, "Receiving incorrect number of A-MPDU packet on subtest 1");
2191 
2192  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 1");
2193  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2194  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2195  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 0, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2196  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2197  }
2198 
2201  m_failedActionCount = 0;
2203  m_addbaPendingCount = 0;
2205  m_addbaNoReplyCount = 0;
2206  m_addbaResetCount = 0;
2207 
2208  Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel> ();
2209  blackList.clear ();
2210  // Block ADDBA request 3 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2211  blackList.push_back (4);
2212  blackList.push_back (5);
2213  blackList.push_back (6);
2214  apPem->SetList (blackList);
2215 
2216  {
2217  RunSubtest (PointerValue (apPem), PointerValue ());
2218  NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 3, "ADDBA response packets are not failed");
2219  // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU packets.
2220  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 6, "Receiving incorrect number of normal MPDU packet on subtest 2");
2221  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 4, "Receiving incorrect number of A-MPDU packet on subtest 2");
2222 
2223  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 2");
2224  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2225  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2226  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 1, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2227  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2228  }
2229 
2230  // TODO: In the second test set, it does not go to reset state since ADDBA response is received after timeout (NO_REPLY)
2231  // but before it does not enter RESET state. More tests should be written to verify all possible scenarios.
2232 }
2233 
2234 //-----------------------------------------------------------------------------
2250 {
2251 public:
2252  Issue40TestCase ();
2253  virtual ~Issue40TestCase ();
2254  virtual void DoRun (void);
2255 
2256 private:
2261  void RunOne (bool useAmpdu);
2262 
2268  void RxSuccessCallback (std::string context, Ptr<const Packet> p);
2275  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination);
2281  void TxFinalDataFailedCallback (std::string context, Mac48Address address);
2282 
2283  uint16_t m_rxCount;
2284  uint16_t m_txCount;
2286 };
2287 
2289  : TestCase ("Test case for issue #40"),
2290  m_rxCount (0),
2291  m_txCount (0),
2292  m_txMacFinalDataFailedCount (0)
2293 {
2294 }
2295 
2297 {
2298 }
2299 
2300 void
2302 {
2303  m_rxCount++;
2304 }
2305 
2306 void
2307 Issue40TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination)
2308 {
2309  for (uint8_t i = 0; i < numPackets; i++)
2310  {
2311  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2312  sourceDevice->Send (pkt, destination, 0);
2313  m_txCount++;
2314  }
2315 }
2316 
2317 void
2319 {
2321 }
2322 
2323 void
2325 {
2326  m_rxCount = 0;
2327  m_txCount = 0;
2329 
2330  RngSeedManager::SetSeed (1);
2331  RngSeedManager::SetRun (1);
2332  int64_t streamNumber = 100;
2333 
2334  NodeContainer wifiApNode, wifiStaNode;
2335  wifiApNode.Create (1);
2336  wifiStaNode.Create (1);
2337 
2339  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2340  phy.SetChannel (channel.Create ());
2341 
2342  WifiHelper wifi;
2343  wifi.SetStandard (WIFI_STANDARD_80211ac);
2344  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2345 
2347  NetDeviceContainer apDevice;
2348  mac.SetType ("ns3::ApWifiMac");
2349  apDevice = wifi.Install (phy, mac, wifiApNode);
2350 
2351  NetDeviceContainer staDevice;
2352  mac.SetType ("ns3::StaWifiMac");
2353  staDevice = wifi.Install (phy, mac, wifiStaNode);
2354 
2355  // Assign fixed streams to random variables in use
2356  wifi.AssignStreams (apDevice, streamNumber);
2357  wifi.AssignStreams (staDevice, streamNumber);
2358 
2360  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2361  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2362  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
2363  mobility.SetPositionAllocator (positionAlloc);
2364 
2365  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2366  mobility.Install (wifiApNode);
2367 
2368  mobility.SetMobilityModel("ns3::WaypointMobilityModel");
2369  mobility.Install (wifiStaNode);
2370 
2371  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxFinalDataFailed", MakeCallback (&Issue40TestCase::TxFinalDataFailedCallback, this));
2372  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/MacRx", MakeCallback (&Issue40TestCase::RxSuccessCallback, this));
2373 
2374  Ptr<WaypointMobilityModel> staWaypointMobility = DynamicCast<WaypointMobilityModel>(wifiStaNode.Get(0)->GetObject<MobilityModel>());
2375  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.0), Vector (10.0, 0.0, 0.0)));
2376  staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.5), Vector (50.0, 0.0, 0.0)));
2377 
2378  if (useAmpdu)
2379  {
2380  // 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
2381  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevice.Get (0));
2382  Ptr<RegularWifiMac> ap_mac = DynamicCast<RegularWifiMac> (ap_device->GetMac ());
2383  NS_ASSERT (ap_mac);
2384  PointerValue ptr;
2385  ap_mac->GetAttribute ("BE_Txop", ptr);
2386  ptr.Get<QosTxop> ()->SetAttribute ("UseExplicitBarAfterMissedBlockAck", BooleanValue (false));
2387  }
2388 
2389  // Transmit a first data packet before the station moves: it should be sent with a high modulation and successfully received
2390  Simulator::Schedule (Seconds (0.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2391 
2392  // 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
2393  Simulator::Schedule (Seconds (2.0), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2394 
2395  // 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
2396  Simulator::Schedule (Seconds (2.1), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2397  Simulator::Schedule (Seconds (2.2), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2398  Simulator::Schedule (Seconds (2.3), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2399  Simulator::Schedule (Seconds (2.4), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2400  Simulator::Schedule (Seconds (2.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2401 
2402  Simulator::Stop (Seconds (3.0));
2403  Simulator::Run ();
2404 
2405  NS_TEST_ASSERT_MSG_EQ (m_txCount, (useAmpdu ? 14 : 7), "Incorrect number of transmitted packets");
2406  NS_TEST_ASSERT_MSG_EQ (m_rxCount, (useAmpdu ? 12 : 6), "Incorrect number of successfully received packets");
2407  NS_TEST_ASSERT_MSG_EQ (m_txMacFinalDataFailedCount, 1, "Incorrect number of dropped TX packets");
2408 
2409  Simulator::Destroy ();
2410 }
2411 
2412 void
2414 {
2415  //Test without A-MPDU
2416  RunOne (false);
2417 
2418  //Test with A-MPDU
2419  RunOne (true);
2420 }
2421 
2422 //-----------------------------------------------------------------------------
2436 {
2437 public:
2438  Issue169TestCase ();
2439  virtual ~Issue169TestCase ();
2440  virtual void DoRun (void);
2441 
2442 private:
2450  void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority);
2451 
2459  void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW);
2460 };
2461 
2463  : TestCase ("Test case for issue #169")
2464 {
2465 }
2466 
2468 {
2469 }
2470 
2471 void
2472 Issue169TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority)
2473 {
2474  SocketPriorityTag priorityTag;
2475  priorityTag.SetPriority (priority);
2476  for (uint8_t i = 0; i < numPackets; i++)
2477  {
2478  Ptr<Packet> packet = Create<Packet> (1000); // 1000 dummy bytes of data
2479  packet->AddPacketTag (priorityTag);
2480  sourceDevice->Send (packet, destination, 0);
2481  }
2482 }
2483 
2484 void
2485 Issue169TestCase::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
2486 {
2487  if (psdus.begin()->second->GetSize () >= 1000)
2488  {
2489  NS_TEST_ASSERT_MSG_EQ (txVector.GetMode ().GetModulationClass (), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Ideal rate manager selected incorrect modulation class");
2490  }
2491 }
2492 
2493 void
2495 {
2496  RngSeedManager::SetSeed (1);
2497  RngSeedManager::SetRun (1);
2498  int64_t streamNumber = 100;
2499 
2500  NodeContainer wifiApNode, wifiStaNode;
2501  wifiApNode.Create (1);
2502  wifiStaNode.Create (1);
2503 
2505  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2506  phy.SetChannel (channel.Create ());
2507 
2508  WifiHelper wifi;
2509  wifi.SetStandard (WIFI_STANDARD_80211ac);
2510  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2511 
2513  NetDeviceContainer apDevice;
2514  mac.SetType ("ns3::ApWifiMac");
2515  apDevice = wifi.Install (phy, mac, wifiApNode);
2516 
2517  NetDeviceContainer staDevice;
2518  mac.SetType ("ns3::StaWifiMac");
2519  staDevice = wifi.Install (phy, mac, wifiStaNode);
2520 
2521  // Assign fixed streams to random variables in use
2522  wifi.AssignStreams (apDevice, streamNumber);
2523  wifi.AssignStreams (staDevice, streamNumber);
2524 
2526  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2527  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2528  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2529  mobility.SetPositionAllocator (positionAlloc);
2530 
2531  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2532  mobility.Install (wifiApNode);
2533  mobility.Install (wifiStaNode);
2534 
2535  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&Issue169TestCase::TxCallback, this));
2536 
2537  //Send best-effort packet (i.e. priority 0)
2538  Simulator::Schedule (Seconds (0.5), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 0);
2539 
2540  //Send non best-effort (voice) packet (i.e. priority 6)
2541  Simulator::Schedule (Seconds (1.0), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 6);
2542 
2543  Simulator::Stop (Seconds (2.0));
2544  Simulator::Run ();
2545 
2546  Simulator::Destroy ();
2547 }
2548 
2549 
2550 //-----------------------------------------------------------------------------
2566 {
2567 public:
2570  virtual void DoRun (void);
2571 
2572 private:
2577  void ChangeChannelWidth (uint16_t channelWidth);
2578 
2584  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2585 
2593  void TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW);
2594 
2599  void CheckLastSelectedMode (WifiMode expectedMode);
2600 
2602 };
2603 
2605  : TestCase ("Test case for use of channel bonding with Ideal rate manager")
2606 {
2607 }
2608 
2610 {
2611 }
2612 
2613 void
2615 {
2616  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", UintegerValue (channelWidth));
2617 }
2618 
2619 void
2621 {
2622  Ptr<Packet> packet = Create<Packet> (1000);
2623  sourceDevice->Send (packet, destination, 0);
2624 }
2625 
2626 void
2627 IdealRateManagerChannelWidthTest::TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
2628 {
2629  if (psduMap.begin ()->second->GetSize () >= 1000)
2630  {
2631  m_txMode = txVector.GetMode ();
2632  }
2633 }
2634 
2635 void
2637 {
2638  NS_TEST_ASSERT_MSG_EQ (m_txMode, expectedMode, "Last selected WifiMode " << m_txMode << " does not match expected WifiMode " << expectedMode);
2639 }
2640 
2641 void
2643 {
2644  RngSeedManager::SetSeed (1);
2645  RngSeedManager::SetRun (1);
2646  int64_t streamNumber = 100;
2647 
2648  NodeContainer wifiApNode, wifiStaNode;
2649  wifiApNode.Create (1);
2650  wifiStaNode.Create (1);
2651 
2653  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2654  phy.SetChannel (channel.Create ());
2655 
2656  WifiHelper wifi;
2657  wifi.SetStandard (WIFI_STANDARD_80211ac);
2658  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2659 
2661  NetDeviceContainer apDevice;
2662  mac.SetType ("ns3::ApWifiMac");
2663  apDevice = wifi.Install (phy, mac, wifiApNode);
2664 
2665  NetDeviceContainer staDevice;
2666  mac.SetType ("ns3::StaWifiMac");
2667  staDevice = wifi.Install (phy, mac, wifiStaNode);
2668 
2669  // Assign fixed streams to random variables in use
2670  wifi.AssignStreams (apDevice, streamNumber);
2671  wifi.AssignStreams (staDevice, streamNumber);
2672 
2674  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2675  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2676  positionAlloc->Add (Vector (50.0, 0.0, 0.0));
2677  mobility.SetPositionAllocator (positionAlloc);
2678 
2679  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2680  mobility.Install (wifiApNode);
2681  mobility.Install (wifiStaNode);
2682 
2683  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerChannelWidthTest::TxCallback, this));
2684 
2685  //Set channel width to 80 MHz & send packet
2686  Simulator::Schedule (Seconds (0.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 80);
2687  Simulator::Schedule (Seconds (1.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2688  //Selected rate should be VHT-MCS 1
2689  Simulator::Schedule (Seconds (1.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs1 ());
2690 
2691  //Set channel width to 20 MHz & send packet
2692  Simulator::Schedule (Seconds (1.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 20);
2693  Simulator::Schedule (Seconds (2.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2694  //Selected rate should be VHT-MCS 3 since SNR should be 6 dB higher than previously
2695  Simulator::Schedule (Seconds (2.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2696 
2697  //Set channel width to 40 MHz & send packet
2698  Simulator::Schedule (Seconds (2.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 40);
2699  Simulator::Schedule (Seconds (3.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2700  //Selected rate should be VHT-MCS 2 since SNR should be 3 dB lower than previously
2701  Simulator::Schedule (Seconds (3.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2702 
2703  Simulator::Stop (Seconds (3.2));
2704  Simulator::Run ();
2705 
2706  Simulator::Destroy ();
2707 }
2708 
2709 
2710 //-----------------------------------------------------------------------------
2719 {
2720 public:
2722  virtual ~IdealRateManagerMimoTest ();
2723  virtual void DoRun (void);
2724 
2725 private:
2731  void SetApMimoSettings (uint8_t antennas, uint8_t maxStreams);
2737  void SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams);
2743  void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2744 
2752  void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW);
2753 
2758  void CheckLastSelectedMode (WifiMode expectedMode);
2763  void CheckLastSelectedNss (uint8_t expectedNss);
2764 
2766 };
2767 
2769  : TestCase ("Test case for use of imbalanced MIMO settings with Ideal rate manager")
2770 {
2771 }
2772 
2774 {
2775 }
2776 
2777 void
2778 IdealRateManagerMimoTest::SetApMimoSettings (uint8_t antennas, uint8_t maxStreams)
2779 {
2780  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2781  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2782  Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2783 }
2784 
2785 void
2786 IdealRateManagerMimoTest::SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams)
2787 {
2788  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2789  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2790  Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2791 }
2792 
2793 void
2795 {
2796  Ptr<Packet> packet = Create<Packet> (1000);
2797  sourceDevice->Send (packet, destination, 0);
2798 }
2799 
2800 void
2801 IdealRateManagerMimoTest::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
2802 {
2803  if (psdus.begin ()->second->GetSize () >= 1000)
2804  {
2805  m_txVector = txVector;
2806  }
2807 }
2808 
2809 void
2811 {
2812  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetNss (), expectedNss, "Last selected Nss " << m_txVector.GetNss () << " does not match expected Nss " << expectedNss);
2813 }
2814 
2815 void
2817 {
2818  NS_TEST_ASSERT_MSG_EQ (m_txVector.GetMode (), expectedMode, "Last selected WifiMode " << m_txVector.GetMode () << " does not match expected WifiMode " << expectedMode);
2819 }
2820 
2821 void
2823 {
2824  RngSeedManager::SetSeed (1);
2825  RngSeedManager::SetRun (1);
2826  int64_t streamNumber = 100;
2827 
2828  NodeContainer wifiApNode, wifiStaNode;
2829  wifiApNode.Create (1);
2830  wifiStaNode.Create (1);
2831 
2833  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2834  phy.SetChannel (channel.Create ());
2835 
2836  WifiHelper wifi;
2837  wifi.SetStandard (WIFI_STANDARD_80211ac);
2838  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2839 
2841  NetDeviceContainer apDevice;
2842  mac.SetType ("ns3::ApWifiMac");
2843  apDevice = wifi.Install (phy, mac, wifiApNode);
2844 
2845  NetDeviceContainer staDevice;
2846  mac.SetType ("ns3::StaWifiMac");
2847  staDevice = wifi.Install (phy, mac, wifiStaNode);
2848 
2849  // Assign fixed streams to random variables in use
2850  wifi.AssignStreams (apDevice, streamNumber);
2851  wifi.AssignStreams (staDevice, streamNumber);
2852 
2854  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2855  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2856  positionAlloc->Add (Vector (40.0, 0.0, 0.0));
2857  mobility.SetPositionAllocator (positionAlloc);
2858 
2859  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2860  mobility.Install (wifiApNode);
2861  mobility.Install (wifiStaNode);
2862 
2863  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerMimoTest::TxCallback, this));
2864 
2865 
2866  // TX: 1 antenna
2867  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2868  // RX: 1 antenna
2869  Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2870  // Send packets (2 times to get one feedback)
2871  Simulator::Schedule (Seconds (1.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2872  Simulator::Schedule (Seconds (1.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2873  // Selected NSS should be 1 since both TX and RX support a single antenna
2874  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2875  // Selected rate should be VHT-MCS 2 because of settings and distance between TX and RX
2876  Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2877 
2878 
2879  // TX: 1 antenna
2880  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2881  // RX: 2 antennas, but only supports 1 spatial stream
2882  Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2883  // Send packets (2 times to get one feedback)
2884  Simulator::Schedule (Seconds (2.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2885  Simulator::Schedule (Seconds (2.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2886  // Selected NSS should be 1 since both TX and RX support a single antenna
2887  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2888  // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB
2889  Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2890 
2891 
2892  // TX: 1 antenna
2893  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2894  // RX: 2 antennas, and supports 2 spatial streams
2895  Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2896  // Send packets (2 times to get one feedback)
2897  Simulator::Schedule (Seconds (3.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2898  Simulator::Schedule (Seconds (3.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2899  // Selected NSS should be 1 since TX supports a single antenna
2900  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2901  // Selected rate should be as previously
2902  Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2903 
2904 
2905  // TX: 2 antennas, but only supports 1 spatial stream
2906  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2907  // RX: 1 antenna
2908  Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2909  // Send packets (2 times to get one feedback)
2910  Simulator::Schedule (Seconds (4.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2911  Simulator::Schedule (Seconds (4.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2912  // Selected NSS should be 1 since both TX and RX support a single antenna
2913  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2914  // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario (more antennas at TX does not result in SNR improvement in AWGN channel)
2915  Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2916 
2917 
2918  // TX: 2 antennas, but only supports 1 spatial stream
2919  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2920  // RX: 2 antennas, but only supports 1 spatial stream
2921  Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2922  // Send packets (2 times to get one feedback)
2923  Simulator::Schedule (Seconds (5.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2924  Simulator::Schedule (Seconds (5.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2925  // Selected NSS should be 1 since both TX and RX support a single antenna
2926  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2927  // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN channel)
2928  Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2929 
2930 
2931  // TX: 2 antennas, but only supports 1 spatial stream
2932  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2933  // RX: 2 antennas, and supports 2 spatial streams
2934  Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2935  // Send packets (2 times to get one feedback)
2936  Simulator::Schedule (Seconds (6.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2937  Simulator::Schedule (Seconds (6.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2938  // Selected NSS should be 1 since TX supports a single antenna
2939  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2940  // Selected rate should be as previously
2941  Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2942 
2943 
2944  // TX: 2 antennas, and supports 2 spatial streams
2945  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2946  // RX: 1 antenna
2947  Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2948  // Send packets (2 times to get one feedback)
2949  Simulator::Schedule (Seconds (7.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2950  Simulator::Schedule (Seconds (7.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2951  // Selected NSS should be 1 since RX supports a single antenna
2952  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2953  // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario (more antennas at TX does not result in SNR improvement in AWGN channel)
2954  Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2955 
2956 
2957  // TX: 2 antennas, and supports 2 spatial streams
2958  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2959  // RX: 2 antennas, but only supports 1 spatial stream
2960  Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2961  // Send packets (2 times to get one feedback)
2962  Simulator::Schedule (Seconds (8.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2963  Simulator::Schedule (Seconds (8.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2964  // Selected NSS should be 1 since RX supports a single antenna
2965  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2966  // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN channel)
2967  Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs3 ());
2968 
2969 
2970  // TX: 2 antennas, and supports 2 spatial streams
2971  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
2972  // RX: 2 antennas, and supports 2 spatial streams
2973  Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2974  // Send packets (2 times to get one feedback)
2975  Simulator::Schedule (Seconds (9.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2976  Simulator::Schedule (Seconds (9.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2977  // Selected NSS should be 2 since both TX and RX support 2 antennas
2978  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 2);
2979  // 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
2980  Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2981 
2982 
2983  // Verify we can go back to initial situation
2984  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2985  Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2986  Simulator::Schedule (Seconds (10.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2987  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2988  Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, WifiPhy::GetVhtMcs2 ());
2989 
2990  Simulator::Stop (Seconds (10.2));
2991  Simulator::Run ();
2992  Simulator::Destroy ();
2993 }
2994 
2995 //-----------------------------------------------------------------------------
3003 {
3004 public:
3006 
3007 private:
3017  bool CheckDataRate (HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate);
3018  virtual void DoRun (void);
3019 };
3020 
3022  : TestCase ("Check data rates for different RU types.")
3023 {
3024 }
3025 
3026 bool
3027 HeRuMcsDataRateTestCase::CheckDataRate (HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate)
3028 {
3029  uint16_t approxWidth = HeRu::GetBandwidth (ruType);
3030  WifiMode mode (mcs);
3031  uint64_t dataRate = round (mode.GetDataRate (approxWidth, guardInterval, nss) / 100000.0);
3032  NS_ABORT_MSG_IF (dataRate > 65535, "Rate is way too high");
3033  if (static_cast<uint16_t> (dataRate) != expectedDataRate)
3034  {
3035  std::cerr << "RU=" << ruType
3036  << " mode=" << mode
3037  << " Nss=" << +nss
3038  << " guardInterval=" << guardInterval
3039  << " expected=" << expectedDataRate << " x100kbps"
3040  << " computed=" << static_cast<uint16_t> (dataRate) << " x100kbps"
3041  << std::endl;
3042  return false;
3043  }
3044  return true;
3045 }
3046 
3047 void
3049 {
3050  bool retval = true;
3051 
3052  //26-tone RU, browse over all MCSs, GIs and Nss's (up to 4, current max)
3053  retval = retval
3054  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs0", 1, 800, 9)
3055  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs1", 1, 1600, 17)
3056  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs2", 1, 3200, 23)
3057  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs3", 1, 3200, 30)
3058  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs4", 2, 1600, 100)
3059  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs5", 3, 1600, 200)
3060  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs6", 4, 1600, 300)
3061  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs7", 4, 3200, 300)
3062  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs8", 4, 1600, 400)
3063  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs9", 4, 3200, 400)
3064  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs10", 4, 1600, 500)
3065  && CheckDataRate (HeRu::RU_26_TONE, "HeMcs11", 4, 3200, 500);
3066 
3067  NS_TEST_EXPECT_MSG_EQ (retval, true, "26-tone RU data rate verification for different MCSs, GIs, and Nss's failed");
3068 
3069  //Check other RU sizes
3070  retval = retval
3071  && CheckDataRate ( HeRu::RU_52_TONE, "HeMcs2", 1, 1600, 50)
3072  && CheckDataRate ( HeRu::RU_106_TONE, "HeMcs9", 1, 800, 500)
3073  && CheckDataRate ( HeRu::RU_242_TONE, "HeMcs5", 1, 1600, 650)
3074  && CheckDataRate ( HeRu::RU_484_TONE, "HeMcs3", 1, 1600, 650)
3075  && CheckDataRate ( HeRu::RU_996_TONE, "HeMcs5", 1, 3200, 2450)
3076  && CheckDataRate (HeRu::RU_2x996_TONE, "HeMcs3", 1, 3200, 2450);
3077 
3078  NS_TEST_EXPECT_MSG_EQ (retval, true, "Data rate verification for RUs above 52-tone RU (included) failed");
3079 }
3080 
3087 class WifiTestSuite : public TestSuite
3088 {
3089 public:
3090  WifiTestSuite ();
3091 };
3092 
3094  : TestSuite ("wifi-devices", UNIT)
3095 {
3096  AddTestCase (new WifiTest, TestCase::QUICK);
3097  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
3098  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
3099  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
3100  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
3101  AddTestCase (new QosFragmentationTestCase, TestCase::QUICK);
3102  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
3103  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
3104  AddTestCase (new Bug2843TestCase, TestCase::QUICK); //Bug 2843
3105  AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
3106  AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399
3107  AddTestCase (new Bug2470TestCase, TestCase::QUICK); //Bug 2470
3108  AddTestCase (new Issue40TestCase, TestCase::QUICK); //Issue #40
3109  AddTestCase (new Issue169TestCase, TestCase::QUICK); //Issue #169
3110  AddTestCase (new IdealRateManagerChannelWidthTest, TestCase::QUICK);
3111  AddTestCase (new IdealRateManagerMimoTest, TestCase::QUICK);
3112  AddTestCase (new HeRuMcsDataRateTestCase, TestCase::QUICK);
3113 }
3114 
MpduInfo structure.
Definition: wifi-phy.h:126
size_t GetNumBands() const
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void RunOne(void)
Run one function.
Definition: wifi-test.cc:173
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
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:2040
virtual ~Bug730TestCase()
Definition: wifi-test.cc:623
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
void SetType(std::string type, Args &&... args)
virtual ~QosFragmentationTestCase()
Definition: wifi-test.cc:769
void Transmit(std::string context, Ptr< const Packet > p, double power)
Callback invoked when PHY transmits a packet.
Definition: wifi-test.cc:783
uint16_t m_countOperationalChannelWidth20
count number of beacon frames announcing a 20 MHz operating channel width
Definition: wifi-test.cc:1613
AttributeValue implementation for Boolean.
Definition: boolean.h:36
virtual void SetProtectionManager(Ptr< WifiProtectionManager > protectionManager)
Set the Protection Manager to use.
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:2318
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:628
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:1455
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:1963
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1670
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:1897
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
virtual ~IdealRateManagerMimoTest()
Definition: wifi-test.cc:2773
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:144
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Definition: wifi-ppdu.h:33
void RxCallback(std::string context, Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
Callback triggered when a packet is received by the PHYs.
Definition: wifi-test.cc:1640
A suite of tests to run.
Definition: test.h:1343
void AddWaypoint(const Waypoint &waypoint)
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1373
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:92
an address for a packet socket
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2822
#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:2012
uint16_t m_rxCount
Count number of successfully received data packets.
Definition: wifi-test.cc:2283
uint16_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:2013
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:2435
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:765
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:50
staDevices
Definition: third.py:103
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet. ...
Definition: qos-utils.cc:84
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:262
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1498
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:1487
VHT PHY (Clause 22)
Definition: wifi-mode.h:62
The 5 GHz band.
Definition: wifi-phy-band.h:35
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:229
encapsulates test code
Definition: test.h:1153
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
virtual ~StaWifiMacScanningTestCase()
Definition: wifi-test.cc:1811
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:595
virtual ~Bug2843TestCase()
Definition: wifi-test.cc:1450
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1816
virtual void ConfigureStandard(WifiStandard standard)=0
helps to create WifiNetDevice objects
Definition: wifi-helper.h:326
Mac48Address m_associatedApBssid
Associated AP&#39;s bssid.
Definition: wifi-test.cc:1803
Make sure that Ideal rate manager recovers when the station is moving away from the access point...
Definition: wifi-test.cc:2249
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
bool CheckDataRate(HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate)
Compare the data rate computed for the provided combination with standard defined one...
Definition: wifi-test.cc:3027
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
uint32_t GetIfIndex(void) const
Address GetAddress(void) const
a polymophic address class
Definition: address.h:90
unsigned int m_numSentPackets
number of sent packets
Definition: wifi-test.cc:463
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:2307
mobility
Definition: third.py:108
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:459
phy
Definition: third.py:93
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:753
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode...
virtual ~Issue169TestCase()
Definition: wifi-test.cc:2467
uint16_t m_countOperationalChannelWidth40
count number of beacon frames announcing a 40 MHz operating channel width
Definition: wifi-test.cc:1614
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1516
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2636
uint16_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:2017
uint16_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:2015
void SetWifiMac(Ptr< RegularWifiMac > mac)
Set the MAC which is using this Acknowledgment Manager.
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:2794
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1822
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:2786
void RxCallback(std::string context, Ptr< const Packet > p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
Callback when packet is received.
Definition: wifi-test.cc:2063
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:2035
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:312
virtual void SetAckManager(Ptr< WifiAckManager > ackManager)
Set the Acknowledgment Manager to use.
base class for all MAC-level wifi objects.
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1626
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:1771
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:461
uint16_t m_reassocReqCount
count number of reassociation requests
Definition: wifi-test.cc:1611
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:774
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:2601
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:1285
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:500
#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:2165
void SetWifiMac(Ptr< RegularWifiMac > mac)
Set the MAC which is using this Protection Manager.
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:2324
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:1313
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2642
wifiApNode
Definition: third.py:90
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:638
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1588
uint16_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:2019
virtual void SetAddress(Mac48Address address)=0
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:288
hold a list of per-remote-station state.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:480
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:918
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3048
uint32_t m_fragments
transmitted fragments
Definition: wifi-test.cc:743
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:2620
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:784
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:925
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:305
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:1609
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2816
void TxDataFailedTrace(std::string context, Mac48Address adress)
Transmit data failed function.
Definition: wifi-test.cc:1306
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:192
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:2778
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:479
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:3115
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1496
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:48
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:119
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2801
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:235
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:742
void SetList(const std::list< uint32_t > &packetlist)
Definition: error-model.cc:520
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:41
uint16_t m_addbaPendingCount
Count number of times ADDBA state machine is in pending state.
Definition: wifi-test.cc:2016
an EUI-48 address
Definition: mac48-address.h:43
ObjectFactory m_manager
manager
Definition: wifi-test.cc:457
NodeContainer Setup(bool nearestApBeaconGeneration, bool staActiveProbe)
Setup test.
Definition: wifi-test.cc:1838
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1301
Ptr< const SpectrumModel > GetSpectrumModel() const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1614
manage and create wifi channel objects for the YANS model.
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:120
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:493
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1667
create MAC layers for a ns3::WifiNetDevice.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
State
Represents the state for this agreement.
void RxSuccessCallback(std::string context, Ptr< const Packet > p)
Callback when packet is successfully received.
Definition: wifi-test.cc:2301
void ChangeChannelWidth(uint16_t channelWidth)
Change the configured channel width for all nodes.
Definition: wifi-test.cc:2614
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:2718
void TxCallback(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2627
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:1412
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:289
void RxErrorCallback(std::string context, Ptr< const Packet > p, double snr)
Callback when packet is dropped.
Definition: wifi-test.cc:2082
Wifi Test Suite.
Definition: wifi-test.cc:3087
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1275
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:1423
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:795
uint16_t m_txCount
Count number of transmitted data packets.
Definition: wifi-test.cc:2284
void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel)
Run subtest for this test suite.
Definition: wifi-test.cc:2105
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:118
Instantiate subclasses of ns3::Object.
Ptr< WifiMac > GetMac(void) const
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
Definition: wifi-mode.h:38
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:956
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2485
static void AssignWifiRandomStreams(Ptr< WifiMac > mac, int64_t stream)
Definition: wifi-test.cc:60
SignalNoiseDbm structure.
Definition: wifi-phy.h:119
virtual void SetChannelWidth(uint16_t channelWidth)
Definition: wifi-phy.cc:1502
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1608
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
AttributeValue implementation for Ssid.
Definition: ssid.h:105
ObjectFactory m_manager
manager
Definition: wifi-test.cc:287
OFDM PHY (Clause 17)
Definition: wifi-mode.h:58
void SendPacketBurst(uint32_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination) const
Triggers the arrival of a burst of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:2094
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
uint32_t m_received
received
Definition: wifi-test.cc:605
void Add(Vector v)
Add a position to the list of positions.
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:298
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
apDevices
Definition: third.py:106
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Data rate verification test for MCSs of different RU sizes.
Definition: wifi-test.cc:3002
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2413
WifiTxVector m_txVector
Store the last TXVECTOR used to transmit Data.
Definition: wifi-test.cc:2765
Make sure that Ideal rate manager properly selects MCS based on the configured channel width...
Definition: wifi-test.cc:2565
void TurnApOff(Ptr< Node > apNode)
Turn the AP node off.
Definition: wifi-test.cc:1830
uint16_t m_txMacFinalDataFailedCount
Count number of unsuccessfully transmitted data packets.
Definition: wifi-test.cc:2285
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:129
void CheckLastSelectedNss(uint8_t expectedNss)
Check if the selected Nss is correct.
Definition: wifi-test.cc:2810
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
uint16_t m_addbaNoReplyCount
Count number of times ADDBA state machine is in no_reply state.
Definition: wifi-test.cc:2018
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2494
Wifi Test.
Definition: wifi-test.cc:95
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:2296
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:1424
Time m_secondTransmissionTime
second transmission time
Definition: wifi-test.cc:462
void ChangeSupportedChannelWidth(void)
Function called to change the supported channel width at runtime.
Definition: wifi-test.cc:1631
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:2014
MpduType type
type
Definition: wifi-phy.h:128
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:917
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
uint16_t m_reassocRespCount
count number of reassociation responses
Definition: wifi-test.cc:1612
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:2472
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
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:127
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Implements the IEEE 802.11 MAC header.
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:136
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Make sure that fragmentation works with QoS stations.
Definition: wifi-test.cc:732
uint16_t m_channelWidth
channel width (in MHz)
Definition: wifi-test.cc:1441
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyBand band, WifiPhyStandard standard, uint16_t frequency, uint16_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1278
Set Channel Frequency Test.
Definition: wifi-test.cc:893
Make sure that when multiple broadcast packets are queued on the same device in a short succession...
Definition: wifi-test.cc:442
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:350