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/boolean.h"
37 #include "ns3/string.h"
38 #include "ns3/packet-socket-address.h"
39 #include "ns3/packet-socket-server.h"
40 #include "ns3/packet-socket-client.h"
41 #include "ns3/packet-socket-helper.h"
42 
43 using namespace ns3;
44 
45 //Helper function to assign streams to random variables, to control
46 //randomness in the tests
47 static void
49 {
50  int64_t currentStream = stream;
51  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
52  if (rmac)
53  {
54  PointerValue ptr;
55  rmac->GetAttribute ("DcaTxop", ptr);
56  Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
57  currentStream += dcaTxop->AssignStreams (currentStream);
58 
59  rmac->GetAttribute ("VO_EdcaTxopN", ptr);
60  Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
61  currentStream += vo_edcaTxopN->AssignStreams (currentStream);
62 
63  rmac->GetAttribute ("VI_EdcaTxopN", ptr);
64  Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
65  currentStream += vi_edcaTxopN->AssignStreams (currentStream);
66 
67  rmac->GetAttribute ("BE_EdcaTxopN", ptr);
68  Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
69  currentStream += be_edcaTxopN->AssignStreams (currentStream);
70 
71  rmac->GetAttribute ("BK_EdcaTxopN", ptr);
72  Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
73  currentStream += bk_edcaTxopN->AssignStreams (currentStream);
74  }
75 }
76 
77 
78 class WifiTest : public TestCase
79 {
80 public:
81  WifiTest ();
82 
83  virtual void DoRun (void);
84 
85 
86 private:
87  void RunOne (void);
88  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
90 
94 };
95 
97  : TestCase ("Wifi")
98 {
99 }
100 
101 void
103 {
104  Ptr<Packet> p = Create<Packet> ();
105  dev->Send (p, dev->GetBroadcast (), 1);
106 }
107 
108 void
110 {
111  Ptr<Node> node = CreateObject<Node> ();
112  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
113 
116  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
117  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
118  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
119  phy->SetErrorRateModel (error);
120  phy->SetChannel (channel);
121  phy->SetDevice (dev);
122  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
124 
125  mobility->SetPosition (pos);
126  node->AggregateObject (mobility);
127  mac->SetAddress (Mac48Address::Allocate ());
128  dev->SetMac (mac);
129  dev->SetPhy (phy);
130  dev->SetRemoteStationManager (manager);
131  node->AddDevice (dev);
132 
133  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
134 }
135 
136 void
138 {
139  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
141  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
142  channel->SetPropagationDelayModel (propDelay);
143  channel->SetPropagationLossModel (propLoss);
144 
145  CreateOne (Vector (0.0, 0.0, 0.0), channel);
146  CreateOne (Vector (5.0, 0.0, 0.0), channel);
147  CreateOne (Vector (5.0, 0.0, 0.0), channel);
148 
149  Simulator::Stop (Seconds (10.0));
150 
151  Simulator::Run ();
152  Simulator::Destroy ();
153 }
154 
155 void
157 {
158  m_mac.SetTypeId ("ns3::AdhocWifiMac");
159  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
160 
161  m_manager.SetTypeId ("ns3::ArfWifiManager");
162  RunOne ();
163  m_manager.SetTypeId ("ns3::AarfWifiManager");
164  RunOne ();
165  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
166  RunOne ();
167  m_manager.SetTypeId ("ns3::OnoeWifiManager");
168  RunOne ();
169  m_manager.SetTypeId ("ns3::AmrrWifiManager");
170  RunOne ();
171  m_manager.SetTypeId ("ns3::IdealWifiManager");
172  RunOne ();
173 
174  m_mac.SetTypeId ("ns3::AdhocWifiMac");
175  RunOne ();
176  m_mac.SetTypeId ("ns3::ApWifiMac");
177  RunOne ();
178  m_mac.SetTypeId ("ns3::StaWifiMac");
179  RunOne ();
180 
181 
182  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
183  m_mac.SetTypeId ("ns3::AdhocWifiMac");
184  RunOne ();
185 }
186 
187 //-----------------------------------------------------------------------------
189 {
190 public:
191  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
192  {
193  }
194  virtual void DoRun (void)
195  {
196  //startingSeq=0, seqNum=2047
197  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
198  //startingSeq=0, seqNum=2048
199  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
200  //startingSeq=2048, seqNum=0
201  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
202  //startingSeq=4095, seqNum=0
203  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
204  //startingSeq=0, seqNum=4095
205  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
206  //startingSeq=4095 seqNum=2047
207  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
208  //startingSeq=2048 seqNum=4095
209  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
210  //startingSeq=2049 seqNum=0
211  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
212  }
213 };
214 
215 
216 //-----------------------------------------------------------------------------
221 {
222 public:
224 
225  virtual void DoRun (void);
226 
227 
228 private:
231  void SwitchCh (Ptr<WifiNetDevice> dev);
232 
236 };
237 
239  : TestCase ("InterferenceHelperSequence")
240 {
241 }
242 
243 void
245 {
246  Ptr<Packet> p = Create<Packet> (9999);
247  dev->Send (p, dev->GetBroadcast (), 1);
248 }
249 
250 void
252 {
253  Ptr<WifiPhy> p = dev->GetPhy ();
254  p->SetChannelNumber (1);
255 }
256 
257 Ptr<Node>
259 {
260  Ptr<Node> node = CreateObject<Node> ();
261  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
262 
265  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
266  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
267  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
268  phy->SetErrorRateModel (error);
269  phy->SetChannel (channel);
270  phy->SetDevice (dev);
271  phy->SetMobility (mobility);
272  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
274 
275  mobility->SetPosition (pos);
276  node->AggregateObject (mobility);
277  mac->SetAddress (Mac48Address::Allocate ());
278  dev->SetMac (mac);
279  dev->SetPhy (phy);
280  dev->SetRemoteStationManager (manager);
281  node->AddDevice (dev);
282 
283  return node;
284 }
285 
286 void
288 {
289  m_mac.SetTypeId ("ns3::AdhocWifiMac");
290  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
291  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
292 
293  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
295  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
296  channel->SetPropagationDelayModel (propDelay);
297  channel->SetPropagationLossModel (propLoss);
298 
299  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
300  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
301  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
302 
303  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
304  propLoss->SetDefaultLoss (999);
305 
306  Simulator::Schedule (Seconds (1.0),
308  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
309 
310  Simulator::Schedule (Seconds (1.0000001),
312  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
313 
314  Simulator::Schedule (Seconds (5.0),
316  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
317 
318  Simulator::Schedule (Seconds (7.0),
320  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
321 
322  Simulator::Stop (Seconds (100.0));
323  Simulator::Run ();
324 
325  Simulator::Destroy ();
326 }
327 
328 
329 //-----------------------------------------------------------------------------
381 {
382 public:
384 
385  virtual void DoRun (void);
386 
387 
388 private:
390 
394 
397  unsigned int m_numSentPackets;
398 
400 };
401 
403  : TestCase ("Test case for DCF immediate access with broadcast frames")
404 {
405 }
406 
407 void
409 {
410  if (m_numSentPackets == 0)
411  {
412  NS_ASSERT_MSG (Simulator::Now () == Time (Seconds (1)), "Packet 0 not transmitted at 1 second");
415  }
416  else if (m_numSentPackets == 1)
417  {
419  }
420 }
421 
422 void
424 {
425  Ptr<Packet> p = Create<Packet> (1000);
426  dev->Send (p, dev->GetBroadcast (), 1);
427 }
428 
429 void
431 {
432  m_mac.SetTypeId ("ns3::AdhocWifiMac");
433  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
434  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
435 
436  //Assign a seed and run number, and later fix the assignment of streams to
437  //WiFi random variables, so that the first backoff used is one slot
438  RngSeedManager::SetSeed (1);
439  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
440 
441  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
443  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
444  channel->SetPropagationDelayModel (propDelay);
445  channel->SetPropagationLossModel (propLoss);
446 
447  Ptr<Node> txNode = CreateObject<Node> ();
448  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
449  Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
451  //Fix the stream assignment to the Dcf Txop objects (backoffs)
452  //The below stream assignment will result in the DcaTxop object
453  //using a backoff value of zero for this test when the
454  //DcaTxop::EndTxNoAck() calls to StartBackoffNow()
455  AssignWifiRandomStreams (txMac, 23);
456 
457  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
458  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
459  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
460  txPhy->SetErrorRateModel (txError);
461  txPhy->SetChannel (channel);
462  txPhy->SetDevice (txDev);
463  txPhy->SetMobility (txMobility);
464  txPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
465 
466  txPhy->TraceConnectWithoutContext ("PhyTxBegin", MakeCallback (&DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin, this));
467 
468  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
469  txNode->AggregateObject (txMobility);
470  txMac->SetAddress (Mac48Address::Allocate ());
471  txDev->SetMac (txMac);
472  txDev->SetPhy (txPhy);
473  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
474  txNode->AddDevice (txDev);
475 
478  m_numSentPackets = 0;
479 
480  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
481  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
482 
483  Simulator::Stop (Seconds (2.0));
484  Simulator::Run ();
485  Simulator::Destroy ();
486 
487  //First packet has 1408 us of transmit time. Slot time is 9 us.
488  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
489  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
490  //1451 us after the first one.
491  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
492  Time expectedSecondTransmissionTime = MicroSeconds (expectedWait1) + MilliSeconds (1000);
493  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, MilliSeconds (1000), "The first transmission time not correct!");
494 
495  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
496 }
497 
498 
499 //-----------------------------------------------------------------------------
512 class Bug730TestCase : public TestCase
513 {
514 public:
515  Bug730TestCase ();
516  virtual ~Bug730TestCase ();
517 
518  virtual void DoRun (void);
519 
520 
521 private:
522  uint32_t m_received;
523 
524  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
525 
526 };
527 
529  : TestCase ("Test case for Bug 730"),
530  m_received (0)
531 {
532 }
533 
535 {
536 }
537 
538 void
539 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
540 {
541  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
542  {
543  m_received++;
544  }
545 }
546 
547 
548 void
550 {
551  m_received = 0;
552 
553  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2304"));
554 
555  NodeContainer wifiStaNode;
556  wifiStaNode.Create (1);
557 
559  wifiApNode.Create (1);
560 
561  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
562  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
563  phy.SetChannel (channel.Create ());
564 
567  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
568  "DataMode", StringValue ("DsssRate1Mbps"),
569  "ControlMode", StringValue ("DsssRate1Mbps"));
570 
572  Ssid ssid = Ssid ("ns-3-ssid");
573  mac.SetType ("ns3::StaWifiMac",
574  "Ssid", SsidValue (ssid),
575  "ActiveProbing", BooleanValue (false));
576 
578  staDevices = wifi.Install (phy, mac, wifiStaNode);
579 
580  mac.SetType ("ns3::ApWifiMac",
581  "Ssid", SsidValue (ssid),
582  "BeaconGeneration", BooleanValue (true));
583 
585  apDevices = wifi.Install (phy, mac, wifiApNode);
586 
588  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
589 
590  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
591  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
592  mobility.SetPositionAllocator (positionAlloc);
593 
594  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
595  mobility.Install (wifiApNode);
596  mobility.Install (wifiStaNode);
597 
598  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
599  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
600 
601  PacketSocketAddress socket;
602  socket.SetSingleDevice (sta_device->GetIfIndex ());
603  socket.SetPhysicalAddress (ap_device->GetAddress ());
604  socket.SetProtocol (1);
605 
606  // give packet socket powers to nodes.
607  PacketSocketHelper packetSocket;
608  packetSocket.Install (wifiStaNode);
609  packetSocket.Install (wifiApNode);
610 
611  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
612  client->SetAttribute ("PacketSize", UintegerValue (1460));
613  client->SetRemote (socket);
614  wifiStaNode.Get(0)->AddApplication (client);
615  client->SetStartTime (Seconds (1));
616  client->SetStopTime (Seconds (51.0));
617 
618  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
619  server->SetLocal (socket);
620  wifiApNode.Get(0)->AddApplication (server);
621  server->SetStartTime (Seconds (0.0));
622  server->SetStopTime (Seconds (52.0));
623 
624  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
625 
626  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
627 
628  Simulator::Stop (Seconds (55));
629  Simulator::Run ();
630 
631  Simulator::Destroy ();
632 
633  bool result = (m_received > 0);
634  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
635 }
636 
638 {
639 public:
641 
642  virtual void DoRun (void);
643 
644 
645 private:
646 
648 
649 };
650 
652  : TestCase ("Test case for setting WifiPhy channel and frequency")
653 {
654 }
655 
658 {
659  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
660  Ptr<WifiPhy> wp = wnd->GetPhy ();
661  return wp->GetObject<YansWifiPhy> ();
662 }
663 
664 void
666 {
667  NodeContainer wifiStaNode;
668  wifiStaNode.Create (1);
670  wifiApNode.Create (1);
671 
672  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
673  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
674  phy.SetChannel (channel.Create ());
675 
676  // Configure and declare other generic components of this example
677  Ssid ssid;
678  ssid = Ssid ("wifi-phy-configuration");
679  WifiMacHelper macSta;
680  macSta.SetType ("ns3::StaWifiMac",
681  "Ssid", SsidValue (ssid),
682  "ActiveProbing", BooleanValue (false));
683  NetDeviceContainer staDevice;
684  Ptr<YansWifiPhy> phySta;
685 
686  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
687  {
688  // case 0
689  // Default configuration, without WifiHelper::SetStandard or WifiHelper
690  phySta = CreateObject<YansWifiPhy> ();
691  // The default results in an invalid configuration of channel 0,
692  // width 20, and frequency 0 MHz
693  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "default configuration");
694  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
695  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 0, "default configuration");
696  }
697  {
698  // case 1
700  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
701  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
702  phySta = GetYansWifiPhyPtr (staDevice);
703  // We expect channel 36, width 20, frequency 5180
704  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
705  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
706  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
707  }
708  {
709  // case 2
712  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
713  phySta = GetYansWifiPhyPtr (staDevice);
714  // We expect channel 1, width 22, frequency 2412
715  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
716  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
717  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
718  }
719  {
720  // case 3
723  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
724  phySta = GetYansWifiPhyPtr (staDevice);
725  // We expect channel 1, width 20, frequency 2412
726  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
727  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
728  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
729  }
730  {
731  // case 4
733  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
735  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
736  phySta = GetYansWifiPhyPtr (staDevice);
737  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
738  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
739  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
740  }
741  {
742  // case 5
744  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
746  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
747  phySta = GetYansWifiPhyPtr (staDevice);
748  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
749  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
750  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
751  }
752  {
753  // case 6
755  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
757  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
758  phySta = GetYansWifiPhyPtr (staDevice);
759  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
760  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
761  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
762  }
763  {
764  // case 7
766  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
768  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
769  phySta = GetYansWifiPhyPtr (staDevice);
770  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11 10Mhz configuration");
771  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11 10Mhz configuration");
772  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 10Mhz configuration");
773  }
774  {
775  // case 8
777  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
779  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
780  phySta = GetYansWifiPhyPtr (staDevice);
781  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5Mhz configuration");
782  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11 5Mhz configuration");
783  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 5Mhz configuration");
784  }
785  {
786  // case 9
788  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
790  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
791  phySta = GetYansWifiPhyPtr (staDevice);
792  // We expect channel 36, width 20, frequency 5180
793  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
794  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
795  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
796  }
797  {
798  // case 10
800  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
802  phy.Set ("ChannelNumber", UintegerValue(44));
803  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
804  phySta = GetYansWifiPhyPtr (staDevice);
805  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
806  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
807  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
808  }
809  {
810  // case 11
812  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
813  phy.Set ("ChannelNumber", UintegerValue(44));
814  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
815  phySta = GetYansWifiPhyPtr (staDevice);
816  // Post-install reconfiguration to channel number 40
817  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber", UintegerValue(40));
818  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
819  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
820  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
821  }
822  {
823  // case 12
825  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
826  phy.Set ("ChannelNumber", UintegerValue (44));
827  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
828  phySta = GetYansWifiPhyPtr (staDevice);
829  // Post-install reconfiguration to channel width 40 MHz
830  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue(40));
831  // Although channel 44 is configured originally for 20 MHz, we
832  // allow it to be used for 40 MHz here
833  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
834  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
835  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
836  }
837  // modify cases 13 and 14 to avoid Config::SetDefault ()
838  {
839  // case 13
841  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
843  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
844  phySta = GetYansWifiPhyPtr (staDevice);
845  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
846  // Post-install reconfiguration to channel width 40 MHz
847  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue(40));
848  // Although channel 44 is configured originally for 20 MHz, we
849  // allow it to be used for 40 MHz here
850  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
851  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
852  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
853  }
854  {
855  // case 14
857  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
858  // Test that setting Frequency to a non-standard value will zero the
859  // channel number
861  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
862  phySta = GetYansWifiPhyPtr (staDevice);
863  phySta->SetAttribute ("Frequency", UintegerValue (5281));
864  // We expect channel number to be zero since frequency doesn't match
865  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
866  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
867  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5281, "802.11 5GHz configuration");
868  }
869  {
870  // case 15:
872  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
874  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
875  phySta = GetYansWifiPhyPtr (staDevice);
876  // Test that setting Frequency to a standard value will set the
877  // channel number correctly
878  phySta->SetAttribute ("Frequency", UintegerValue (5500));
879  // We expect channel number to be 100 due to frequency 5500
880  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "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 (), 5500, "802.11 5GHz configuration");
883  }
884  {
885  // case 16:
887  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
889  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
890  phySta = GetYansWifiPhyPtr (staDevice);
891  // This case will error exit due to invalid channel number unless
892  // we provide the DefineChannelNumber() below
893  phySta->DefineChannelNumber (99, WIFI_PHY_STANDARD_80211n_5GHZ, 5185, 40);
894  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
895  }
896  {
897  // case 17:
899  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
900  // Test how channel number behaves when frequency is non-standard
902  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
903  phySta = GetYansWifiPhyPtr (staDevice);
904  phySta->SetAttribute ("Frequency", UintegerValue (5181));
905  // We expect channel number to be 0 due to unknown center frequency 5181
906  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
907  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
908  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5181, "802.11 5GHz configuration");
909  phySta->SetAttribute ("Frequency", UintegerValue (5180));
910  // We expect channel number to be 36 due to known center frequency 5180
911  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
912  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
913  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
914  phySta->SetAttribute ("Frequency", UintegerValue (5179));
915  // We expect channel number to be 0 due to unknown center frequency 5179
916  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
917  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
918  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
919  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
920  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
921  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
922  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
923  }
924  {
925  // case 18:
927  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
928  // Set both channel and frequency to consistent values
930  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get(0));
931  phySta = GetYansWifiPhyPtr (staDevice);
932  phySta->SetAttribute ("Frequency", UintegerValue (5200));
933  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
934  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
935  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
936  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
937  // Set both channel and frequency to inconsistent values
938  phySta->SetAttribute ("Frequency", UintegerValue (5200));
939  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
940  // We expect channel number to be 36
941  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "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 (), 5180, "802.11 5GHz configuration");
944  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
945  phySta->SetAttribute ("Frequency", UintegerValue (5200));
946  // We expect channel number to be 40
947  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
948  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
949  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
950  phySta->SetAttribute ("Frequency", UintegerValue (5179));
951  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
952  // We expect channel number to be 36
953  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
954  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
955  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
956  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
957  phySta->SetAttribute ("Frequency", UintegerValue (5179));
958  // We expect channel number to be 0
959  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
960  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
961  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
962  }
963 
964 Simulator::Destroy ();
965 
966 }
967 
968 //-----------------------------------------------------------------------------
976 class Bug2222TestCase : public TestCase
977 {
978 public:
979  Bug2222TestCase ();
980  virtual ~Bug2222TestCase ();
981 
982  virtual void DoRun (void);
983 
984 
985 private:
987 
988  void PopulateArpCache ();
989  void TxDataFailedTrace (std::string context, Mac48Address adr);
990 };
991 
993  : TestCase ("Test case for Bug 2222"),
994  m_countInternalCollisions (0)
995 {
996 }
997 
999 {
1000 }
1001 
1002 void
1004 {
1005  //Indicate the long retry counter has been increased in the wifi remote station manager
1007 }
1008 
1009 void
1011 {
1013 
1014  //Generate same backoff for AC_VI and AC_VO
1015  //The below combination will work
1016  RngSeedManager::SetSeed (1);
1017  RngSeedManager::SetRun (2);
1018  int64_t streamNumber = 100;
1019 
1020  NodeContainer wifiNodes;
1021  wifiNodes.Create (2);
1022 
1023  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1024  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1025  phy.SetChannel (channel.Create ());
1026 
1027  WifiHelper wifi;
1029  Ssid ssid = Ssid ("ns-3-ssid");
1030  mac.SetType ("ns3::AdhocWifiMac",
1031  "QosSupported", BooleanValue (true));
1032 
1033  NetDeviceContainer wifiDevices;
1034  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1035 
1036  // Assign fixed streams to random variables in use
1037  wifi.AssignStreams (wifiDevices, streamNumber);
1038 
1040  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1041 
1042  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1043  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1044  mobility.SetPositionAllocator (positionAlloc);
1045 
1046  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1047  mobility.Install (wifiNodes);
1048 
1049  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1050  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1051 
1052  PacketSocketAddress socket;
1053  socket.SetSingleDevice (device1->GetIfIndex ());
1054  socket.SetPhysicalAddress (device2->GetAddress ());
1055  socket.SetProtocol (1);
1056 
1057  PacketSocketHelper packetSocket;
1058  packetSocket.Install (wifiNodes);
1059 
1060  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1061  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1062  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1063  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1064  clientLowPriority->SetRemote (socket);
1065  wifiNodes.Get(0)->AddApplication (clientLowPriority);
1066  clientLowPriority->SetStartTime (Seconds (1.0));
1067  clientLowPriority->SetStopTime (Seconds (2.0));
1068 
1069  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1070  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1071  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1072  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1073  clientHighPriority->SetRemote (socket);
1074  wifiNodes.Get(0)->AddApplication (clientHighPriority);
1075  clientHighPriority->SetStartTime (Seconds (1.0));
1076  clientHighPriority->SetStopTime (Seconds (2.0));
1077 
1078  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1079  server->SetLocal (socket);
1080  wifiNodes.Get(1)->AddApplication (server);
1081  server->SetStartTime (Seconds (1.0));
1082  server->SetStopTime (Seconds (2.0));
1083 
1084  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1085 
1086  Simulator::Stop (Seconds (2.0));
1087  Simulator::Run ();
1088  Simulator::Destroy ();
1089 
1090  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1091 }
1092 
1093 //-----------------------------------------------------------------------------
1094 
1095 class WifiTestSuite : public TestSuite
1096 {
1097 public:
1098  WifiTestSuite ();
1099 };
1100 
1102  : TestSuite ("devices-wifi", UNIT)
1103 {
1104  AddTestCase (new WifiTest, TestCase::QUICK);
1105  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
1106  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
1107  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
1108  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
1109  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
1110  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
1111 }
1112 
ERP-OFDM PHY (Clause 19, Section 19.5)
void RunOne(void)
Definition: wifi-test.cc:137
tuple channel
Definition: third.py:85
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:112
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:157
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual ~Bug730TestCase()
Definition: wifi-test.cc:534
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()
AttributeValue implementation for Boolean.
Definition: boolean.h:34
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
HT OFDM PHY for the 5 GHz band (clause 20)
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Definition: wifi-test.cc:539
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:683
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:462
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.
Make it easy to create and manage PHY objects for the yans model.
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:769
A suite of tests to run.
Definition: test.h:1333
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
virtual Address GetAddress(void) const
void SetPropagationLossModel(Ptr< PropagationLossModel > loss)
an address for a packet socket
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
void ConfigureStandard(enum WifiPhyStandard standard)
Definition: wifi-mac.cc:290
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:903
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:278
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:792
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
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:88
HT OFDM PHY for the 2.4 GHz band (clause 20)
encapsulates test code
Definition: test.h:1147
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:306
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:512
helps to create WifiNetDevice objects
Definition: wifi-helper.h:231
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wifi-helper.cc:712
a polymophic address class
Definition: address.h:90
Keep track of the current position and velocity of an object.
void SetChannel(Ptr< YansWifiChannel > channel)
Ptr< WifiPhy > GetPhy(void) const
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Definition: wifi-test.cc:258
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:86
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
tuple mobility
Definition: third.py:101
virtual uint16_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1329
tuple phy
Definition: third.py:86
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
bool DefineChannelNumber(uint16_t channelNumber, enum WifiPhyStandard standard, uint32_t frequency, uint32_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:930
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:44
uint32_t m_countInternalCollisions
Definition: wifi-test.cc:986
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Definition: vector.h:166
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:430
#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:161
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:706
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Definition: wifi-test.cc:657
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:787
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:1010
tuple staDevices
Definition: third.py:96
virtual uint32_t GetFrequency(void) const
Definition: wifi-phy.cc:1143
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:549
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
tuple mac
Definition: third.py:92
virtual void SetChannelNumber(uint16_t id)
Set channel number.
Definition: wifi-phy.cc:1275
hold a list of per-remote-station state.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:835
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:665
tuple wifiApNode
Definition: third.py:83
void SwitchCh(Ptr< WifiNetDevice > dev)
Definition: wifi-test.cc:251
virtual uint32_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1157
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:156
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.
Hold objects of type Ptr.
Definition: pointer.h:36
VHT OFDM PHY (clause 22)
static WifiTestSuite g_wifiTestSuite
Definition: wifi-test.cc:1113
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:47
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
ObjectFactory m_mac
Definition: wifi-test.cc:92
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:194
virtual uint32_t GetIfIndex(void) const
an EUI-48 address
Definition: mac48-address.h:43
tuple ssid
Definition: third.py:93
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:998
manage and create wifi channel objects for the yans model.
ObjectFactory m_propDelay
Definition: wifi-test.cc:93
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
void SendOnePacket(Ptr< WifiNetDevice > dev)
Definition: wifi-test.cc:423
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:229
create MAC layers for a ns3::WifiNetDevice.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
void SetPosition(const Vector &position)
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:38
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:976
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())
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:90
Helper class used to assign positions and mobility models to nodes.
virtual Address GetBroadcast(void) const
ObjectFactory m_manager
Definition: wifi-test.cc:91
Instantiate subclasses of ns3::Object.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:128
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
static void AssignWifiRandomStreams(Ptr< WifiMac > mac, int64_t stream)
Definition: wifi-test.cc:48
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
AttributeValue implementation for Ssid.
Definition: ssid.h:95
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:774
void NotifyPhyTxBegin(Ptr< const Packet > p)
Definition: wifi-test.cc:408
uint32_t m_received
Definition: wifi-test.cc:522
void Add(Vector v)
Add a position to the list of positions.
void SendOnePacket(Ptr< WifiNetDevice > dev)
Definition: wifi-test.cc:244
void SendOnePacket(Ptr< WifiNetDevice > dev)
Definition: wifi-test.cc:102
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:911
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:340
tuple wifi
Definition: third.py:89
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void TxDataFailedTrace(std::string context, Mac48Address adr)
Definition: wifi-test.cc:1003
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
handle packet fragmentation and retransmissions.
Definition: dca-txop.h:67
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:191
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:69
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Definition: wifi-test.cc:109
WifiTest()
Definition: wifi-test.cc:96
Make sure that when multiple broadcast packets are queued on the same device in a short succession...
Definition: wifi-test.cc:380
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:287