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/wifi-phy-tag.h"
45 #include "ns3/yans-wifi-phy.h"
46 #include "ns3/mgt-headers.h"
47 #include "ns3/ht-configuration.h"
48 #include "ns3/wifi-phy-header.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  {
463  NS_ASSERT_MSG (Simulator::Now () == Time (Seconds (1)), "Packet 0 not transmitted at 1 second");
466  }
467  else if (m_numSentPackets == 1)
468  {
470  }
471 }
472 
473 void
475 {
476  Ptr<Packet> p = Create<Packet> (1000);
477  dev->Send (p, dev->GetBroadcast (), 1);
478 }
479 
480 void
482 {
483  m_mac.SetTypeId ("ns3::AdhocWifiMac");
484  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
485  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
486 
487  //Assign a seed and run number, and later fix the assignment of streams to
488  //WiFi random variables, so that the first backoff used is one slot
489  RngSeedManager::SetSeed (1);
490  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
491 
492  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
494  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
495  channel->SetPropagationDelayModel (propDelay);
496  channel->SetPropagationLossModel (propLoss);
497 
498  Ptr<Node> txNode = CreateObject<Node> ();
499  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
500  Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
501  txMac->SetDevice (txDev);
502  txMac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
503  //Fix the stream assignment to the Dcf Txop objects (backoffs)
504  //The below stream assignment will result in the Txop object
505  //using a backoff value of zero for this test when the
506  //Txop::EndTxNoAck() calls to StartBackoffNow()
507  AssignWifiRandomStreams (txMac, 23);
508 
509  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
510  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
511  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
512  txPhy->SetErrorRateModel (txError);
513  txPhy->SetChannel (channel);
514  txPhy->SetDevice (txDev);
515  txPhy->SetMobility (txMobility);
516  txPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
517 
518  txPhy->TraceConnectWithoutContext ("PhyTxBegin", MakeCallback (&DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin, this));
519 
520  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
521  txNode->AggregateObject (txMobility);
522  txMac->SetAddress (Mac48Address::Allocate ());
523  txDev->SetMac (txMac);
524  txDev->SetPhy (txPhy);
525  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
526  txNode->AddDevice (txDev);
527 
530  m_numSentPackets = 0;
531 
532  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
533  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
534 
535  Simulator::Stop (Seconds (2.0));
536  Simulator::Run ();
537  Simulator::Destroy ();
538 
539  //First packet has 1408 us of transmit time. Slot time is 9 us.
540  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
541  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
542  //1451 us after the first one.
543  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
544  Time expectedSecondTransmissionTime = MicroSeconds (expectedWait1) + MilliSeconds (1000);
545  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, MilliSeconds (1000), "The first transmission time not correct!");
546 
547  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
548 }
549 
550 
551 //-----------------------------------------------------------------------------
564 class Bug730TestCase : public TestCase
565 {
566 public:
567  Bug730TestCase ();
568  virtual ~Bug730TestCase ();
569 
570  virtual void DoRun (void);
571 
572 
573 private:
574  uint32_t m_received;
575 
582  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
583 
584 };
585 
587  : TestCase ("Test case for Bug 730"),
588  m_received (0)
589 {
590 }
591 
593 {
594 }
595 
596 void
597 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
598 {
599  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
600  {
601  m_received++;
602  }
603 }
604 
605 
606 void
608 {
609  m_received = 0;
610 
611  NodeContainer wifiStaNode;
612  wifiStaNode.Create (1);
613 
615  wifiApNode.Create (1);
616 
617  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
618  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
619  phy.SetChannel (channel.Create ());
620 
622  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
623  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
624  "DataMode", StringValue ("DsssRate1Mbps"),
625  "ControlMode", StringValue ("DsssRate1Mbps"));
626 
628  Ssid ssid = Ssid ("ns-3-ssid");
629  mac.SetType ("ns3::StaWifiMac",
630  "Ssid", SsidValue (ssid),
631  "ActiveProbing", BooleanValue (false));
632 
634  staDevices = wifi.Install (phy, mac, wifiStaNode);
635 
636  mac.SetType ("ns3::ApWifiMac",
637  "Ssid", SsidValue (ssid),
638  "BeaconGeneration", BooleanValue (true));
639 
641  apDevices = wifi.Install (phy, mac, wifiApNode);
642 
644  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
645 
646  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
647  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
648  mobility.SetPositionAllocator (positionAlloc);
649 
650  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
651  mobility.Install (wifiApNode);
652  mobility.Install (wifiStaNode);
653 
654  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
655  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
656 
657  PacketSocketAddress socket;
658  socket.SetSingleDevice (sta_device->GetIfIndex ());
659  socket.SetPhysicalAddress (ap_device->GetAddress ());
660  socket.SetProtocol (1);
661 
662  // give packet socket powers to nodes.
663  PacketSocketHelper packetSocket;
664  packetSocket.Install (wifiStaNode);
665  packetSocket.Install (wifiApNode);
666 
667  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
668  client->SetAttribute ("PacketSize", UintegerValue (1460));
669  client->SetRemote (socket);
670  wifiStaNode.Get (0)->AddApplication (client);
671  client->SetStartTime (Seconds (1));
672  client->SetStopTime (Seconds (51.0));
673 
674  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
675  server->SetLocal (socket);
676  wifiApNode.Get (0)->AddApplication (server);
677  server->SetStartTime (Seconds (0.0));
678  server->SetStopTime (Seconds (52.0));
679 
680  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
681 
682  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
683 
684  Simulator::Stop (Seconds (55));
685  Simulator::Run ();
686 
687  Simulator::Destroy ();
688 
689  bool result = (m_received > 0);
690  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
691 }
692 
693 //-----------------------------------------------------------------------------
702 {
703 public:
705  virtual ~QosFragmentationTestCase ();
706 
707  virtual void DoRun (void);
708 
709 
710 private:
711  uint32_t m_received;
712  uint32_t m_fragments;
713 
720  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
721 
728  void Transmit (std::string context, Ptr<const Packet> p, double power);
729 };
730 
732  : TestCase ("Test case for fragmentation with QoS stations"),
733  m_received (0),
734  m_fragments (0)
735 {
736 }
737 
739 {
740 }
741 
742 void
743 QosFragmentationTestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
744 {
745  if (p->GetSize () == 1400)
746  {
747  m_received++;
748  }
749 }
750 
751 void
752 QosFragmentationTestCase::Transmit (std::string context, Ptr<const Packet> p, double power)
753 {
754  WifiMacHeader hdr;
755  p->PeekHeader (hdr);
756  if (hdr.IsQosData ())
757  {
758  NS_TEST_EXPECT_MSG_LT_OR_EQ (p->GetSize (), 400, "Unexpected fragment size");
759  m_fragments++;
760  }
761 }
762 
763 void
765 {
766  NodeContainer wifiStaNode;
767  wifiStaNode.Create (1);
768 
770  wifiApNode.Create (1);
771 
772  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
773  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
774  phy.SetChannel (channel.Create ());
775 
777  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
778  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
779  "DataMode", StringValue ("HtMcs7"));
780 
782  Ssid ssid = Ssid ("ns-3-ssid");
783  mac.SetType ("ns3::StaWifiMac",
784  "Ssid", SsidValue (ssid),
785  "ActiveProbing", BooleanValue (false));
786 
788  staDevices = wifi.Install (phy, mac, wifiStaNode);
789 
790  mac.SetType ("ns3::ApWifiMac",
791  "Ssid", SsidValue (ssid),
792  "BeaconGeneration", BooleanValue (true));
793 
795  apDevices = wifi.Install (phy, mac, wifiApNode);
796 
798  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
799 
800  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
801  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
802  mobility.SetPositionAllocator (positionAlloc);
803 
804  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
805  mobility.Install (wifiApNode);
806  mobility.Install (wifiStaNode);
807 
808  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
809  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
810 
811  // set the TXOP limit on BE AC
812  Ptr<RegularWifiMac> sta_mac = DynamicCast<RegularWifiMac> (sta_device->GetMac ());
813  NS_ASSERT (sta_mac);
814  PointerValue ptr;
815  sta_mac->GetAttribute ("BE_Txop", ptr);
816  ptr.Get<QosTxop> ()->SetTxopLimit (MicroSeconds (3008));
817 
818  PacketSocketAddress socket;
819  socket.SetSingleDevice (sta_device->GetIfIndex ());
820  socket.SetPhysicalAddress (ap_device->GetAddress ());
821  socket.SetProtocol (1);
822 
823  // give packet socket powers to nodes.
824  PacketSocketHelper packetSocket;
825  packetSocket.Install (wifiStaNode);
826  packetSocket.Install (wifiApNode);
827 
828  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
829  client->SetAttribute ("PacketSize", UintegerValue (1400));
830  client->SetAttribute ("MaxPackets", UintegerValue (1));
831  client->SetRemote (socket);
832  wifiStaNode.Get (0)->AddApplication (client);
833  client->SetStartTime (Seconds (1));
834  client->SetStopTime (Seconds (3.0));
835 
836  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
837  server->SetLocal (socket);
838  wifiApNode.Get (0)->AddApplication (server);
839  server->SetStartTime (Seconds (0.0));
840  server->SetStopTime (Seconds (4.0));
841 
842  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&QosFragmentationTestCase::Receive, this));
843 
844  Config::Set ("/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("400"));
845  Config::Connect ("/NodeList/0/DeviceList/0/Phy/PhyTxBegin", MakeCallback (&QosFragmentationTestCase::Transmit, this));
846 
847  Simulator::Stop (Seconds (5));
848  Simulator::Run ();
849 
850  Simulator::Destroy ();
851 
852  NS_TEST_ASSERT_MSG_EQ (m_received, 1, "Unexpected number of received packets");
853  NS_TEST_ASSERT_MSG_EQ (m_fragments, 4, "Unexpected number of transmitted fragments");
854 }
855 
863 {
864 public:
866 
867  virtual void DoRun (void);
868 
869 
870 private:
877 
878 };
879 
881  : TestCase ("Test case for setting WifiPhy channel and frequency")
882 {
883 }
884 
887 {
888  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
889  Ptr<WifiPhy> wp = wnd->GetPhy ();
890  return wp->GetObject<YansWifiPhy> ();
891 }
892 
893 void
895 {
896  NodeContainer wifiStaNode;
897  wifiStaNode.Create (1);
899  wifiApNode.Create (1);
900 
901  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
902  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
903  phy.SetChannel (channel.Create ());
904 
905  // Configure and declare other generic components of this example
906  Ssid ssid;
907  ssid = Ssid ("wifi-phy-configuration");
908  WifiMacHelper macSta;
909  macSta.SetType ("ns3::StaWifiMac",
910  "Ssid", SsidValue (ssid),
911  "ActiveProbing", BooleanValue (false));
912  NetDeviceContainer staDevice;
913  Ptr<YansWifiPhy> phySta;
914 
915  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
916  {
917  // case 0
918  // Default configuration, without WifiHelper::SetStandard or WifiHelper
919  phySta = CreateObject<YansWifiPhy> ();
920  // The default results in an invalid configuration of channel 0,
921  // width 20, and frequency 0 MHz
922  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "default configuration");
923  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
924  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 0, "default configuration");
925  }
926  {
927  // case 1
929  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
930  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
931  phySta = GetYansWifiPhyPtr (staDevice);
932  // We expect channel 36, width 20, frequency 5180
933  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
934  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
935  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
936  }
937  {
938  // case 2
940  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
941  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
942  phySta = GetYansWifiPhyPtr (staDevice);
943  // We expect channel 1, width 22, frequency 2412
944  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
945  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
946  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
947  }
948  {
949  // case 3
951  wifi.SetStandard (WIFI_PHY_STANDARD_80211g);
952  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
953  phySta = GetYansWifiPhyPtr (staDevice);
954  // We expect channel 1, width 20, frequency 2412
955  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
956  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
957  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
958  }
959  {
960  // case 4
962  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
963  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
964  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
965  phySta = GetYansWifiPhyPtr (staDevice);
966  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
967  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
968  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
969  }
970  {
971  // case 5
973  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
975  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
976  phySta = GetYansWifiPhyPtr (staDevice);
977  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
978  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
979  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
980  }
981  {
982  // case 6
984  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
985  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
986  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
987  phySta = GetYansWifiPhyPtr (staDevice);
988  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
989  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
990  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
991  }
992  {
993  // case 7
995  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
996  wifi.SetStandard (WIFI_PHY_STANDARD_80211_10MHZ);
997  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
998  phySta = GetYansWifiPhyPtr (staDevice);
999  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11 10Mhz configuration");
1000  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11 10Mhz configuration");
1001  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 10Mhz configuration");
1002  }
1003  {
1004  // case 8
1005  WifiHelper wifi;
1006  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1007  wifi.SetStandard (WIFI_PHY_STANDARD_80211_5MHZ);
1008  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1009  phySta = GetYansWifiPhyPtr (staDevice);
1010  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5Mhz configuration");
1011  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11 5Mhz configuration");
1012  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 5Mhz configuration");
1013  }
1014  {
1015  // case 9
1016  WifiHelper wifi;
1017  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1018  wifi.SetStandard (WIFI_PHY_STANDARD_holland);
1019  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1020  phySta = GetYansWifiPhyPtr (staDevice);
1021  // We expect channel 36, width 20, frequency 5180
1022  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
1023  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
1024  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
1025  }
1026  {
1027  // case 10
1028  WifiHelper wifi;
1029  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1030  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1031  phy.Set ("ChannelNumber", UintegerValue (44));
1032  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1033  phySta = GetYansWifiPhyPtr (staDevice);
1034  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1035  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1036  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1037  }
1038  {
1039  // case 11
1040  WifiHelper wifi;
1041  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1042  phy.Set ("ChannelNumber", UintegerValue (44));
1043  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1044  phySta = GetYansWifiPhyPtr (staDevice);
1045  // Post-install reconfiguration to channel number 40
1046  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber", UintegerValue (40));
1047  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1048  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1049  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1050  }
1051  {
1052  // case 12
1053  WifiHelper wifi;
1054  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1055  phy.Set ("ChannelNumber", UintegerValue (44));
1056  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1057  phySta = GetYansWifiPhyPtr (staDevice);
1058  // Post-install reconfiguration to channel width 40 MHz
1059  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
1060  // Although channel 44 is configured originally for 20 MHz, we
1061  // allow it to be used for 40 MHz here
1062  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1063  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1064  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1065  }
1066  {
1067  // case 13
1068  WifiHelper wifi;
1069  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1070  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1071  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1072  phySta = GetYansWifiPhyPtr (staDevice);
1073  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
1074  // Post-install reconfiguration to channel width 40 MHz
1075  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
1076  // Although channel 44 is configured originally for 20 MHz, we
1077  // allow it to be used for 40 MHz here
1078  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1079  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1080  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1081  }
1082  {
1083  // case 14
1084  WifiHelper wifi;
1085  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1086  // Test that setting Frequency to a non-standard value will zero the
1087  // channel number
1088  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1089  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1090  phySta = GetYansWifiPhyPtr (staDevice);
1091  phySta->SetAttribute ("Frequency", UintegerValue (5281));
1092  // We expect channel number to be zero since frequency doesn't match
1093  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1094  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1095  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5281, "802.11 5GHz configuration");
1096  }
1097  {
1098  // case 15:
1099  WifiHelper wifi;
1100  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1101  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1102  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1103  phySta = GetYansWifiPhyPtr (staDevice);
1104  // Test that setting Frequency to a standard value will set the
1105  // channel number correctly
1106  phySta->SetAttribute ("Frequency", UintegerValue (5500));
1107  // We expect channel number to be 100 due to frequency 5500
1108  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
1109  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1110  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
1111  }
1112  {
1113  // case 16:
1114  WifiHelper wifi;
1115  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1116  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1117  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1118  phySta = GetYansWifiPhyPtr (staDevice);
1119  // This case will error exit due to invalid channel number unless
1120  // we provide the DefineChannelNumber() below
1121  phySta->DefineChannelNumber (99, WIFI_PHY_STANDARD_80211n_5GHZ, 5185, 40);
1122  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
1123  }
1124  {
1125  // case 17:
1126  WifiHelper wifi;
1127  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1128  // Test how channel number behaves when frequency is non-standard
1129  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1130  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1131  phySta = GetYansWifiPhyPtr (staDevice);
1132  phySta->SetAttribute ("Frequency", UintegerValue (5181));
1133  // We expect channel number to be 0 due to unknown center frequency 5181
1134  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1135  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1136  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5181, "802.11 5GHz configuration");
1137  phySta->SetAttribute ("Frequency", UintegerValue (5180));
1138  // We expect channel number to be 36 due to known center frequency 5180
1139  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1140  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1141  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1142  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1143  // We expect channel number to be 0 due to unknown center frequency 5179
1144  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1145  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1146  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1147  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1148  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1149  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1150  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1151  }
1152  {
1153  // case 18:
1154  WifiHelper wifi;
1155  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1156  // Set both channel and frequency to consistent values
1157  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
1158  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1159  phySta = GetYansWifiPhyPtr (staDevice);
1160  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1161  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
1162  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1163  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1164  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1165  // Set both channel and frequency to inconsistent values
1166  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1167  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1168  // We expect channel number to be 36
1169  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1170  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1171  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1172  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1173  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1174  // We expect channel number to be 40
1175  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1176  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1177  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1178  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1179  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1180  // We expect channel number to be 36
1181  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1182  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1183  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1184  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1185  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1186  // We expect channel number to be 0
1187  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1188  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1189  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1190  }
1191 
1192  Simulator::Destroy ();
1193 }
1194 
1195 //-----------------------------------------------------------------------------
1204 {
1205 public:
1206  Bug2222TestCase ();
1207  virtual ~Bug2222TestCase ();
1208 
1209  virtual void DoRun (void);
1210 
1211 
1212 private:
1214 
1216  void PopulateArpCache ();
1222  void TxDataFailedTrace (std::string context, Mac48Address adr);
1223 };
1224 
1226  : TestCase ("Test case for Bug 2222"),
1227  m_countInternalCollisions (0)
1228 {
1229 }
1230 
1232 {
1233 }
1234 
1235 void
1237 {
1238  //Indicate the long retry counter has been increased in the wifi remote station manager
1240 }
1241 
1242 void
1244 {
1246 
1247  //Generate same backoff for AC_VI and AC_VO
1248  //The below combination will work
1249  RngSeedManager::SetSeed (1);
1250  RngSeedManager::SetRun (2);
1251  int64_t streamNumber = 100;
1252 
1253  NodeContainer wifiNodes;
1254  wifiNodes.Create (2);
1255 
1256  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1257  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1258  phy.SetChannel (channel.Create ());
1259 
1260  WifiHelper wifi;
1261  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1262  "DataMode", StringValue ("OfdmRate54Mbps"),
1263  "ControlMode", StringValue ("OfdmRate24Mbps"));
1265  Ssid ssid = Ssid ("ns-3-ssid");
1266  mac.SetType ("ns3::AdhocWifiMac",
1267  "QosSupported", BooleanValue (true));
1268 
1269  NetDeviceContainer wifiDevices;
1270  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1271 
1272  // Assign fixed streams to random variables in use
1273  wifi.AssignStreams (wifiDevices, streamNumber);
1274 
1276  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1277 
1278  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1279  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1280  mobility.SetPositionAllocator (positionAlloc);
1281 
1282  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1283  mobility.Install (wifiNodes);
1284 
1285  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1286  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1287 
1288  PacketSocketAddress socket;
1289  socket.SetSingleDevice (device1->GetIfIndex ());
1290  socket.SetPhysicalAddress (device2->GetAddress ());
1291  socket.SetProtocol (1);
1292 
1293  PacketSocketHelper packetSocket;
1294  packetSocket.Install (wifiNodes);
1295 
1296  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1297  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1298  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1299  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1300  clientLowPriority->SetRemote (socket);
1301  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1302  clientLowPriority->SetStartTime (Seconds (1.0));
1303  clientLowPriority->SetStopTime (Seconds (2.0));
1304 
1305  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1306  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1307  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1308  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1309  clientHighPriority->SetRemote (socket);
1310  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1311  clientHighPriority->SetStartTime (Seconds (1.0));
1312  clientHighPriority->SetStopTime (Seconds (2.0));
1313 
1314  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1315  server->SetLocal (socket);
1316  wifiNodes.Get (1)->AddApplication (server);
1317  server->SetStartTime (Seconds (1.0));
1318  server->SetStopTime (Seconds (2.0));
1319 
1320  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1321 
1322  Simulator::Stop (Seconds (2.0));
1323  Simulator::Run ();
1324  Simulator::Destroy ();
1325 
1326  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1327 }
1328 
1329 //-----------------------------------------------------------------------------
1343 {
1344 public:
1345  Bug2843TestCase ();
1346  virtual ~Bug2843TestCase ();
1347  virtual void DoRun (void);
1348 
1349 private:
1353  typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1354  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1355 
1362  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1369  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1370 
1371  uint16_t m_channelWidth;
1372 };
1373 
1375  : TestCase ("Test case for Bug 2843"),
1376  m_channelWidth (20)
1377 {
1378 }
1379 
1381 {
1382 }
1383 
1384 void
1386 {
1387  // Extract starting frequency and number of subbands
1388  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1389  std::size_t numBands = c->GetNumBands ();
1390  double startingFreq = c->Begin ()->fl;
1391 
1392  // Get channel bandwidth and modulation class
1393  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1394  Ptr<Packet> packet = wifiTxParams->packet->Copy ();
1395  WifiPhyTag tag;
1396  if (!packet->RemovePacketTag (tag))
1397  {
1398  NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag");
1399  return;
1400  }
1401 
1402  WifiModulationClass modulationClass = tag.GetModulation ();
1403  WifiPreamble preamble = tag.GetPreambleType ();
1404  if ((modulationClass != WIFI_MOD_CLASS_HT) || (preamble != WIFI_PREAMBLE_HT_GF))
1405  {
1406  LSigHeader sig;
1407  packet->RemoveHeader (sig);
1408  m_channelWidth = 20;
1409  }
1410  if (modulationClass == WIFI_MOD_CLASS_VHT)
1411  {
1412  VhtSigHeader vhtSig;
1413  packet->RemoveHeader (vhtSig);
1414  m_channelWidth = vhtSig.GetChannelWidth ();
1415  }
1416 
1417  // Build a tuple and check if seen before (if so store it)
1418  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, m_channelWidth, numBands, modulationClass);
1419  bool found = false;
1420  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1421  {
1422  if (*it == tupleForCurrentTx)
1423  {
1424  found = true;
1425  }
1426  }
1427  if (!found)
1428  {
1429  m_distinctTuples.push_back (tupleForCurrentTx);
1430  }
1431 }
1432 
1433 void
1434 Bug2843TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1435  Address& destination) const
1436 {
1437  for (uint8_t i = 0; i < numPackets; i++)
1438  {
1439  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1440  sourceDevice->Send (pkt, destination, 0);
1441  }
1442 }
1443 
1444 void
1446 {
1447  uint16_t channelWidth = 40; // at least 40 MHz expected here
1448 
1449  NodeContainer wifiStaNode;
1450  wifiStaNode.Create (1);
1451 
1453  wifiApNode.Create (1);
1454 
1455  SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default ();
1456  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1457  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1458  lossModel->SetFrequency (5.180e9);
1459  spectrumChannel->AddPropagationLossModel (lossModel);
1460 
1462  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1463  spectrumChannel->SetPropagationDelayModel (delayModel);
1464 
1465  spectrumPhy.SetChannel (spectrumChannel);
1466  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1467  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1468  spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
1469  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1470  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1471 
1472  WifiHelper wifi;
1473  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
1474  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1475  "DataMode", StringValue ("VhtMcs8"),
1476  "ControlMode", StringValue ("VhtMcs8"),
1477  "RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1478 
1480  mac.SetType ("ns3::StaWifiMac");
1481  NetDeviceContainer staDevice;
1482  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1483 
1484  mac.SetType ("ns3::ApWifiMac");
1485  NetDeviceContainer apDevice;
1486  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1487 
1489  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1490  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1491  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1492  mobility.SetPositionAllocator (positionAlloc);
1493 
1494  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1495  mobility.Install (wifiApNode);
1496  mobility.Install (wifiStaNode);
1497 
1498  // Send two 5 packet-bursts
1499  Simulator::Schedule (Seconds (0.5), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1500  Simulator::Schedule (Seconds (0.6), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1501 
1502  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2843TestCase::StoreDistinctTuple, this));
1503 
1504  Simulator::Stop (Seconds (0.8));
1505  Simulator::Run ();
1506 
1507  Simulator::Destroy ();
1508 
1509  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1510  std::size_t numberTuples = m_distinctTuples.size ();
1511  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1512  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");
1513  // Note that the first tuple should the one initiated by the beacon, i.e. legacy OFDM (20 MHz)
1514  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1515  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)");
1516  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1517  // Second tuple
1518  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1519  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)");
1520  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1521 }
1522 
1523 //-----------------------------------------------------------------------------
1536 {
1537 public:
1538  Bug2831TestCase ();
1539  virtual ~Bug2831TestCase ();
1540  virtual void DoRun (void);
1541 
1542 private:
1546  void ChangeSupportedChannelWidth (void);
1552  void RxCallback (std::string context, Ptr<const Packet> p);
1553 
1556 
1561 };
1562 
1564  : TestCase ("Test case for Bug 2831"),
1565  m_reassocReqCount (0),
1566  m_reassocRespCount (0),
1567  m_countOperationalChannelWidth20 (0),
1568  m_countOperationalChannelWidth40 (0)
1569 {
1570 }
1571 
1573 {
1574 }
1575 
1576 void
1578 {
1579  m_apPhy->SetChannelNumber (38);
1580  m_apPhy->SetChannelWidth (40);
1581  m_staPhy->SetChannelNumber (38);
1582  m_staPhy->SetChannelWidth (40);
1583 }
1584 
1585 void
1587 {
1588  Ptr<Packet> packet = p->Copy ();
1589  WifiMacHeader hdr;
1590  packet->RemoveHeader (hdr);
1591  if (hdr.IsReassocReq ())
1592  {
1594  }
1595  else if (hdr.IsReassocResp ())
1596  {
1598  }
1599  else if (hdr.IsBeacon ())
1600  {
1601  MgtBeaconHeader beacon;
1602  packet->RemoveHeader (beacon);
1603  HtOperation htOperation = beacon.GetHtOperation ();
1604  if (htOperation.GetStaChannelWidth () > 0)
1605  {
1607  }
1608  else
1609  {
1611  }
1612  }
1613 }
1614 
1615 void
1617 {
1618  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1619  ObjectFactory propDelay;
1620  propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1621  Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1622  Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel> ();
1623  channel->SetPropagationDelayModel (propagationDelay);
1624  channel->SetPropagationLossModel (propagationLoss);
1625 
1626  Ptr<Node> apNode = CreateObject<Node> ();
1627  Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1628  Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration> ();
1629  apDev->SetHtConfiguration (apHtConfiguration);
1631  mac.SetTypeId ("ns3::ApWifiMac");
1632  mac.Set ("EnableBeaconJitter", BooleanValue (false));
1633  Ptr<WifiMac> apMac = mac.Create<WifiMac> ();
1634  apMac->SetDevice (apDev);
1636 
1637  Ptr<Node> staNode = CreateObject<Node> ();
1638  Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> ();
1639  Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration> ();
1640  staDev->SetHtConfiguration (staHtConfiguration);
1641  mac.SetTypeId ("ns3::StaWifiMac");
1642  Ptr<WifiMac> staMac = mac.Create<WifiMac> ();
1643  staMac->SetDevice (staDev);
1645 
1646  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
1647  apMobility->SetPosition (Vector (0.0, 0.0, 0.0));
1648  apNode->AggregateObject (apMobility);
1649 
1650  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
1651  m_apPhy = CreateObject<YansWifiPhy> ();
1652  m_apPhy->SetErrorRateModel (error);
1654  m_apPhy->SetMobility (apMobility);
1655  m_apPhy->SetDevice (apDev);
1657  m_apPhy->SetChannelNumber (36);
1658  m_apPhy->SetChannelWidth (20);
1659 
1660  Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel> ();
1661  staMobility->SetPosition (Vector (1.0, 0.0, 0.0));
1662  staNode->AggregateObject (staMobility);
1663 
1664  m_staPhy = CreateObject<YansWifiPhy> ();
1665  m_staPhy->SetErrorRateModel (error);
1667  m_staPhy->SetMobility (staMobility);
1668  m_staPhy->SetDevice (apDev);
1670  m_staPhy->SetChannelNumber (36);
1671  m_staPhy->SetChannelWidth (20);
1672 
1673  apMac->SetAddress (Mac48Address::Allocate ());
1674  apDev->SetMac (apMac);
1675  apDev->SetPhy (m_apPhy);
1676  ObjectFactory manager;
1677  manager.SetTypeId ("ns3::ConstantRateWifiManager");
1678  apDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1679  apNode->AddDevice (apDev);
1680 
1681  staMac->SetAddress (Mac48Address::Allocate ());
1682  staDev->SetMac (staMac);
1683  staDev->SetPhy (m_staPhy);
1684  staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1685  staNode->AddDevice (staDev);
1686 
1687  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this));
1688 
1689  Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1690 
1691  Simulator::Stop (Seconds (3.0));
1692  Simulator::Run ();
1693  Simulator::Destroy ();
1694 
1695  NS_TEST_ASSERT_MSG_EQ (m_reassocReqCount, 1, "Reassociation request not received");
1696  NS_TEST_ASSERT_MSG_EQ (m_reassocRespCount, 1, "Reassociation response not received");
1697  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operational channel width before channel change");
1698  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operational channel width after channel change");
1699 }
1700 
1701 //-----------------------------------------------------------------------------
1718 {
1719 public:
1721  virtual ~StaWifiMacScanningTestCase ();
1722  virtual void DoRun (void);
1723 
1724 private:
1730  void AssocCallback (std::string context, Mac48Address bssid);
1735  void TurnBeaconGenerationOn (Ptr<Node> apNode);
1740  void TurnApOff (Ptr<Node> apNode);
1747  NodeContainer Setup (bool nearestApBeaconGeneration, bool staActiveProbe);
1748 
1750 };
1751 
1753  : TestCase ("Test case for StaWifiMac scanning capability")
1754 {
1755 }
1756 
1758 {
1759 }
1760 
1761 void
1763 {
1764  m_associatedApBssid = bssid;
1765 }
1766 
1767 void
1769 {
1770  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1771  Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac> (netDevice->GetMac ());
1772  mac->SetAttribute ("BeaconGeneration", BooleanValue (true));
1773 }
1774 
1775 void
1777 {
1778  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1779  Ptr<WifiPhy> phy = netDevice->GetPhy ();
1780  phy->SetOffMode ();
1781 }
1782 
1784 StaWifiMacScanningTestCase::Setup (bool nearestApBeaconGeneration, bool staActiveProbe)
1785 {
1786  NodeContainer apNodes;
1787  apNodes.Create (2);
1788 
1789  Ptr<Node> apNodeNearest = CreateObject<Node> ();
1790  Ptr<Node> staNode = CreateObject<Node> ();
1791 
1792  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1793  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1794  phy.SetChannel (channel.Create ());
1795 
1796  WifiHelper wifi;
1797  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_2_4GHZ);
1798  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
1799 
1801  NetDeviceContainer apDevice, apDeviceNearest;
1802  mac.SetType ("ns3::ApWifiMac",
1803  "BeaconGeneration", BooleanValue (true));
1804  apDevice = wifi.Install (phy, mac, apNodes);
1805  mac.SetType ("ns3::ApWifiMac",
1806  "BeaconGeneration", BooleanValue (nearestApBeaconGeneration));
1807  apDeviceNearest = wifi.Install (phy, mac, apNodeNearest);
1808 
1809  NetDeviceContainer staDevice;
1810  mac.SetType ("ns3::StaWifiMac",
1811  "ActiveProbing", BooleanValue (staActiveProbe));
1812  staDevice = wifi.Install (phy, mac, staNode);
1813 
1815  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1816  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Furthest AP
1817  positionAlloc->Add (Vector (10.0, 0.0, 0.0)); // Second nearest AP
1818  positionAlloc->Add (Vector (5.0, 5.0, 0.0)); // Nearest AP
1819  positionAlloc->Add (Vector (6.0, 5.0, 0.0)); // STA
1820  mobility.SetPositionAllocator (positionAlloc);
1821 
1822  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1823  mobility.Install (apNodes);
1824  mobility.Install (apNodeNearest);
1825  mobility.Install (staNode);
1826 
1827  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc", MakeCallback (&StaWifiMacScanningTestCase::AssocCallback, this));
1828 
1829  NodeContainer allNodes = NodeContainer (apNodes, apNodeNearest, staNode);
1830  return allNodes;
1831 }
1832 
1833 void
1835 {
1836  {
1837  RngSeedManager::SetSeed (1);
1838  RngSeedManager::SetRun (1);
1839 
1840  NodeContainer nodes = Setup (false, false);
1841  Ptr<Node> nearestAp = nodes.Get (2);
1842  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1843 
1844  Simulator::Schedule (Seconds (0.05), &StaWifiMacScanningTestCase::TurnBeaconGenerationOn, this, nearestAp);
1845 
1846  Simulator::Stop (Seconds (0.2));
1847  Simulator::Run ();
1848  Simulator::Destroy ();
1849 
1850  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1851  }
1853  {
1854  RngSeedManager::SetSeed (1);
1855  RngSeedManager::SetRun (1);
1856 
1857  NodeContainer nodes = Setup (true, true);
1858  Ptr<Node> nearestAp = nodes.Get (2);
1859  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1860 
1861  Simulator::Stop (Seconds (0.2));
1862  Simulator::Run ();
1863  Simulator::Destroy ();
1864 
1865  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1866  }
1868  {
1869  RngSeedManager::SetSeed (1);
1870  RngSeedManager::SetRun (1);
1871 
1872  NodeContainer nodes = Setup (true, false);
1873  Ptr<Node> nearestAp = nodes.Get (2);
1874  Mac48Address secondNearestApAddr = DynamicCast<WifiNetDevice> (nodes.Get (1)->GetDevice (0))->GetMac ()->GetAddress ();
1875 
1876  Simulator::Schedule (Seconds (0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
1877 
1878  Simulator::Stop (Seconds (1.5));
1879  Simulator::Run ();
1880  Simulator::Destroy ();
1881 
1882  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, secondNearestApAddr, "STA is associated to the wrong AP");
1883  }
1884 }
1885 
1886 //-----------------------------------------------------------------------------
1910 {
1911 public:
1912  Bug2470TestCase ();
1913  virtual ~Bug2470TestCase ();
1914  virtual void DoRun (void);
1915 
1916 private:
1925  void AddbaStateChangedCallback (std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
1935  void RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise);
1942  void RxDropCallback (std::string context, Ptr<const Packet> p, WifiPhyRxfailureReason reason);
1949  void SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1955  void RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel);
1956 
1965 };
1966 
1968  : TestCase ("Test case for Bug 2470"),
1969  m_receivedNormalMpduCount (0),
1970  m_receivedAmpduCount (0),
1971  m_droppedActionCount (0),
1972  m_addbaEstablishedCount (0),
1973  m_addbaPendingCount (0),
1974  m_addbaRejectedCount (0),
1975  m_addbaNoReplyCount (0),
1976  m_addbaResetCount (0)
1977 {
1978 }
1979 
1981 {
1982 }
1983 
1984 void
1986 {
1987  switch (state)
1988  {
1989  case OriginatorBlockAckAgreement::ESTABLISHED:
1991  break;
1992  case OriginatorBlockAckAgreement::PENDING:
1994  break;
1995  case OriginatorBlockAckAgreement::REJECTED:
1997  break;
1998  case OriginatorBlockAckAgreement::NO_REPLY:
2000  break;
2001  case OriginatorBlockAckAgreement::RESET:
2003  break;
2004  }
2005 }
2006 
2007 void
2008 Bug2470TestCase::RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise)
2009 {
2010  Ptr<Packet> packet = p->Copy ();
2011  if (aMpdu.type != MpduType::NORMAL_MPDU)
2012  {
2014  }
2015  else
2016  {
2017  WifiMacHeader hdr;
2018  packet->RemoveHeader (hdr);
2019  if (hdr.IsData ())
2020  {
2022  }
2023  }
2024 }
2025 
2026 void
2028 {
2029  Ptr<Packet> packet = p->Copy ();
2030  WifiMacHeader hdr;
2031  packet->RemoveHeader (hdr);
2032  if (hdr.IsAction ())
2033  {
2035  }
2036 }
2037 
2038 void
2039 Bug2470TestCase::SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice,
2040  Address& destination) const
2041 {
2042  for (uint32_t i = 0; i < numPackets; i++)
2043  {
2044  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2045  sourceDevice->Send (pkt, destination, 0);
2046  }
2047 }
2048 
2049 void
2051 {
2052  RngSeedManager::SetSeed (1);
2053  RngSeedManager::SetRun (1);
2054  int64_t streamNumber = 200;
2055 
2056  NodeContainer wifiApNode, wifiStaNode;
2057  wifiApNode.Create (1);
2058  wifiStaNode.Create (1);
2059 
2060  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
2061  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2062  phy.SetChannel (channel.Create ());
2063 
2064  WifiHelper wifi;
2065  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
2066  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2067  "DataMode", StringValue ("HtMcs7"),
2068  "ControlMode", StringValue ("HtMcs7"));
2069 
2071  NetDeviceContainer apDevice;
2072  phy.Set ("PostReceptionErrorModel", apErrorModel);
2073  mac.SetType ("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue (false));
2074  apDevice = wifi.Install (phy, mac, wifiApNode);
2075 
2076  NetDeviceContainer staDevice;
2077  phy.Set ("PostReceptionErrorModel", staErrorModel);
2078  mac.SetType ("ns3::StaWifiMac");
2079  staDevice = wifi.Install (phy, mac, wifiStaNode);
2080 
2081  // Assign fixed streams to random variables in use
2082  wifi.AssignStreams (apDevice, streamNumber);
2083  wifi.AssignStreams (staDevice, streamNumber);
2084 
2086  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2087  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2088  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2089  mobility.SetPositionAllocator (positionAlloc);
2090 
2091  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2092  mobility.Install (wifiApNode);
2093  mobility.Install (wifiStaNode);
2094 
2095  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this));
2096  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxDrop", MakeCallback (&Bug2470TestCase::RxDropCallback, this));
2097  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this));
2098 
2099  Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2100  Simulator::Schedule (Seconds (0.8), &Bug2470TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2101 
2102  Simulator::Stop (Seconds (1.0));
2103  Simulator::Run ();
2104  Simulator::Destroy ();
2105 }
2106 
2107 void
2109 {
2110  // Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel
2111  // instead of ListErrorModel since packet UID is incremented between simulations. But
2112  // problem may occur because of random stream, therefore we suppress usage of RNG as
2113  // much as possible (i.e., removing beacon jitter).
2114  Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel> ();
2115  std::list<uint32_t> blackList;
2116  // Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2117  blackList.push_back (8);
2118  blackList.push_back (9);
2119  blackList.push_back (10);
2120  blackList.push_back (11);
2121  blackList.push_back (12);
2122  blackList.push_back (13);
2123  staPem->SetList (blackList);
2124 
2125  {
2126  RunSubtest (PointerValue (), PointerValue (staPem));
2127  NS_TEST_ASSERT_MSG_EQ (m_droppedActionCount, 6, "ADDBA request packet is not dropped correctly");
2128  // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by normal
2129  // MPDU because of failed ADDBA handshake.For the second set, the first packet should be sent by
2130  // normal MPDU, and the rest with A-MPDU. In total we expect to receive 2 normal MPDU packets and
2131  // 8 A-MPDU packets.
2132  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 2, "Receiving incorrect number of normal MPDU packet on subtest 1");
2133  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 8, "Receiving incorrect number of A-MPDU packet on subtest 1");
2134 
2135  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 1");
2136  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2137  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2138  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 0, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2139  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2140  }
2141 
2146  m_addbaPendingCount = 0;
2148  m_addbaNoReplyCount = 0;
2149  m_addbaResetCount = 0;
2150 
2151  Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel> ();
2152  blackList.clear ();
2153  // Block ADDBA request 3 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2154  blackList.push_back (4);
2155  blackList.push_back (5);
2156  blackList.push_back (6);
2157  apPem->SetList (blackList);
2158 
2159  {
2160  RunSubtest (PointerValue (apPem), PointerValue ());
2161  NS_TEST_ASSERT_MSG_EQ (m_droppedActionCount, 3, "ADDBA response packet is not dropped correctly");
2162  // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU packets.
2163  NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 6, "Receiving incorrect number of normal MPDU packet on subtest 2");
2164  NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 4, "Receiving incorrect number of A-MPDU packet on subtest 2");
2165 
2166  NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 2");
2167  NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2168  NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2169  NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 1, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2170  NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2171  }
2172 
2173  // TODO: In the second test set, it does not go to reset state since ADDBA response is received after timeout (NO_REPLY)
2174  // but before it does not enter RESET state. More tests should be written to verify all possible scenarios.
2175 }
2176 
2183 class WifiTestSuite : public TestSuite
2184 {
2185 public:
2186  WifiTestSuite ();
2187 };
2188 
2190  : TestSuite ("devices-wifi", UNIT)
2191 {
2192  AddTestCase (new WifiTest, TestCase::QUICK);
2193  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
2194  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
2195  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
2196  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
2197  AddTestCase (new QosFragmentationTestCase, TestCase::QUICK);
2198  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
2199  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
2200  AddTestCase (new Bug2843TestCase, TestCase::QUICK); //Bug 2843
2201  AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
2202  AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399
2203  AddTestCase (new Bug2470TestCase, TestCase::QUICK); //Bug 2470
2204 }
2205 
ERP-OFDM PHY (Clause 19, Section 19.5)
MpduInfo structure.
Definition: wifi-phy.h:71
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:142
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:1559
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:1985
virtual ~Bug730TestCase()
Definition: wifi-test.cc:592
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:738
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint16_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1122
void Transmit(std::string context, Ptr< const Packet > p, double power)
Callback invoked when PHY transmits a packet.
Definition: wifi-test.cc:752
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:597
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:1385
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Hold variables of type string.
Definition: string.h:41
Make sure that the ADDBA handshake process is protected.
Definition: wifi-test.cc:1909
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1616
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:1834
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:91
Implements the IEEE 802.11ac PHY header (VHT-SIG-A1/A2/B).
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
void RxCallback(std::string context, Ptr< const Packet > p)
Callback triggered when a packet is received by the PHYs.
Definition: wifi-test.cc:1586
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
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:743
uint16_t GetChannelWidth(void) const
Return the channel width (in MHz).
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
Definition: ht-operation.h:52
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
staDevices
Definition: third.py:96
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:268
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1445
uint8_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:1962
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:1434
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:1757
uint8_t m_reassocReqCount
count number of reassociation requests
Definition: wifi-test.cc:1557
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:564
virtual ~Bug2843TestCase()
Definition: wifi-test.cc:1380
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1762
helps to create WifiNetDevice objects
Definition: wifi-helper.h:299
Mac48Address m_associatedApBssid
Associated AP&#39;s bssid.
Definition: wifi-test.cc:1749
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
uint8_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:1960
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:2008
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:85
mobility
Definition: third.py:101
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:439
phy
Definition: third.py:86
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:719
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1357
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1768
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
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:1980
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:299
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1572
HE PHY for the 5 GHz band (clause 26)
nodes
Definition: first.py:25
Make sure that Wifi STA is correctly associating to the best AP (i.e., nearest from STA)...
Definition: wifi-test.cc:1717
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:743
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:321
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:1213
void SetChannel(Ptr< SpectrumChannel > channel)
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Definition: vector.h:217
ssid
Definition: third.py:93
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:481
#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:2108
uint8_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:1964
holds a vector of ns3::NetDevice pointers
mac
Definition: third.py:92
Implements the IEEE 802.11 OFDM and ERP OFDM L-SIG PHY header.
calculate a propagation delay.
Address GetBroadcast(void) const
HT PHY (Clause 20)
Definition: wifi-mode.h:58
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
WifiPreamble GetPreambleType(void) const
Getter for preamble parameter.
Definition: wifi-phy-tag.cc:80
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:1243
wifiApNode
Definition: third.py:83
uint8_t m_addbaNoReplyCount
Count number of times ADDBA state machine is in no_reply state.
Definition: wifi-test.cc:1963
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:607
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1535
virtual void SetAddress(Mac48Address address)=0
uint8_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:1958
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:275
hold a list of per-remote-station state.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:871
uint32_t m_fragments
transmitted fragments
Definition: wifi-test.cc:712
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:762
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:894
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:1555
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:2206
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1337
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:47
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:1343
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:711
void SetList(const std::list< uint32_t > &packetlist)
Definition: error-model.cc:520
uint8_t m_droppedActionCount
Count dropped ADDBA request/response.
Definition: wifi-test.cc:1959
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:1784
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1231
Ptr< const SpectrumModel > GetSpectrumModel() const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1455
Ptr< Packet > packet
The packet being transmitted with this signal.
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:474
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1509
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:1560
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:148
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:1342
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:276
Wifi Test Suite.
Definition: wifi-test.cc:2183
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1203
WifiModulationClass GetModulation(void) const
Getter for modulation parameter.
Definition: wifi-phy-tag.cc:86
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:1353
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:764
void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel)
Run subtest for this test suite.
Definition: wifi-test.cc:2050
wifi
Definition: third.py:89
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:64
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1554
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
Definition: wifi-phy.h:48
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:2039
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:574
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.
Tag for WifiTxVector and WifiPreamble information to be embedded in outgoing transmissions as a Packe...
Definition: wifi-phy-tag.h:36
apDevices
Definition: third.py:99
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:1776
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
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.
std::vector< FreqWidthSubbandModulationTuple > m_distinctTuples
vector of distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
Definition: wifi-test.cc:1354
uint8_t m_addbaPendingCount
Count number of times ADDBA state machine is in pending state.
Definition: wifi-test.cc:1961
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1217
void RxDropCallback(std::string context, Ptr< const Packet > p, WifiPhyRxfailureReason reason)
Callback when packet is dropped.
Definition: wifi-test.cc:2027
void TxDataFailedTrace(std::string context, Mac48Address adr)
Transmit data failed function.
Definition: wifi-test.cc:1236
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:1577
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:73
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:886
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
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:841
uint8_t m_reassocRespCount
count number of reassociation responses
Definition: wifi-test.cc:1558
uint8_t m_receivedNormalMpduCount
Count received normal MPDU packets on STA.
Definition: wifi-test.cc:1957
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:701
uint16_t m_channelWidth
Definition: wifi-test.cc:1371
Set Channel Frequency Test.
Definition: wifi-test.cc:862
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