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/yans-wifi-helper.h"
25 #include "ns3/mobility-helper.h"
26 #include "ns3/wifi-net-device.h"
27 #include "ns3/adhoc-wifi-mac.h"
28 #include "ns3/propagation-delay-model.h"
29 #include "ns3/propagation-loss-model.h"
30 #include "ns3/yans-error-rate-model.h"
31 #include "ns3/constant-position-mobility-model.h"
32 #include "ns3/test.h"
33 #include "ns3/pointer.h"
34 #include "ns3/rng-seed-manager.h"
35 #include "ns3/config.h"
36 #include "ns3/string.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/spectrum-value.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 <tuple>
46 #include <vector>
47 
48 using namespace ns3;
49 
50 //Helper function to assign streams to random variables, to control
51 //randomness in the tests
52 static void
54 {
55  int64_t currentStream = stream;
56  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
57  if (rmac)
58  {
59  PointerValue ptr;
60  rmac->GetAttribute ("DcaTxop", ptr);
61  Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
62  currentStream += dcaTxop->AssignStreams (currentStream);
63 
64  rmac->GetAttribute ("VO_EdcaTxopN", ptr);
65  Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
66  currentStream += vo_edcaTxopN->AssignStreams (currentStream);
67 
68  rmac->GetAttribute ("VI_EdcaTxopN", ptr);
69  Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
70  currentStream += vi_edcaTxopN->AssignStreams (currentStream);
71 
72  rmac->GetAttribute ("BE_EdcaTxopN", ptr);
73  Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
74  currentStream += be_edcaTxopN->AssignStreams (currentStream);
75 
76  rmac->GetAttribute ("BK_EdcaTxopN", ptr);
77  Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
78  bk_edcaTxopN->AssignStreams (currentStream);
79  }
80 }
81 
88 class WifiTest : public TestCase
89 {
90 public:
91  WifiTest ();
92 
93  virtual void DoRun (void);
94 
95 
96 private:
98  void RunOne (void);
104  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
110 
114 };
115 
117  : TestCase ("Wifi")
118 {
119 }
120 
121 void
123 {
124  Ptr<Packet> p = Create<Packet> ();
125  dev->Send (p, dev->GetBroadcast (), 1);
126 }
127 
128 void
130 {
131  Ptr<Node> node = CreateObject<Node> ();
132  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
133 
136  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
137  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
138  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
139  phy->SetErrorRateModel (error);
140  phy->SetChannel (channel);
141  phy->SetDevice (dev);
142  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
144 
145  mobility->SetPosition (pos);
146  node->AggregateObject (mobility);
147  mac->SetAddress (Mac48Address::Allocate ());
148  dev->SetMac (mac);
149  dev->SetPhy (phy);
150  dev->SetRemoteStationManager (manager);
151  node->AddDevice (dev);
152 
153  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
154 }
155 
156 void
158 {
159  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
161  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
162  channel->SetPropagationDelayModel (propDelay);
163  channel->SetPropagationLossModel (propLoss);
164 
165  CreateOne (Vector (0.0, 0.0, 0.0), channel);
166  CreateOne (Vector (5.0, 0.0, 0.0), channel);
167  CreateOne (Vector (5.0, 0.0, 0.0), channel);
168 
169  Simulator::Stop (Seconds (10.0));
170 
171  Simulator::Run ();
172  Simulator::Destroy ();
173 }
174 
175 void
177 {
178  m_mac.SetTypeId ("ns3::AdhocWifiMac");
179  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
180 
181  m_manager.SetTypeId ("ns3::ArfWifiManager");
182  RunOne ();
183  m_manager.SetTypeId ("ns3::AarfWifiManager");
184  RunOne ();
185  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
186  RunOne ();
187  m_manager.SetTypeId ("ns3::OnoeWifiManager");
188  RunOne ();
189  m_manager.SetTypeId ("ns3::AmrrWifiManager");
190  RunOne ();
191  m_manager.SetTypeId ("ns3::IdealWifiManager");
192  RunOne ();
193 
194  m_mac.SetTypeId ("ns3::AdhocWifiMac");
195  RunOne ();
196  m_mac.SetTypeId ("ns3::ApWifiMac");
197  RunOne ();
198  m_mac.SetTypeId ("ns3::StaWifiMac");
199  RunOne ();
200 
201 
202  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
203  m_mac.SetTypeId ("ns3::AdhocWifiMac");
204  RunOne ();
205 }
206 
214 {
215 public:
216  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
217  {
218  }
219  virtual void DoRun (void)
220  {
221  //startingSeq=0, seqNum=2047
222  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
223  //startingSeq=0, seqNum=2048
224  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
225  //startingSeq=2048, seqNum=0
226  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
227  //startingSeq=4095, seqNum=0
228  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
229  //startingSeq=0, seqNum=4095
230  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
231  //startingSeq=4095 seqNum=2047
232  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
233  //startingSeq=2048 seqNum=4095
234  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
235  //startingSeq=2049 seqNum=0
236  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
237  }
238 };
239 
240 
245 {
246 public:
248 
249  virtual void DoRun (void);
250 
251 
252 private:
269  void SwitchCh (Ptr<WifiNetDevice> dev);
270 
274 };
275 
277  : TestCase ("InterferenceHelperSequence")
278 {
279 }
280 
281 void
283 {
284  Ptr<Packet> p = Create<Packet> (9999);
285  dev->Send (p, dev->GetBroadcast (), 1);
286 }
287 
288 void
290 {
291  Ptr<WifiPhy> p = dev->GetPhy ();
292  p->SetChannelNumber (1);
293 }
294 
295 Ptr<Node>
297 {
298  Ptr<Node> node = CreateObject<Node> ();
299  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
300 
303  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
304  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
305  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
306  phy->SetErrorRateModel (error);
307  phy->SetChannel (channel);
308  phy->SetDevice (dev);
309  phy->SetMobility (mobility);
310  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
312 
313  mobility->SetPosition (pos);
314  node->AggregateObject (mobility);
315  mac->SetAddress (Mac48Address::Allocate ());
316  dev->SetMac (mac);
317  dev->SetPhy (phy);
318  dev->SetRemoteStationManager (manager);
319  node->AddDevice (dev);
320 
321  return node;
322 }
323 
324 void
326 {
327  m_mac.SetTypeId ("ns3::AdhocWifiMac");
328  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
329  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
330 
331  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
333  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
334  channel->SetPropagationDelayModel (propDelay);
335  channel->SetPropagationLossModel (propLoss);
336 
337  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
338  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
339  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
340 
341  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
342  propLoss->SetDefaultLoss (999);
343 
344  Simulator::Schedule (Seconds (1.0),
346  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
347 
348  Simulator::Schedule (Seconds (1.0000001),
350  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
351 
352  Simulator::Schedule (Seconds (5.0),
354  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
355 
356  Simulator::Schedule (Seconds (7.0),
358  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
359 
360  Simulator::Stop (Seconds (100.0));
361  Simulator::Run ();
362 
363  Simulator::Destroy ();
364 }
365 
366 
367 //-----------------------------------------------------------------------------
419 {
420 public:
422 
423  virtual void DoRun (void);
424 
425 
426 private:
432 
436 
439  unsigned int m_numSentPackets;
440 
446 };
447 
449  : TestCase ("Test case for DCF immediate access with broadcast frames")
450 {
451 }
452 
453 void
455 {
456  if (m_numSentPackets == 0)
457  {
458  NS_ASSERT_MSG (Simulator::Now () == Time (Seconds (1)), "Packet 0 not transmitted at 1 second");
461  }
462  else if (m_numSentPackets == 1)
463  {
465  }
466 }
467 
468 void
470 {
471  Ptr<Packet> p = Create<Packet> (1000);
472  dev->Send (p, dev->GetBroadcast (), 1);
473 }
474 
475 void
477 {
478  m_mac.SetTypeId ("ns3::AdhocWifiMac");
479  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
480  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
481 
482  //Assign a seed and run number, and later fix the assignment of streams to
483  //WiFi random variables, so that the first backoff used is one slot
484  RngSeedManager::SetSeed (1);
485  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
486 
487  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
489  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
490  channel->SetPropagationDelayModel (propDelay);
491  channel->SetPropagationLossModel (propLoss);
492 
493  Ptr<Node> txNode = CreateObject<Node> ();
494  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
495  Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
497  //Fix the stream assignment to the Dcf Txop objects (backoffs)
498  //The below stream assignment will result in the DcaTxop object
499  //using a backoff value of zero for this test when the
500  //DcaTxop::EndTxNoAck() calls to StartBackoffNow()
501  AssignWifiRandomStreams (txMac, 23);
502 
503  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
504  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
505  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
506  txPhy->SetErrorRateModel (txError);
507  txPhy->SetChannel (channel);
508  txPhy->SetDevice (txDev);
509  txPhy->SetMobility (txMobility);
510  txPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
511 
512  txPhy->TraceConnectWithoutContext ("PhyTxBegin", MakeCallback (&DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin, this));
513 
514  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
515  txNode->AggregateObject (txMobility);
516  txMac->SetAddress (Mac48Address::Allocate ());
517  txDev->SetMac (txMac);
518  txDev->SetPhy (txPhy);
519  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
520  txNode->AddDevice (txDev);
521 
524  m_numSentPackets = 0;
525 
526  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
527  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
528 
529  Simulator::Stop (Seconds (2.0));
530  Simulator::Run ();
531  Simulator::Destroy ();
532 
533  //First packet has 1408 us of transmit time. Slot time is 9 us.
534  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
535  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
536  //1451 us after the first one.
537  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
538  Time expectedSecondTransmissionTime = MicroSeconds (expectedWait1) + MilliSeconds (1000);
539  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, MilliSeconds (1000), "The first transmission time not correct!");
540 
541  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
542 }
543 
544 
545 //-----------------------------------------------------------------------------
558 class Bug730TestCase : public TestCase
559 {
560 public:
561  Bug730TestCase ();
562  virtual ~Bug730TestCase ();
563 
564  virtual void DoRun (void);
565 
566 
567 private:
568  uint32_t m_received;
569 
576  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
577 
578 };
579 
581  : TestCase ("Test case for Bug 730"),
582  m_received (0)
583 {
584 }
585 
587 {
588 }
589 
590 void
591 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
592 {
593  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
594  {
595  m_received++;
596  }
597 }
598 
599 
600 void
602 {
603  m_received = 0;
604 
605  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2304"));
606 
607  NodeContainer wifiStaNode;
608  wifiStaNode.Create (1);
609 
611  wifiApNode.Create (1);
612 
613  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
614  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
615  phy.SetChannel (channel.Create ());
616 
619  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
620  "DataMode", StringValue ("DsssRate1Mbps"),
621  "ControlMode", StringValue ("DsssRate1Mbps"));
622 
624  Ssid ssid = Ssid ("ns-3-ssid");
625  mac.SetType ("ns3::StaWifiMac",
626  "Ssid", SsidValue (ssid),
627  "ActiveProbing", BooleanValue (false));
628 
630  staDevices = wifi.Install (phy, mac, wifiStaNode);
631 
632  mac.SetType ("ns3::ApWifiMac",
633  "Ssid", SsidValue (ssid),
634  "BeaconGeneration", BooleanValue (true));
635 
637  apDevices = wifi.Install (phy, mac, wifiApNode);
638 
640  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
641 
642  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
643  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
644  mobility.SetPositionAllocator (positionAlloc);
645 
646  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
647  mobility.Install (wifiApNode);
648  mobility.Install (wifiStaNode);
649 
650  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
651  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
652 
653  PacketSocketAddress socket;
654  socket.SetSingleDevice (sta_device->GetIfIndex ());
655  socket.SetPhysicalAddress (ap_device->GetAddress ());
656  socket.SetProtocol (1);
657 
658  // give packet socket powers to nodes.
659  PacketSocketHelper packetSocket;
660  packetSocket.Install (wifiStaNode);
661  packetSocket.Install (wifiApNode);
662 
663  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
664  client->SetAttribute ("PacketSize", UintegerValue (1460));
665  client->SetRemote (socket);
666  wifiStaNode.Get (0)->AddApplication (client);
667  client->SetStartTime (Seconds (1));
668  client->SetStopTime (Seconds (51.0));
669 
670  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
671  server->SetLocal (socket);
672  wifiApNode.Get (0)->AddApplication (server);
673  server->SetStartTime (Seconds (0.0));
674  server->SetStopTime (Seconds (52.0));
675 
676  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
677 
678  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
679 
680  Simulator::Stop (Seconds (55));
681  Simulator::Run ();
682 
683  Simulator::Destroy ();
684 
685  bool result = (m_received > 0);
686  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
687 }
688 
696 {
697 public:
699 
700  virtual void DoRun (void);
701 
702 
703 private:
710 
711 };
712 
714  : TestCase ("Test case for setting WifiPhy channel and frequency")
715 {
716 }
717 
720 {
721  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
722  Ptr<WifiPhy> wp = wnd->GetPhy ();
723  return wp->GetObject<YansWifiPhy> ();
724 }
725 
726 void
728 {
729  NodeContainer wifiStaNode;
730  wifiStaNode.Create (1);
732  wifiApNode.Create (1);
733 
734  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
735  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
736  phy.SetChannel (channel.Create ());
737 
738  // Configure and declare other generic components of this example
739  Ssid ssid;
740  ssid = Ssid ("wifi-phy-configuration");
741  WifiMacHelper macSta;
742  macSta.SetType ("ns3::StaWifiMac",
743  "Ssid", SsidValue (ssid),
744  "ActiveProbing", BooleanValue (false));
745  NetDeviceContainer staDevice;
746  Ptr<YansWifiPhy> phySta;
747 
748  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
749  {
750  // case 0
751  // Default configuration, without WifiHelper::SetStandard or WifiHelper
752  phySta = CreateObject<YansWifiPhy> ();
753  // The default results in an invalid configuration of channel 0,
754  // width 20, and frequency 0 MHz
755  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "default configuration");
756  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
757  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 0, "default configuration");
758  }
759  {
760  // case 1
762  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
763  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
764  phySta = GetYansWifiPhyPtr (staDevice);
765  // We expect channel 36, width 20, frequency 5180
766  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
767  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
768  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
769  }
770  {
771  // case 2
774  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
775  phySta = GetYansWifiPhyPtr (staDevice);
776  // We expect channel 1, width 22, frequency 2412
777  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
778  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
779  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
780  }
781  {
782  // case 3
785  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
786  phySta = GetYansWifiPhyPtr (staDevice);
787  // We expect channel 1, width 20, frequency 2412
788  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
789  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
790  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
791  }
792  {
793  // case 4
795  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
797  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
798  phySta = GetYansWifiPhyPtr (staDevice);
799  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
800  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
801  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
802  }
803  {
804  // case 5
806  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
808  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
809  phySta = GetYansWifiPhyPtr (staDevice);
810  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
811  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
812  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
813  }
814  {
815  // case 6
817  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
819  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
820  phySta = GetYansWifiPhyPtr (staDevice);
821  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
822  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
823  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
824  }
825  {
826  // case 7
828  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
830  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
831  phySta = GetYansWifiPhyPtr (staDevice);
832  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11 10Mhz configuration");
833  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11 10Mhz configuration");
834  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 10Mhz configuration");
835  }
836  {
837  // case 8
839  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
841  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
842  phySta = GetYansWifiPhyPtr (staDevice);
843  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5Mhz configuration");
844  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11 5Mhz configuration");
845  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 5Mhz configuration");
846  }
847  {
848  // case 9
850  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
852  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
853  phySta = GetYansWifiPhyPtr (staDevice);
854  // We expect channel 36, width 20, frequency 5180
855  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
856  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
857  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
858  }
859  {
860  // case 10
862  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
864  phy.Set ("ChannelNumber", UintegerValue (44));
865  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
866  phySta = GetYansWifiPhyPtr (staDevice);
867  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
868  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
869  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
870  }
871  {
872  // case 11
874  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
875  phy.Set ("ChannelNumber", UintegerValue (44));
876  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
877  phySta = GetYansWifiPhyPtr (staDevice);
878  // Post-install reconfiguration to channel number 40
879  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber", UintegerValue (40));
880  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
881  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
882  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
883  }
884  {
885  // case 12
887  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
888  phy.Set ("ChannelNumber", UintegerValue (44));
889  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
890  phySta = GetYansWifiPhyPtr (staDevice);
891  // Post-install reconfiguration to channel width 40 MHz
892  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
893  // Although channel 44 is configured originally for 20 MHz, we
894  // allow it to be used for 40 MHz here
895  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
896  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
897  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
898  }
899  // modify cases 13 and 14 to avoid Config::SetDefault ()
900  {
901  // case 13
903  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
905  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
906  phySta = GetYansWifiPhyPtr (staDevice);
907  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
908  // Post-install reconfiguration to channel width 40 MHz
909  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
910  // Although channel 44 is configured originally for 20 MHz, we
911  // allow it to be used for 40 MHz here
912  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
913  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
914  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
915  }
916  {
917  // case 14
919  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
920  // Test that setting Frequency to a non-standard value will zero the
921  // channel number
923  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
924  phySta = GetYansWifiPhyPtr (staDevice);
925  phySta->SetAttribute ("Frequency", UintegerValue (5281));
926  // We expect channel number to be zero since frequency doesn't match
927  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
928  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
929  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5281, "802.11 5GHz configuration");
930  }
931  {
932  // case 15:
934  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
936  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
937  phySta = GetYansWifiPhyPtr (staDevice);
938  // Test that setting Frequency to a standard value will set the
939  // channel number correctly
940  phySta->SetAttribute ("Frequency", UintegerValue (5500));
941  // We expect channel number to be 100 due to frequency 5500
942  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
943  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
944  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
945  }
946  {
947  // case 16:
949  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
951  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
952  phySta = GetYansWifiPhyPtr (staDevice);
953  // This case will error exit due to invalid channel number unless
954  // we provide the DefineChannelNumber() below
955  phySta->DefineChannelNumber (99, WIFI_PHY_STANDARD_80211n_5GHZ, 5185, 40);
956  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
957  }
958  {
959  // case 17:
961  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
962  // Test how channel number behaves when frequency is non-standard
964  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
965  phySta = GetYansWifiPhyPtr (staDevice);
966  phySta->SetAttribute ("Frequency", UintegerValue (5181));
967  // We expect channel number to be 0 due to unknown center frequency 5181
968  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
969  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
970  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5181, "802.11 5GHz configuration");
971  phySta->SetAttribute ("Frequency", UintegerValue (5180));
972  // We expect channel number to be 36 due to known center frequency 5180
973  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
974  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
975  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
976  phySta->SetAttribute ("Frequency", UintegerValue (5179));
977  // We expect channel number to be 0 due to unknown center frequency 5179
978  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
979  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
980  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
981  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
982  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
983  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
984  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
985  }
986  {
987  // case 18:
989  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
990  // Set both channel and frequency to consistent values
992  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
993  phySta = GetYansWifiPhyPtr (staDevice);
994  phySta->SetAttribute ("Frequency", UintegerValue (5200));
995  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
996  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
997  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
998  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
999  // Set both channel and frequency to inconsistent values
1000  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1001  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1002  // We expect channel number to be 36
1003  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1004  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1005  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1006  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1007  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1008  // We expect channel number to be 40
1009  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1010  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1011  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1012  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1013  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1014  // We expect channel number to be 36
1015  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1016  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1017  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1018  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1019  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1020  // We expect channel number to be 0
1021  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1022  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1023  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1024  }
1025 
1026  Simulator::Destroy ();
1027 
1028 }
1029 
1030 //-----------------------------------------------------------------------------
1039 {
1040 public:
1041  Bug2222TestCase ();
1042  virtual ~Bug2222TestCase ();
1043 
1044  virtual void DoRun (void);
1045 
1046 
1047 private:
1049 
1051  void PopulateArpCache ();
1057  void TxDataFailedTrace (std::string context, Mac48Address adr);
1058 };
1059 
1061  : TestCase ("Test case for Bug 2222"),
1062  m_countInternalCollisions (0)
1063 {
1064 }
1065 
1067 {
1068 }
1069 
1070 void
1072 {
1073  //Indicate the long retry counter has been increased in the wifi remote station manager
1075 }
1076 
1077 void
1079 {
1081 
1082  //Generate same backoff for AC_VI and AC_VO
1083  //The below combination will work
1084  RngSeedManager::SetSeed (1);
1085  RngSeedManager::SetRun (2);
1086  int64_t streamNumber = 100;
1087 
1088  NodeContainer wifiNodes;
1089  wifiNodes.Create (2);
1090 
1091  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1092  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1093  phy.SetChannel (channel.Create ());
1094 
1095  WifiHelper wifi;
1096  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1097  "DataMode", StringValue ("OfdmRate54Mbps"),
1098  "ControlMode", StringValue ("OfdmRate24Mbps"));
1100  Ssid ssid = Ssid ("ns-3-ssid");
1101  mac.SetType ("ns3::AdhocWifiMac",
1102  "QosSupported", BooleanValue (true));
1103 
1104  NetDeviceContainer wifiDevices;
1105  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1106 
1107  // Assign fixed streams to random variables in use
1108  wifi.AssignStreams (wifiDevices, streamNumber);
1109 
1111  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1112 
1113  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1114  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1115  mobility.SetPositionAllocator (positionAlloc);
1116 
1117  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1118  mobility.Install (wifiNodes);
1119 
1120  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1121  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1122 
1123  PacketSocketAddress socket;
1124  socket.SetSingleDevice (device1->GetIfIndex ());
1125  socket.SetPhysicalAddress (device2->GetAddress ());
1126  socket.SetProtocol (1);
1127 
1128  PacketSocketHelper packetSocket;
1129  packetSocket.Install (wifiNodes);
1130 
1131  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1132  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1133  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1134  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1135  clientLowPriority->SetRemote (socket);
1136  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1137  clientLowPriority->SetStartTime (Seconds (1.0));
1138  clientLowPriority->SetStopTime (Seconds (2.0));
1139 
1140  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1141  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1142  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1143  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1144  clientHighPriority->SetRemote (socket);
1145  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1146  clientHighPriority->SetStartTime (Seconds (1.0));
1147  clientHighPriority->SetStopTime (Seconds (2.0));
1148 
1149  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1150  server->SetLocal (socket);
1151  wifiNodes.Get (1)->AddApplication (server);
1152  server->SetStartTime (Seconds (1.0));
1153  server->SetStopTime (Seconds (2.0));
1154 
1155  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1156 
1157  Simulator::Stop (Seconds (2.0));
1158  Simulator::Run ();
1159  Simulator::Destroy ();
1160 
1161  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1162 }
1163 
1164 //-----------------------------------------------------------------------------
1178 {
1179 public:
1180  Bug2483TestCase ();
1181  virtual ~Bug2483TestCase ();
1182  virtual void DoRun (void);
1183 
1184 private:
1188  typedef std::tuple<double, uint8_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1189  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1190 
1197  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1204  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1205 };
1206 
1208  : TestCase ("Test case for Bug 2483")
1209 {
1210 }
1211 
1213 {
1214 }
1215 
1216 void
1218 {
1219  // Extract starting frequency and number of subbands
1220  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1221  uint32_t numBands = c->GetNumBands ();
1222  double startingFreq = c->Begin ()->fl;
1223 
1224  // Get channel bandwidth and modulation class
1225  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1226  Ptr<Packet> packet = wifiTxParams->packet->Copy ();
1227  WifiPhyTag tag;
1228  if (!packet->RemovePacketTag (tag))
1229  {
1230  NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag");
1231  return;
1232  }
1233  WifiTxVector txVector = tag.GetWifiTxVector ();
1234  uint8_t channelWidth = txVector.GetChannelWidth ();
1235  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1236 
1237  // Build a tuple and check if seen before (if so store it)
1238  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, channelWidth,
1239  numBands, modulationClass);
1240  bool found = false;
1241  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1242  {
1243  if (*it == tupleForCurrentTx)
1244  {
1245  found = true;
1246  }
1247  }
1248  if (!found)
1249  {
1250  m_distinctTuples.push_back (tupleForCurrentTx);
1251  }
1252 }
1253 
1254 void
1255 Bug2483TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1256  Address& destination) const
1257 {
1258  for (uint8_t i = 0; i < numPackets; i++)
1259  {
1260  Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1261  sourceDevice->Send (pkt, destination, 0);
1262  }
1263 }
1264 
1265 void
1267 {
1268  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1269  Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
1270 
1271  uint8_t channelWidth = 40; // at least 40 MHz expected here
1272 
1273  NodeContainer wifiStaNode;
1274  wifiStaNode.Create (1);
1275 
1277  wifiApNode.Create (1);
1278 
1279  SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default ();
1280  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1281  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1282  lossModel->SetFrequency (5.180e9);
1283  spectrumChannel->AddPropagationLossModel (lossModel);
1284 
1286  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1287  spectrumChannel->SetPropagationDelayModel (delayModel);
1288 
1289  spectrumPhy.SetChannel (spectrumChannel);
1290  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1291  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1292  spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth));
1293  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1294  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1295 
1296  WifiHelper wifi;
1298  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1299  "DataMode", StringValue ("VhtMcs8"),
1300  "ControlMode", StringValue ("VhtMcs8"));
1301 
1303  mac.SetType ("ns3::StaWifiMac");
1304  NetDeviceContainer staDevice;
1305  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1306 
1307  mac.SetType ("ns3::ApWifiMac");
1308  NetDeviceContainer apDevice;
1309  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1310 
1312  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1313  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1314  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1315  mobility.SetPositionAllocator (positionAlloc);
1316 
1317  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1318  mobility.Install (wifiApNode);
1319  mobility.Install (wifiStaNode);
1320 
1321  // Send two 5 packet-bursts
1322  Simulator::Schedule (Seconds (0.5), &Bug2483TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1323  Simulator::Schedule (Seconds (0.6), &Bug2483TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1324 
1325  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2483TestCase::StoreDistinctTuple, this));
1326 
1327  Simulator::Stop (Seconds (0.8));
1328  Simulator::Run ();
1329 
1330  Simulator::Destroy ();
1331 
1332  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1333  uint8_t numberTuples = m_distinctTuples.size ();
1334  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1335  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");
1336  // Note that the first tuple should the one initiated by the beacon, i.e. legacy OFDM (20 MHz)
1337  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1338  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)");
1339  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1340  // Second tuple
1341  NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1342  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)");
1343  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1344 }
1345 
1346 //-----------------------------------------------------------------------------
1359 {
1360 public:
1361  Bug2831TestCase ();
1362  virtual ~Bug2831TestCase ();
1363  virtual void DoRun (void);
1364 
1365 private:
1369  void ChangeSupportedChannelWidth (void);
1375  void RxCallback (std::string context, Ptr<const Packet> p);
1376 
1379 
1384 };
1385 
1387  : TestCase ("Test case for Bug 2831"),
1388  m_reassocReqCount (0),
1389  m_reassocRespCount (0),
1390  m_countOperationalChannelWidth20 (0),
1391  m_countOperationalChannelWidth40 (0)
1392 {
1393 }
1394 
1396 {
1397 }
1398 
1399 void
1401 {
1402  m_apPhy->SetChannelNumber (38);
1403  m_apPhy->SetChannelWidth (40);
1404  m_staPhy->SetChannelNumber (38);
1405  m_staPhy->SetChannelWidth (40);
1406 }
1407 
1408 void
1410 {
1411  Ptr<Packet> packet = p->Copy ();
1412  WifiMacHeader hdr;
1413  packet->RemoveHeader (hdr);
1414  if (hdr.IsReassocReq ())
1415  {
1417  }
1418  else if (hdr.IsReassocResp ())
1419  {
1421  }
1422  else if (hdr.IsBeacon ())
1423  {
1424  MgtBeaconHeader beacon;
1425  packet->RemoveHeader (beacon);
1426  HtOperation htOperation = beacon.GetHtOperation ();
1427  if (htOperation.GetStaChannelWidth () > 0)
1428  {
1430  }
1431  else
1432  {
1434  }
1435  }
1436 }
1437 
1438 void
1440 {
1441  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1442  ObjectFactory propDelay;
1443  propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1444  Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1445  Ptr<PropagationLossModel> propagationLoss = CreateObject<RandomPropagationLossModel> ();
1446  channel->SetPropagationDelayModel (propagationDelay);
1447  channel->SetPropagationLossModel (propagationLoss);
1448 
1449  Ptr<Node> apNode = CreateObject<Node> ();
1450  Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1452  mac.SetTypeId ("ns3::ApWifiMac");
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_80211n_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 
1523 class WifiTestSuite : public TestSuite
1524 {
1525 public:
1526  WifiTestSuite ();
1527 };
1528 
1530  : TestSuite ("devices-wifi", UNIT)
1531 {
1532  AddTestCase (new WifiTest, TestCase::QUICK);
1533  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
1534  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
1535  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
1536  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
1537  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
1538  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
1539  AddTestCase (new Bug2483TestCase, TestCase::QUICK); //Bug 2483
1540  AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
1541 }
1542 
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:157
tuple channel
Definition: third.py:85
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:133
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:1382
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1482
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:1189
virtual ~Bug730TestCase()
Definition: wifi-test.cc:586
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)
void PopulateArpCache()
Populate ARP cache function.
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:591
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:700
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 stored in this container at a given index.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1439
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
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
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:1409
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:821
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
void ConfigureStandard(WifiPhyStandard standard)
Definition: wifi-mac.cc:289
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:666
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
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:80
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:1217
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:213
encapsulates test code
Definition: test.h:1155
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: dca-txop.cc:228
uint8_t m_reassocReqCount
count number of reassociation requests
Definition: wifi-test.cc:1380
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:558
helps to create WifiNetDevice objects
Definition: wifi-helper.h:213
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1260
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:439
uint8_t GetChannelWidth(void) const
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:435
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:654
virtual void SetStandard(WifiPhyStandard standard)
Definition: wifi-helper.cc:723
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:1266
Ptr< WifiPhy > GetPhy(void) const
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:296
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:68
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1395
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
void SetPropagationDelayModel(const Ptr< PropagationDelayModel > delay)
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
tuple mobility
Definition: third.py:101
tuple phy
Definition: third.py:86
Time m_firstTransmissionTime
first transmission time
Definition: wifi-test.cc:437
std::tuple< double, uint8_t, uint32_t, WifiModulationClass > FreqWidthSubbandModulationTuple
A tuple of {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type}.
Definition: wifi-test.cc:1188
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
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:41
uint32_t m_countInternalCollisions
count internal collisions
Definition: wifi-test.cc:1048
void SetChannel(Ptr< SpectrumChannel > channel)
Ptr< const SpectrumModel > GetSpectrumModel() const
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Definition: vector.h:217
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:476
#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
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:719
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Definition: wifi-helper.cc:729
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:831
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:1078
tuple staDevices
Definition: third.py:96
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:601
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1358
virtual void SetAddress(Mac48Address address)=0
tuple mac
Definition: third.py:92
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:272
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:685
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:727
tuple wifiApNode
Definition: third.py:83
void SwitchCh(Ptr< WifiNetDevice > dev)
Switch channel function.
Definition: wifi-test.cc:289
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:1378
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:176
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
tuple apDevices
Definition: third.py:99
keep track of a set of node pointers.
virtual void SetChannelWidth(uint8_t channelwidth)
Definition: wifi-phy.cc:1266
Hold objects of type Ptr.
Definition: pointer.h:36
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:1543
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:112
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:219
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:433
tuple ssid
Definition: third.py:93
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1066
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1428
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:113
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:469
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:1383
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:139
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:273
Wifi Test Suite.
Definition: wifi-test.cc:1523
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1038
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())
uint8_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1280
Helper class used to assign positions and mobility models to nodes.
WifiTxVector GetWifiTxVector(void) const
Getter for WifiTxVector parameter.
Definition: wifi-phy-tag.cc:79
Address GetBroadcast(void) const
ObjectFactory m_manager
manager
Definition: wifi-test.cc:111
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:1212
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:53
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1377
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:271
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:1255
void NotifyPhyTxBegin(Ptr< const Packet > p)
Notify Phy transmit begin.
Definition: wifi-test.cc:454
uint32_t m_received
received
Definition: wifi-test.cc:568
void Add(Vector v)
Add a position to the list of positions.
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:266
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:282
Tag for WifiTxVector and WifiPreamble information to be embedded in outgoing transmissions as a Packe...
Definition: wifi-phy-tag.h:35
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint8_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1042
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:122
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
tuple wifi
Definition: third.py:89
Wifi Test.
Definition: wifi-test.cc:88
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:1137
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:487
Make sure that the correct channel width and center frequency have been set for OFDM basic rate trans...
Definition: wifi-test.cc:1177
WifiMode GetMode(void) const
void TxDataFailedTrace(std::string context, Mac48Address adr)
Transmit data failed function.
Definition: wifi-test.cc:1071
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:438
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:1400
handle packet fragmentation and retransmissions.
Definition: dca-txop.h:58
This class can be used to hold variables of floating point type such as 'double' or 'float'...
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:827
uint8_t m_reassocRespCount
count number of reassociation responses
Definition: wifi-test.cc:1381
Implements the IEEE 802.11 MAC header.
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:129
Set Channel Frequency Test.
Definition: wifi-test.cc:695
Make sure that when multiple broadcast packets are queued on the same device in a short succession...
Definition: wifi-test.cc:418
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:325