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/packet-socket-server.h"
39 #include "ns3/packet-socket-client.h"
40 #include "ns3/packet-socket-helper.h"
41 #include "ns3/spectrum-wifi-helper.h"
42 #include "ns3/multi-model-spectrum-channel.h"
43 #include "ns3/wifi-spectrum-signal-parameters.h"
44 #include "ns3/yans-wifi-phy.h"
45 #include "ns3/mgt-headers.h"
46 #include "ns3/ht-configuration.h"
47 #include "ns3/wifi-ppdu.h"
48 #include "ns3/wifi-psdu.h"
49 
50 using namespace ns3;
51 
52 //Helper function to assign streams to random variables, to control
53 //randomness in the tests
54 static void
56 {
57  int64_t currentStream = stream;
58  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
59  if (rmac)
60  {
61  PointerValue ptr;
62  rmac->GetAttribute ("Txop", ptr);
63  Ptr<Txop> txop = ptr.Get<Txop> ();
64  currentStream += txop->AssignStreams (currentStream);
65 
66  rmac->GetAttribute ("VO_Txop", ptr);
67  Ptr<QosTxop> vo_txop = ptr.Get<QosTxop> ();
68  currentStream += vo_txop->AssignStreams (currentStream);
69 
70  rmac->GetAttribute ("VI_Txop", ptr);
71  Ptr<QosTxop> vi_txop = ptr.Get<QosTxop> ();
72  currentStream += vi_txop->AssignStreams (currentStream);
73 
74  rmac->GetAttribute ("BE_Txop", ptr);
75  Ptr<QosTxop> be_txop = ptr.Get<QosTxop> ();
76  currentStream += be_txop->AssignStreams (currentStream);
77 
78  rmac->GetAttribute ("BK_Txop", ptr);
79  Ptr<QosTxop> bk_txop = ptr.Get<QosTxop> ();
80  bk_txop->AssignStreams (currentStream);
81  }
82 }
83 
90 class WifiTest : public TestCase
91 {
92 public:
93  WifiTest ();
94 
95  virtual void DoRun (void);
96 
97 
98 private:
100  void RunOne (void);
106  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
112 
116 };
117 
119  : TestCase ("Wifi")
120 {
121 }
122 
123 void
125 {
126  Ptr<Packet> p = Create<Packet> ();
127  dev->Send (p, dev->GetBroadcast (), 1);
128 }
129 
130 void
132 {
133  Ptr<Node> node = CreateObject<Node> ();
134  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
135 
137  mac->SetDevice (dev);
138  mac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
139  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
140  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
141  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
142  phy->SetErrorRateModel (error);
143  phy->SetChannel (channel);
144  phy->SetDevice (dev);
145  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
147 
148  mobility->SetPosition (pos);
149  node->AggregateObject (mobility);
150  mac->SetAddress (Mac48Address::Allocate ());
151  dev->SetMac (mac);
152  dev->SetPhy (phy);
153  dev->SetRemoteStationManager (manager);
154  node->AddDevice (dev);
155 
156  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
157 }
158 
159 void
161 {
162  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
164  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
165  channel->SetPropagationDelayModel (propDelay);
166  channel->SetPropagationLossModel (propLoss);
167 
168  CreateOne (Vector (0.0, 0.0, 0.0), channel);
169  CreateOne (Vector (5.0, 0.0, 0.0), channel);
170  CreateOne (Vector (5.0, 0.0, 0.0), channel);
171 
172  Simulator::Stop (Seconds (10.0));
173 
174  Simulator::Run ();
175  Simulator::Destroy ();
176 }
177 
178 void
180 {
181  m_mac.SetTypeId ("ns3::AdhocWifiMac");
182  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
183 
184  m_manager.SetTypeId ("ns3::ArfWifiManager");
185  RunOne ();
186  m_manager.SetTypeId ("ns3::AarfWifiManager");
187  RunOne ();
188  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
189  RunOne ();
190  m_manager.SetTypeId ("ns3::OnoeWifiManager");
191  RunOne ();
192  m_manager.SetTypeId ("ns3::AmrrWifiManager");
193  RunOne ();
194  m_manager.SetTypeId ("ns3::IdealWifiManager");
195  RunOne ();
196 
197  m_mac.SetTypeId ("ns3::AdhocWifiMac");
198  RunOne ();
199  m_mac.SetTypeId ("ns3::ApWifiMac");
200  RunOne ();
201  m_mac.SetTypeId ("ns3::StaWifiMac");
202  RunOne ();
203 
204 
205  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
206  m_mac.SetTypeId ("ns3::AdhocWifiMac");
207  RunOne ();
208 }
209 
217 {
218 public:
219  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
220  {
221  }
222  virtual void DoRun (void)
223  {
224  //startingSeq=0, seqNum=2047
225  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
226  //startingSeq=0, seqNum=2048
227  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
228  //startingSeq=2048, seqNum=0
229  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
230  //startingSeq=4095, seqNum=0
231  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
232  //startingSeq=0, seqNum=4095
233  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
234  //startingSeq=4095 seqNum=2047
235  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
236  //startingSeq=2048 seqNum=4095
237  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
238  //startingSeq=2049 seqNum=0
239  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
240  }
241 };
242 
243 
248 {
249 public:
251 
252  virtual void DoRun (void);
253 
254 
255 private:
272  void SwitchCh (Ptr<WifiNetDevice> dev);
273 
277 };
278 
280  : TestCase ("InterferenceHelperSequence")
281 {
282 }
283 
284 void
286 {
287  Ptr<Packet> p = Create<Packet> (1000);
288  dev->Send (p, dev->GetBroadcast (), 1);
289 }
290 
291 void
293 {
294  Ptr<WifiPhy> p = dev->GetPhy ();
295  p->SetChannelNumber (1);
296 }
297 
298 Ptr<Node>
300 {
301  Ptr<Node> node = CreateObject<Node> ();
302  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
303 
305  mac->SetDevice (dev);
306  mac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
307  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
308  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
309  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
310  phy->SetErrorRateModel (error);
311  phy->SetChannel (channel);
312  phy->SetDevice (dev);
313  phy->SetMobility (mobility);
314  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
316 
317  mobility->SetPosition (pos);
318  node->AggregateObject (mobility);
319  mac->SetAddress (Mac48Address::Allocate ());
320  dev->SetMac (mac);
321  dev->SetPhy (phy);
322  dev->SetRemoteStationManager (manager);
323  node->AddDevice (dev);
324 
325  return node;
326 }
327 
328 void
330 {
331  m_mac.SetTypeId ("ns3::AdhocWifiMac");
332  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
333  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
334 
335  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
337  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
338  channel->SetPropagationDelayModel (propDelay);
339  channel->SetPropagationLossModel (propLoss);
340 
341  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
342  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
343  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
344 
345  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
346  propLoss->SetDefaultLoss (999);
347 
348  Simulator::Schedule (Seconds (1.0),
350  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
351 
352  Simulator::Schedule (Seconds (1.0000001),
354  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
355 
356  Simulator::Schedule (Seconds (5.0),
358  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
359 
360  Simulator::Schedule (Seconds (7.0),
362  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
363 
364  Simulator::Stop (Seconds (100.0));
365  Simulator::Run ();
366 
367  Simulator::Destroy ();
368 }
369 
370 
371 //-----------------------------------------------------------------------------
423 {
424 public:
426 
427  virtual void DoRun (void);
428 
429 
430 private:
436 
440 
443  unsigned int m_numSentPackets;
444 
450  void NotifyPhyTxBegin (Ptr<const Packet> p, double txPowerW);
451 };
452 
454  : TestCase ("Test case for DCF immediate access with broadcast frames")
455 {
456 }
457 
458 void
460 {
461  if (m_numSentPackets == 0)
462  {
465  }
466  else if (m_numSentPackets == 1)
467  {
469  }
470 }
471 
472 void
474 {
475  Ptr<Packet> p = Create<Packet> (1000);
476  dev->Send (p, dev->GetBroadcast (), 1);
477 }
478 
479 void
481 {
482  m_mac.SetTypeId ("ns3::AdhocWifiMac");
483  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
484  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
485 
486  //Assign a seed and run number, and later fix the assignment of streams to
487  //WiFi random variables, so that the first backoff used is one slot
488  RngSeedManager::SetSeed (1);
489  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
490 
491  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
493  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
494  channel->SetPropagationDelayModel (propDelay);
495  channel->SetPropagationLossModel (propLoss);
496 
497  Ptr<Node> txNode = CreateObject<Node> ();
498  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
499  Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
500  txMac->SetDevice (txDev);
501  txMac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
502  //Fix the stream assignment to the Dcf Txop objects (backoffs)
503  //The below stream assignment will result in the Txop object
504  //using a backoff value of zero for this test when the
505  //Txop::EndTxNoAck() calls to StartBackoffNow()
506  AssignWifiRandomStreams (txMac, 23);
507 
508  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
509  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
510  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
511  txPhy->SetErrorRateModel (txError);
512  txPhy->SetChannel (channel);
513  txPhy->SetDevice (txDev);
514  txPhy->SetMobility (txMobility);
515  txPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
516 
517  txPhy->TraceConnectWithoutContext ("PhyTxBegin", MakeCallback (&DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin, this));
518 
519  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
520  txNode->AggregateObject (txMobility);
521  txMac->SetAddress (Mac48Address::Allocate ());
522  txDev->SetMac (txMac);
523  txDev->SetPhy (txPhy);
524  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
525  txNode->AddDevice (txDev);
526 
529  m_numSentPackets = 0;
530 
531  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
532  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
533 
534  Simulator::Stop (Seconds (2.0));
535  Simulator::Run ();
536  Simulator::Destroy ();
537 
538  // First packet is transmitted a DIFS after the packet is queued. A DIFS
539  // is 2 slots (2 * 9 = 18 us) plus a SIFS (16 us), i.e., 34 us
540  Time expectedFirstTransmissionTime = Seconds (1.0) + MicroSeconds (34);
541 
542  //First packet has 1408 us of transmit time. Slot time is 9 us.
543  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
544  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
545  //1451 us after the first one.
546  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
547  Time expectedSecondTransmissionTime = expectedFirstTransmissionTime + MicroSeconds (expectedWait1);
548  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, expectedFirstTransmissionTime, "The first transmission time not correct!");
549 
550  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
551 }
552 
553 
554 //-----------------------------------------------------------------------------
567 class Bug730TestCase : public TestCase
568 {
569 public:
570  Bug730TestCase ();
571  virtual ~Bug730TestCase ();
572 
573  virtual void DoRun (void);
574 
575 
576 private:
577  uint32_t m_received;
578 
585  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
586 
587 };
588 
590  : TestCase ("Test case for Bug 730"),
591  m_received (0)
592 {
593 }
594 
596 {
597 }
598 
599 void
600 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
601 {
602  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
603  {
604  m_received++;
605  }
606 }
607 
608 
609 void
611 {
612  m_received = 0;
613 
614  NodeContainer wifiStaNode;
615  wifiStaNode.Create (1);
616 
618  wifiApNode.Create (1);
619 
620  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
621  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
622  phy.SetChannel (channel.Create ());
623 
625  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
626  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
627  "DataMode", StringValue ("DsssRate1Mbps"),
628  "ControlMode", StringValue ("DsssRate1Mbps"));
629 
631  Ssid ssid = Ssid ("ns-3-ssid");
632  mac.SetType ("ns3::StaWifiMac",
633  "Ssid", SsidValue (ssid),
634  "ActiveProbing", BooleanValue (false));
635 
637  staDevices = wifi.Install (phy, mac, wifiStaNode);
638 
639  mac.SetType ("ns3::ApWifiMac",
640  "Ssid", SsidValue (ssid),
641  "BeaconGeneration", BooleanValue (true));
642 
644  apDevices = wifi.Install (phy, mac, wifiApNode);
645 
647  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
648 
649  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
650  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
651  mobility.SetPositionAllocator (positionAlloc);
652 
653  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
654  mobility.Install (wifiApNode);
655  mobility.Install (wifiStaNode);
656 
657  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
658  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
659 
660  PacketSocketAddress socket;
661  socket.SetSingleDevice (sta_device->GetIfIndex ());
662  socket.SetPhysicalAddress (ap_device->GetAddress ());
663  socket.SetProtocol (1);
664 
665  // give packet socket powers to nodes.
666  PacketSocketHelper packetSocket;
667  packetSocket.Install (wifiStaNode);
668  packetSocket.Install (wifiApNode);
669 
670  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
671  client->SetAttribute ("PacketSize", UintegerValue (1460));
672  client->SetRemote (socket);
673  wifiStaNode.Get (0)->AddApplication (client);
674  client->SetStartTime (Seconds (1));
675  client->SetStopTime (Seconds (51.0));
676 
677  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
678  server->SetLocal (socket);
679  wifiApNode.Get (0)->AddApplication (server);
680  server->SetStartTime (Seconds (0.0));
681  server->SetStopTime (Seconds (52.0));
682 
683  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
684 
685  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
686 
687  Simulator::Stop (Seconds (55));
688  Simulator::Run ();
689 
690  Simulator::Destroy ();
691 
692  bool result = (m_received > 0);
693  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
694 }
695 
696 //-----------------------------------------------------------------------------
705 {
706 public:
708  virtual ~QosFragmentationTestCase ();
709 
710  virtual void DoRun (void);
711 
712 
713 private:
714  uint32_t m_received;
715  uint32_t m_fragments;
716 
723  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
724 
731  void Transmit (std::string context, Ptr<const Packet> p, double power);
732 };
733 
735  : TestCase ("Test case for fragmentation with QoS stations"),
736  m_received (0),
737  m_fragments (0)
738 {
739 }
740 
742 {
743 }
744 
745 void
746 QosFragmentationTestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
747 {
748  if (p->GetSize () == 1400)
749  {
750  m_received++;
751  }
752 }
753 
754 void
755 QosFragmentationTestCase::Transmit (std::string context, Ptr<const Packet> p, double power)
756 {
757  WifiMacHeader hdr;
758  p->PeekHeader (hdr);
759  if (hdr.IsQosData ())
760  {
761  NS_TEST_EXPECT_MSG_LT_OR_EQ (p->GetSize (), 400, "Unexpected fragment size");
762  m_fragments++;
763  }
764 }
765 
766 void
768 {
769  NodeContainer wifiStaNode;
770  wifiStaNode.Create (1);
771 
773  wifiApNode.Create (1);
774 
775  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
776  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
777  phy.SetChannel (channel.Create ());
778 
780  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
781  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
782  "DataMode", StringValue ("HtMcs7"));
783 
785  Ssid ssid = Ssid ("ns-3-ssid");
786  mac.SetType ("ns3::StaWifiMac",
787  "Ssid", SsidValue (ssid),
788  "ActiveProbing", BooleanValue (false));
789 
791  staDevices = wifi.Install (phy, mac, wifiStaNode);
792 
793  mac.SetType ("ns3::ApWifiMac",
794  "Ssid", SsidValue (ssid),
795  "BeaconGeneration", BooleanValue (true));
796 
798  apDevices = wifi.Install (phy, mac, wifiApNode);
799 
801  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
802 
803  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
804  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
805  mobility.SetPositionAllocator (positionAlloc);
806 
807  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
808  mobility.Install (wifiApNode);
809  mobility.Install (wifiStaNode);
810 
811  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
812  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
813 
814  // set the TXOP limit on BE AC
815  Ptr<RegularWifiMac> sta_mac = DynamicCast<RegularWifiMac> (sta_device->GetMac ());
816  NS_ASSERT (sta_mac);
817  PointerValue ptr;
818  sta_mac->GetAttribute ("BE_Txop", ptr);
819  ptr.Get<QosTxop> ()->SetTxopLimit (MicroSeconds (3008));
820 
821  PacketSocketAddress socket;
822  socket.SetSingleDevice (sta_device->GetIfIndex ());
823  socket.SetPhysicalAddress (ap_device->GetAddress ());
824  socket.SetProtocol (1);
825 
826  // give packet socket powers to nodes.
827  PacketSocketHelper packetSocket;
828  packetSocket.Install (wifiStaNode);
829  packetSocket.Install (wifiApNode);
830 
831  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
832  client->SetAttribute ("PacketSize", UintegerValue (1400));
833  client->SetAttribute ("MaxPackets", UintegerValue (1));
834  client->SetRemote (socket);
835  wifiStaNode.Get (0)->AddApplication (client);
836  client->SetStartTime (Seconds (1));
837  client->SetStopTime (Seconds (3.0));
838 
839  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
840  server->SetLocal (socket);
841  wifiApNode.Get (0)->AddApplication (server);
842  server->SetStartTime (Seconds (0.0));
843  server->SetStopTime (Seconds (4.0));
844 
845  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&QosFragmentationTestCase::Receive, this));
846 
847  Config::Set ("/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("400"));
848  Config::Connect ("/NodeList/0/DeviceList/0/Phy/PhyTxBegin", MakeCallback (&QosFragmentationTestCase::Transmit, this));
849 
850  Simulator::Stop (Seconds (5));
851  Simulator::Run ();
852 
853  Simulator::Destroy ();
854 
855  NS_TEST_ASSERT_MSG_EQ (m_received, 1, "Unexpected number of received packets");
856  NS_TEST_ASSERT_MSG_EQ (m_fragments, 4, "Unexpected number of transmitted fragments");
857 }
858 
866 {
867 public:
869 
870  virtual void DoRun (void);
871 
872 
873 private:
880 
881 };
882 
884  : TestCase ("Test case for setting WifiPhy channel and frequency")
885 {
886 }
887 
890 {
891  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
892  Ptr<WifiPhy> wp = wnd->GetPhy ();
893  return wp->GetObject<YansWifiPhy> ();
894 }
895 
896 void
898 {
899  NodeContainer wifiStaNode;
900  wifiStaNode.Create (1);
902  wifiApNode.Create (1);
903 
904  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
905  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
906  phy.SetChannel (channel.Create ());
907 
908  // Configure and declare other generic components of this example
909  Ssid ssid;
910  ssid = Ssid ("wifi-phy-configuration");
911  WifiMacHelper macSta;
912  macSta.SetType ("ns3::StaWifiMac",
913  "Ssid", SsidValue (ssid),
914  "ActiveProbing", BooleanValue (false));
915  NetDeviceContainer staDevice;
916  Ptr<YansWifiPhy> phySta;
917 
918  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
919  {
920  // case 0
921  // Default configuration, without WifiHelper::SetStandard or WifiHelper
922  phySta = CreateObject<YansWifiPhy> ();
923  // The default results in an invalid configuration of channel 0,
924  // width 20, and frequency 0 MHz
925  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "default configuration");
926  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
927  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 0, "default configuration");
928  }
929  {
930  // case 1
932  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
933  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
934  phySta = GetYansWifiPhyPtr (staDevice);
935  // We expect channel 36, width 20, frequency 5180
936  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
937  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
938  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
939  }
940  {
941  // case 2
943  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
944  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
945  phySta = GetYansWifiPhyPtr (staDevice);
946  // We expect channel 1, width 22, frequency 2412
947  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
948  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
949  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
950  }
951  {
952  // case 3
954  wifi.SetStandard (WIFI_PHY_STANDARD_80211g);
955  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
956  phySta = GetYansWifiPhyPtr (staDevice);
957  // We expect channel 1, width 20, frequency 2412
958  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
959  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
960  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
961  }
962  {
963  // case 4
965  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
966  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
967  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
968  phySta = GetYansWifiPhyPtr (staDevice);
969  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
970  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
971  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
972  }
973  {
974  // case 5
976  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
978  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
979  phySta = GetYansWifiPhyPtr (staDevice);
980  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
981  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
982  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
983  }
984  {
985  // case 6
987  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
988  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
989  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
990  phySta = GetYansWifiPhyPtr (staDevice);
991  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
992  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
993  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
994  }
995  {
996  // case 7
998  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
999  wifi.SetStandard (WIFI_PHY_STANDARD_80211_10MHZ);
1000  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1001  phySta = GetYansWifiPhyPtr (staDevice);
1002  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11 10Mhz configuration");
1003  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11 10Mhz configuration");
1004  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 10Mhz configuration");
1005  }
1006  {
1007  // case 8
1008  WifiHelper wifi;
1009  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1010  wifi.SetStandard (WIFI_PHY_STANDARD_80211_5MHZ);
1011  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1012  phySta = GetYansWifiPhyPtr (staDevice);
1013  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5Mhz configuration");
1014  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11 5Mhz configuration");
1015  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 5Mhz configuration");
1016  }
1017  {
1018  // case 9
1019  WifiHelper wifi;
1020  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1021  wifi.SetStandard (WIFI_PHY_STANDARD_holland);
1022  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1023  phySta = GetYansWifiPhyPtr (staDevice);
1024  // We expect channel 36, width 20, frequency 5180
1025  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
1026  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
1027  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
1028  }
1029  {
1030  // case 10
1031  WifiHelper wifi;
1032  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1033  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1034  phy.Set ("ChannelNumber", UintegerValue (44));
1035  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1036  phySta = GetYansWifiPhyPtr (staDevice);
1037  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1038  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1039  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1040  }
1041  {
1042  // case 11
1043  WifiHelper wifi;
1044  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1045  phy.Set ("ChannelNumber", UintegerValue (44));
1046  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1047  phySta = GetYansWifiPhyPtr (staDevice);
1048  // Post-install reconfiguration to channel number 40
1049  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber", UintegerValue (40));
1050  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1051  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1052  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1053  }
1054  {
1055  // case 12
1056  WifiHelper wifi;
1057  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1058  phy.Set ("ChannelNumber", UintegerValue (44));
1059  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1060  phySta = GetYansWifiPhyPtr (staDevice);
1061  // Post-install reconfiguration to channel width 40 MHz
1062  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
1063  // Although channel 44 is configured originally for 20 MHz, we
1064  // allow it to be used for 40 MHz here
1065  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1066  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1067  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1068  }
1069  {
1070  // case 13
1071  WifiHelper wifi;
1072  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1073  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1074  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1075  phySta = GetYansWifiPhyPtr (staDevice);
1076  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
1077  // Post-install reconfiguration to channel width 40 MHz
1078  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
1079  // Although channel 44 is configured originally for 20 MHz, we
1080  // allow it to be used for 40 MHz here
1081  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1082  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1083  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1084  }
1085  {
1086  // case 14
1087  WifiHelper wifi;
1088  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1089  // Test that setting Frequency to a non-standard value will zero the
1090  // channel number
1091  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1092  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1093  phySta = GetYansWifiPhyPtr (staDevice);
1094  phySta->SetAttribute ("Frequency", UintegerValue (5281));
1095  // We expect channel number to be zero since frequency doesn't match
1096  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1097  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1098  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5281, "802.11 5GHz configuration");
1099  }
1100  {
1101  // case 15:
1102  WifiHelper wifi;
1103  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1104  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1105  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1106  phySta = GetYansWifiPhyPtr (staDevice);
1107  // Test that setting Frequency to a standard value will set the
1108  // channel number correctly
1109  phySta->SetAttribute ("Frequency", UintegerValue (5500));
1110  // We expect channel number to be 100 due to frequency 5500
1111  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
1112  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1113  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
1114  }
1115  {
1116  // case 16:
1117  WifiHelper wifi;
1118  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1119  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1120  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1121  phySta = GetYansWifiPhyPtr (staDevice);
1122  // This case will error exit due to invalid channel number unless
1123  // we provide the DefineChannelNumber() below
1124  phySta->DefineChannelNumber (99, WIFI_PHY_STANDARD_80211n_5GHZ, 5185, 40);
1125  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
1126  }
1127  {
1128  // case 17:
1129  WifiHelper wifi;
1130  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1131  // Test how channel number behaves when frequency is non-standard
1132  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1133  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1134  phySta = GetYansWifiPhyPtr (staDevice);
1135  phySta->SetAttribute ("Frequency", UintegerValue (5181));
1136  // We expect channel number to be 0 due to unknown center frequency 5181
1137  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1138  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1139  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5181, "802.11 5GHz configuration");
1140  phySta->SetAttribute ("Frequency", UintegerValue (5180));
1141  // We expect channel number to be 36 due to known center frequency 5180
1142  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1143  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1144  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1145  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1146  // We expect channel number to be 0 due to unknown center frequency 5179
1147  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1148  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1149  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1150  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1151  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1152  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1153  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1154  }
1155  {
1156  // case 18:
1157  WifiHelper wifi;
1158  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1159  // Set both channel and frequency to consistent values
1160  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1161  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1162  phySta = GetYansWifiPhyPtr (staDevice);
1163  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1164  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
1165  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "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 (), 5200, "802.11 5GHz configuration");
1168  // Set both channel and frequency to inconsistent values
1169  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1170  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1171  // We expect channel number to be 36
1172  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1173  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1174  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1175  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1176  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1177  // We expect channel number to be 40
1178  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1179  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1180  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1181  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1182  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1183  // We expect channel number to be 36
1184  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1185  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1186  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1187  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1188  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1189  // We expect channel number to be 0
1190  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1191  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1192  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1193  }
1194 
1195  Simulator::Destroy ();
1196 }
1197 
1198 //-----------------------------------------------------------------------------
1207 {
1208 public:
1209  Bug2222TestCase ();
1210  virtual ~Bug2222TestCase ();
1211 
1212  virtual void DoRun (void);
1213 
1214 
1215 private:
1217 
1219  void PopulateArpCache ();
1225  void TxDataFailedTrace (std::string context, Mac48Address adr);
1226 };
1227 
1229  : TestCase ("Test case for Bug 2222"),
1230  m_countInternalCollisions (0)
1231 {
1232 }
1233 
1235 {
1236 }
1237 
1238 void
1240 {
1241  //Indicate the long retry counter has been increased in the wifi remote station manager
1243 }
1244 
1245 void
1247 {
1249 
1250  //Generate same backoff for AC_VI and AC_VO
1251  //The below combination will work
1252  RngSeedManager::SetSeed (1);
1253  RngSeedManager::SetRun (16);
1254  int64_t streamNumber = 100;
1255 
1256  NodeContainer wifiNodes;
1257  wifiNodes.Create (2);
1258 
1259  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1260  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1261  phy.SetChannel (channel.Create ());
1262 
1263  WifiHelper wifi;
1264  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1265  "DataMode", StringValue ("OfdmRate54Mbps"),
1266  "ControlMode", StringValue ("OfdmRate24Mbps"));
1268  Ssid ssid = Ssid ("ns-3-ssid");
1269  mac.SetType ("ns3::AdhocWifiMac",
1270  "QosSupported", BooleanValue (true));
1271 
1272  NetDeviceContainer wifiDevices;
1273  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1274 
1275  // Assign fixed streams to random variables in use
1276  wifi.AssignStreams (wifiDevices, streamNumber);
1277 
1279  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1280 
1281  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1282  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1283  mobility.SetPositionAllocator (positionAlloc);
1284 
1285  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1286  mobility.Install (wifiNodes);
1287 
1288  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1289  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1290 
1291  PacketSocketAddress socket;
1292  socket.SetSingleDevice (device1->GetIfIndex ());
1293  socket.SetPhysicalAddress (device2->GetAddress ());
1294  socket.SetProtocol (1);
1295 
1296  PacketSocketHelper packetSocket;
1297  packetSocket.Install (wifiNodes);
1298 
1299  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1300  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1301  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1302  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1303  clientLowPriority->SetRemote (socket);
1304  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1305  clientLowPriority->SetStartTime (Seconds (0.0));
1306  clientLowPriority->SetStopTime (Seconds (1.0));
1307 
1308  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1309  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1310  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1311  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1312  clientHighPriority->SetRemote (socket);
1313  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1314  clientHighPriority->SetStartTime (Seconds (0.0));
1315  clientHighPriority->SetStopTime (Seconds (1.0));
1316 
1317  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1318  server->SetLocal (socket);
1319  wifiNodes.Get (1)->AddApplication (server);
1320  server->SetStartTime (Seconds (0.0));
1321  server->SetStopTime (Seconds (1.0));
1322 
1323  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1324 
1325  Simulator::Stop (Seconds (1.0));
1326  Simulator::Run ();
1327  Simulator::Destroy ();
1328 
1329  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1330 }
1331 
1332 //-----------------------------------------------------------------------------
1346 {
1347 public:
1348  Bug2843TestCase ();
1349  virtual ~Bug2843TestCase ();
1350  virtual void DoRun (void);
1351 
1352 private:
1356  typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1357  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1358 
1365  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1372  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1373 
1374  uint16_t m_channelWidth;
1375 };
1376 
1378  : TestCase ("Test case for Bug 2843"),
1379  m_channelWidth (20)
1380 {
1381 }
1382 
1384 {
1385 }
1386 
1387 void
1389 {
1390  // Extract starting frequency and number of subbands
1391  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1392  std::size_t numBands = c->GetNumBands ();
1393  double startingFreq = c->Begin ()->fl;
1394 
1395  // Get channel bandwidth and modulation class
1396  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1397 
1398  Ptr<WifiPpdu> ppdu = Copy (wifiTxParams->ppdu);
1399  WifiTxVector txVector = ppdu->GetTxVector ();
1400  m_channelWidth = txVector.GetChannelWidth ();
1401  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1402 
1403  // Build a tuple and check if seen before (if so store it)
1404  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, m_channelWidth, numBands, modulationClass);
1405  bool found = false;
1406  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1407  {
1408  if (*it == tupleForCurrentTx)
1409  {
1410  found = true;
1411  }
1412  }
1413  if (!found)
1414  {
1415  m_distinctTuples.push_back (tupleForCurrentTx);
1416  }
1417 }
1418 
1419 void
1420 Bug2843TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1421  Address& destination) const
1422 {
1423  for (uint8_t i = 0; i < numPackets; i++)
1424  {
1425  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1426  sourceDevice->Send (pkt, destination, 0);
1427  }
1428 }
1429 
1430 void
1432 {
1433  uint16_t channelWidth = 40; // at least 40 MHz expected here
1434 
1435  NodeContainer wifiStaNode;
1436  wifiStaNode.Create (1);
1437 
1439  wifiApNode.Create (1);
1440 
1441  SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default ();
1442  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1443  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1444  lossModel->SetFrequency (5.180e9);
1445  spectrumChannel->AddPropagationLossModel (lossModel);
1446 
1448  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1449  spectrumChannel->SetPropagationDelayModel (delayModel);
1450 
1451  spectrumPhy.SetChannel (spectrumChannel);
1452  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1453  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1454  spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
1455  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1456  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1457 
1458  WifiHelper wifi;
1459  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
1460  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1461  "DataMode", StringValue ("VhtMcs8"),
1462  "ControlMode", StringValue ("VhtMcs8"),
1463  "RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1464 
1466  mac.SetType ("ns3::StaWifiMac");
1467  NetDeviceContainer staDevice;
1468  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1469 
1470  mac.SetType ("ns3::ApWifiMac");
1471  NetDeviceContainer apDevice;
1472  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1473 
1475  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1476  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1477  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1478  mobility.SetPositionAllocator (positionAlloc);
1479 
1480  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1481  mobility.Install (wifiApNode);
1482  mobility.Install (wifiStaNode);
1483 
1484  // Send two 5 packet-bursts
1485  Simulator::Schedule (Seconds (0.5), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1486  Simulator::Schedule (Seconds (0.6), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1487 
1488  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2843TestCase::StoreDistinctTuple, this));
1489 
1490  Simulator::Stop (Seconds (0.8));
1491  Simulator::Run ();
1492 
1493  Simulator::Destroy ();
1494 
1495  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1496  std::size_t numberTuples = m_distinctTuples.size ();
1497  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1498  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");
1499  // Note that the first tuple should the one initiated by the beacon, i.e. non-HT OFDM (20 MHz)
1500  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1501  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)");
1502  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1503  // Second tuple
1504  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1505  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)");
1506  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1507 }
1508 
1509 //-----------------------------------------------------------------------------
1522 {
1523 public:
1524  Bug2831TestCase ();
1525  virtual ~Bug2831TestCase ();
1526  virtual void DoRun (void);
1527 
1528 private:
1532  void ChangeSupportedChannelWidth (void);
1538  void RxCallback (std::string context, Ptr<const Packet> p);
1539 
1542 
1547 };
1548 
1550  : TestCase ("Test case for Bug 2831"),
1551  m_reassocReqCount (0),
1552  m_reassocRespCount (0),
1553  m_countOperationalChannelWidth20 (0),
1554  m_countOperationalChannelWidth40 (0)
1555 {
1556 }
1557 
1559 {
1560 }
1561 
1562 void
1564 {
1565  m_apPhy->SetChannelNumber (38);
1566  m_apPhy->SetChannelWidth (40);
1567  m_staPhy->SetChannelNumber (38);
1568  m_staPhy->SetChannelWidth (40);
1569 }
1570 
1571 void
1573 {
1574  Ptr<Packet> packet = p->Copy ();
1575  WifiMacHeader hdr;
1576  packet->RemoveHeader (hdr);
1577  if (hdr.IsReassocReq ())
1578  {
1580  }
1581  else if (hdr.IsReassocResp ())
1582  {
1584  }
1585  else if (hdr.IsBeacon ())
1586  {
1587  MgtBeaconHeader beacon;
1588  packet->RemoveHeader (beacon);
1589  HtOperation htOperation = beacon.GetHtOperation ();
1590  if (htOperation.GetStaChannelWidth () > 0)
1591  {
1593  }
1594  else
1595  {
1597  }
1598  }
1599 }
1600 
1601 void
1603 {
1604  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1605  ObjectFactory propDelay;
1606  propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1607  Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1608  Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel> ();
1609  channel->SetPropagationDelayModel (propagationDelay);
1610  channel->SetPropagationLossModel (propagationLoss);
1611 
1612  Ptr<Node> apNode = CreateObject<Node> ();
1613  Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1614  Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration> ();
1615  apDev->SetHtConfiguration (apHtConfiguration);
1617  mac.SetTypeId ("ns3::ApWifiMac");
1618  mac.Set ("EnableBeaconJitter", BooleanValue (false));
1619  Ptr<WifiMac> apMac = mac.Create<WifiMac> ();
1620  apMac->SetDevice (apDev);
1622 
1623  Ptr<Node> staNode = CreateObject<Node> ();
1624  Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> ();
1625  Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration> ();
1626  staDev->SetHtConfiguration (staHtConfiguration);
1627  mac.SetTypeId ("ns3::StaWifiMac");
1628  Ptr<WifiMac> staMac = mac.Create<WifiMac> ();
1629  staMac->SetDevice (staDev);
1631 
1632  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
1633  apMobility->SetPosition (Vector (0.0, 0.0, 0.0));
1634  apNode->AggregateObject (apMobility);
1635 
1636  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
1637  m_apPhy = CreateObject<YansWifiPhy> ();
1638  m_apPhy->SetErrorRateModel (error);
1640  m_apPhy->SetMobility (apMobility);
1641  m_apPhy->SetDevice (apDev);
1643  m_apPhy->SetChannelNumber (36);
1644  m_apPhy->SetChannelWidth (20);
1645 
1646  Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel> ();
1647  staMobility->SetPosition (Vector (1.0, 0.0, 0.0));
1648  staNode->AggregateObject (staMobility);
1649 
1650  m_staPhy = CreateObject<YansWifiPhy> ();
1651  m_staPhy->SetErrorRateModel (error);
1653  m_staPhy->SetMobility (staMobility);
1654  m_staPhy->SetDevice (apDev);
1656  m_staPhy->SetChannelNumber (36);
1657  m_staPhy->SetChannelWidth (20);
1658 
1659  apMac->SetAddress (Mac48Address::Allocate ());
1660  apDev->SetMac (apMac);
1661  apDev->SetPhy (m_apPhy);
1662  ObjectFactory manager;
1663  manager.SetTypeId ("ns3::ConstantRateWifiManager");
1664  apDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1665  apNode->AddDevice (apDev);
1666 
1667  staMac->SetAddress (Mac48Address::Allocate ());
1668  staDev->SetMac (staMac);
1669  staDev->SetPhy (m_staPhy);
1670  staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1671  staNode->AddDevice (staDev);
1672 
1673  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this));
1674 
1675  Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1676 
1677  Simulator::Stop (Seconds (3.0));
1678  Simulator::Run ();
1679  Simulator::Destroy ();
1680 
1681  NS_TEST_ASSERT_MSG_EQ (m_reassocReqCount, 1, "Reassociation request not received");
1682  NS_TEST_ASSERT_MSG_EQ (m_reassocRespCount, 1, "Reassociation response not received");
1683  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operational channel width before channel change");
1684  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operational channel width after channel change");
1685 }
1686 
1687 //-----------------------------------------------------------------------------
1704 {
1705 public:
1707  virtual ~StaWifiMacScanningTestCase ();
1708  virtual void DoRun (void);
1709 
1710 private:
1716  void AssocCallback (std::string context, Mac48Address bssid);
1721  void TurnBeaconGenerationOn (Ptr<Node> apNode);
1726  void TurnApOff (Ptr<Node> apNode);
1733  NodeContainer Setup (bool nearestApBeaconGeneration, bool staActiveProbe);
1734 
1736 };
1737 
1739  : TestCase ("Test case for StaWifiMac scanning capability")
1740 {
1741 }
1742 
1744 {
1745 }
1746 
1747 void
1749 {
1750  m_associatedApBssid = bssid;
1751 }
1752 
1753 void
1755 {
1756  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1757  Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac> (netDevice->GetMac ());
1758  mac->SetAttribute ("BeaconGeneration", BooleanValue (true));
1759 }
1760 
1761 void
1763 {
1764  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1765  Ptr<WifiPhy> phy = netDevice->GetPhy ();
1766  phy->SetOffMode ();
1767 }
1768 
1770 StaWifiMacScanningTestCase::Setup (bool nearestApBeaconGeneration, bool staActiveProbe)
1771 {
1772  NodeContainer apNodes;
1773  apNodes.Create (2);
1774 
1775  Ptr<Node> apNodeNearest = CreateObject<Node> ();
1776  Ptr<Node> staNode = CreateObject<Node> ();
1777 
1778  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1779  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1780  phy.SetChannel (channel.Create ());
1781 
1782  WifiHelper wifi;
1783  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_2_4GHZ);
1784  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
1785 
1787  NetDeviceContainer apDevice, apDeviceNearest;
1788  mac.SetType ("ns3::ApWifiMac",
1789  "BeaconGeneration", BooleanValue (true));
1790  apDevice = wifi.Install (phy, mac, apNodes);
1791  mac.SetType ("ns3::ApWifiMac",
1792  "BeaconGeneration", BooleanValue (nearestApBeaconGeneration));
1793  apDeviceNearest = wifi.Install (phy, mac, apNodeNearest);
1794 
1795  NetDeviceContainer staDevice;
1796  mac.SetType ("ns3::StaWifiMac",
1797  "ActiveProbing", BooleanValue (staActiveProbe));
1798  staDevice = wifi.Install (phy, mac, staNode);
1799 
1801  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1802  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Furthest AP
1803  positionAlloc->Add (Vector (10.0, 0.0, 0.0)); // Second nearest AP
1804  positionAlloc->Add (Vector (5.0, 5.0, 0.0)); // Nearest AP
1805  positionAlloc->Add (Vector (6.0, 5.0, 0.0)); // STA
1806  mobility.SetPositionAllocator (positionAlloc);
1807 
1808  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1809  mobility.Install (apNodes);
1810  mobility.Install (apNodeNearest);
1811  mobility.Install (staNode);
1812 
1813  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc", MakeCallback (&StaWifiMacScanningTestCase::AssocCallback, this));
1814 
1815  NodeContainer allNodes = NodeContainer (apNodes, apNodeNearest, staNode);
1816  return allNodes;
1817 }
1818 
1819 void
1821 {
1822  {
1823  RngSeedManager::SetSeed (1);
1824  RngSeedManager::SetRun (1);
1825 
1826  NodeContainer nodes = Setup (false, false);
1827  Ptr<Node> nearestAp = nodes.Get (2);
1828  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1829 
1830  Simulator::Schedule (Seconds (0.05), &StaWifiMacScanningTestCase::TurnBeaconGenerationOn, this, nearestAp);
1831 
1832  Simulator::Stop (Seconds (0.2));
1833  Simulator::Run ();
1834  Simulator::Destroy ();
1835 
1836  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1837  }
1839  {
1840  RngSeedManager::SetSeed (1);
1841  RngSeedManager::SetRun (1);
1842 
1843  NodeContainer nodes = Setup (true, true);
1844  Ptr<Node> nearestAp = nodes.Get (2);
1845  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1846 
1847  Simulator::Stop (Seconds (0.2));
1848  Simulator::Run ();
1849  Simulator::Destroy ();
1850 
1851  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1852  }
1854  {
1855  RngSeedManager::SetSeed (1);
1856  RngSeedManager::SetRun (1);
1857 
1858  NodeContainer nodes = Setup (true, false);
1859  Ptr<Node> nearestAp = nodes.Get (2);
1860  Mac48Address secondNearestApAddr = DynamicCast<WifiNetDevice> (nodes.Get (1)->GetDevice (0))->GetMac ()->GetAddress ();
1861 
1862  Simulator::Schedule (Seconds (0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
1863 
1864  Simulator::Stop (Seconds (1.5));
1865  Simulator::Run ();
1866  Simulator::Destroy ();
1867 
1868  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, secondNearestApAddr, "STA is associated to the wrong AP");
1869  }
1870 }
1871 
1872 //-----------------------------------------------------------------------------
1896 {
1897 public:
1898  Bug2470TestCase ();
1899  virtual ~Bug2470TestCase ();
1900  virtual void DoRun (void);
1901 
1902 private:
1911  void AddbaStateChangedCallback (std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
1921  void RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise);
1928  void RxDropCallback (std::string context, Ptr<const Packet> p, WifiPhyRxfailureReason reason);
1935  void SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1941  void RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel);
1942 
1951 };
1952 
1954  : TestCase ("Test case for Bug 2470"),
1955  m_receivedNormalMpduCount (0),
1956  m_receivedAmpduCount (0),
1957  m_droppedActionCount (0),
1958  m_addbaEstablishedCount (0),
1959  m_addbaPendingCount (0),
1960  m_addbaRejectedCount (0),
1961  m_addbaNoReplyCount (0),
1962  m_addbaResetCount (0)
1963 {
1964 }
1965 
1967 {
1968 }
1969 
1970 void
1972 {
1973  switch (state)
1974  {
1975  case OriginatorBlockAckAgreement::ESTABLISHED:
1977  break;
1978  case OriginatorBlockAckAgreement::PENDING:
1980  break;
1981  case OriginatorBlockAckAgreement::REJECTED:
1983  break;
1984  case OriginatorBlockAckAgreement::NO_REPLY:
1986  break;
1987  case OriginatorBlockAckAgreement::RESET:
1989  break;
1990  }
1991 }
1992 
1993 void
1994 Bug2470TestCase::RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise)
1995 {
1996  Ptr<Packet> packet = p->Copy ();
1997  if (aMpdu.type != MpduType::NORMAL_MPDU)
1998  {
2000  }
2001  else
2002  {
2003  WifiMacHeader hdr;
2004  packet->RemoveHeader (hdr);
2005  if (hdr.IsData ())
2006  {
2008  }
2009  }
2010 }
2011 
2012 void
2014 {
2015  Ptr<Packet> packet = p->Copy ();
2016  WifiMacHeader hdr;
2017  packet->RemoveHeader (hdr);
2018  if (hdr.IsAction ())
2019  {
2021  }
2022 }
2023 
2024 void
2025 Bug2470TestCase::SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice,
2026  Address& destination) const
2027 {
2028  for (uint32_t i = 0; i < numPackets; i++)
2029  {
2030  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2031  sourceDevice->Send (pkt, destination, 0);
2032  }
2033 }
2034 
2035 void
2037 {
2038  RngSeedManager::SetSeed (1);
2039  RngSeedManager::SetRun (1);
2040  int64_t streamNumber = 200;
2041 
2042  NodeContainer wifiApNode, wifiStaNode;
2043  wifiApNode.Create (1);
2044  wifiStaNode.Create (1);
2045 
2046  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2047  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2048  phy.SetChannel (channel.Create ());
2049 
2050  WifiHelper wifi;
2051  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
2052  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2053  "DataMode", StringValue ("HtMcs7"),
2054  "ControlMode", StringValue ("HtMcs7"));
2055 
2057  NetDeviceContainer apDevice;
2058  phy.Set ("PostReceptionErrorModel", apErrorModel);
2059  mac.SetType ("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue (false));
2060  apDevice = wifi.Install (phy, mac, wifiApNode);
2061 
2062  NetDeviceContainer staDevice;
2063  phy.Set ("PostReceptionErrorModel", staErrorModel);
2064  mac.SetType ("ns3::StaWifiMac");
2065  staDevice = wifi.Install (phy, mac, wifiStaNode);
2066 
2067  // Assign fixed streams to random variables in use
2068  wifi.AssignStreams (apDevice, streamNumber);
2069  wifi.AssignStreams (staDevice, streamNumber);
2070 
2072  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2073  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2074  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2075  mobility.SetPositionAllocator (positionAlloc);
2076 
2077  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2078  mobility.Install (wifiApNode);
2079  mobility.Install (wifiStaNode);
2080 
2081  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this));
2082  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxDrop", MakeCallback (&Bug2470TestCase::RxDropCallback, this));
2083  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this));
2084 
2085  Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2086  Simulator::Schedule (Seconds (0.5) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2087  Simulator::Schedule (Seconds (0.8), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2088  Simulator::Schedule (Seconds (0.8) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2089 
2090  Simulator::Stop (Seconds (1.0));
2091  Simulator::Run ();
2092  Simulator::Destroy ();
2093 }
2094 
2095 void
2097 {
2098  // Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel
2099  // instead of ListErrorModel since packet UID is incremented between simulations. But
2100  // problem may occur because of random stream, therefore we suppress usage of RNG as
2101  // much as possible (i.e., removing beacon jitter).
2102  Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel> ();
2103  std::list<uint32_t> blackList;
2104  // Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2105  blackList.push_back (8);
2106  blackList.push_back (9);
2107  blackList.push_back (10);
2108  blackList.push_back (11);
2109  blackList.push_back (12);
2110  blackList.push_back (13);
2111  staPem->SetList (blackList);
2112 
2113  {
2114  RunSubtest (PointerValue (), PointerValue (staPem));
2115  NS_TEST_ASSERT_MSG_EQ (m_droppedActionCount, 6, "ADDBA request packet is not dropped correctly");
2116  // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by normal
2117  // MPDU because of failed ADDBA handshake.For the second set, the first packet should be sent by
2118  // normal MPDU, and the rest with A-MPDU. In total we expect to receive 2 normal MPDU packets and
2119  // 8 A-MPDU packets.
2120  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 2, "Receiving incorrect number of normal MPDU packet on subtest 1");
2121  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 8, "Receiving incorrect number of A-MPDU packet on subtest 1");
2122 
2123  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 1");
2124  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2125  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2126  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 0, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2127  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2128  }
2129 
2134  m_addbaPendingCount = 0;
2136  m_addbaNoReplyCount = 0;
2137  m_addbaResetCount = 0;
2138 
2139  Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel> ();
2140  blackList.clear ();
2141  // Block ADDBA request 3 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2142  blackList.push_back (4);
2143  blackList.push_back (5);
2144  blackList.push_back (8);
2145  apPem->SetList (blackList);
2146 
2147  {
2148  RunSubtest (PointerValue (apPem), PointerValue ());
2149  NS_TEST_ASSERT_MSG_EQ (m_droppedActionCount, 3, "ADDBA response packet is not dropped correctly");
2150  // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU packets.
2151  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 6, "Receiving incorrect number of normal MPDU packet on subtest 2");
2152  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 4, "Receiving incorrect number of A-MPDU packet on subtest 2");
2153 
2154  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 2");
2155  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2156  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2157  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 1, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2158  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2159  }
2160 
2161  // TODO: In the second test set, it does not go to reset state since ADDBA response is received after timeout (NO_REPLY)
2162  // but before it does not enter RESET state. More tests should be written to verify all possible scenarios.
2163 }
2164 
2171 class WifiTestSuite : public TestSuite
2172 {
2173 public:
2174  WifiTestSuite ();
2175 };
2176 
2178  : TestSuite ("wifi-devices", UNIT)
2179 {
2180  AddTestCase (new WifiTest, TestCase::QUICK);
2181  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
2182  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
2183  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
2184  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
2185  AddTestCase (new QosFragmentationTestCase, TestCase::QUICK);
2186  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
2187  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
2188  AddTestCase (new Bug2843TestCase, TestCase::QUICK); //Bug 2843
2189  AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
2190  AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399
2191  AddTestCase (new Bug2470TestCase, TestCase::QUICK); //Bug 2470
2192 }
2193 
ERP-OFDM PHY (Clause 19, Section 19.5)
MpduInfo structure.
Definition: wifi-phy.h:76
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:160
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:157
uint8_t m_countOperationalChannelWidth20
count number of beacon frames announcing a 20 MHz operating channel width
Definition: wifi-test.cc:1545
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void AddbaStateChangedCallback(std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
Callback when ADDBA state changed.
Definition: wifi-test.cc:1971
virtual ~Bug730TestCase()
Definition: wifi-test.cc:595
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
OFDM PHY for the 5 GHz band (Clause 17 with 5 MHz channel bandwidth)
void PopulateArpCache()
Populate ARP cache function.
virtual ~QosFragmentationTestCase()
Definition: wifi-test.cc:741
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint16_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1153
void Transmit(std::string context, Ptr< const Packet > p, double power)
Callback invoked when PHY transmits a packet.
Definition: wifi-test.cc:755
AttributeValue implementation for Boolean.
Definition: boolean.h:36
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
HT PHY for the 5 GHz band (clause 20)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:600
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
void StoreDistinctTuple(std::string context, Ptr< SpectrumSignalParameters > txParams)
Stores the distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples that have been used during the testcase run.
Definition: wifi-test.cc:1388
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:1895
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1602
Make it easy to create and manage PHY objects for the yans model.
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:805
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1820
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:142
A suite of tests to run.
Definition: test.h:1342
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
#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:1943
void RxCallback(std::string context, Ptr< const Packet > p)
Callback triggered when a packet is received by the PHYs.
Definition: wifi-test.cc:1572
uint16_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:1944
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:285
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
void ConfigureStandard(WifiPhyStandard standard)
Definition: wifi-mac.cc:270
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:748
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:52
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:1431
HT PHY for the 2.4 GHz band (clause 20)
void SendPacketBurst(uint8_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination) const
Triggers the arrival of a burst of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:1420
VHT PHY (Clause 22)
Definition: wifi-mode.h:60
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:216
encapsulates test code
Definition: test.h:1155
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
virtual ~StaWifiMacScanningTestCase()
Definition: wifi-test.cc:1743
uint8_t m_reassocReqCount
count number of reassociation requests
Definition: wifi-test.cc:1543
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:567
virtual ~Bug2843TestCase()
Definition: wifi-test.cc:1383
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1748
helps to create WifiNetDevice objects
Definition: wifi-helper.h:300
Mac48Address m_associatedApBssid
Associated AP&#39;s bssid.
Definition: wifi-test.cc:1735
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
uint32_t GetIfIndex(void) const
Address GetAddress(void) const
void RxCallback(std::string context, Ptr< const Packet > p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise)
Callback when packet is received.
Definition: wifi-test.cc:1994
a polymophic address class
Definition: address.h:90
unsigned int m_numSentPackets
number of sent packets
Definition: wifi-test.cc:443
channel
Definition: third.py:92
mobility
Definition: third.py:108
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:439
phy
Definition: third.py:93
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:724
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1388
uint16_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:1948
uint16_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:1946
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1754
Keep track of the current position and velocity of an object.
The MPDU is not part of an A-MPDU.
virtual ~Bug2470TestCase()
Definition: wifi-test.cc:1966
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:299
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1558
HE PHY for the 5 GHz band (clause 26)
nodes
Definition: first.py:32
Make sure that Wifi STA is correctly associating to the best AP (i.e., nearest from STA)...
Definition: wifi-test.cc:1703
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-mac.cc:221
Time m_firstTransmissionTime
first transmission time
Definition: wifi-test.cc:441
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:746
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: txop.cc:333
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:1216
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:480
#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:168
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2096
holds a vector of ns3::NetDevice pointers
mac
Definition: third.py:99
WifiMode GetMode(void) const
calculate a propagation delay.
Address GetBroadcast(void) const
Hold together all Wifi-related objects.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1246
wifiApNode
Definition: third.py:90
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:610
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1521
uint16_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:1950
virtual void SetAddress(Mac48Address address)=0
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:275
hold a list of per-remote-station state.
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:494
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:871
uint32_t m_fragments
transmitted fragments
Definition: wifi-test.cc:715
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:767
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:897
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
void SwitchCh(Ptr< WifiNetDevice > dev)
Switch channel function.
Definition: wifi-test.cc:292
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:1541
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:179
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
bool IsData(void) const
Return true if the Type is DATA.
void NotifyPhyTxBegin(Ptr< const Packet > p, double txPowerW)
Notify Phy transmit begin.
Definition: wifi-test.cc:459
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:2194
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1368
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:114
virtual void SetChannelWidth(uint16_t channelwidth)
Definition: wifi-phy.cc:1374
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:222
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
uint32_t m_received
received packets
Definition: wifi-test.cc:714
void SetList(const std::list< uint32_t > &packetlist)
Definition: error-model.cc:520
uint16_t m_addbaPendingCount
Count number of times ADDBA state machine is in pending state.
Definition: wifi-test.cc:1947
an EUI-48 address
Definition: mac48-address.h:43
ObjectFactory m_manager
manager
Definition: wifi-test.cc:437
NodeContainer Setup(bool nearestApBeaconGeneration, bool staActiveProbe)
Setup test.
Definition: wifi-test.cc:1770
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1234
Ptr< const SpectrumModel > GetSpectrumModel() const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1486
manage and create wifi channel objects for the yans model.
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:115
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:473
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1540
create MAC layers for a ns3::WifiNetDevice.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
State
Represents the state for this agreement.
uint8_t m_countOperationalChannelWidth40
count number of beacon frames announcing a 40 MHz operating channel width
Definition: wifi-test.cc:1546
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
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:1345
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:276
Wifi Test Suite.
Definition: wifi-test.cc:2171
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1206
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
std::tuple< double, uint16_t, uint32_t, WifiModulationClass > FreqWidthSubbandModulationTuple
A tuple of {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type}.
Definition: wifi-test.cc:1356
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:767
void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel)
Run subtest for this test suite.
Definition: wifi-test.cc:2036
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:113
Instantiate subclasses of ns3::Object.
Ptr< WifiMac > GetMac(void) const
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
Definition: wifi-mode.h:36
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:128
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
static void AssignWifiRandomStreams(Ptr< WifiMac > mac, int64_t stream)
Definition: wifi-test.cc:55
SignalNoiseDbm structure.
Definition: wifi-phy.h:69
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1540
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
AttributeValue implementation for Ssid.
Definition: ssid.h:110
WifiPhyRxfailureReason
Enumeration of the possible reeception failure reasons.
Definition: wifi-phy.h:53
ObjectFactory m_manager
manager
Definition: wifi-test.cc:274
OFDM PHY (Clause 17)
Definition: wifi-mode.h:56
void SendPacketBurst(uint32_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination) const
Triggers the arrival of a burst of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:2025
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
Ptr< T > Get(void) const
Definition: pointer.h:194
uint32_t m_received
received
Definition: wifi-test.cc:577
void Add(Vector v)
Add a position to the list of positions.
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:285
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint16_t m_droppedActionCount
Count dropped ADDBA request/response.
Definition: wifi-test.cc:1945
apDevices
Definition: third.py:106
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
void TurnApOff(Ptr< Node > apNode)
Turn the AP node off.
Definition: wifi-test.cc:1762
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:124
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
uint16_t m_addbaNoReplyCount
Count number of times ADDBA state machine is in no_reply state.
Definition: wifi-test.cc:1949
bool IsAction() const
Return true if the header is an Action header.
Wifi Test.
Definition: wifi-test.cc:90
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
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:1357
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1248
void RxDropCallback(std::string context, Ptr< const Packet > p, WifiPhyRxfailureReason reason)
Callback when packet is dropped.
Definition: wifi-test.cc:2013
void TxDataFailedTrace(std::string context, Mac48Address adr)
Transmit data failed function.
Definition: wifi-test.cc:1239
Time m_secondTransmissionTime
second transmission time
Definition: wifi-test.cc:442
void ChangeSupportedChannelWidth(void)
Function called to change the supported channel width at runtime.
Definition: wifi-test.cc:1563
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
MpduType type
type
Definition: wifi-phy.h:78
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:889
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
void 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:924
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition: ptr.h:688
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:847
uint8_t m_reassocRespCount
count number of reassociation responses
Definition: wifi-test.cc:1544
Implements the IEEE 802.11 MAC header.
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:131
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Make sure that fragmentation works with QoS stations.
Definition: wifi-test.cc:704
uint16_t m_channelWidth
channel width (in MHz)
Definition: wifi-test.cc:1374
Set Channel Frequency Test.
Definition: wifi-test.cc:865
Make sure that when multiple broadcast packets are queued on the same device in a short succession...
Definition: wifi-test.cc:422
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:65
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:329