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 
41 using namespace ns3;
42 
43 //Helper function to assign streams to random variables, to control
44 //randomness in the tests
45 static void
47 {
48  int64_t currentStream = stream;
49  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
50  if (rmac)
51  {
52  PointerValue ptr;
53  rmac->GetAttribute ("DcaTxop", ptr);
54  Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
55  currentStream += dcaTxop->AssignStreams (currentStream);
56 
57  rmac->GetAttribute ("VO_EdcaTxopN", ptr);
58  Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
59  currentStream += vo_edcaTxopN->AssignStreams (currentStream);
60 
61  rmac->GetAttribute ("VI_EdcaTxopN", ptr);
62  Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
63  currentStream += vi_edcaTxopN->AssignStreams (currentStream);
64 
65  rmac->GetAttribute ("BE_EdcaTxopN", ptr);
66  Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
67  currentStream += be_edcaTxopN->AssignStreams (currentStream);
68 
69  rmac->GetAttribute ("BK_EdcaTxopN", ptr);
70  Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
71  bk_edcaTxopN->AssignStreams (currentStream);
72  }
73 }
74 
81 class WifiTest : public TestCase
82 {
83 public:
84  WifiTest ();
85 
86  virtual void DoRun (void);
87 
88 
89 private:
91  void RunOne (void);
97  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
103 
107 };
108 
110  : TestCase ("Wifi")
111 {
112 }
113 
114 void
116 {
117  Ptr<Packet> p = Create<Packet> ();
118  dev->Send (p, dev->GetBroadcast (), 1);
119 }
120 
121 void
123 {
124  Ptr<Node> node = CreateObject<Node> ();
125  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
126 
129  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
130  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
131  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
132  phy->SetErrorRateModel (error);
133  phy->SetChannel (channel);
134  phy->SetDevice (dev);
135  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
137 
138  mobility->SetPosition (pos);
139  node->AggregateObject (mobility);
140  mac->SetAddress (Mac48Address::Allocate ());
141  dev->SetMac (mac);
142  dev->SetPhy (phy);
143  dev->SetRemoteStationManager (manager);
144  node->AddDevice (dev);
145 
146  Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
147 }
148 
149 void
151 {
152  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
154  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
155  channel->SetPropagationDelayModel (propDelay);
156  channel->SetPropagationLossModel (propLoss);
157 
158  CreateOne (Vector (0.0, 0.0, 0.0), channel);
159  CreateOne (Vector (5.0, 0.0, 0.0), channel);
160  CreateOne (Vector (5.0, 0.0, 0.0), channel);
161 
162  Simulator::Stop (Seconds (10.0));
163 
164  Simulator::Run ();
165  Simulator::Destroy ();
166 }
167 
168 void
170 {
171  m_mac.SetTypeId ("ns3::AdhocWifiMac");
172  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
173 
174  m_manager.SetTypeId ("ns3::ArfWifiManager");
175  RunOne ();
176  m_manager.SetTypeId ("ns3::AarfWifiManager");
177  RunOne ();
178  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
179  RunOne ();
180  m_manager.SetTypeId ("ns3::OnoeWifiManager");
181  RunOne ();
182  m_manager.SetTypeId ("ns3::AmrrWifiManager");
183  RunOne ();
184  m_manager.SetTypeId ("ns3::IdealWifiManager");
185  RunOne ();
186 
187  m_mac.SetTypeId ("ns3::AdhocWifiMac");
188  RunOne ();
189  m_mac.SetTypeId ("ns3::ApWifiMac");
190  RunOne ();
191  m_mac.SetTypeId ("ns3::StaWifiMac");
192  RunOne ();
193 
194 
195  m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
196  m_mac.SetTypeId ("ns3::AdhocWifiMac");
197  RunOne ();
198 }
199 
207 {
208 public:
209  QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
210  {
211  }
212  virtual void DoRun (void)
213  {
214  //startingSeq=0, seqNum=2047
215  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
216  //startingSeq=0, seqNum=2048
217  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
218  //startingSeq=2048, seqNum=0
219  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
220  //startingSeq=4095, seqNum=0
221  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
222  //startingSeq=0, seqNum=4095
223  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
224  //startingSeq=4095 seqNum=2047
225  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
226  //startingSeq=2048 seqNum=4095
227  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
228  //startingSeq=2049 seqNum=0
229  NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
230  }
231 };
232 
233 
238 {
239 public:
241 
242  virtual void DoRun (void);
243 
244 
245 private:
262  void SwitchCh (Ptr<WifiNetDevice> dev);
263 
267 };
268 
270  : TestCase ("InterferenceHelperSequence")
271 {
272 }
273 
274 void
276 {
277  Ptr<Packet> p = Create<Packet> (9999);
278  dev->Send (p, dev->GetBroadcast (), 1);
279 }
280 
281 void
283 {
284  Ptr<WifiPhy> p = dev->GetPhy ();
285  p->SetChannelNumber (1);
286 }
287 
288 Ptr<Node>
290 {
291  Ptr<Node> node = CreateObject<Node> ();
292  Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
293 
296  Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
297  Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
298  Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
299  phy->SetErrorRateModel (error);
300  phy->SetChannel (channel);
301  phy->SetDevice (dev);
302  phy->SetMobility (mobility);
303  phy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
305 
306  mobility->SetPosition (pos);
307  node->AggregateObject (mobility);
308  mac->SetAddress (Mac48Address::Allocate ());
309  dev->SetMac (mac);
310  dev->SetPhy (phy);
311  dev->SetRemoteStationManager (manager);
312  node->AddDevice (dev);
313 
314  return node;
315 }
316 
317 void
319 {
320  m_mac.SetTypeId ("ns3::AdhocWifiMac");
321  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
322  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
323 
324  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
326  Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
327  channel->SetPropagationDelayModel (propDelay);
328  channel->SetPropagationLossModel (propLoss);
329 
330  Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
331  Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
332  Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
333 
334  propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
335  propLoss->SetDefaultLoss (999);
336 
337  Simulator::Schedule (Seconds (1.0),
339  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
340 
341  Simulator::Schedule (Seconds (1.0000001),
343  DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
344 
345  Simulator::Schedule (Seconds (5.0),
347  DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
348 
349  Simulator::Schedule (Seconds (7.0),
351  DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
352 
353  Simulator::Stop (Seconds (100.0));
354  Simulator::Run ();
355 
356  Simulator::Destroy ();
357 }
358 
359 
360 //-----------------------------------------------------------------------------
412 {
413 public:
415 
416  virtual void DoRun (void);
417 
418 
419 private:
425 
429 
432  unsigned int m_numSentPackets;
433 
439 };
440 
442  : TestCase ("Test case for DCF immediate access with broadcast frames")
443 {
444 }
445 
446 void
448 {
449  if (m_numSentPackets == 0)
450  {
451  NS_ASSERT_MSG (Simulator::Now () == Time (Seconds (1)), "Packet 0 not transmitted at 1 second");
454  }
455  else if (m_numSentPackets == 1)
456  {
458  }
459 }
460 
461 void
463 {
464  Ptr<Packet> p = Create<Packet> (1000);
465  dev->Send (p, dev->GetBroadcast (), 1);
466 }
467 
468 void
470 {
471  m_mac.SetTypeId ("ns3::AdhocWifiMac");
472  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
473  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
474 
475  //Assign a seed and run number, and later fix the assignment of streams to
476  //WiFi random variables, so that the first backoff used is one slot
477  RngSeedManager::SetSeed (1);
478  RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
479 
480  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
482  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
483  channel->SetPropagationDelayModel (propDelay);
484  channel->SetPropagationLossModel (propLoss);
485 
486  Ptr<Node> txNode = CreateObject<Node> ();
487  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
488  Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
490  //Fix the stream assignment to the Dcf Txop objects (backoffs)
491  //The below stream assignment will result in the DcaTxop object
492  //using a backoff value of zero for this test when the
493  //DcaTxop::EndTxNoAck() calls to StartBackoffNow()
494  AssignWifiRandomStreams (txMac, 23);
495 
496  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
497  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
498  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
499  txPhy->SetErrorRateModel (txError);
500  txPhy->SetChannel (channel);
501  txPhy->SetDevice (txDev);
502  txPhy->SetMobility (txMobility);
503  txPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
504 
505  txPhy->TraceConnectWithoutContext ("PhyTxBegin", MakeCallback (&DcfImmediateAccessBroadcastTestCase::NotifyPhyTxBegin, this));
506 
507  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
508  txNode->AggregateObject (txMobility);
509  txMac->SetAddress (Mac48Address::Allocate ());
510  txDev->SetMac (txMac);
511  txDev->SetPhy (txPhy);
512  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
513  txNode->AddDevice (txDev);
514 
517  m_numSentPackets = 0;
518 
519  Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
520  Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
521 
522  Simulator::Stop (Seconds (2.0));
523  Simulator::Run ();
524  Simulator::Destroy ();
525 
526  //First packet has 1408 us of transmit time. Slot time is 9 us.
527  //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
528  //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
529  //1451 us after the first one.
530  uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
531  Time expectedSecondTransmissionTime = MicroSeconds (expectedWait1) + MilliSeconds (1000);
532  NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, MilliSeconds (1000), "The first transmission time not correct!");
533 
534  NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
535 }
536 
537 
538 //-----------------------------------------------------------------------------
551 class Bug730TestCase : public TestCase
552 {
553 public:
554  Bug730TestCase ();
555  virtual ~Bug730TestCase ();
556 
557  virtual void DoRun (void);
558 
559 
560 private:
561  uint32_t m_received;
562 
569  void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
570 
571 };
572 
574  : TestCase ("Test case for Bug 730"),
575  m_received (0)
576 {
577 }
578 
580 {
581 }
582 
583 void
584 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
585 {
586  if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
587  {
588  m_received++;
589  }
590 }
591 
592 
593 void
595 {
596  m_received = 0;
597 
598  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2304"));
599 
600  NodeContainer wifiStaNode;
601  wifiStaNode.Create (1);
602 
604  wifiApNode.Create (1);
605 
606  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
607  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
608  phy.SetChannel (channel.Create ());
609 
612  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
613  "DataMode", StringValue ("DsssRate1Mbps"),
614  "ControlMode", StringValue ("DsssRate1Mbps"));
615 
617  Ssid ssid = Ssid ("ns-3-ssid");
618  mac.SetType ("ns3::StaWifiMac",
619  "Ssid", SsidValue (ssid),
620  "ActiveProbing", BooleanValue (false));
621 
623  staDevices = wifi.Install (phy, mac, wifiStaNode);
624 
625  mac.SetType ("ns3::ApWifiMac",
626  "Ssid", SsidValue (ssid),
627  "BeaconGeneration", BooleanValue (true));
628 
630  apDevices = wifi.Install (phy, mac, wifiApNode);
631 
633  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
634 
635  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
636  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
637  mobility.SetPositionAllocator (positionAlloc);
638 
639  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
640  mobility.Install (wifiApNode);
641  mobility.Install (wifiStaNode);
642 
643  Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
644  Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
645 
646  PacketSocketAddress socket;
647  socket.SetSingleDevice (sta_device->GetIfIndex ());
648  socket.SetPhysicalAddress (ap_device->GetAddress ());
649  socket.SetProtocol (1);
650 
651  // give packet socket powers to nodes.
652  PacketSocketHelper packetSocket;
653  packetSocket.Install (wifiStaNode);
654  packetSocket.Install (wifiApNode);
655 
656  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
657  client->SetAttribute ("PacketSize", UintegerValue (1460));
658  client->SetRemote (socket);
659  wifiStaNode.Get (0)->AddApplication (client);
660  client->SetStartTime (Seconds (1));
661  client->SetStopTime (Seconds (51.0));
662 
663  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
664  server->SetLocal (socket);
665  wifiApNode.Get (0)->AddApplication (server);
666  server->SetStartTime (Seconds (0.0));
667  server->SetStopTime (Seconds (52.0));
668 
669  Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
670 
671  Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
672 
673  Simulator::Stop (Seconds (55));
674  Simulator::Run ();
675 
676  Simulator::Destroy ();
677 
678  bool result = (m_received > 0);
679  NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
680 }
681 
689 {
690 public:
692 
693  virtual void DoRun (void);
694 
695 
696 private:
703 
704 };
705 
707  : TestCase ("Test case for setting WifiPhy channel and frequency")
708 {
709 }
710 
713 {
714  Ptr<WifiNetDevice> wnd = nc.Get (0)->GetObject<WifiNetDevice> ();
715  Ptr<WifiPhy> wp = wnd->GetPhy ();
716  return wp->GetObject<YansWifiPhy> ();
717 }
718 
719 void
721 {
722  NodeContainer wifiStaNode;
723  wifiStaNode.Create (1);
725  wifiApNode.Create (1);
726 
727  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
728  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
729  phy.SetChannel (channel.Create ());
730 
731  // Configure and declare other generic components of this example
732  Ssid ssid;
733  ssid = Ssid ("wifi-phy-configuration");
734  WifiMacHelper macSta;
735  macSta.SetType ("ns3::StaWifiMac",
736  "Ssid", SsidValue (ssid),
737  "ActiveProbing", BooleanValue (false));
738  NetDeviceContainer staDevice;
739  Ptr<YansWifiPhy> phySta;
740 
741  // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
742  {
743  // case 0
744  // Default configuration, without WifiHelper::SetStandard or WifiHelper
745  phySta = CreateObject<YansWifiPhy> ();
746  // The default results in an invalid configuration of channel 0,
747  // width 20, and frequency 0 MHz
748  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "default configuration");
749  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
750  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 0, "default configuration");
751  }
752  {
753  // case 1
755  // By default, WifiHelper will use WIFI_PHY_STANDARD_80211a
756  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
757  phySta = GetYansWifiPhyPtr (staDevice);
758  // We expect channel 36, width 20, frequency 5180
759  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
760  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
761  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
762  }
763  {
764  // case 2
767  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
768  phySta = GetYansWifiPhyPtr (staDevice);
769  // We expect channel 1, width 22, frequency 2412
770  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
771  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
772  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
773  }
774  {
775  // case 3
778  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
779  phySta = GetYansWifiPhyPtr (staDevice);
780  // We expect channel 1, width 20, frequency 2412
781  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
782  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
783  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
784  }
785  {
786  // case 4
788  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
790  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
791  phySta = GetYansWifiPhyPtr (staDevice);
792  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
793  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
794  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
795  }
796  {
797  // case 5
799  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
801  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
802  phySta = GetYansWifiPhyPtr (staDevice);
803  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
804  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
805  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
806  }
807  {
808  // case 6
810  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
812  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
813  phySta = GetYansWifiPhyPtr (staDevice);
814  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
815  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
816  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
817  }
818  {
819  // case 7
821  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
823  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
824  phySta = GetYansWifiPhyPtr (staDevice);
825  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11 10Mhz configuration");
826  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11 10Mhz configuration");
827  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 10Mhz configuration");
828  }
829  {
830  // case 8
832  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
834  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
835  phySta = GetYansWifiPhyPtr (staDevice);
836  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5Mhz configuration");
837  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11 5Mhz configuration");
838  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11 5Mhz configuration");
839  }
840  {
841  // case 9
843  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
845  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
846  phySta = GetYansWifiPhyPtr (staDevice);
847  // We expect channel 36, width 20, frequency 5180
848  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5Mhz configuration");
849  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5Mhz configuration");
850  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5Mhz configuration");
851  }
852  {
853  // case 10
855  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
857  phy.Set ("ChannelNumber", UintegerValue (44));
858  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
859  phySta = GetYansWifiPhyPtr (staDevice);
860  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
861  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
862  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
863  }
864  {
865  // case 11
867  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
868  phy.Set ("ChannelNumber", UintegerValue (44));
869  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
870  phySta = GetYansWifiPhyPtr (staDevice);
871  // Post-install reconfiguration to channel number 40
872  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelNumber", UintegerValue (40));
873  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
874  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
875  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
876  }
877  {
878  // case 12
880  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
881  phy.Set ("ChannelNumber", UintegerValue (44));
882  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
883  phySta = GetYansWifiPhyPtr (staDevice);
884  // Post-install reconfiguration to channel width 40 MHz
885  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
886  // Although channel 44 is configured originally for 20 MHz, we
887  // allow it to be used for 40 MHz here
888  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
889  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
890  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
891  }
892  // modify cases 13 and 14 to avoid Config::SetDefault ()
893  {
894  // case 13
896  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
898  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
899  phySta = GetYansWifiPhyPtr (staDevice);
900  phySta->SetAttribute ("ChannelNumber", UintegerValue (44));
901  // Post-install reconfiguration to channel width 40 MHz
902  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelWidth", UintegerValue (40));
903  // Although channel 44 is configured originally for 20 MHz, we
904  // allow it to be used for 40 MHz here
905  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
906  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
907  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
908  }
909  {
910  // case 14
912  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
913  // Test that setting Frequency to a non-standard value will zero the
914  // channel number
916  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
917  phySta = GetYansWifiPhyPtr (staDevice);
918  phySta->SetAttribute ("Frequency", UintegerValue (5281));
919  // We expect channel number to be zero since frequency doesn't match
920  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "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 (), 5281, "802.11 5GHz configuration");
923  }
924  {
925  // case 15:
927  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
929  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
930  phySta = GetYansWifiPhyPtr (staDevice);
931  // Test that setting Frequency to a standard value will set the
932  // channel number correctly
933  phySta->SetAttribute ("Frequency", UintegerValue (5500));
934  // We expect channel number to be 100 due to frequency 5500
935  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
936  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
937  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
938  }
939  {
940  // case 16:
942  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
944  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
945  phySta = GetYansWifiPhyPtr (staDevice);
946  // This case will error exit due to invalid channel number unless
947  // we provide the DefineChannelNumber() below
948  phySta->DefineChannelNumber (99, WIFI_PHY_STANDARD_80211n_5GHZ, 5185, 40);
949  phySta->SetAttribute ("ChannelNumber", UintegerValue (99));
950  }
951  {
952  // case 17:
954  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
955  // Test how channel number behaves when frequency is non-standard
957  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
958  phySta = GetYansWifiPhyPtr (staDevice);
959  phySta->SetAttribute ("Frequency", UintegerValue (5181));
960  // We expect channel number to be 0 due to unknown center frequency 5181
961  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
962  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
963  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5181, "802.11 5GHz configuration");
964  phySta->SetAttribute ("Frequency", UintegerValue (5180));
965  // We expect channel number to be 36 due to known center frequency 5180
966  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
967  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
968  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
969  phySta->SetAttribute ("Frequency", UintegerValue (5179));
970  // We expect channel number to be 0 due to unknown center frequency 5179
971  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
972  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
973  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
974  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
975  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
976  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
977  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
978  }
979  {
980  // case 18:
982  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
983  // Set both channel and frequency to consistent values
985  staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
986  phySta = GetYansWifiPhyPtr (staDevice);
987  phySta->SetAttribute ("Frequency", UintegerValue (5200));
988  phySta->SetAttribute ("ChannelNumber", UintegerValue (40));
989  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
990  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
991  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
992  // Set both channel and frequency to inconsistent values
993  phySta->SetAttribute ("Frequency", UintegerValue (5200));
994  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
995  // We expect channel number to be 36
996  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "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 (), 5180, "802.11 5GHz configuration");
999  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1000  phySta->SetAttribute ("Frequency", UintegerValue (5200));
1001  // We expect channel number to be 40
1002  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1003  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1004  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1005  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1006  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1007  // We expect channel number to be 36
1008  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1009  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1010  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1011  phySta->SetAttribute ("ChannelNumber", UintegerValue (36));
1012  phySta->SetAttribute ("Frequency", UintegerValue (5179));
1013  // We expect channel number to be 0
1014  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 0, "802.11 5GHz configuration");
1015  NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1016  NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5179, "802.11 5GHz configuration");
1017  }
1018 
1019  Simulator::Destroy ();
1020 
1021 }
1022 
1023 //-----------------------------------------------------------------------------
1032 {
1033 public:
1034  Bug2222TestCase ();
1035  virtual ~Bug2222TestCase ();
1036 
1037  virtual void DoRun (void);
1038 
1039 
1040 private:
1042 
1044  void PopulateArpCache ();
1050  void TxDataFailedTrace (std::string context, Mac48Address adr);
1051 };
1052 
1054  : TestCase ("Test case for Bug 2222"),
1055  m_countInternalCollisions (0)
1056 {
1057 }
1058 
1060 {
1061 }
1062 
1063 void
1065 {
1066  //Indicate the long retry counter has been increased in the wifi remote station manager
1068 }
1069 
1070 void
1072 {
1074 
1075  //Generate same backoff for AC_VI and AC_VO
1076  //The below combination will work
1077  RngSeedManager::SetSeed (1);
1078  RngSeedManager::SetRun (2);
1079  int64_t streamNumber = 100;
1080 
1081  NodeContainer wifiNodes;
1082  wifiNodes.Create (2);
1083 
1084  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1085  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
1086  phy.SetChannel (channel.Create ());
1087 
1088  WifiHelper wifi;
1089  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1090  "DataMode", StringValue ("OfdmRate54Mbps"),
1091  "ControlMode", StringValue ("OfdmRate24Mbps"));
1093  Ssid ssid = Ssid ("ns-3-ssid");
1094  mac.SetType ("ns3::AdhocWifiMac",
1095  "QosSupported", BooleanValue (true));
1096 
1097  NetDeviceContainer wifiDevices;
1098  wifiDevices = wifi.Install (phy, mac, wifiNodes);
1099 
1100  // Assign fixed streams to random variables in use
1101  wifi.AssignStreams (wifiDevices, streamNumber);
1102 
1104  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1105 
1106  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1107  positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1108  mobility.SetPositionAllocator (positionAlloc);
1109 
1110  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1111  mobility.Install (wifiNodes);
1112 
1113  Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1114  Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1115 
1116  PacketSocketAddress socket;
1117  socket.SetSingleDevice (device1->GetIfIndex ());
1118  socket.SetPhysicalAddress (device2->GetAddress ());
1119  socket.SetProtocol (1);
1120 
1121  PacketSocketHelper packetSocket;
1122  packetSocket.Install (wifiNodes);
1123 
1124  Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1125  clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1126  clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1127  clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1128  clientLowPriority->SetRemote (socket);
1129  wifiNodes.Get (0)->AddApplication (clientLowPriority);
1130  clientLowPriority->SetStartTime (Seconds (1.0));
1131  clientLowPriority->SetStopTime (Seconds (2.0));
1132 
1133  Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1134  clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1135  clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1136  clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1137  clientHighPriority->SetRemote (socket);
1138  wifiNodes.Get (0)->AddApplication (clientHighPriority);
1139  clientHighPriority->SetStartTime (Seconds (1.0));
1140  clientHighPriority->SetStopTime (Seconds (2.0));
1141 
1142  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1143  server->SetLocal (socket);
1144  wifiNodes.Get (1)->AddApplication (server);
1145  server->SetStartTime (Seconds (1.0));
1146  server->SetStopTime (Seconds (2.0));
1147 
1148  Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1149 
1150  Simulator::Stop (Seconds (2.0));
1151  Simulator::Run ();
1152  Simulator::Destroy ();
1153 
1154  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1155 }
1156 
1163 class WifiTestSuite : public TestSuite
1164 {
1165 public:
1166  WifiTestSuite ();
1167 };
1168 
1170  : TestSuite ("devices-wifi", UNIT)
1171 {
1172  AddTestCase (new WifiTest, TestCase::QUICK);
1173  AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
1174  AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
1175  AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
1176  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
1177  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
1178  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
1179 }
1180 
ERP-OFDM PHY (Clause 19, Section 19.5)
void RunOne(void)
Run one function.
Definition: wifi-test.cc:150
tuple channel
Definition: third.py:85
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:132
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:157
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1496
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:579
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.
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)
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:584
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:719
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.
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
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
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1001
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:796
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
void ConfigureStandard(WifiPhyStandard standard)
Definition: wifi-mac.cc:289
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 PHY for the 2.4 GHz band (clause 20)
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:206
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
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:551
helps to create WifiNetDevice objects
Definition: wifi-helper.h:213
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1270
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:432
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:428
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)
Create one function.
Definition: wifi-test.cc:289
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:68
void SetPropagationDelayModel(const Ptr< PropagationDelayModel > delay)
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:430
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:1041
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:469
#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
virtual void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:742
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:712
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Definition: wifi-helper.cc:748
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:849
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:1071
tuple staDevices
Definition: third.py:96
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:594
tuple mac
Definition: third.py:92
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:265
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...
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:720
tuple wifiApNode
Definition: third.py:83
void SwitchCh(Ptr< WifiNetDevice > dev)
Switch channel function.
Definition: wifi-test.cc:282
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:169
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
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:1181
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:105
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:212
uint32_t GetIfIndex(void) const
an EUI-48 address
Definition: mac48-address.h:43
ObjectFactory m_manager
manager
Definition: wifi-test.cc:426
tuple ssid
Definition: third.py:93
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1059
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1442
manage and create wifi channel objects for the yans model.
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:106
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:462
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)
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:266
Wifi Test Suite.
Definition: wifi-test.cc:1163
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1031
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
uint8_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1304
Helper class used to assign positions and mobility models to nodes.
Address GetBroadcast(void) const
ObjectFactory m_manager
manager
Definition: wifi-test.cc:104
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:46
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:993
AttributeValue implementation for Ssid.
Definition: ssid.h:117
ObjectFactory m_manager
manager
Definition: wifi-test.cc:264
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:782
void NotifyPhyTxBegin(Ptr< const Packet > p)
Notify Phy transmit begin.
Definition: wifi-test.cc:447
uint32_t m_received
received
Definition: wifi-test.cc:561
void Add(Vector v)
Add a position to the list of positions.
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:275
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint8_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1052
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:115
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1009
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:81
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)
Transmit data failed function.
Definition: wifi-test.cc:1064
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:431
handle packet fragmentation and retransmissions.
Definition: dca-txop.h:58
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
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:122
Set Channel Frequency Test.
Definition: wifi-test.cc:688
Make sure that when multiple broadcast packets are queued on the same device in a short succession...
Definition: wifi-test.cc:411
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: wifi-test.cc:318