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/packet-socket-server.h"
38 #include "ns3/packet-socket-client.h"
39 #include "ns3/packet-socket-helper.h"
40 #include "ns3/spectrum-wifi-helper.h"
41 #include "ns3/multi-model-spectrum-channel.h"
42 #include "ns3/wifi-spectrum-signal-parameters.h"
43 #include "ns3/wifi-phy-tag.h"
44 #include "ns3/yans-wifi-phy.h"
45 #include "ns3/mgt-headers.h"
46 
47 using namespace ns3;
48 
49 //Helper function to assign streams to random variables, to control
50 //randomness in the tests
51 static void
53 {
54  int64_t currentStream = stream;
55  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
56  if (rmac)
57  {
58  PointerValue ptr;
59  rmac->GetAttribute ("Txop", ptr);
60  Ptr<Txop> txop = ptr.Get<Txop> ();
61  currentStream += txop->AssignStreams (currentStream);
62 
63  rmac->GetAttribute ("VO_Txop", ptr);
64  Ptr<QosTxop> vo_txop = ptr.Get<QosTxop> ();
65  currentStream += vo_txop->AssignStreams (currentStream);
66 
67  rmac->GetAttribute ("VI_Txop", ptr);
68  Ptr<QosTxop> vi_txop = ptr.Get<QosTxop> ();
69  currentStream += vi_txop->AssignStreams (currentStream);
70 
71  rmac->GetAttribute ("BE_Txop", ptr);
72  Ptr<QosTxop> be_txop = ptr.Get<QosTxop> ();
73  currentStream += be_txop->AssignStreams (currentStream);
74 
75  rmac->GetAttribute ("BK_Txop", ptr);
76  Ptr<QosTxop> bk_txop = ptr.Get<QosTxop> ();
77  bk_txop->AssignStreams (currentStream);
78  }
79 }
80 
87 class WifiTest : public TestCase
88 {
89 public:
90  WifiTest ();
91 
92  virtual void DoRun (void);
93 
94 
95 private:
97  void RunOne (void);
103  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
109 
113 };
114 
116  : TestCase ("Wifi")
117 {
118 }
119 
120 void
122 {
123  Ptr<Packet> p = Create<Packet> ();
124  dev->Send (p, dev->GetBroadcast (), 1);
125 }
126 
127 void
129 {
130  Ptr<Node> node = CreateObject<Node> ();
131  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
132 
135  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
136  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
137  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
138  phy->SetErrorRateModel (error);
139  phy->SetChannel (channel);
140  phy->SetDevice (dev);
141  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
143 
144  mobility->SetPosition (pos);
145  node->AggregateObject (mobility);
146  mac->SetAddress (Mac48Address::Allocate ());
147  dev->SetMac (mac);
148  dev->SetPhy (phy);
149  dev->SetRemoteStationManager (manager);
150  node->AddDevice (dev);
151 
152  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
153 }
154 
155 void
157 {
158  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
160  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
161  channel->SetPropagationDelayModel (propDelay);
162  channel->SetPropagationLossModel (propLoss);
163 
164  CreateOne (Vector (0.0, 0.0, 0.0), channel);
165  CreateOne (Vector (5.0, 0.0, 0.0), channel);
166  CreateOne (Vector (5.0, 0.0, 0.0), channel);
167 
168  Simulator::Stop (Seconds (10.0));
169 
170  Simulator::Run ();
171  Simulator::Destroy ();
172 }
173 
174 void
176 {
177  m_mac.SetTypeId ("ns3::AdhocWifiMac");
178  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
179 
180  m_manager.SetTypeId ("ns3::ArfWifiManager");
181  RunOne ();
182  m_manager.SetTypeId ("ns3::AarfWifiManager");
183  RunOne ();
184  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
185  RunOne ();
186  m_manager.SetTypeId ("ns3::OnoeWifiManager");
187  RunOne ();
188  m_manager.SetTypeId ("ns3::AmrrWifiManager");
189  RunOne ();
190  m_manager.SetTypeId ("ns3::IdealWifiManager");
191  RunOne ();
192 
193  m_mac.SetTypeId ("ns3::AdhocWifiMac");
194  RunOne ();
195  m_mac.SetTypeId ("ns3::ApWifiMac");
196  RunOne ();
197  m_mac.SetTypeId ("ns3::StaWifiMac");
198  RunOne ();
199 
200 
201  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
202  m_mac.SetTypeId ("ns3::AdhocWifiMac");
203  RunOne ();
204 }
205 
213 {
214 public:
215  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
216  {
217  }
218  virtual void DoRun (void)
219  {
220  //startingSeq=0, seqNum=2047
221  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
222  //startingSeq=0, seqNum=2048
223  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
224  //startingSeq=2048, seqNum=0
225  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
226  //startingSeq=4095, seqNum=0
227  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
228  //startingSeq=0, seqNum=4095
229  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
230  //startingSeq=4095 seqNum=2047
231  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
232  //startingSeq=2048 seqNum=4095
233  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
234  //startingSeq=2049 seqNum=0
235  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
236  }
237 };
238 
239 
244 {
245 public:
247 
248  virtual void DoRun (void);
249 
250 
251 private:
268  void SwitchCh (Ptr<WifiNetDevice> dev);
269 
273 };
274 
276  : TestCase ("InterferenceHelperSequence")
277 {
278 }
279 
280 void
282 {
283  Ptr<Packet> p = Create<Packet> (9999);
284  dev->Send (p, dev->GetBroadcast (), 1);
285 }
286 
287 void
289 {
290  Ptr<WifiPhy> p = dev->GetPhy ();
291  p->SetChannelNumber (1);
292 }
293 
294 Ptr<Node>
296 {
297  Ptr<Node> node = CreateObject<Node> ();
298  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
299 
302  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
303  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
304  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
305  phy->SetErrorRateModel (error);
306  phy->SetChannel (channel);
307  phy->SetDevice (dev);
308  phy->SetMobility (mobility);
309  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
311 
312  mobility->SetPosition (pos);
313  node->AggregateObject (mobility);
314  mac->SetAddress (Mac48Address::Allocate ());
315  dev->SetMac (mac);
316  dev->SetPhy (phy);
317  dev->SetRemoteStationManager (manager);
318  node->AddDevice (dev);
319 
320  return node;
321 }
322 
323 void
325 {
326  m_mac.SetTypeId ("ns3::AdhocWifiMac");
327  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
328  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
329 
330  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
332  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
333  channel->SetPropagationDelayModel (propDelay);
334  channel->SetPropagationLossModel (propLoss);
335 
336  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
337  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
338  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
339 
340  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
341  propLoss->SetDefaultLoss (999);
342 
343  Simulator::Schedule (Seconds (1.0),
345  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
346 
347  Simulator::Schedule (Seconds (1.0000001),
349  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
350 
351  Simulator::Schedule (Seconds (5.0),
353  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
354 
355  Simulator::Schedule (Seconds (7.0),
357  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
358 
359  Simulator::Stop (Seconds (100.0));
360  Simulator::Run ();
361 
362  Simulator::Destroy ();
363 }
364 
365 
366 //-----------------------------------------------------------------------------
418 {
419 public:
421 
422  virtual void DoRun (void);
423 
424 
425 private:
431 
435 
438  unsigned int m_numSentPackets;
439 
444  void NotifyPhyTxBegin (Ptr<const Packet> p);
445 };
446 
448  : TestCase ("Test case for DCF immediate access with broadcast frames")
449 {
450 }
451 
452 void
454 {
455  if (m_numSentPackets == 0)
456  {
457  NS_ASSERT_MSG (Simulator::Now () == Time (Seconds (1)), "Packet 0 not transmitted at 1 second");
460  }
461  else if (m_numSentPackets == 1)
462  {
464  }
465 }
466 
467 void
469 {
470  Ptr<Packet> p = Create<Packet> (1000);
471  dev->Send (p, dev->GetBroadcast (), 1);
472 }
473 
474 void
476 {
477  m_mac.SetTypeId ("ns3::AdhocWifiMac");
478  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
479  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
480 
481  //Assign a seed and run number, and later fix the assignment of streams to
482  //WiFi random variables, so that the first backoff used is one slot
483  RngSeedManager::SetSeed (1);
484  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
485 
486  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
488  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
489  channel->SetPropagationDelayModel (propDelay);
490  channel->SetPropagationLossModel (propLoss);
491 
492  Ptr<Node> txNode = CreateObject<Node> ();
493  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
494  Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
496  //Fix the stream assignment to the Dcf Txop objects (backoffs)
497  //The below stream assignment will result in the Txop object
498  //using a backoff value of zero for this test when the
499  //Txop::EndTxNoAck() calls to StartBackoffNow()
500  AssignWifiRandomStreams (txMac, 23);
501 
502  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
503  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
504  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
505  txPhy->SetErrorRateModel (txError);
506  txPhy->SetChannel (channel);
507  txPhy->SetDevice (txDev);
508  txPhy->SetMobility (txMobility);
509  txPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
510 
511  txPhy->TraceConnectWithoutContext ("PhyTxBegin", MakeCallback (&DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin, this));
512 
513  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
514  txNode->AggregateObject (txMobility);
515  txMac->SetAddress (Mac48Address::Allocate ());
516  txDev->SetMac (txMac);
517  txDev->SetPhy (txPhy);
518  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
519  txNode->AddDevice (txDev);
520 
523  m_numSentPackets = 0;
524 
525  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
526  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
527 
528  Simulator::Stop (Seconds (2.0));
529  Simulator::Run ();
530  Simulator::Destroy ();
531 
532  //First packet has 1408 us of transmit time. Slot time is 9 us.
533  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
534  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
535  //1451 us after the first one.
536  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
537  Time expectedSecondTransmissionTime = MicroSeconds (expectedWait1) + MilliSeconds (1000);
538  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, MilliSeconds (1000), "The first transmission time not correct!");
539 
540  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
541 }
542 
543 
544 //-----------------------------------------------------------------------------
557 class Bug730TestCase : public TestCase
558 {
559 public:
560  Bug730TestCase ();
561  virtual ~Bug730TestCase ();
562 
563  virtual void DoRun (void);
564 
565 
566 private:
567  uint32_t m_received;
568 
575  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
576 
577 };
578 
580  : TestCase ("Test case for Bug 730"),
581  m_received (0)
582 {
583 }
584 
586 {
587 }
588 
589 void
590 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
591 {
592  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
593  {
594  m_received++;
595  }
596 }
597 
598 
599 void
601 {
602  m_received = 0;
603 
604  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2304"));
605 
606  NodeContainer wifiStaNode;
607  wifiStaNode.Create (1);
608 
610  wifiApNode.Create (1);
611 
612  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
613  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
614  phy.SetChannel (channel.Create ());
615 
618  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
619  "DataMode", StringValue ("DsssRate1Mbps"),
620  "ControlMode", StringValue ("DsssRate1Mbps"));
621 
623  Ssid ssid = Ssid ("ns-3-ssid");
624  mac.SetType ("ns3::StaWifiMac",
625  "Ssid", SsidValue (ssid),
626  "ActiveProbing", BooleanValue (false));
627 
629  staDevices = wifi.Install (phy, mac, wifiStaNode);
630 
631  mac.SetType ("ns3::ApWifiMac",
632  "Ssid", SsidValue (ssid),
633  "BeaconGeneration", BooleanValue (true));
634 
636  apDevices = wifi.Install (phy, mac, wifiApNode);
637 
639  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
640 
641  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
642  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
643  mobility.SetPositionAllocator (positionAlloc);
644 
645  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
646  mobility.Install (wifiApNode);
647  mobility.Install (wifiStaNode);
648 
649  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
650  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
651 
652  PacketSocketAddress socket;
653  socket.SetSingleDevice (sta_device->GetIfIndex ());
654  socket.SetPhysicalAddress (ap_device->GetAddress ());
655  socket.SetProtocol (1);
656 
657  // give packet socket powers to nodes.
658  PacketSocketHelper packetSocket;
659  packetSocket.Install (wifiStaNode);
660  packetSocket.Install (wifiApNode);
661 
662  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
663  client->SetAttribute ("PacketSize", UintegerValue (1460));
664  client->SetRemote (socket);
665  wifiStaNode.Get (0)->AddApplication (client);
666  client->SetStartTime (Seconds (1));
667  client->SetStopTime (Seconds (51.0));
668 
669  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
670  server->SetLocal (socket);
671  wifiApNode.Get (0)->AddApplication (server);
672  server->SetStartTime (Seconds (0.0));
673  server->SetStopTime (Seconds (52.0));
674 
675  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
676 
677  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
678 
679  Simulator::Stop (Seconds (55));
680  Simulator::Run ();
681 
682  Simulator::Destroy ();
683 
684  bool result = (m_received > 0);
685  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
686 }
687 
695 {
696 public:
698 
699  virtual void DoRun (void);
700 
701 
702 private:
709 
710 };
711 
713  : TestCase ("Test case for setting WifiPhy channel and frequency")
714 {
715 }
716 
719 {
720  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
721  Ptr<WifiPhy> wp = wnd->GetPhy ();
722  return wp->GetObject<YansWifiPhy> ();
723 }
724 
725 void
727 {
728  NodeContainer wifiStaNode;
729  wifiStaNode.Create (1);
731  wifiApNode.Create (1);
732 
733  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
734  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
735  phy.SetChannel (channel.Create ());
736 
737  // Configure and declare other generic components of this example
738  Ssid ssid;
739  ssid = Ssid ("wifi-phy-configuration");
740  WifiMacHelper macSta;
741  macSta.SetType ("ns3::StaWifiMac",
742  "Ssid", SsidValue (ssid),
743  "ActiveProbing", BooleanValue (false));
744  NetDeviceContainer staDevice;
745  Ptr<YansWifiPhy> phySta;
746 
747  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
748  {
749  // case 0
750  // Default configuration, without WifiHelper::SetStandard or WifiHelper
751  phySta = CreateObject<YansWifiPhy> ();
752  // The default results in an invalid configuration of channel 0,
753  // width 20, and frequency 0 MHz
754  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "default configuration");
755  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
756  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 0, "default configuration");
757  }
758  {
759  // case 1
761  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
762  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
763  phySta = GetYansWifiPhyPtr (staDevice);
764  // We expect channel 36, width 20, frequency 5180
765  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
766  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
767  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
768  }
769  {
770  // case 2
773  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
774  phySta = GetYansWifiPhyPtr (staDevice);
775  // We expect channel 1, width 22, frequency 2412
776  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
777  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
778  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
779  }
780  {
781  // case 3
784  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
785  phySta = GetYansWifiPhyPtr (staDevice);
786  // We expect channel 1, width 20, frequency 2412
787  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
788  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
789  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
790  }
791  {
792  // case 4
794  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
796  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
797  phySta = GetYansWifiPhyPtr (staDevice);
798  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
799  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
800  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
801  }
802  {
803  // case 5
805  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
807  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
808  phySta = GetYansWifiPhyPtr (staDevice);
809  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
810  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
811  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
812  }
813  {
814  // case 6
816  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
818  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
819  phySta = GetYansWifiPhyPtr (staDevice);
820  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
821  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
822  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
823  }
824  {
825  // case 7
827  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
829  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
830  phySta = GetYansWifiPhyPtr (staDevice);
831  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11 10Mhz configuration");
832  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11 10Mhz configuration");
833  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 10Mhz configuration");
834  }
835  {
836  // case 8
838  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
840  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
841  phySta = GetYansWifiPhyPtr (staDevice);
842  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5Mhz configuration");
843  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11 5Mhz configuration");
844  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 5Mhz configuration");
845  }
846  {
847  // case 9
849  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
851  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
852  phySta = GetYansWifiPhyPtr (staDevice);
853  // We expect channel 36, width 20, frequency 5180
854  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
855  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
856  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
857  }
858  {
859  // case 10
861  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
863  phy.Set ("ChannelNumber", UintegerValue (44));
864  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
865  phySta = GetYansWifiPhyPtr (staDevice);
866  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
867  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
868  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
869  }
870  {
871  // case 11
873  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
874  phy.Set ("ChannelNumber", UintegerValue (44));
875  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
876  phySta = GetYansWifiPhyPtr (staDevice);
877  // Post-install reconfiguration to channel number 40
878  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber", UintegerValue (40));
879  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
880  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
881  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
882  }
883  {
884  // case 12
886  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
887  phy.Set ("ChannelNumber", UintegerValue (44));
888  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
889  phySta = GetYansWifiPhyPtr (staDevice);
890  // Post-install reconfiguration to channel width 40 MHz
891  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
892  // Although channel 44 is configured originally for 20 MHz, we
893  // allow it to be used for 40 MHz here
894  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
895  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
896  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
897  }
898  // modify cases 13 and 14 to avoid Config::SetDefault ()
899  {
900  // case 13
902  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
904  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
905  phySta = GetYansWifiPhyPtr (staDevice);
906  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
907  // Post-install reconfiguration to channel width 40 MHz
908  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
909  // Although channel 44 is configured originally for 20 MHz, we
910  // allow it to be used for 40 MHz here
911  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
912  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
913  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
914  }
915  {
916  // case 14
918  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
919  // Test that setting Frequency to a non-standard value will zero the
920  // channel number
922  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
923  phySta = GetYansWifiPhyPtr (staDevice);
924  phySta->SetAttribute ("Frequency", UintegerValue (5281));
925  // We expect channel number to be zero since frequency doesn't match
926  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
927  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
928  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5281, "802.11 5GHz configuration");
929  }
930  {
931  // case 15:
933  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
935  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
936  phySta = GetYansWifiPhyPtr (staDevice);
937  // Test that setting Frequency to a standard value will set the
938  // channel number correctly
939  phySta->SetAttribute ("Frequency", UintegerValue (5500));
940  // We expect channel number to be 100 due to frequency 5500
941  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
942  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
943  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
944  }
945  {
946  // case 16:
948  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
950  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
951  phySta = GetYansWifiPhyPtr (staDevice);
952  // This case will error exit due to invalid channel number unless
953  // we provide the DefineChannelNumber() below
954  phySta->DefineChannelNumber (99, WIFI_PHY_STANDARD_80211n_5GHZ, 5185, 40);
955  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
956  }
957  {
958  // case 17:
960  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
961  // Test how channel number behaves when frequency is non-standard
963  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
964  phySta = GetYansWifiPhyPtr (staDevice);
965  phySta->SetAttribute ("Frequency", UintegerValue (5181));
966  // We expect channel number to be 0 due to unknown center frequency 5181
967  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
968  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
969  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5181, "802.11 5GHz configuration");
970  phySta->SetAttribute ("Frequency", UintegerValue (5180));
971  // We expect channel number to be 36 due to known center frequency 5180
972  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
973  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
974  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
975  phySta->SetAttribute ("Frequency", UintegerValue (5179));
976  // We expect channel number to be 0 due to unknown center frequency 5179
977  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
978  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
979  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
980  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
981  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
982  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
983  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
984  }
985  {
986  // case 18:
988  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
989  // Set both channel and frequency to consistent values
991  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
992  phySta = GetYansWifiPhyPtr (staDevice);
993  phySta->SetAttribute ("Frequency", UintegerValue (5200));
994  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
995  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
996  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
997  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
998  // Set both channel and frequency to inconsistent values
999  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1000  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1001  // We expect channel number to be 36
1002  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1003  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1004  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1005  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1006  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1007  // We expect channel number to be 40
1008  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1009  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1010  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1011  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1012  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1013  // We expect channel number to be 36
1014  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1015  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1016  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1017  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1018  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1019  // We expect channel number to be 0
1020  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1021  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1022  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1023  }
1024 
1025  Simulator::Destroy ();
1026 
1027 }
1028 
1029 //-----------------------------------------------------------------------------
1038 {
1039 public:
1040  Bug2222TestCase ();
1041  virtual ~Bug2222TestCase ();
1042 
1043  virtual void DoRun (void);
1044 
1045 
1046 private:
1048 
1050  void PopulateArpCache ();
1056  void TxDataFailedTrace (std::string context, Mac48Address adr);
1057 };
1058 
1060  : TestCase ("Test case for Bug 2222"),
1061  m_countInternalCollisions (0)
1062 {
1063 }
1064 
1066 {
1067 }
1068 
1069 void
1071 {
1072  //Indicate the long retry counter has been increased in the wifi remote station manager
1074 }
1075 
1076 void
1078 {
1080 
1081  //Generate same backoff for AC_VI and AC_VO
1082  //The below combination will work
1083  RngSeedManager::SetSeed (1);
1084  RngSeedManager::SetRun (2);
1085  int64_t streamNumber = 100;
1086 
1087  NodeContainer wifiNodes;
1088  wifiNodes.Create (2);
1089 
1090  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1091  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1092  phy.SetChannel (channel.Create ());
1093 
1094  WifiHelper wifi;
1095  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1096  "DataMode", StringValue ("OfdmRate54Mbps"),
1097  "ControlMode", StringValue ("OfdmRate24Mbps"));
1099  Ssid ssid = Ssid ("ns-3-ssid");
1100  mac.SetType ("ns3::AdhocWifiMac",
1101  "QosSupported", BooleanValue (true));
1102 
1103  NetDeviceContainer wifiDevices;
1104  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1105 
1106  // Assign fixed streams to random variables in use
1107  wifi.AssignStreams (wifiDevices, streamNumber);
1108 
1110  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1111 
1112  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1113  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1114  mobility.SetPositionAllocator (positionAlloc);
1115 
1116  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1117  mobility.Install (wifiNodes);
1118 
1119  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1120  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1121 
1122  PacketSocketAddress socket;
1123  socket.SetSingleDevice (device1->GetIfIndex ());
1124  socket.SetPhysicalAddress (device2->GetAddress ());
1125  socket.SetProtocol (1);
1126 
1127  PacketSocketHelper packetSocket;
1128  packetSocket.Install (wifiNodes);
1129 
1130  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1131  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1132  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1133  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1134  clientLowPriority->SetRemote (socket);
1135  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1136  clientLowPriority->SetStartTime (Seconds (1.0));
1137  clientLowPriority->SetStopTime (Seconds (2.0));
1138 
1139  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1140  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1141  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1142  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1143  clientHighPriority->SetRemote (socket);
1144  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1145  clientHighPriority->SetStartTime (Seconds (1.0));
1146  clientHighPriority->SetStopTime (Seconds (2.0));
1147 
1148  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1149  server->SetLocal (socket);
1150  wifiNodes.Get (1)->AddApplication (server);
1151  server->SetStartTime (Seconds (1.0));
1152  server->SetStopTime (Seconds (2.0));
1153 
1154  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1155 
1156  Simulator::Stop (Seconds (2.0));
1157  Simulator::Run ();
1158  Simulator::Destroy ();
1159 
1160  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1161 }
1162 
1163 //-----------------------------------------------------------------------------
1177 {
1178 public:
1179  Bug2483TestCase ();
1180  virtual ~Bug2483TestCase ();
1181  virtual void DoRun (void);
1182 
1183 private:
1187  typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1188  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1189 
1196  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1203  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1204 };
1205 
1207  : TestCase ("Test case for Bug 2483")
1208 {
1209 }
1210 
1212 {
1213 }
1214 
1215 void
1217 {
1218  // Extract starting frequency and number of subbands
1219  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1220  std::size_t numBands = c->GetNumBands ();
1221  double startingFreq = c->Begin ()->fl;
1222 
1223  // Get channel bandwidth and modulation class
1224  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1225  Ptr<Packet> packet = wifiTxParams->packet->Copy ();
1226  WifiPhyTag tag;
1227  if (!packet->RemovePacketTag (tag))
1228  {
1229  NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag");
1230  return;
1231  }
1232  WifiTxVector txVector = tag.GetWifiTxVector ();
1233  uint16_t channelWidth = txVector.GetChannelWidth ();
1234  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1235 
1236  // Build a tuple and check if seen before (if so store it)
1237  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, channelWidth,
1238  numBands, modulationClass);
1239  bool found = false;
1240  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1241  {
1242  if (*it == tupleForCurrentTx)
1243  {
1244  found = true;
1245  }
1246  }
1247  if (!found)
1248  {
1249  m_distinctTuples.push_back (tupleForCurrentTx);
1250  }
1251 }
1252 
1253 void
1254 Bug2483TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1255  Address& destination) const
1256 {
1257  for (uint8_t i = 0; i < numPackets; i++)
1258  {
1259  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1260  sourceDevice->Send (pkt, destination, 0);
1261  }
1262 }
1263 
1264 void
1266 {
1267  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1268  Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
1269 
1270  uint16_t channelWidth = 40; // at least 40 MHz expected here
1271 
1272  NodeContainer wifiStaNode;
1273  wifiStaNode.Create (1);
1274 
1276  wifiApNode.Create (1);
1277 
1278  SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default ();
1279  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1280  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1281  lossModel->SetFrequency (5.180e9);
1282  spectrumChannel->AddPropagationLossModel (lossModel);
1283 
1285  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1286  spectrumChannel->SetPropagationDelayModel (delayModel);
1287 
1288  spectrumPhy.SetChannel (spectrumChannel);
1289  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1290  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1291  spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
1292  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1293  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1294 
1295  WifiHelper wifi;
1297  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1298  "DataMode", StringValue ("VhtMcs8"),
1299  "ControlMode", StringValue ("VhtMcs8"));
1300 
1302  mac.SetType ("ns3::StaWifiMac");
1303  NetDeviceContainer staDevice;
1304  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1305 
1306  mac.SetType ("ns3::ApWifiMac");
1307  NetDeviceContainer apDevice;
1308  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1309 
1311  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1312  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1313  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1314  mobility.SetPositionAllocator (positionAlloc);
1315 
1316  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1317  mobility.Install (wifiApNode);
1318  mobility.Install (wifiStaNode);
1319 
1320  // Send two 5 packet-bursts
1321  Simulator::Schedule (Seconds (0.5), &Bug2483TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1322  Simulator::Schedule (Seconds (0.6), &Bug2483TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1323 
1324  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2483TestCase::StoreDistinctTuple, this));
1325 
1326  Simulator::Stop (Seconds (0.8));
1327  Simulator::Run ();
1328 
1329  Simulator::Destroy ();
1330 
1331  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1332  std::size_t numberTuples = m_distinctTuples.size ();
1333  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1334  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");
1335  // Note that the first tuple should the one initiated by the beacon, i.e. legacy OFDM (20 MHz)
1336  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1337  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)");
1338  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1339  // Second tuple
1340  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1341  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)");
1342  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1343 }
1344 
1345 //-----------------------------------------------------------------------------
1358 {
1359 public:
1360  Bug2831TestCase ();
1361  virtual ~Bug2831TestCase ();
1362  virtual void DoRun (void);
1363 
1364 private:
1368  void ChangeSupportedChannelWidth (void);
1374  void RxCallback (std::string context, Ptr<const Packet> p);
1375 
1378 
1383 };
1384 
1386  : TestCase ("Test case for Bug 2831"),
1387  m_reassocReqCount (0),
1388  m_reassocRespCount (0),
1389  m_countOperationalChannelWidth20 (0),
1390  m_countOperationalChannelWidth40 (0)
1391 {
1392 }
1393 
1395 {
1396 }
1397 
1398 void
1400 {
1401  m_apPhy->SetChannelNumber (38);
1402  m_apPhy->SetChannelWidth (40);
1403  m_staPhy->SetChannelNumber (38);
1404  m_staPhy->SetChannelWidth (40);
1405 }
1406 
1407 void
1409 {
1410  Ptr<Packet> packet = p->Copy ();
1411  WifiMacHeader hdr;
1412  packet->RemoveHeader (hdr);
1413  if (hdr.IsReassocReq ())
1414  {
1416  }
1417  else if (hdr.IsReassocResp ())
1418  {
1420  }
1421  else if (hdr.IsBeacon ())
1422  {
1423  MgtBeaconHeader beacon;
1424  packet->RemoveHeader (beacon);
1425  HtOperation htOperation = beacon.GetHtOperation ();
1426  if (htOperation.GetStaChannelWidth () > 0)
1427  {
1429  }
1430  else
1431  {
1433  }
1434  }
1435 }
1436 
1437 void
1439 {
1440  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1441  ObjectFactory propDelay;
1442  propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1443  Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1444  Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel> ();
1445  channel->SetPropagationDelayModel (propagationDelay);
1446  channel->SetPropagationLossModel (propagationLoss);
1447 
1448  Ptr<Node> apNode = CreateObject<Node> ();
1449  Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1451  mac.SetTypeId ("ns3::ApWifiMac");
1452  mac.Set ("EnableBeaconJitter", BooleanValue (false));
1453  Ptr<WifiMac> apMac = mac.Create<WifiMac> ();
1455 
1456  Ptr<Node> staNode = CreateObject<Node> ();
1457  Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> ();
1458  mac.SetTypeId ("ns3::StaWifiMac");
1459  Ptr<WifiMac> staMac = mac.Create<WifiMac> ();
1461 
1462  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
1463  apMobility->SetPosition (Vector (0.0, 0.0, 0.0));
1464  apNode->AggregateObject (apMobility);
1465 
1466  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
1467  m_apPhy = CreateObject<YansWifiPhy> ();
1468  m_apPhy->SetErrorRateModel (error);
1469  m_apPhy->SetChannel (channel);
1470  m_apPhy->SetMobility (apMobility);
1471  m_apPhy->SetDevice (apDev);
1472  m_apPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211ax_5GHZ);
1473  m_apPhy->SetChannelNumber (36);
1474  m_apPhy->SetChannelWidth (20);
1475 
1476  Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel> ();
1477  staMobility->SetPosition (Vector (1.0, 0.0, 0.0));
1478  staNode->AggregateObject (staMobility);
1479 
1480  m_staPhy = CreateObject<YansWifiPhy> ();
1481  m_staPhy->SetErrorRateModel (error);
1482  m_staPhy->SetChannel (channel);
1483  m_staPhy->SetMobility (staMobility);
1484  m_staPhy->SetDevice (apDev);
1486  m_staPhy->SetChannelNumber (36);
1487  m_staPhy->SetChannelWidth (20);
1488 
1489  apMac->SetAddress (Mac48Address::Allocate ());
1490  apDev->SetMac (apMac);
1491  apDev->SetPhy (m_apPhy);
1492  ObjectFactory manager;
1493  manager.SetTypeId ("ns3::ConstantRateWifiManager");
1494  apDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1495  apNode->AddDevice (apDev);
1496 
1497  staMac->SetAddress (Mac48Address::Allocate ());
1498  staDev->SetMac (staMac);
1499  staDev->SetPhy (m_staPhy);
1500  staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
1501  staNode->AddDevice (staDev);
1502 
1503  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this));
1504 
1505  Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1506 
1507  Simulator::Stop (Seconds (3.0));
1508  Simulator::Run ();
1509  Simulator::Destroy ();
1510 
1511  NS_TEST_ASSERT_MSG_EQ (m_reassocReqCount, 1, "Reassociation request not received");
1512  NS_TEST_ASSERT_MSG_EQ (m_reassocRespCount, 1, "Reassociation response not received");
1513  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operational channel width before channel change");
1514  NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operational channel width after channel change");
1515 }
1516 
1517 //-----------------------------------------------------------------------------
1534 {
1535 public:
1537  virtual ~StaWifiMacScanningTestCase ();
1538  virtual void DoRun (void);
1539 
1540 private:
1546  void AssocCallback (std::string context, Mac48Address bssid);
1551  void TurnBeaconGenerationOn (Ptr<Node> apNode);
1556  void TurnApOff (Ptr<Node> apNode);
1563  NodeContainer Setup (bool nearestApBeaconGeneration, bool staActiveProbe);
1564 
1566 };
1567 
1569  : TestCase ("Test case for StaWifiMac scanning capability")
1570 {
1571 }
1572 
1574 {
1575 }
1576 
1577 void
1579 {
1580  m_associatedApBssid = bssid;
1581 }
1582 
1583 void
1585 {
1586  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1587  Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac> (netDevice->GetMac ());
1588  mac->SetAttribute ("BeaconGeneration", BooleanValue (true));
1589 }
1590 
1591 void
1593 {
1594  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1595  Ptr<WifiPhy> phy = netDevice->GetPhy ();
1596  phy->SetOffMode();
1597 }
1598 
1600 StaWifiMacScanningTestCase::Setup (bool nearestApBeaconGeneration, bool staActiveProbe)
1601 {
1602  NodeContainer apNodes;
1603  apNodes.Create (2);
1604 
1605  Ptr<Node> apNodeNearest = CreateObject<Node> ();
1606  Ptr<Node> staNode = CreateObject<Node> ();
1607 
1608  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1609  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1610  phy.SetChannel (channel.Create ());
1611 
1612  WifiHelper wifi;
1614  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
1615 
1617  NetDeviceContainer apDevice, apDeviceNearest;
1618  mac.SetType ("ns3::ApWifiMac",
1619  "BeaconGeneration", BooleanValue (true));
1620  apDevice = wifi.Install (phy, mac, apNodes);
1621  mac.SetType ("ns3::ApWifiMac",
1622  "BeaconGeneration", BooleanValue (nearestApBeaconGeneration));
1623  apDeviceNearest = wifi.Install (phy, mac, apNodeNearest);
1624 
1625  NetDeviceContainer staDevice;
1626  mac.SetType ("ns3::StaWifiMac",
1627  "ActiveProbing", BooleanValue (staActiveProbe));
1628  staDevice = wifi.Install (phy, mac, staNode);
1629 
1631  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1632  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Furthest AP
1633  positionAlloc->Add (Vector (10.0, 0.0, 0.0)); // Second nearest AP
1634  positionAlloc->Add (Vector (5.0, 5.0, 0.0)); // Nearest AP
1635  positionAlloc->Add (Vector (6.0, 5.0, 0.0)); // STA
1636  mobility.SetPositionAllocator (positionAlloc);
1637 
1638  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1639  mobility.Install (apNodes);
1640  mobility.Install (apNodeNearest);
1641  mobility.Install (staNode);
1642 
1643  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc", MakeCallback (&StaWifiMacScanningTestCase::AssocCallback, this));
1644 
1645  NodeContainer allNodes = NodeContainer (apNodes, apNodeNearest, staNode);
1646  return allNodes;
1647 }
1648 
1649 void
1651 {
1652  {
1653  NodeContainer nodes = Setup (false, false);
1654  Ptr<Node> nearestAp = nodes.Get (2);
1655  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1656 
1657  Simulator::Schedule (Seconds (0.05), &StaWifiMacScanningTestCase::TurnBeaconGenerationOn, this, nearestAp);
1658 
1659  Simulator::Stop (Seconds (0.2));
1660  Simulator::Run ();
1661  Simulator::Destroy ();
1662 
1663  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1664  }
1666  {
1667  NodeContainer nodes = Setup (true, true);
1668  Ptr<Node> nearestAp = nodes.Get (2);
1669  Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1670 
1671  Simulator::Stop (Seconds (0.2));
1672  Simulator::Run ();
1673  Simulator::Destroy ();
1674 
1675  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1676  }
1678  {
1679  NodeContainer nodes = Setup (true, false);
1680  Ptr<Node> nearestAp = nodes.Get (2);
1681  Mac48Address secondNearestApAddr = DynamicCast<WifiNetDevice> (nodes.Get (1)->GetDevice (0))->GetMac ()->GetAddress ();
1682 
1683  Simulator::Schedule (Seconds (0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
1684 
1685  Simulator::Stop (Seconds (1.5));
1686  Simulator::Run ();
1687  Simulator::Destroy ();
1688 
1689  NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, secondNearestApAddr, "STA is associated to the wrong AP");
1690  }
1691 }
1692 
1699 class WifiTestSuite : public TestSuite
1700 {
1701 public:
1702  WifiTestSuite ();
1703 };
1704 
1706  : TestSuite ("devices-wifi", UNIT)
1707 {
1708  AddTestCase (new WifiTest, TestCase::QUICK);
1709  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
1710  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
1711  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
1712  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
1713  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
1714  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
1715  AddTestCase (new Bug2483TestCase, TestCase::QUICK); //Bug 2483
1716  AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
1717  AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399
1718 }
1719 
ERP-OFDM PHY (Clause 19, Section 19.5)
bool IsBeacon(void) const
Return true if the header is a Beacon header.
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:156
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:134
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:1381
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1407
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
std::vector< FreqWidthSubbandModulationTuple > m_distinctTuples
vector of distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
Definition: wifi-test.cc:1188
virtual ~Bug730TestCase()
Definition: wifi-test.cc:585
Ptr< T > Get(void) const
Definition: pointer.h:194
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)
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint16_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1016
size_t GetNumBands() const
AttributeValue implementation for Boolean.
Definition: boolean.h:36
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
void SetPropagationLossModel(const Ptr< PropagationLossModel > loss)
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:590
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Ptr< YansWifiChannel > Create(void) const
void SetRemoteStationManager(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())
Definition: wifi-helper.cc:701
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
Hold variables of type string.
Definition: string.h:41
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1438
Make it easy to create and manage PHY objects for the yans model.
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:777
uint16_t GetChannelWidth(void) const
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1650
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
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:90
Address GetAddress(void) const
an address for a packet socket
void RxCallback(std::string context, Ptr< const Packet > p)
Callback triggered when a packet is received by the PHYs.
Definition: wifi-test.cc:1408
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1015
virtual void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
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
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:831
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
void ConfigureStandard(WifiPhyStandard standard)
Definition: wifi-mac.cc:248
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:654
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:83
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:1216
HT PHY for the 2.4 GHz band (clause 20)
VHT PHY (Clause 22)
Definition: wifi-mode.h:60
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:212
encapsulates test code
Definition: test.h:1155
virtual ~StaWifiMacScanningTestCase()
Definition: wifi-test.cc:1573
uint8_t m_reassocReqCount
count number of reassociation requests
Definition: wifi-test.cc:1379
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:557
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1578
helps to create WifiNetDevice objects
Definition: wifi-helper.h:212
Mac48Address m_associatedApBssid
Associated AP&#39;s bssid.
Definition: wifi-test.cc:1565
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1235
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
a polymophic address class
Definition: address.h:90
unsigned int m_numSentPackets
number of sent packets
Definition: wifi-test.cc:438
channel
Definition: third.py:85
mobility
Definition: third.py:101
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:434
phy
Definition: third.py:86
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:642
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1584
virtual void SetStandard(WifiPhyStandard standard)
Definition: wifi-helper.cc:724
Keep track of the current position and velocity of an object.
void SetChannel(Ptr< YansWifiChannel > channel)
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1265
Ptr< WifiPhy > GetPhy(void) const
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:295
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1394
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
void SetPropagationDelayModel(const Ptr< PropagationDelayModel > delay)
HE PHY for the 5 GHz band (clause 26)
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
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:1533
Time m_firstTransmissionTime
first transmission time
Definition: wifi-test.cc:436
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: txop.cc:305
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
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:1187
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:42
uint32_t m_countInternalCollisions
count internal collisions
Definition: wifi-test.cc:1047
void SetChannel(Ptr< SpectrumChannel > channel)
Ptr< const SpectrumModel > GetSpectrumModel() const
Hold an unsigned integer type.
Definition: uinteger.h:44
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1255
ssid
Definition: third.py:93
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:475
#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
holds a vector of ns3::NetDevice pointers
mac
Definition: third.py:92
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:718
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Definition: wifi-helper.cc:730
calculate a propagation delay.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the Phy and Mac aspects ...
Definition: wifi-helper.cc:832
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:142
Hold together all Wifi-related objects.
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:1077
wifiApNode
Definition: third.py:83
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:600
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1357
virtual void SetAddress(Mac48Address address)=0
void SetOffMode(void)
Put in off mode.
Definition: wifi-phy.cc:1549
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:271
hold a list of per-remote-station state.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:843
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:673
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:726
void SwitchCh(Ptr< WifiNetDevice > dev)
Switch channel function.
Definition: wifi-test.cc:288
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
Ptr< YansWifiPhy > m_staPhy
STA PHY.
Definition: wifi-test.cc:1377
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:175
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
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:1720
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:111
virtual void SetChannelWidth(uint16_t channelwidth)
Definition: wifi-phy.cc:1241
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
void SetMobilityModel(std::string type, 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())
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:218
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
uint32_t GetIfIndex(void) const
an EUI-48 address
Definition: mac48-address.h:43
ObjectFactory m_manager
manager
Definition: wifi-test.cc:432
NodeContainer Setup(bool nearestApBeaconGeneration, bool staActiveProbe)
Setup test.
Definition: wifi-test.cc:1600
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1065
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1353
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:112
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:468
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:223
create MAC layers for a ns3::WifiNetDevice.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
uint8_t m_countOperationalChannelWidth40
count number of beacon frames announcing a 40 MHz operating channel width
Definition: wifi-test.cc:1382
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:140
void SetPosition(const Vector &position)
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:272
Wifi Test Suite.
Definition: wifi-test.cc:1699
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1037
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())
wifi
Definition: third.py:89
Helper class used to assign positions and mobility models to nodes.
WifiTxVector GetWifiTxVector(void) const
Getter for WifiTxVector parameter.
Definition: wifi-phy-tag.cc:80
Address GetBroadcast(void) const
ObjectFactory m_manager
manager
Definition: wifi-test.cc:110
Instantiate subclasses of ns3::Object.
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
virtual ~Bug2483TestCase()
Definition: wifi-test.cc:1211
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:52
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1376
virtual 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:1007
AttributeValue implementation for Ssid.
Definition: ssid.h:110
ObjectFactory m_manager
manager
Definition: wifi-test.cc:270
OFDM PHY (Clause 17)
Definition: wifi-mode.h:56
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:782
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start.
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:1254
void NotifyPhyTxBegin(Ptr< const Packet > p)
Notify Phy transmit begin.
Definition: wifi-test.cc:453
uint32_t m_received
received
Definition: wifi-test.cc:567
void Add(Vector v)
Add a position to the list of positions.
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:268
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:281
Tag for WifiTxVector and WifiPreamble information to be embedded in outgoing transmissions as a Packe...
Definition: wifi-phy-tag.h:36
Ptr< WifiMac > GetMac(void) const
apDevices
Definition: third.py:99
void TurnApOff(Ptr< Node > apNode)
Turn the AP node off.
Definition: wifi-test.cc:1592
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:121
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1023
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:365
Wifi Test.
Definition: wifi-test.cc:87
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1111
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:500
Make sure that the correct channel width and center frequency have been set for OFDM basic rate trans...
Definition: wifi-test.cc:1176
WifiMode GetMode(void) const
void TxDataFailedTrace(std::string context, Mac48Address adr)
Transmit data failed function.
Definition: wifi-test.cc:1070
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
Time m_secondTransmissionTime
second transmission time
Definition: wifi-test.cc:437
uint8_t GetStaChannelWidth(void) const
Return the STA channel width.
void ChangeSupportedChannelWidth(void)
Function called to change the supported channel width at runtime.
Definition: wifi-test.cc:1399
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
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:69
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:1380
Implements the IEEE 802.11 MAC header.
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:128
Set Channel Frequency Test.
Definition: wifi-test.cc:694
Make sure that when multiple broadcast packets are queued on the same device in a short succession...
Definition: wifi-test.cc:417
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:64
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:324