A Discrete-Event Network Simulator
API
wifi-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 * 2010 NICTA
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * Quincy Tse <quincy.tse@nicta.com.au>
20 * Sébastien Deronne <sebastien.deronne@gmail.com>
21 */
22
23#include "ns3/adhoc-wifi-mac.h"
24#include "ns3/ap-wifi-mac.h"
25#include "ns3/config.h"
26#include "ns3/constant-position-mobility-model.h"
27#include "ns3/error-model.h"
28#include "ns3/fcfs-wifi-queue-scheduler.h"
29#include "ns3/frame-exchange-manager.h"
30#include "ns3/ht-configuration.h"
31#include "ns3/interference-helper.h"
32#include "ns3/mgt-headers.h"
33#include "ns3/mobility-helper.h"
34#include "ns3/multi-model-spectrum-channel.h"
35#include "ns3/packet-socket-client.h"
36#include "ns3/packet-socket-helper.h"
37#include "ns3/packet-socket-server.h"
38#include "ns3/pointer.h"
39#include "ns3/propagation-loss-model.h"
40#include "ns3/rng-seed-manager.h"
41#include "ns3/socket.h"
42#include "ns3/spectrum-wifi-helper.h"
43#include "ns3/string.h"
44#include "ns3/test.h"
45#include "ns3/vht-phy.h"
46#include "ns3/waypoint-mobility-model.h"
47#include "ns3/wifi-default-ack-manager.h"
48#include "ns3/wifi-default-assoc-manager.h"
49#include "ns3/wifi-default-protection-manager.h"
50#include "ns3/wifi-net-device.h"
51#include "ns3/wifi-ppdu.h"
52#include "ns3/wifi-psdu.h"
53#include "ns3/wifi-spectrum-signal-parameters.h"
54#include "ns3/yans-error-rate-model.h"
55#include "ns3/yans-wifi-helper.h"
56#include "ns3/yans-wifi-phy.h"
57
58using namespace ns3;
59
60// Helper function to assign streams to random variables, to control
61// randomness in the tests
62static void
64{
65 int64_t currentStream = stream;
66 PointerValue ptr;
67 if (!mac->GetQosSupported())
68 {
69 mac->GetAttribute("Txop", ptr);
70 Ptr<Txop> txop = ptr.Get<Txop>();
71 currentStream += txop->AssignStreams(currentStream);
72 }
73 else
74 {
75 mac->GetAttribute("VO_Txop", ptr);
76 Ptr<QosTxop> vo_txop = ptr.Get<QosTxop>();
77 currentStream += vo_txop->AssignStreams(currentStream);
78
79 mac->GetAttribute("VI_Txop", ptr);
80 Ptr<QosTxop> vi_txop = ptr.Get<QosTxop>();
81 currentStream += vi_txop->AssignStreams(currentStream);
82
83 mac->GetAttribute("BE_Txop", ptr);
84 Ptr<QosTxop> be_txop = ptr.Get<QosTxop>();
85 currentStream += be_txop->AssignStreams(currentStream);
86
87 mac->GetAttribute("BK_Txop", ptr);
88 Ptr<QosTxop> bk_txop = ptr.Get<QosTxop>();
89 bk_txop->AssignStreams(currentStream);
90 }
91}
92
99class WifiTest : public TestCase
100{
101 public:
102 WifiTest();
103
104 void DoRun() override;
105
106 private:
108 void RunOne();
114 void CreateOne(Vector pos, Ptr<YansWifiChannel> channel);
120
124};
125
127 : TestCase("Wifi")
128{
129}
130
131void
133{
134 Ptr<Packet> p = Create<Packet>();
135 dev->Send(p, dev->GetBroadcast(), 1);
136}
137
138void
140{
141 Ptr<Node> node = CreateObject<Node>();
142 Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice>();
143 node->AddDevice(dev);
144
145 auto mobility = CreateObject<ConstantPositionMobilityModel>();
146 auto phy = CreateObject<YansWifiPhy>();
147 Ptr<InterferenceHelper> interferenceHelper = CreateObject<InterferenceHelper>();
148 phy->SetInterferenceHelper(interferenceHelper);
149 auto error = CreateObject<YansErrorRateModel>();
150 phy->SetErrorRateModel(error);
151 phy->SetChannel(channel);
152 phy->SetDevice(dev);
153 phy->ConfigureStandard(WIFI_STANDARD_80211a);
154 dev->SetPhy(phy);
155 auto manager = m_manager.Create<WifiRemoteStationManager>();
156 dev->SetRemoteStationManager(manager);
157
159 mac->SetDevice(dev);
160 mac->SetAddress(Mac48Address::Allocate());
161 dev->SetMac(mac);
162 mac->ConfigureStandard(WIFI_STANDARD_80211a);
163 if (mac->GetTypeOfStation() == STA)
164 {
165 StaticCast<StaWifiMac>(mac)->SetAssocManager(CreateObject<WifiDefaultAssocManager>());
166 }
167 mac->SetMacQueueScheduler(CreateObject<FcfsWifiQueueScheduler>());
168 Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager();
169 Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager>();
170 protectionManager->SetWifiMac(mac);
171 fem->SetProtectionManager(protectionManager);
172 Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager>();
173 ackManager->SetWifiMac(mac);
174 fem->SetAckManager(ackManager);
175
176 mobility->SetPosition(pos);
178
179 Simulator::Schedule(Seconds(1.0), &WifiTest::SendOnePacket, this, dev);
180}
181
182void
184{
185 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel>();
187 Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel>();
188 channel->SetPropagationDelayModel(propDelay);
189 channel->SetPropagationLossModel(propLoss);
190
191 CreateOne(Vector(0.0, 0.0, 0.0), channel);
192 CreateOne(Vector(5.0, 0.0, 0.0), channel);
193 CreateOne(Vector(5.0, 0.0, 0.0), channel);
194
195 Simulator::Stop(Seconds(10.0));
196
197 Simulator::Run();
198 Simulator::Destroy();
199}
200
201void
203{
204 m_mac.SetTypeId("ns3::AdhocWifiMac");
205 m_propDelay.SetTypeId("ns3::ConstantSpeedPropagationDelayModel");
206
207 m_manager.SetTypeId("ns3::ArfWifiManager");
208 RunOne();
209 m_manager.SetTypeId("ns3::AarfWifiManager");
210 RunOne();
211 m_manager.SetTypeId("ns3::ConstantRateWifiManager");
212 RunOne();
213 m_manager.SetTypeId("ns3::OnoeWifiManager");
214 RunOne();
215 m_manager.SetTypeId("ns3::AmrrWifiManager");
216 RunOne();
217 m_manager.SetTypeId("ns3::IdealWifiManager");
218 RunOne();
219
220 m_mac.SetTypeId("ns3::AdhocWifiMac");
221 RunOne();
222 m_mac.SetTypeId("ns3::ApWifiMac");
223 RunOne();
224 m_mac.SetTypeId("ns3::StaWifiMac");
225 RunOne();
226
227 m_propDelay.SetTypeId("ns3::RandomPropagationDelayModel");
228 m_mac.SetTypeId("ns3::AdhocWifiMac");
229 RunOne();
230}
231
239{
240 public:
242 : TestCase("QosUtilsIsOldPacket")
243 {
244 }
245
246 void DoRun() override
247 {
248 // startingSeq=0, seqNum=2047
250 false,
251 "2047 is new in comparison to 0");
252 // startingSeq=0, seqNum=2048
253 NS_TEST_EXPECT_MSG_EQ(QosUtilsIsOldPacket(0, 2048), true, "2048 is old in comparison to 0");
254 // startingSeq=2048, seqNum=0
255 NS_TEST_EXPECT_MSG_EQ(QosUtilsIsOldPacket(2048, 0), true, "0 is old in comparison to 2048");
256 // startingSeq=4095, seqNum=0
258 false,
259 "0 is new in comparison to 4095");
260 // startingSeq=0, seqNum=4095
261 NS_TEST_EXPECT_MSG_EQ(QosUtilsIsOldPacket(0, 4095), true, "4095 is old in comparison to 0");
262 // startingSeq=4095 seqNum=2047
264 true,
265 "2047 is old in comparison to 4095");
266 // startingSeq=2048 seqNum=4095
268 false,
269 "4095 is new in comparison to 2048");
270 // startingSeq=2049 seqNum=0
272 false,
273 "0 is new in comparison to 2049");
274 }
275};
276
281{
282 public:
284
285 void DoRun() override;
286
287 private:
305
309};
310
312 : TestCase("InterferenceHelperSequence")
313{
314}
315
316void
318{
319 Ptr<Packet> p = Create<Packet>(1000);
320 dev->Send(p, dev->GetBroadcast(), 1);
321}
322
323void
325{
326 Ptr<WifiPhy> p = dev->GetPhy();
328}
329
332{
333 Ptr<Node> node = CreateObject<Node>();
334 Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice>();
335 node->AddDevice(dev);
336
337 auto mobility = CreateObject<ConstantPositionMobilityModel>();
338 auto phy = CreateObject<YansWifiPhy>();
339 Ptr<InterferenceHelper> interferenceHelper = CreateObject<InterferenceHelper>();
340 phy->SetInterferenceHelper(interferenceHelper);
341 auto error = CreateObject<YansErrorRateModel>();
342 phy->SetErrorRateModel(error);
343 phy->SetChannel(channel);
344 phy->SetDevice(dev);
345 phy->SetMobility(mobility);
346 phy->ConfigureStandard(WIFI_STANDARD_80211a);
347 dev->SetPhy(phy);
348 auto manager = m_manager.Create<WifiRemoteStationManager>();
349 dev->SetRemoteStationManager(manager);
350
352 mac->SetDevice(dev);
353 mac->SetAddress(Mac48Address::Allocate());
354 dev->SetMac(mac);
355 mac->ConfigureStandard(WIFI_STANDARD_80211a);
356 mac->SetMacQueueScheduler(CreateObject<FcfsWifiQueueScheduler>());
357 Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager();
358 Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager>();
359 protectionManager->SetWifiMac(mac);
360 fem->SetProtectionManager(protectionManager);
361 Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager>();
362 ackManager->SetWifiMac(mac);
363 fem->SetAckManager(ackManager);
364
365 mobility->SetPosition(pos);
367
368 return node;
369}
370
371void
373{
374 m_mac.SetTypeId("ns3::AdhocWifiMac");
375 m_propDelay.SetTypeId("ns3::ConstantSpeedPropagationDelayModel");
376 m_manager.SetTypeId("ns3::ConstantRateWifiManager");
377
378 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel>();
380 Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel>();
381 channel->SetPropagationDelayModel(propDelay);
382 channel->SetPropagationLossModel(propLoss);
383
384 Ptr<Node> rxOnly = CreateOne(Vector(0.0, 0.0, 0.0), channel);
385 Ptr<Node> senderA = CreateOne(Vector(5.0, 0.0, 0.0), channel);
386 Ptr<Node> senderB = CreateOne(Vector(-5.0, 0.0, 0.0), channel);
387
388 propLoss->SetLoss(senderB->GetObject<MobilityModel>(),
389 rxOnly->GetObject<MobilityModel>(),
390 0,
391 true);
392 propLoss->SetDefaultLoss(999);
393
394 Simulator::Schedule(Seconds(1.0),
396 this,
397 DynamicCast<WifiNetDevice>(senderB->GetDevice(0)));
398
399 Simulator::Schedule(Seconds(1.0000001),
401 this,
402 DynamicCast<WifiNetDevice>(rxOnly->GetDevice(0)));
403
404 Simulator::Schedule(Seconds(5.0),
406 this,
407 DynamicCast<WifiNetDevice>(senderA->GetDevice(0)));
408
409 Simulator::Schedule(Seconds(7.0),
411 this,
412 DynamicCast<WifiNetDevice>(senderB->GetDevice(0)));
413
414 Simulator::Stop(Seconds(100.0));
415 Simulator::Run();
416
417 Simulator::Destroy();
418}
419
420//-----------------------------------------------------------------------------
472{
473 public:
475
476 void DoRun() override;
477
478 private:
484
488
491 unsigned int m_numSentPackets;
492
498 void NotifyPhyTxBegin(Ptr<const Packet> p, double txPowerW);
499};
500
502 : TestCase("Test case for DCF immediate access with broadcast frames")
503{
504}
505
506void
508{
509 if (m_numSentPackets == 0)
510 {
513 }
514 else if (m_numSentPackets == 1)
515 {
517 }
518}
519
520void
522{
523 Ptr<Packet> p = Create<Packet>(1000);
524 dev->Send(p, dev->GetBroadcast(), 1);
525}
526
527void
529{
530 m_mac.SetTypeId("ns3::AdhocWifiMac");
531 m_propDelay.SetTypeId("ns3::ConstantSpeedPropagationDelayModel");
532 m_manager.SetTypeId("ns3::ConstantRateWifiManager");
533
534 // Assign a seed and run number, and later fix the assignment of streams to
535 // WiFi random variables, so that the first backoff used is one slot
536 RngSeedManager::SetSeed(1);
537 RngSeedManager::SetRun(40); // a value of 17 will result in zero slots
538
539 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel>();
541 Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel>();
542 channel->SetPropagationDelayModel(propDelay);
543 channel->SetPropagationLossModel(propLoss);
544
545 Ptr<Node> txNode = CreateObject<Node>();
546 Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice>();
547
548 Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel>();
549 Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy>();
550 Ptr<InterferenceHelper> txInterferenceHelper = CreateObject<InterferenceHelper>();
551 txPhy->SetInterferenceHelper(txInterferenceHelper);
552 Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel>();
553 txPhy->SetErrorRateModel(txError);
554 txPhy->SetChannel(channel);
555 txPhy->SetDevice(txDev);
556 txPhy->SetMobility(txMobility);
558
560 "PhyTxBegin",
562
563 txMobility->SetPosition(Vector(0.0, 0.0, 0.0));
564 txNode->AggregateObject(txMobility);
565 txDev->SetPhy(txPhy);
567 txNode->AddDevice(txDev);
568
569 auto txMac = m_mac.Create<WifiMac>();
570 txMac->SetDevice(txDev);
571 txMac->SetAddress(Mac48Address::Allocate());
572 txDev->SetMac(txMac);
573 txMac->ConfigureStandard(WIFI_STANDARD_80211a);
574 txMac->SetMacQueueScheduler(CreateObject<FcfsWifiQueueScheduler>());
575 auto fem = txMac->GetFrameExchangeManager();
576 auto protectionManager = CreateObject<WifiDefaultProtectionManager>();
577 protectionManager->SetWifiMac(txMac);
578 fem->SetProtectionManager(protectionManager);
579 auto ackManager = CreateObject<WifiDefaultAckManager>();
580 ackManager->SetWifiMac(txMac);
581 fem->SetAckManager(ackManager);
582
583 // Fix the stream assignment to the Dcf Txop objects (backoffs)
584 // The below stream assignment will result in the Txop object
585 // using a backoff value of zero for this test when the
586 // Txop::EndTxNoAck() calls to StartBackoffNow()
587 AssignWifiRandomStreams(txMac, 23);
588
592
593 Simulator::Schedule(Seconds(1.0),
595 this,
596 txDev);
597 Simulator::Schedule(Seconds(1.0) + MicroSeconds(1),
599 this,
600 txDev);
601
602 Simulator::Stop(Seconds(2.0));
603 Simulator::Run();
604 Simulator::Destroy();
605
606 // First packet is transmitted a DIFS after the packet is queued. A DIFS
607 // is 2 slots (2 * 9 = 18 us) plus a SIFS (16 us), i.e., 34 us
608 Time expectedFirstTransmissionTime = Seconds(1.0) + MicroSeconds(34);
609
610 // First packet has 1408 us of transmit time. Slot time is 9 us.
611 // Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
612 // Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
613 // 1451 us after the first one.
614 uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
615 Time expectedSecondTransmissionTime =
616 expectedFirstTransmissionTime + MicroSeconds(expectedWait1);
618 expectedFirstTransmissionTime,
619 "The first transmission time not correct!");
620
622 expectedSecondTransmissionTime,
623 "The second transmission time not correct!");
624}
625
626//-----------------------------------------------------------------------------
640{
641 public:
643 ~Bug730TestCase() override;
644
645 void DoRun() override;
646
647 private:
649
656 void Receive(std::string context, Ptr<const Packet> p, const Address& adr);
657};
658
660 : TestCase("Test case for Bug 730"),
661 m_received(0)
662{
663}
664
666{
667}
668
669void
670Bug730TestCase::Receive(std::string context, Ptr<const Packet> p, const Address& adr)
671{
672 if ((p->GetSize() == 1460) && (Simulator::Now() > Seconds(20)))
673 {
674 m_received++;
675 }
676}
677
678void
680{
681 m_received = 0;
682
683 NodeContainer wifiStaNode;
684 wifiStaNode.Create(1);
685
687 wifiApNode.Create(1);
688
689 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
691 phy.SetChannel(channel.Create());
692
694 wifi.SetStandard(WIFI_STANDARD_80211b);
695 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
696 "DataMode",
697 StringValue("DsssRate1Mbps"),
698 "ControlMode",
699 StringValue("DsssRate1Mbps"));
700
702 Ssid ssid = Ssid("ns-3-ssid");
703 mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid), "ActiveProbing", BooleanValue(false));
704
706 staDevices = wifi.Install(phy, mac, wifiStaNode);
707
708 mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid), "BeaconGeneration", BooleanValue(true));
709
711 apDevices = wifi.Install(phy, mac, wifiApNode);
712
714 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
715
716 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
717 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
718 mobility.SetPositionAllocator(positionAlloc);
719
720 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
721 mobility.Install(wifiApNode);
722 mobility.Install(wifiStaNode);
723
724 Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice>(apDevices.Get(0));
725 Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice>(staDevices.Get(0));
726
727 PacketSocketAddress socket;
728 socket.SetSingleDevice(sta_device->GetIfIndex());
729 socket.SetPhysicalAddress(ap_device->GetAddress());
730 socket.SetProtocol(1);
731
732 // give packet socket powers to nodes.
733 PacketSocketHelper packetSocket;
734 packetSocket.Install(wifiStaNode);
735 packetSocket.Install(wifiApNode);
736
737 Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient>();
738 client->SetAttribute("PacketSize", UintegerValue(1460));
739 client->SetRemote(socket);
740 wifiStaNode.Get(0)->AddApplication(client);
741 client->SetStartTime(Seconds(1));
742 client->SetStopTime(Seconds(51.0));
743
744 Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer>();
745 server->SetLocal(socket);
746 wifiApNode.Get(0)->AddApplication(server);
747 server->SetStartTime(Seconds(0.0));
748 server->SetStopTime(Seconds(52.0));
749
750 Config::Connect("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx",
752
753 Simulator::Schedule(Seconds(10.0),
755 "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold",
756 StringValue("800"));
757
758 Simulator::Stop(Seconds(55));
759 Simulator::Run();
760
761 Simulator::Destroy();
762
763 bool result = (m_received > 0);
765 result,
766 true,
767 "packet reception unexpectedly stopped after adapting fragmentation threshold!");
768}
769
770//-----------------------------------------------------------------------------
779{
780 public:
782 ~QosFragmentationTestCase() override;
783
784 void DoRun() override;
785
786 private:
789
796 void Receive(std::string context, Ptr<const Packet> p, const Address& adr);
797
804 void Transmit(std::string context, Ptr<const Packet> p, double power);
805};
806
808 : TestCase("Test case for fragmentation with QoS stations"),
809 m_received(0),
810 m_fragments(0)
811{
812}
813
815{
816}
817
818void
820{
821 if (p->GetSize() == 1400)
822 {
823 m_received++;
824 }
825}
826
827void
828QosFragmentationTestCase::Transmit(std::string context, Ptr<const Packet> p, double power)
829{
830 WifiMacHeader hdr;
831 p->PeekHeader(hdr);
832 if (hdr.IsQosData())
833 {
834 NS_TEST_EXPECT_MSG_LT_OR_EQ(p->GetSize(), 400, "Unexpected fragment size");
835 m_fragments++;
836 }
837}
838
839void
841{
842 NodeContainer wifiStaNode;
843 wifiStaNode.Create(1);
844
846 wifiApNode.Create(1);
847
848 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
850 phy.SetChannel(channel.Create());
851
853 wifi.SetStandard(WIFI_STANDARD_80211n);
854 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode", StringValue("HtMcs7"));
855
857 Ssid ssid = Ssid("ns-3-ssid");
858 mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid), "ActiveProbing", BooleanValue(false));
859
861 staDevices = wifi.Install(phy, mac, wifiStaNode);
862
863 mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid), "BeaconGeneration", BooleanValue(true));
864
866 apDevices = wifi.Install(phy, mac, wifiApNode);
867
869 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
870
871 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
872 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
873 mobility.SetPositionAllocator(positionAlloc);
874
875 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
876 mobility.Install(wifiApNode);
877 mobility.Install(wifiStaNode);
878
879 Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice>(apDevices.Get(0));
880 Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice>(staDevices.Get(0));
881
882 // set the TXOP limit on BE AC
883 PointerValue ptr;
884 sta_device->GetMac()->GetAttribute("BE_Txop", ptr);
885 ptr.Get<QosTxop>()->SetTxopLimit(MicroSeconds(3008));
886
887 PacketSocketAddress socket;
888 socket.SetSingleDevice(sta_device->GetIfIndex());
889 socket.SetPhysicalAddress(ap_device->GetAddress());
890 socket.SetProtocol(1);
891
892 // give packet socket powers to nodes.
893 PacketSocketHelper packetSocket;
894 packetSocket.Install(wifiStaNode);
895 packetSocket.Install(wifiApNode);
896
897 Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient>();
898 client->SetAttribute("PacketSize", UintegerValue(1400));
899 client->SetAttribute("MaxPackets", UintegerValue(1));
900 client->SetRemote(socket);
901 wifiStaNode.Get(0)->AddApplication(client);
902 client->SetStartTime(Seconds(1));
903 client->SetStopTime(Seconds(3.0));
904
905 Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer>();
906 server->SetLocal(socket);
907 wifiApNode.Get(0)->AddApplication(server);
908 server->SetStartTime(Seconds(0.0));
909 server->SetStopTime(Seconds(4.0));
910
911 Config::Connect("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx",
913
914 Config::Set("/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold",
915 StringValue("400"));
916 Config::Connect("/NodeList/0/DeviceList/0/Phy/PhyTxBegin",
918
919 Simulator::Stop(Seconds(5));
920 Simulator::Run();
921
922 Simulator::Destroy();
923
924 NS_TEST_ASSERT_MSG_EQ(m_received, 1, "Unexpected number of received packets");
925 NS_TEST_ASSERT_MSG_EQ(m_fragments, 4, "Unexpected number of transmitted fragments");
926}
927
935{
936 public:
938
939 void DoRun() override;
940
941 private:
948};
949
951 : TestCase("Test case for setting WifiPhy channel and frequency")
952{
953}
954
957{
958 Ptr<WifiNetDevice> wnd = nc.Get(0)->GetObject<WifiNetDevice>();
959 Ptr<WifiPhy> wp = wnd->GetPhy();
960 return wp->GetObject<YansWifiPhy>();
961}
962
963void
965{
966 NodeContainer wifiStaNode;
967 wifiStaNode.Create(1);
969 wifiApNode.Create(1);
970
971 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
973 phy.SetChannel(channel.Create());
974
975 // Configure and declare other generic components of this example
976 Ssid ssid;
977 ssid = Ssid("wifi-phy-configuration");
978 WifiMacHelper macSta;
979 macSta.SetType("ns3::StaWifiMac",
980 "Ssid",
982 "ActiveProbing",
983 BooleanValue(false));
984 NetDeviceContainer staDevice;
985 Ptr<YansWifiPhy> phySta;
986
987 // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
988 {
989 // case 0:
990 // Default configuration, without WifiHelper::SetStandard or WifiHelper
991 phySta = CreateObject<YansWifiPhy>();
992 // The default results in an invalid configuration
994 false,
995 "default configuration");
996 }
997 {
998 // case 1:
1000 wifi.SetStandard(WIFI_STANDARD_80211a);
1001 wifi.SetRemoteStationManager("ns3::ArfWifiManager");
1002 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1003 phySta = GetYansWifiPhyPtr(staDevice);
1004 // We expect channel 36, width 20, frequency 5180
1005 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 36, "default configuration");
1006 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "default configuration");
1007 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5180, "default configuration");
1008 }
1009 {
1010 // case 2:
1012 wifi.SetStandard(WIFI_STANDARD_80211b);
1013 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1014 phySta = GetYansWifiPhyPtr(staDevice);
1015 // We expect channel 1, width 22, frequency 2412
1016 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 1, "802.11b configuration");
1017 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 22, "802.11b configuration");
1018 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 2412, "802.11b configuration");
1019 }
1020 {
1021 // case 3:
1023 wifi.SetStandard(WIFI_STANDARD_80211g);
1024 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1025 phySta = GetYansWifiPhyPtr(staDevice);
1026 // We expect channel 1, width 20, frequency 2412
1027 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 1, "802.11g configuration");
1028 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11g configuration");
1029 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 2412, "802.11g configuration");
1030 }
1031 {
1032 // case 4:
1034 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1035 wifi.SetStandard(WIFI_STANDARD_80211n);
1036 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_5GHZ, 0}"));
1037 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1038 phySta = GetYansWifiPhyPtr(staDevice);
1039 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 36, "802.11n-5GHz configuration");
1040 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11n-5GHz configuration");
1041 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5180, "802.11n-5GHz configuration");
1042 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1043 }
1044 {
1045 // case 5:
1047 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1048 wifi.SetStandard(WIFI_STANDARD_80211n);
1049 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1050 phySta = GetYansWifiPhyPtr(staDevice);
1051 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 1, "802.11n-2.4GHz configuration");
1052 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11n-2.4GHz configuration");
1053 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 2412, "802.11n-2.4GHz configuration");
1054 }
1055 {
1056 // case 6:
1058 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1059 wifi.SetStandard(WIFI_STANDARD_80211ac);
1060 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1061 phySta = GetYansWifiPhyPtr(staDevice);
1062 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 42, "802.11ac configuration");
1063 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 80, "802.11ac configuration");
1064 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5210, "802.11ac configuration");
1065 }
1066 {
1067 // case 7:
1068 // By default, WifiHelper will use WIFI_PHY_STANDARD_80211ax
1070 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1071 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_2_4GHZ, 0}"));
1072 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1073 phySta = GetYansWifiPhyPtr(staDevice);
1074 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 1, "802.11ax-2.4GHz configuration");
1075 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11ax-2.4GHz configuration");
1076 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 2412, "802.11ax-2.4GHz configuration");
1077 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1078 }
1079 {
1080 // case 8:
1082 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1083 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1084 phySta = GetYansWifiPhyPtr(staDevice);
1085 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 42, "802.11ax-5GHz configuration");
1086 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 80, "802.11ax-5GHz configuration");
1087 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5210, "802.11ax-5GHz configuration");
1088 }
1089 {
1090 // case 9:
1092 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1093 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_6GHZ, 0}"));
1094 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1095 phySta = GetYansWifiPhyPtr(staDevice);
1096 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 7, "802.11ax-6GHz configuration");
1097 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 80, "802.11ax-6GHz configuration");
1098 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5975, "802.11ax-6GHz configuration");
1099 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1100 }
1101 {
1102 // case 10:
1104 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1105 wifi.SetStandard(WIFI_STANDARD_80211p);
1106 phy.Set("ChannelSettings", StringValue("{0, 10, BAND_5GHZ, 0}"));
1107 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1108 phySta = GetYansWifiPhyPtr(staDevice);
1109 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 172, "802.11p 10Mhz configuration");
1110 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 10, "802.11p 10Mhz configuration");
1111 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5860, "802.11p 10Mhz configuration");
1112 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1113 }
1114 {
1115 // case 11:
1117 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1118 wifi.SetStandard(WIFI_STANDARD_80211p);
1119 phy.Set("ChannelSettings", StringValue("{0, 5, BAND_5GHZ, 0}"));
1120 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1121 phySta = GetYansWifiPhyPtr(staDevice);
1122 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 171, "802.11p 5Mhz configuration");
1123 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 5, "802.11p 5Mhz configuration");
1124 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5860, "802.11p 5Mhz configuration");
1125 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1126 }
1127 {
1128 // case 12:
1130 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1131 wifi.SetStandard(WIFI_STANDARD_80211n);
1132 phy.Set("ChannelSettings", StringValue("{44, 20, BAND_5GHZ, 0}"));
1133 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1134 phySta = GetYansWifiPhyPtr(staDevice);
1135 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 44, "802.11 5GHz configuration");
1136 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1137 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5220, "802.11 5GHz configuration");
1138 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1139 }
1140 {
1141 // case 13:
1143 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1144 phy.Set("ChannelSettings", StringValue("{44, 0, BAND_5GHZ, 0}"));
1145 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1146 phySta = GetYansWifiPhyPtr(staDevice);
1147 // Post-install reconfiguration to channel number 40
1148 std::ostringstream path;
1149 path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex()
1150 << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings";
1151 Config::Set(path.str(), StringValue("{40, 0, BAND_5GHZ, 0}"));
1152 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 40, "802.11 5GHz configuration");
1153 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1154 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5200, "802.11 5GHz configuration");
1155 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1156 }
1157 {
1158 // case 14:
1160 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1161 phy.Set("ChannelSettings", StringValue("{44, 0, BAND_5GHZ, 0}"));
1162 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1163 phySta = GetYansWifiPhyPtr(staDevice);
1164 // Post-install reconfiguration to a 40 MHz channel
1165 std::ostringstream path;
1166 path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex()
1167 << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings";
1168 Config::Set(path.str(), StringValue("{46, 0, BAND_5GHZ, 0}"));
1169 // Although channel 44 is configured originally for 20 MHz, we
1170 // allow it to be used for 40 MHz here
1171 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 46, "802.11 5GHz configuration");
1172 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 40, "802.11 5GHz configuration");
1173 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5230, "802.11 5GHz configuration");
1174 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1175 }
1176 {
1177 // case 15:
1179 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1180 wifi.SetStandard(WIFI_STANDARD_80211n);
1181 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1182 phySta = GetYansWifiPhyPtr(staDevice);
1183 phySta->SetAttribute("ChannelSettings", StringValue("{3, 20, BAND_2_4GHZ, 0}"));
1184 return;
1185 // Post-install reconfiguration to a 40 MHz channel
1186 std::ostringstream path;
1187 path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex()
1188 << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings";
1189 Config::Set(path.str(), StringValue("{4, 40, BAND_2_4GHZ, 0}"));
1190 // Although channel 44 is configured originally for 20 MHz, we
1191 // allow it to be used for 40 MHz here
1192 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 4, "802.11 5GHz configuration");
1193 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 40, "802.11 5GHz configuration");
1194 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 2427, "802.11 5GHz configuration");
1195 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1196 }
1197 {
1198 // case 16:
1200 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1201 // Test that setting Frequency to a non-standard value will throw an exception
1202 wifi.SetStandard(WIFI_STANDARD_80211n);
1203 phy.Set("ChannelSettings", StringValue("{44, 0, BAND_5GHZ, 0}"));
1204 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1205 phySta = GetYansWifiPhyPtr(staDevice);
1206 bool exceptionThrown = false;
1207 try
1208 {
1209 phySta->SetAttribute("ChannelSettings", StringValue("{45, 0, BAND_5GHZ, 0}"));
1210 }
1211 catch (const std::runtime_error&)
1212 {
1213 exceptionThrown = true;
1214 }
1215 // We expect that an exception is thrown
1216 NS_TEST_ASSERT_MSG_EQ(exceptionThrown, true, "802.11 5GHz configuration");
1217 }
1218 {
1219 // case 17:
1221 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1222 wifi.SetStandard(WIFI_STANDARD_80211n);
1223 phy.Set("ChannelSettings", StringValue("{44, 0, BAND_5GHZ, 0}"));
1224 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1225 phySta = GetYansWifiPhyPtr(staDevice);
1226 // Test that setting channel to a standard value will set the
1227 // frequency correctly
1228 phySta->SetAttribute("ChannelSettings", StringValue("{100, 0, BAND_5GHZ, 0}"));
1229 // We expect frequency to be 5500 due to channel number being 100
1230 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 100, "802.11 5GHz configuration");
1231 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1232 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5500, "802.11 5GHz configuration");
1233 }
1234 {
1235 // case 18:
1236 // Set a wrong channel after initialization
1238 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1239 wifi.SetStandard(WIFI_STANDARD_80211n);
1240 phy.Set("ChannelSettings", StringValue("{44, 0, BAND_5GHZ, 0}"));
1241 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1242 phySta = GetYansWifiPhyPtr(staDevice);
1243 bool exceptionThrown = false;
1244 try
1245 {
1247 }
1248 catch (const std::runtime_error&)
1249 {
1250 exceptionThrown = true;
1251 }
1252 // We expect that an exception is thrown
1253 NS_TEST_ASSERT_MSG_EQ(exceptionThrown, true, "802.11 5GHz configuration");
1254 }
1255 {
1256 // case 19:
1258 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1259 // Test how channel number behaves when frequency is non-standard
1260 wifi.SetStandard(WIFI_STANDARD_80211n);
1261 phy.Set("ChannelSettings", StringValue("{44, 0, BAND_5GHZ, 0}"));
1262 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1263 phySta = GetYansWifiPhyPtr(staDevice);
1264 bool exceptionThrown = false;
1265 try
1266 {
1267 phySta->SetAttribute("ChannelSettings", StringValue("{45, 0, BAND_5GHZ, 0}"));
1268 }
1269 catch (const std::runtime_error&)
1270 {
1271 exceptionThrown = true;
1272 }
1273 // We expect that an exception is thrown due to unknown channel number 45
1274 NS_TEST_ASSERT_MSG_EQ(exceptionThrown, true, "802.11 5GHz configuration");
1275 phySta->SetAttribute("ChannelSettings", StringValue("{36, 0, BAND_5GHZ, 0}"));
1276 // We expect channel number to be 36 due to known center frequency 5180
1277 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 36, "802.11 5GHz configuration");
1278 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1279 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5180, "802.11 5GHz configuration");
1280 exceptionThrown = false;
1281 try
1282 {
1283 phySta->SetAttribute("ChannelSettings", StringValue("{43, 0, BAND_5GHZ, 0}"));
1284 }
1285 catch (const std::runtime_error&)
1286 {
1287 exceptionThrown = true;
1288 }
1289 // We expect that an exception is thrown due to unknown channel number 43
1290 NS_TEST_ASSERT_MSG_EQ(exceptionThrown, true, "802.11 5GHz configuration");
1291 phySta->SetAttribute("ChannelSettings", StringValue("{36, 0, BAND_5GHZ, 0}"));
1292 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 36, "802.11 5GHz configuration");
1293 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1294 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5180, "802.11 5GHz configuration");
1295 }
1296 {
1297 // case 20:
1299 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
1300 phy.Set("ChannelSettings", StringValue("{40, 0, BAND_5GHZ, 0}"));
1301 wifi.SetStandard(WIFI_STANDARD_80211n);
1302 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1303 phySta = GetYansWifiPhyPtr(staDevice);
1304 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 40, "802.11 5GHz configuration");
1305 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1306 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5200, "802.11 5GHz configuration");
1307 // Set both channel and frequency to consistent values after initialization
1308 wifi.SetStandard(WIFI_STANDARD_80211n);
1309 staDevice = wifi.Install(phy, macSta, wifiStaNode.Get(0));
1310 phySta = GetYansWifiPhyPtr(staDevice);
1311 phySta->SetAttribute("ChannelSettings", StringValue("{40, 0, BAND_5GHZ, 0}"));
1312 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 40, "802.11 5GHz configuration");
1313 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1314 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5200, "802.11 5GHz configuration");
1315
1316 phySta->SetAttribute("ChannelSettings", StringValue("{36, 0, BAND_5GHZ, 0}"));
1317 // We expect channel number to be 36
1318 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 36, "802.11 5GHz configuration");
1319 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1320 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5180, "802.11 5GHz configuration");
1321 phySta->SetAttribute("ChannelSettings", StringValue("{40, 0, BAND_5GHZ, 0}"));
1322 // We expect channel number to be 40
1323 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 40, "802.11 5GHz configuration");
1324 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1325 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5200, "802.11 5GHz configuration");
1326 bool exceptionThrown = false;
1327 try
1328 {
1329 phySta->SetAttribute("ChannelSettings", StringValue("{45, 0, BAND_5GHZ, 0}"));
1330 }
1331 catch (const std::runtime_error&)
1332 {
1333 exceptionThrown = true;
1334 }
1335 phySta->SetAttribute("ChannelSettings", StringValue("{36, 0, BAND_5GHZ, 0}"));
1336 // We expect channel number to be 36 and an exception to be thrown
1337 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 36, "802.11 5GHz configuration");
1338 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1339 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5180, "802.11 5GHz configuration");
1340 NS_TEST_ASSERT_MSG_EQ(exceptionThrown, true, "802.11 5GHz configuration");
1341 phySta->SetAttribute("ChannelSettings", StringValue("{36, 0, BAND_5GHZ, 0}"));
1342 exceptionThrown = false;
1343 try
1344 {
1345 phySta->SetAttribute("ChannelSettings", StringValue("{43, 0, BAND_5GHZ, 0}"));
1346 }
1347 catch (const std::runtime_error&)
1348 {
1349 exceptionThrown = true;
1350 }
1351 // We expect channel number to be 36 and an exception to be thrown
1352 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelNumber(), 36, "802.11 5GHz configuration");
1353 NS_TEST_ASSERT_MSG_EQ(phySta->GetChannelWidth(), 20, "802.11 5GHz configuration");
1354 NS_TEST_ASSERT_MSG_EQ(phySta->GetFrequency(), 5180, "802.11 5GHz configuration");
1355 NS_TEST_ASSERT_MSG_EQ(exceptionThrown, true, "802.11 5GHz configuration");
1356 }
1357
1358 Simulator::Destroy();
1359}
1360
1361//-----------------------------------------------------------------------------
1370{
1371 public:
1373 ~Bug2222TestCase() override;
1374
1375 void DoRun() override;
1376
1377 private:
1379
1385 void TxDataFailedTrace(std::string context, Mac48Address adr);
1386};
1387
1389 : TestCase("Test case for Bug 2222"),
1390 m_countInternalCollisions(0)
1391{
1392}
1393
1395{
1396}
1397
1398void
1400{
1401 // Indicate the long retry counter has been increased in the wifi remote station manager
1403}
1404
1405void
1407{
1409
1410 // Generate same backoff for AC_VI and AC_VO
1411 // The below combination will work
1412 RngSeedManager::SetSeed(1);
1413 RngSeedManager::SetRun(1);
1414 int64_t streamNumber = 100;
1415
1416 NodeContainer wifiNodes;
1417 wifiNodes.Create(2);
1418
1419 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
1421 phy.SetChannel(channel.Create());
1422
1424 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
1425 "DataMode",
1426 StringValue("OfdmRate54Mbps"),
1427 "ControlMode",
1428 StringValue("OfdmRate24Mbps"));
1430 Ssid ssid = Ssid("ns-3-ssid");
1431 mac.SetType("ns3::AdhocWifiMac", "QosSupported", BooleanValue(true));
1432
1433 NetDeviceContainer wifiDevices;
1434 wifiDevices = wifi.Install(phy, mac, wifiNodes);
1435
1436 // Assign fixed streams to random variables in use
1437 wifi.AssignStreams(wifiDevices, streamNumber);
1438
1440 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
1441
1442 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
1443 positionAlloc->Add(Vector(10.0, 0.0, 0.0));
1444 mobility.SetPositionAllocator(positionAlloc);
1445
1446 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
1447 mobility.Install(wifiNodes);
1448
1449 Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice>(wifiDevices.Get(0));
1450 Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice>(wifiDevices.Get(1));
1451
1452 PacketSocketAddress socket;
1453 socket.SetSingleDevice(device1->GetIfIndex());
1454 socket.SetPhysicalAddress(device2->GetAddress());
1455 socket.SetProtocol(1);
1456
1457 PacketSocketHelper packetSocket;
1458 packetSocket.Install(wifiNodes);
1459
1460 Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient>();
1461 clientLowPriority->SetAttribute("PacketSize", UintegerValue(1460));
1462 clientLowPriority->SetAttribute("MaxPackets", UintegerValue(1));
1463 clientLowPriority->SetAttribute("Priority", UintegerValue(4)); // AC_VI
1464 clientLowPriority->SetRemote(socket);
1465 wifiNodes.Get(0)->AddApplication(clientLowPriority);
1466 clientLowPriority->SetStartTime(Seconds(0.0));
1467 clientLowPriority->SetStopTime(Seconds(1.0));
1468
1469 Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient>();
1470 clientHighPriority->SetAttribute("PacketSize", UintegerValue(1460));
1471 clientHighPriority->SetAttribute("MaxPackets", UintegerValue(1));
1472 clientHighPriority->SetAttribute("Priority", UintegerValue(6)); // AC_VO
1473 clientHighPriority->SetRemote(socket);
1474 wifiNodes.Get(0)->AddApplication(clientHighPriority);
1475 clientHighPriority->SetStartTime(Seconds(0.0));
1476 clientHighPriority->SetStopTime(Seconds(1.0));
1477
1478 Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer>();
1479 server->SetLocal(socket);
1480 wifiNodes.Get(1)->AddApplication(server);
1481 server->SetStartTime(Seconds(0.0));
1482 server->SetStopTime(Seconds(1.0));
1483
1484 Config::Connect("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed",
1486
1487 Simulator::Stop(Seconds(1.0));
1488 Simulator::Run();
1489 Simulator::Destroy();
1490
1492 1,
1493 "unexpected number of internal collisions!");
1494}
1495
1496//-----------------------------------------------------------------------------
1510{
1511 public:
1513 ~Bug2843TestCase() override;
1514 void DoRun() override;
1515
1516 private:
1521 typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass>
1523 std::vector<FreqWidthSubbandModulationTuple>
1526
1533 void StoreDistinctTuple(std::string context, Ptr<SpectrumSignalParameters> txParams);
1540 void SendPacketBurst(uint8_t numPackets,
1541 Ptr<NetDevice> sourceDevice,
1542 Address& destination) const;
1543
1545};
1546
1548 : TestCase("Test case for Bug 2843"),
1549 m_channelWidth(20)
1550{
1551}
1552
1554{
1555}
1556
1557void
1559{
1560 // Extract starting frequency and number of subbands
1562 std::size_t numBands = c->GetNumBands();
1563 double startingFreq = c->Begin()->fl;
1564
1565 // Get channel bandwidth and modulation class
1567 DynamicCast<WifiSpectrumSignalParameters>(txParams);
1568
1569 Ptr<WifiPpdu> ppdu = wifiTxParams->ppdu->Copy();
1570 WifiTxVector txVector = ppdu->GetTxVector();
1571 m_channelWidth = txVector.GetChannelWidth();
1572 WifiModulationClass modulationClass = txVector.GetMode().GetModulationClass();
1573
1574 // Build a tuple and check if seen before (if so store it)
1575 FreqWidthSubbandModulationTuple tupleForCurrentTx =
1576 std::make_tuple(startingFreq, m_channelWidth, numBands, modulationClass);
1577 bool found = false;
1578 for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin();
1579 it != m_distinctTuples.end();
1580 it++)
1581 {
1582 if (*it == tupleForCurrentTx)
1583 {
1584 found = true;
1585 }
1586 }
1587 if (!found)
1588 {
1589 m_distinctTuples.push_back(tupleForCurrentTx);
1590 }
1591}
1592
1593void
1595 Ptr<NetDevice> sourceDevice,
1596 Address& destination) const
1597{
1598 for (uint8_t i = 0; i < numPackets; i++)
1599 {
1600 Ptr<Packet> pkt = Create<Packet>(1000); // 1000 dummy bytes of data
1601 sourceDevice->Send(pkt, destination, 0);
1602 }
1603}
1604
1605void
1607{
1608 uint16_t channelWidth = 40; // at least 40 MHz expected here
1609
1610 NodeContainer wifiStaNode;
1611 wifiStaNode.Create(1);
1612
1614 wifiApNode.Create(1);
1615
1616 SpectrumWifiPhyHelper spectrumPhy;
1617 Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel>();
1618 Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel>();
1619 lossModel->SetFrequency(5.190e9);
1620 spectrumChannel->AddPropagationLossModel(lossModel);
1621
1623 CreateObject<ConstantSpeedPropagationDelayModel>();
1624 spectrumChannel->SetPropagationDelayModel(delayModel);
1625
1626 spectrumPhy.SetChannel(spectrumChannel);
1627 spectrumPhy.SetErrorRateModel("ns3::NistErrorRateModel");
1628 spectrumPhy.Set("ChannelSettings", StringValue("{38, 40, BAND_5GHZ, 0}"));
1629 spectrumPhy.Set("TxPowerStart", DoubleValue(10));
1630 spectrumPhy.Set("TxPowerEnd", DoubleValue(10));
1631
1633 wifi.SetStandard(WIFI_STANDARD_80211ac);
1634 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
1635 "DataMode",
1636 StringValue("VhtMcs8"),
1637 "ControlMode",
1638 StringValue("VhtMcs8"),
1639 "RtsCtsThreshold",
1640 StringValue("500")); // so as to force RTS/CTS for data frames
1641
1643 mac.SetType("ns3::StaWifiMac");
1644 NetDeviceContainer staDevice;
1645 staDevice = wifi.Install(spectrumPhy, mac, wifiStaNode);
1646
1647 mac.SetType("ns3::ApWifiMac");
1648 NetDeviceContainer apDevice;
1649 apDevice = wifi.Install(spectrumPhy, mac, wifiApNode);
1650
1652 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
1653 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
1654 positionAlloc->Add(Vector(1.0, 0.0, 0.0)); // put close enough in order to use MCS
1655 mobility.SetPositionAllocator(positionAlloc);
1656
1657 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
1658 mobility.Install(wifiApNode);
1659 mobility.Install(wifiStaNode);
1660
1661 // Send two 5 packet-bursts
1662 Simulator::Schedule(Seconds(0.5),
1664 this,
1665 5,
1666 apDevice.Get(0),
1667 staDevice.Get(0)->GetAddress());
1668 Simulator::Schedule(Seconds(0.6),
1670 this,
1671 5,
1672 apDevice.Get(0),
1673 staDevice.Get(0)->GetAddress());
1674
1675 Config::Connect("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams",
1677
1678 Simulator::Stop(Seconds(0.8));
1679 Simulator::Run();
1680
1681 Simulator::Destroy();
1682
1683 // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type}
1684 // tuples
1685 std::size_t numberTuples = m_distinctTuples.size();
1686 NS_TEST_ASSERT_MSG_EQ(numberTuples, 2, "Only two distinct tuples expected");
1687 NS_TEST_ASSERT_MSG_EQ(std::get<0>(m_distinctTuples[0]) - 20e6,
1688 std::get<0>(m_distinctTuples[1]),
1689 "The starting frequency of the first tuple should be shifted 20 MHz to "
1690 "the right wrt second tuple");
1691 // Note that the first tuple should the one initiated by the beacon, i.e. non-HT OFDM (20 MHz)
1693 20,
1694 "First tuple's channel width should be 20 MHz");
1696 193,
1697 "First tuple should have 193 subbands (64+DC, 20MHz+DC, inband and 64*2 "
1698 "out-of-band, 20MHz on each side)");
1701 "First tuple should be OFDM");
1702 // Second tuple
1704 channelWidth,
1705 "Second tuple's channel width should be 40 MHz");
1707 385,
1708 "Second tuple should have 385 subbands (128+DC, 40MHz+DC, inband and "
1709 "128*2 out-of-band, 40MHz on each side)");
1712 "Second tuple should be VHT_OFDM");
1713}
1714
1715//-----------------------------------------------------------------------------
1728{
1729 public:
1731 ~Bug2831TestCase() override;
1732 void DoRun() override;
1733
1734 private:
1745 void RxCallback(std::string context, Ptr<const Packet> p, RxPowerWattPerChannelBand rxPowersW);
1746
1749
1756};
1757
1759 : TestCase("Test case for Bug 2831"),
1760 m_assocReqCount(0),
1761 m_assocRespCount(0),
1762 m_countOperationalChannelWidth20(0),
1763 m_countOperationalChannelWidth40(0)
1764{
1765}
1766
1768{
1769}
1770
1771void
1773{
1776}
1777
1778void
1781 RxPowerWattPerChannelBand rxPowersW)
1782{
1783 Ptr<Packet> packet = p->Copy();
1784 WifiMacHeader hdr;
1785 packet->RemoveHeader(hdr);
1786 if (hdr.IsAssocReq())
1787 {
1789 }
1790 else if (hdr.IsAssocResp())
1791 {
1793 }
1794 else if (hdr.IsBeacon())
1795 {
1796 MgtBeaconHeader beacon;
1797 packet->RemoveHeader(beacon);
1798 const auto& htOperation = beacon.GetHtOperation();
1799 if (htOperation.has_value() && htOperation->GetStaChannelWidth() > 0)
1800 {
1802 }
1803 else
1804 {
1806 }
1807 }
1808}
1809
1810void
1812{
1813 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel>();
1814 ObjectFactory propDelay;
1815 propDelay.SetTypeId("ns3::ConstantSpeedPropagationDelayModel");
1816 Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel>();
1817 Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel>();
1818 channel->SetPropagationDelayModel(propagationDelay);
1819 channel->SetPropagationLossModel(propagationLoss);
1820
1821 Ptr<Node> apNode = CreateObject<Node>();
1822 Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice>();
1823 apNode->AddDevice(apDev);
1825 Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration>();
1826 apDev->SetHtConfiguration(apHtConfiguration);
1827 ObjectFactory manager;
1828 manager.SetTypeId("ns3::ConstantRateWifiManager");
1830
1831 auto apMobility = CreateObject<ConstantPositionMobilityModel>();
1832 apMobility->SetPosition(Vector(0.0, 0.0, 0.0));
1833 apNode->AggregateObject(apMobility);
1834
1835 auto error = CreateObject<YansErrorRateModel>();
1836 m_apPhy = CreateObject<YansWifiPhy>();
1837 apDev->SetPhy(m_apPhy);
1838 Ptr<InterferenceHelper> apInterferenceHelper = CreateObject<InterferenceHelper>();
1839 m_apPhy->SetInterferenceHelper(apInterferenceHelper);
1840 m_apPhy->SetErrorRateModel(error);
1842 m_apPhy->SetMobility(apMobility);
1843 m_apPhy->SetDevice(apDev);
1846
1848 mac.SetTypeId("ns3::ApWifiMac");
1849 mac.Set("EnableBeaconJitter", BooleanValue(false));
1850 mac.Set("QosSupported", BooleanValue(true));
1851 Ptr<WifiMac> apMac = mac.Create<WifiMac>();
1852 apMac->SetDevice(apDev);
1853 apMac->SetAddress(Mac48Address::Allocate());
1854 apDev->SetMac(apMac);
1855 apMac->ConfigureStandard(WIFI_STANDARD_80211ax);
1856 apMac->SetMacQueueScheduler(CreateObject<FcfsWifiQueueScheduler>());
1857 Ptr<FrameExchangeManager> fem = apMac->GetFrameExchangeManager();
1858 Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager>();
1859 protectionManager->SetWifiMac(apMac);
1860 fem->SetProtectionManager(protectionManager);
1861 Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager>();
1862 ackManager->SetWifiMac(apMac);
1863 fem->SetAckManager(ackManager);
1864
1865 Ptr<Node> staNode = CreateObject<Node>();
1866 Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice>();
1867 staNode->AddDevice(staDev);
1869 Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration>();
1870 staDev->SetHtConfiguration(staHtConfiguration);
1872
1873 Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel>();
1874 staMobility->SetPosition(Vector(1.0, 0.0, 0.0));
1875 staNode->AggregateObject(staMobility);
1876
1877 m_staPhy = CreateObject<YansWifiPhy>();
1878 staDev->SetPhy(m_staPhy);
1879 Ptr<InterferenceHelper> staInterferenceHelper = CreateObject<InterferenceHelper>();
1880 m_staPhy->SetInterferenceHelper(staInterferenceHelper);
1883 m_staPhy->SetMobility(staMobility);
1884 m_staPhy->SetDevice(apDev);
1887
1888 mac.SetTypeId("ns3::StaWifiMac");
1889 auto staMac = mac.Create<WifiMac>();
1890 staDev->SetMac(staMac);
1891 staMac->SetDevice(staDev);
1892 staMac->SetAddress(Mac48Address::Allocate());
1893 staMac->ConfigureStandard(WIFI_STANDARD_80211ax);
1894 StaticCast<StaWifiMac>(staMac)->SetAssocManager(CreateObject<WifiDefaultAssocManager>());
1895 staMac->SetMacQueueScheduler(CreateObject<FcfsWifiQueueScheduler>());
1896 fem = staMac->GetFrameExchangeManager();
1897 protectionManager = CreateObject<WifiDefaultProtectionManager>();
1898 protectionManager->SetWifiMac(staMac);
1899 fem->SetProtectionManager(protectionManager);
1900 ackManager = CreateObject<WifiDefaultAckManager>();
1901 ackManager->SetWifiMac(staMac);
1902 fem->SetAckManager(ackManager);
1903
1904 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin",
1906
1907 Simulator::Schedule(Seconds(1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1908
1909 Simulator::Stop(Seconds(3.0));
1910 Simulator::Run();
1911 Simulator::Destroy();
1912
1913 NS_TEST_ASSERT_MSG_EQ(m_assocReqCount, 2, "Second Association request not received");
1914 NS_TEST_ASSERT_MSG_EQ(m_assocRespCount, 2, "Second Association response not received");
1916 10,
1917 "Incorrect operational channel width before channel change");
1919 20,
1920 "Incorrect operational channel width after channel change");
1921}
1922
1923//-----------------------------------------------------------------------------
1940{
1941 public:
1943 ~StaWifiMacScanningTestCase() override;
1944 void DoRun() override;
1945
1946 private:
1952 void AssocCallback(std::string context, Mac48Address bssid);
1957 void TurnBeaconGenerationOn(Ptr<Node> apNode);
1962 void TurnApOff(Ptr<Node> apNode);
1969 NodeContainer Setup(bool nearestApBeaconGeneration, bool staActiveProbe);
1970
1972};
1973
1975 : TestCase("Test case for StaWifiMac scanning capability")
1976{
1977}
1978
1980{
1981}
1982
1983void
1985{
1986 m_associatedApBssid = bssid;
1987}
1988
1989void
1991{
1992 Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice>(apNode->GetDevice(0));
1993 Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac>(netDevice->GetMac());
1994 mac->SetAttribute("BeaconGeneration", BooleanValue(true));
1995}
1996
1997void
1999{
2000 Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice>(apNode->GetDevice(0));
2001 Ptr<WifiPhy> phy = netDevice->GetPhy();
2002 phy->SetOffMode();
2003}
2004
2006StaWifiMacScanningTestCase::Setup(bool nearestApBeaconGeneration, bool staActiveProbe)
2007{
2008 RngSeedManager::SetSeed(1);
2009 RngSeedManager::SetRun(1);
2010 int64_t streamNumber = 1;
2011
2012 NodeContainer apNodes;
2013 apNodes.Create(2);
2014
2015 Ptr<Node> apNodeNearest = CreateObject<Node>();
2016 Ptr<Node> staNode = CreateObject<Node>();
2017
2019 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
2020 phy.SetChannel(channel.Create());
2021
2023 wifi.SetStandard(WIFI_STANDARD_80211n);
2024 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager");
2025
2027 NetDeviceContainer apDevice;
2028 NetDeviceContainer apDeviceNearest;
2029 mac.SetType("ns3::ApWifiMac", "BeaconGeneration", BooleanValue(true));
2030 apDevice = wifi.Install(phy, mac, apNodes);
2031 mac.SetType("ns3::ApWifiMac", "BeaconGeneration", BooleanValue(nearestApBeaconGeneration));
2032 apDeviceNearest = wifi.Install(phy, mac, apNodeNearest);
2033
2034 NetDeviceContainer staDevice;
2035 mac.SetType("ns3::StaWifiMac", "ActiveProbing", BooleanValue(staActiveProbe));
2036 staDevice = wifi.Install(phy, mac, staNode);
2037
2038 // Assign fixed streams to random variables in use
2039 wifi.AssignStreams(apDevice, streamNumber);
2040 wifi.AssignStreams(apDeviceNearest, streamNumber + 1);
2041 wifi.AssignStreams(staDevice, streamNumber + 2);
2042
2044 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
2045 positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // Furthest AP
2046 positionAlloc->Add(Vector(10.0, 0.0, 0.0)); // Second nearest AP
2047 positionAlloc->Add(Vector(5.0, 5.0, 0.0)); // Nearest AP
2048 positionAlloc->Add(Vector(6.0, 5.0, 0.0)); // STA
2049 mobility.SetPositionAllocator(positionAlloc);
2050
2051 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
2052 mobility.Install(apNodes);
2053 mobility.Install(apNodeNearest);
2054 mobility.Install(staNode);
2055
2056 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc",
2058
2059 NodeContainer allNodes = NodeContainer(apNodes, apNodeNearest, staNode);
2060 return allNodes;
2061}
2062
2063void
2065{
2066 {
2067 NodeContainer nodes = Setup(false, false);
2068 Ptr<Node> nearestAp = nodes.Get(2);
2069 Mac48Address nearestApAddr =
2070 DynamicCast<WifiNetDevice>(nearestAp->GetDevice(0))->GetMac()->GetAddress();
2071
2072 Simulator::Schedule(Seconds(0.05),
2074 this,
2075 nearestAp);
2076
2077 Simulator::Stop(Seconds(0.2));
2078 Simulator::Run();
2079 Simulator::Destroy();
2080
2082 nearestApAddr,
2083 "STA is associated to the wrong AP");
2084 }
2086 {
2087 NodeContainer nodes = Setup(true, true);
2088 Ptr<Node> nearestAp = nodes.Get(2);
2089 Mac48Address nearestApAddr =
2090 DynamicCast<WifiNetDevice>(nearestAp->GetDevice(0))->GetMac()->GetAddress();
2091
2092 Simulator::Stop(Seconds(0.2));
2093 Simulator::Run();
2094 Simulator::Destroy();
2095
2097 nearestApAddr,
2098 "STA is associated to the wrong AP");
2099 }
2101 {
2102 NodeContainer nodes = Setup(true, false);
2103 Ptr<Node> nearestAp = nodes.Get(2);
2104 Mac48Address secondNearestApAddr =
2105 DynamicCast<WifiNetDevice>(nodes.Get(1)->GetDevice(0))->GetMac()->GetAddress();
2106
2107 Simulator::Schedule(Seconds(0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
2108
2109 Simulator::Stop(Seconds(1.5));
2110 Simulator::Run();
2111 Simulator::Destroy();
2112
2114 secondNearestApAddr,
2115 "STA is associated to the wrong AP");
2116 }
2117}
2118
2119//-----------------------------------------------------------------------------
2143{
2144 public:
2146 ~Bug2470TestCase() override;
2147 void DoRun() override;
2148
2149 private:
2158 void AddbaStateChangedCallback(std::string context,
2159 Time t,
2160 Mac48Address recipient,
2161 uint8_t tid,
2173 void RxCallback(std::string context,
2175 uint16_t channelFreqMhz,
2176 WifiTxVector txVector,
2177 MpduInfo aMpdu,
2178 SignalNoiseDbm signalNoise,
2179 uint16_t staId);
2186 void RxErrorCallback(std::string context, Ptr<const Packet> p, double snr);
2193 void SendPacketBurst(uint32_t numPackets,
2194 Ptr<NetDevice> sourceDevice,
2195 Address& destination) const;
2201 void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel);
2202
2209 uint16_t
2211 uint16_t
2214};
2215
2217 : TestCase("Test case for Bug 2470"),
2218 m_receivedNormalMpduCount(0),
2219 m_receivedAmpduCount(0),
2220 m_failedActionCount(0),
2221 m_addbaEstablishedCount(0),
2222 m_addbaPendingCount(0),
2223 m_addbaRejectedCount(0),
2224 m_addbaNoReplyCount(0),
2225 m_addbaResetCount(0)
2226{
2227}
2228
2230{
2231}
2232
2233void
2235 Time t,
2236 Mac48Address recipient,
2237 uint8_t tid,
2239{
2240 switch (state)
2241 {
2242 case OriginatorBlockAckAgreement::ESTABLISHED:
2244 break;
2245 case OriginatorBlockAckAgreement::PENDING:
2247 break;
2248 case OriginatorBlockAckAgreement::REJECTED:
2250 break;
2251 case OriginatorBlockAckAgreement::NO_REPLY:
2253 break;
2254 case OriginatorBlockAckAgreement::RESET:
2256 break;
2257 }
2258}
2259
2260void
2263 uint16_t channelFreqMhz,
2264 WifiTxVector txVector,
2265 MpduInfo aMpdu,
2266 SignalNoiseDbm signalNoise,
2267 uint16_t staId)
2268{
2269 Ptr<Packet> packet = p->Copy();
2270 if (aMpdu.type != MpduType::NORMAL_MPDU)
2271 {
2273 }
2274 else
2275 {
2276 WifiMacHeader hdr;
2277 packet->RemoveHeader(hdr);
2278 if (hdr.IsData())
2279 {
2281 }
2282 }
2283}
2284
2285void
2286Bug2470TestCase::RxErrorCallback(std::string context, Ptr<const Packet> p, double snr)
2287{
2288 Ptr<Packet> packet = p->Copy();
2289 WifiMacHeader hdr;
2290 packet->RemoveHeader(hdr);
2291 if (hdr.IsAction())
2292 {
2294 }
2295}
2296
2297void
2299 Ptr<NetDevice> sourceDevice,
2300 Address& destination) const
2301{
2302 for (uint32_t i = 0; i < numPackets; i++)
2303 {
2304 Ptr<Packet> pkt = Create<Packet>(1000); // 1000 dummy bytes of data
2305 sourceDevice->Send(pkt, destination, 0);
2306 }
2307}
2308
2309void
2311{
2312 RngSeedManager::SetSeed(1);
2313 RngSeedManager::SetRun(1);
2314 int64_t streamNumber = 200;
2315
2317 NodeContainer wifiStaNode;
2318 wifiApNode.Create(1);
2319 wifiStaNode.Create(1);
2320
2322 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
2323 phy.SetChannel(channel.Create());
2324
2326 wifi.SetStandard(WIFI_STANDARD_80211n);
2327 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
2328 "DataMode",
2329 StringValue("HtMcs7"),
2330 "ControlMode",
2331 StringValue("HtMcs7"));
2332
2334 NetDeviceContainer apDevice;
2335 phy.Set("PostReceptionErrorModel", apErrorModel);
2336 phy.Set("ChannelSettings", StringValue("{36, 20, BAND_5GHZ, 0}"));
2337 mac.SetType("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue(false));
2338 apDevice = wifi.Install(phy, mac, wifiApNode);
2339
2340 NetDeviceContainer staDevice;
2341 phy.Set("PostReceptionErrorModel", staErrorModel);
2342 mac.SetType("ns3::StaWifiMac");
2343 staDevice = wifi.Install(phy, mac, wifiStaNode);
2344
2345 // Assign fixed streams to random variables in use
2346 wifi.AssignStreams(apDevice, streamNumber);
2347 wifi.AssignStreams(staDevice, streamNumber);
2348
2350 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
2351 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
2352 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
2353 mobility.SetPositionAllocator(positionAlloc);
2354
2355 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
2356 mobility.Install(wifiApNode);
2357 mobility.Install(wifiStaNode);
2358
2360 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx",
2362 Config::Connect("/NodeList/*/DeviceList/*/Phy/State/RxError",
2364 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/BE_Txop/"
2365 "BlockAckManager/AgreementState",
2367
2368 Simulator::Schedule(Seconds(0.5),
2370 this,
2371 1,
2372 apDevice.Get(0),
2373 staDevice.Get(0)->GetAddress());
2374 Simulator::Schedule(Seconds(0.5) + MicroSeconds(5),
2376 this,
2377 4,
2378 apDevice.Get(0),
2379 staDevice.Get(0)->GetAddress());
2380 Simulator::Schedule(Seconds(0.8),
2382 this,
2383 1,
2384 apDevice.Get(0),
2385 staDevice.Get(0)->GetAddress());
2386 Simulator::Schedule(Seconds(0.8) + MicroSeconds(5),
2388 this,
2389 4,
2390 apDevice.Get(0),
2391 staDevice.Get(0)->GetAddress());
2392
2393 Simulator::Stop(Seconds(1.0));
2394 Simulator::Run();
2395 Simulator::Destroy();
2396}
2397
2398void
2400{
2401 // Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel
2402 // instead of ListErrorModel since packet UID is incremented between simulations. But
2403 // problem may occur because of random stream, therefore we suppress usage of RNG as
2404 // much as possible (i.e., removing beacon jitter).
2405 Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel>();
2406 std::list<uint32_t> blackList;
2407 // Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the ADDBA
2408 // response timeout interval)
2409 blackList.push_back(9);
2410 blackList.push_back(10);
2411 blackList.push_back(11);
2412 blackList.push_back(12);
2413 blackList.push_back(13);
2414 blackList.push_back(14);
2415 staPem->SetList(blackList);
2416
2417 {
2419 NS_TEST_ASSERT_MSG_EQ(m_failedActionCount, 6, "ADDBA request packets are not failed");
2420 // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by
2421 // normal MPDU because of failed ADDBA handshake. For the second set, the first packet
2422 // should be sent by normal MPDU, and the rest with A-MPDU. In total we expect to receive 2
2423 // normal MPDU packets and 8 A-MPDU packets.
2425 2,
2426 "Receiving incorrect number of normal MPDU packet on subtest 1");
2428 8,
2429 "Receiving incorrect number of A-MPDU packet on subtest 1");
2430
2432 1,
2433 "Incorrect number of times the ADDBA state machine was in "
2434 "established state on subtest 1");
2437 1,
2438 "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2441 0,
2442 "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2445 0,
2446 "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2449 0,
2450 "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2451 }
2452
2461
2462 Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel>();
2463 blackList.clear();
2464 // Block ADDBA request 4 times (== maximum number of MAC frame transmissions in the ADDBA
2465 // response timeout interval)
2466 blackList.push_back(5);
2467 blackList.push_back(6);
2468 blackList.push_back(7);
2469 blackList.push_back(9);
2470 apPem->SetList(blackList);
2471
2472 {
2474 NS_TEST_ASSERT_MSG_EQ(m_failedActionCount, 4, "ADDBA response packets are not failed");
2475 // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU
2476 // packets.
2478 6,
2479 "Receiving incorrect number of normal MPDU packet on subtest 2");
2481 4,
2482 "Receiving incorrect number of A-MPDU packet on subtest 2");
2483
2485 1,
2486 "Incorrect number of times the ADDBA state machine was in "
2487 "established state on subtest 2");
2490 1,
2491 "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2494 0,
2495 "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2498 1,
2499 "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2502 0,
2503 "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2504 }
2505
2506 // TODO: In the second test set, it does not go to reset state since ADDBA response is received
2507 // after timeout (NO_REPLY) but before it does not enter RESET state. More tests should be
2508 // written to verify all possible scenarios.
2509}
2510
2511//-----------------------------------------------------------------------------
2527{
2528 public:
2530 ~Issue40TestCase() override;
2531 void DoRun() override;
2532
2533 private:
2538 void RunOne(bool useAmpdu);
2539
2545 void RxSuccessCallback(std::string context, Ptr<const Packet> p);
2552 void SendPackets(uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination);
2558 void TxFinalDataFailedCallback(std::string context, Mac48Address address);
2559
2560 uint16_t m_rxCount;
2561 uint16_t m_txCount;
2562 uint16_t
2564};
2565
2567 : TestCase("Test case for issue #40"),
2568 m_rxCount(0),
2569 m_txCount(0),
2570 m_txMacFinalDataFailedCount(0)
2571{
2572}
2573
2575{
2576}
2577
2578void
2580{
2581 m_rxCount++;
2582}
2583
2584void
2585Issue40TestCase::SendPackets(uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination)
2586{
2587 for (uint8_t i = 0; i < numPackets; i++)
2588 {
2589 Ptr<Packet> pkt = Create<Packet>(1000); // 1000 dummy bytes of data
2590 sourceDevice->Send(pkt, destination, 0);
2591 m_txCount++;
2592 }
2593}
2594
2595void
2597{
2599}
2600
2601void
2603{
2604 m_rxCount = 0;
2605 m_txCount = 0;
2607
2608 RngSeedManager::SetSeed(1);
2609 RngSeedManager::SetRun(1);
2610 int64_t streamNumber = 100;
2611
2613 NodeContainer wifiStaNode;
2614 wifiApNode.Create(1);
2615 wifiStaNode.Create(1);
2616
2618 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
2619 phy.SetChannel(channel.Create());
2620
2622 wifi.SetStandard(WIFI_STANDARD_80211ac);
2623 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
2624
2626 NetDeviceContainer apDevice;
2627 mac.SetType("ns3::ApWifiMac");
2628 apDevice = wifi.Install(phy, mac, wifiApNode);
2629
2630 NetDeviceContainer staDevice;
2631 mac.SetType("ns3::StaWifiMac");
2632 staDevice = wifi.Install(phy, mac, wifiStaNode);
2633
2634 // Assign fixed streams to random variables in use
2635 wifi.AssignStreams(apDevice, streamNumber);
2636 wifi.AssignStreams(staDevice, streamNumber);
2637
2639 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
2640 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
2641 positionAlloc->Add(Vector(10.0, 0.0, 0.0));
2642 mobility.SetPositionAllocator(positionAlloc);
2643
2644 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
2645 mobility.Install(wifiApNode);
2646
2647 mobility.SetMobilityModel("ns3::WaypointMobilityModel");
2648 mobility.Install(wifiStaNode);
2649
2650 Config::Connect("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxFinalDataFailed",
2652 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/MacRx",
2654
2655 Ptr<WaypointMobilityModel> staWaypointMobility =
2656 DynamicCast<WaypointMobilityModel>(wifiStaNode.Get(0)->GetObject<MobilityModel>());
2657 staWaypointMobility->AddWaypoint(Waypoint(Seconds(1.0), Vector(10.0, 0.0, 0.0)));
2658 staWaypointMobility->AddWaypoint(Waypoint(Seconds(1.5), Vector(50.0, 0.0, 0.0)));
2659
2660 if (useAmpdu)
2661 {
2662 // Disable use of BAR that are sent with the lowest modulation so that we can also reproduce
2663 // the problem with A-MPDU, i.e. the lack of feedback about SNR change
2664 Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice>(apDevice.Get(0));
2665 PointerValue ptr;
2666 ap_device->GetMac()->GetAttribute("BE_Txop", ptr);
2667 ptr.Get<QosTxop>()->SetAttribute("UseExplicitBarAfterMissedBlockAck", BooleanValue(false));
2668 }
2669
2670 // Transmit a first data packet before the station moves: it should be sent with a high
2671 // modulation and successfully received
2672 Simulator::Schedule(Seconds(0.5),
2674 this,
2675 useAmpdu ? 2 : 1,
2676 apDevice.Get(0),
2677 staDevice.Get(0)->GetAddress());
2678
2679 // Transmit a second data packet once the station is away from the access point: it should be
2680 // sent with the same high modulation and be unsuccessfully received
2681 Simulator::Schedule(Seconds(2.0),
2683 this,
2684 useAmpdu ? 2 : 1,
2685 apDevice.Get(0),
2686 staDevice.Get(0)->GetAddress());
2687
2688 // Keep on transmitting data packets while the station is away from the access point: it should
2689 // be sent with a lower modulation and be successfully received
2690 Simulator::Schedule(Seconds(2.1),
2692 this,
2693 useAmpdu ? 2 : 1,
2694 apDevice.Get(0),
2695 staDevice.Get(0)->GetAddress());
2696 Simulator::Schedule(Seconds(2.2),
2698 this,
2699 useAmpdu ? 2 : 1,
2700 apDevice.Get(0),
2701 staDevice.Get(0)->GetAddress());
2702 Simulator::Schedule(Seconds(2.3),
2704 this,
2705 useAmpdu ? 2 : 1,
2706 apDevice.Get(0),
2707 staDevice.Get(0)->GetAddress());
2708 Simulator::Schedule(Seconds(2.4),
2710 this,
2711 useAmpdu ? 2 : 1,
2712 apDevice.Get(0),
2713 staDevice.Get(0)->GetAddress());
2714 Simulator::Schedule(Seconds(2.5),
2716 this,
2717 useAmpdu ? 2 : 1,
2718 apDevice.Get(0),
2719 staDevice.Get(0)->GetAddress());
2720
2721 Simulator::Stop(Seconds(3.0));
2722 Simulator::Run();
2723
2725 (useAmpdu ? 14 : 7),
2726 "Incorrect number of transmitted packets");
2728 (useAmpdu ? 12 : 6),
2729 "Incorrect number of successfully received packets");
2730 NS_TEST_ASSERT_MSG_EQ(m_txMacFinalDataFailedCount, 1, "Incorrect number of dropped TX packets");
2731
2732 Simulator::Destroy();
2733}
2734
2735void
2737{
2738 // Test without A-MPDU
2739 RunOne(false);
2740
2741 // Test with A-MPDU
2742 RunOne(true);
2743}
2744
2745//-----------------------------------------------------------------------------
2759{
2760 public:
2762 ~Issue169TestCase() override;
2763 void DoRun() override;
2764
2765 private:
2773 void SendPackets(uint8_t numPackets,
2774 Ptr<NetDevice> sourceDevice,
2775 Address& destination,
2776 uint8_t priority);
2777
2785 void TxCallback(std::string context,
2786 WifiConstPsduMap psdus,
2787 WifiTxVector txVector,
2788 double txPowerW);
2789};
2790
2792 : TestCase("Test case for issue #169")
2793{
2794}
2795
2797{
2798}
2799
2800void
2802 Ptr<NetDevice> sourceDevice,
2803 Address& destination,
2804 uint8_t priority)
2805{
2806 SocketPriorityTag priorityTag;
2807 priorityTag.SetPriority(priority);
2808 for (uint8_t i = 0; i < numPackets; i++)
2809 {
2810 Ptr<Packet> packet = Create<Packet>(1000); // 1000 dummy bytes of data
2811 packet->AddPacketTag(priorityTag);
2812 sourceDevice->Send(packet, destination, 0);
2813 }
2814}
2815
2816void
2818 WifiConstPsduMap psdus,
2819 WifiTxVector txVector,
2820 double txPowerW)
2821{
2822 if (psdus.begin()->second->GetSize() >= 1000)
2823 {
2826 "Ideal rate manager selected incorrect modulation class");
2827 }
2828}
2829
2830void
2832{
2833 RngSeedManager::SetSeed(1);
2834 RngSeedManager::SetRun(1);
2835 int64_t streamNumber = 100;
2836
2838 NodeContainer wifiStaNode;
2839 wifiApNode.Create(1);
2840 wifiStaNode.Create(1);
2841
2843 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
2844 phy.SetChannel(channel.Create());
2845
2847 wifi.SetStandard(WIFI_STANDARD_80211ac);
2848 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
2849
2851 NetDeviceContainer apDevice;
2852 mac.SetType("ns3::ApWifiMac");
2853 apDevice = wifi.Install(phy, mac, wifiApNode);
2854
2855 NetDeviceContainer staDevice;
2856 mac.SetType("ns3::StaWifiMac");
2857 staDevice = wifi.Install(phy, mac, wifiStaNode);
2858
2859 // Assign fixed streams to random variables in use
2860 wifi.AssignStreams(apDevice, streamNumber);
2861 wifi.AssignStreams(staDevice, streamNumber);
2862
2864 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
2865 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
2866 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
2867 mobility.SetPositionAllocator(positionAlloc);
2868
2869 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
2870 mobility.Install(wifiApNode);
2871 mobility.Install(wifiStaNode);
2872
2873 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin",
2875
2876 // Send best-effort packet (i.e. priority 0)
2877 Simulator::Schedule(Seconds(0.5),
2879 this,
2880 1,
2881 apDevice.Get(0),
2882 staDevice.Get(0)->GetAddress(),
2883 0);
2884
2885 // Send non best-effort (voice) packet (i.e. priority 6)
2886 Simulator::Schedule(Seconds(1.0),
2888 this,
2889 1,
2890 apDevice.Get(0),
2891 staDevice.Get(0)->GetAddress(),
2892 6);
2893
2894 Simulator::Stop(Seconds(2.0));
2895 Simulator::Run();
2896
2897 Simulator::Destroy();
2898}
2899
2900//-----------------------------------------------------------------------------
2916{
2917 public:
2920 void DoRun() override;
2921
2922 private:
2927 void ChangeChannelWidth(uint16_t channelWidth);
2928
2934 void SendPacket(Ptr<NetDevice> sourceDevice, Address& destination);
2935
2943 void TxCallback(std::string context,
2944 WifiConstPsduMap psduMap,
2945 WifiTxVector txVector,
2946 double txPowerW);
2947
2952 void CheckLastSelectedMode(WifiMode expectedMode);
2953
2955};
2956
2958 : TestCase("Test case for use of channel bonding with Ideal rate manager")
2959{
2960}
2961
2963{
2964}
2965
2966void
2968{
2969 Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelSettings",
2970 StringValue("{0, " + std::to_string(channelWidth) + ", BAND_5GHZ, 0}"));
2971}
2972
2973void
2975{
2976 Ptr<Packet> packet = Create<Packet>(1000);
2977 sourceDevice->Send(packet, destination, 0);
2978}
2979
2980void
2982 WifiConstPsduMap psduMap,
2983 WifiTxVector txVector,
2984 double txPowerW)
2985{
2986 if (psduMap.begin()->second->GetSize() >= 1000)
2987 {
2988 m_txMode = txVector.GetMode();
2989 }
2990}
2991
2992void
2994{
2996 expectedMode,
2997 "Last selected WifiMode "
2998 << m_txMode << " does not match expected WifiMode " << expectedMode);
2999}
3000
3001void
3003{
3004 RngSeedManager::SetSeed(1);
3005 RngSeedManager::SetRun(1);
3006 int64_t streamNumber = 100;
3007
3009 NodeContainer wifiStaNode;
3010 wifiApNode.Create(1);
3011 wifiStaNode.Create(1);
3012
3014 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
3015 phy.SetChannel(channel.Create());
3016
3018 wifi.SetStandard(WIFI_STANDARD_80211ac);
3019 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
3020
3022 NetDeviceContainer apDevice;
3023 mac.SetType("ns3::ApWifiMac");
3024 apDevice = wifi.Install(phy, mac, wifiApNode);
3025
3026 NetDeviceContainer staDevice;
3027 mac.SetType("ns3::StaWifiMac");
3028 staDevice = wifi.Install(phy, mac, wifiStaNode);
3029
3030 // Assign fixed streams to random variables in use
3031 wifi.AssignStreams(apDevice, streamNumber);
3032 wifi.AssignStreams(staDevice, streamNumber);
3033
3035 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
3036 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
3037 positionAlloc->Add(Vector(50.0, 0.0, 0.0));
3038 mobility.SetPositionAllocator(positionAlloc);
3039
3040 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
3041 mobility.Install(wifiApNode);
3042 mobility.Install(wifiStaNode);
3043
3044 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin",
3046
3047 // Set channel width to 80 MHz & send packet
3048 Simulator::Schedule(Seconds(0.5),
3050 this,
3051 80);
3052 Simulator::Schedule(Seconds(1.0),
3054 this,
3055 apDevice.Get(0),
3056 staDevice.Get(0)->GetAddress());
3057 // Selected rate should be VHT-MCS 1
3058 Simulator::Schedule(Seconds(1.1),
3060 this,
3061 VhtPhy::GetVhtMcs1());
3062
3063 // Set channel width to 20 MHz & send packet
3064 Simulator::Schedule(Seconds(1.5),
3066 this,
3067 20);
3068 Simulator::Schedule(Seconds(2.0),
3070 this,
3071 apDevice.Get(0),
3072 staDevice.Get(0)->GetAddress());
3073 // Selected rate should be VHT-MCS 3 since SNR should be 6 dB higher than previously
3074 Simulator::Schedule(Seconds(2.1),
3076 this,
3077 VhtPhy::GetVhtMcs3());
3078
3079 // Set channel width to 40 MHz & send packet
3080 Simulator::Schedule(Seconds(2.5),
3082 this,
3083 40);
3084 Simulator::Schedule(Seconds(3.0),
3086 this,
3087 apDevice.Get(0),
3088 staDevice.Get(0)->GetAddress());
3089 // Selected rate should be VHT-MCS 2 since SNR should be 3 dB lower than previously
3090 Simulator::Schedule(Seconds(3.1),
3092 this,
3093 VhtPhy::GetVhtMcs2());
3094
3095 Simulator::Stop(Seconds(3.2));
3096 Simulator::Run();
3097
3098 Simulator::Destroy();
3099}
3100
3101//-----------------------------------------------------------------------------
3111{
3112 public:
3114 ~IdealRateManagerMimoTest() override;
3115 void DoRun() override;
3116
3117 private:
3123 void SetApMimoSettings(uint8_t antennas, uint8_t maxStreams);
3129 void SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams);
3135 void SendPacket(Ptr<NetDevice> sourceDevice, Address& destination);
3136
3144 void TxCallback(std::string context,
3145 WifiConstPsduMap psdus,
3146 WifiTxVector txVector,
3147 double txPowerW);
3148
3153 void CheckLastSelectedMode(WifiMode expectedMode);
3158 void CheckLastSelectedNss(uint8_t expectedNss);
3159
3161};
3162
3164 : TestCase("Test case for use of imbalanced MIMO settings with Ideal rate manager")
3165{
3166}
3167
3169{
3170}
3171
3172void
3173IdealRateManagerMimoTest::SetApMimoSettings(uint8_t antennas, uint8_t maxStreams)
3174{
3175 Config::Set("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas",
3176 UintegerValue(antennas));
3177 Config::Set("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams",
3178 UintegerValue(maxStreams));
3179 Config::Set("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams",
3180 UintegerValue(maxStreams));
3181}
3182
3183void
3184IdealRateManagerMimoTest::SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams)
3185{
3186 Config::Set("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas",
3187 UintegerValue(antennas));
3188 Config::Set("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams",
3189 UintegerValue(maxStreams));
3190 Config::Set("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams",
3191 UintegerValue(maxStreams));
3192}
3193
3194void
3196{
3197 Ptr<Packet> packet = Create<Packet>(1000);
3198 sourceDevice->Send(packet, destination, 0);
3199}
3200
3201void
3203 WifiConstPsduMap psdus,
3204 WifiTxVector txVector,
3205 double txPowerW)
3206{
3207 if (psdus.begin()->second->GetSize() >= 1000)
3208 {
3209 m_txVector = txVector;
3210 }
3211}
3212
3213void
3215{
3217 expectedNss,
3218 "Last selected Nss " << m_txVector.GetNss()
3219 << " does not match expected Nss " << expectedNss);
3220}
3221
3222void
3224{
3226 expectedMode,
3227 "Last selected WifiMode " << m_txVector.GetMode()
3228 << " does not match expected WifiMode "
3229 << expectedMode);
3230}
3231
3232void
3234{
3235 RngSeedManager::SetSeed(1);
3236 RngSeedManager::SetRun(1);
3237 int64_t streamNumber = 100;
3238
3240 NodeContainer wifiStaNode;
3241 wifiApNode.Create(1);
3242 wifiStaNode.Create(1);
3243
3245 YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
3246 phy.SetChannel(channel.Create());
3247
3249 wifi.SetStandard(WIFI_STANDARD_80211ac);
3250 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
3251
3253 NetDeviceContainer apDevice;
3254 mac.SetType("ns3::ApWifiMac");
3255 apDevice = wifi.Install(phy, mac, wifiApNode);
3256
3257 NetDeviceContainer staDevice;
3258 mac.SetType("ns3::StaWifiMac");
3259 staDevice = wifi.Install(phy, mac, wifiStaNode);
3260
3261 // Assign fixed streams to random variables in use
3262 wifi.AssignStreams(apDevice, streamNumber);
3263 wifi.AssignStreams(staDevice, streamNumber);
3264
3266 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
3267 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
3268 positionAlloc->Add(Vector(40.0, 0.0, 0.0));
3269 mobility.SetPositionAllocator(positionAlloc);
3270
3271 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
3272 mobility.Install(wifiApNode);
3273 mobility.Install(wifiStaNode);
3274
3275 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin",
3277
3278 // TX: 1 antenna
3279 Simulator::Schedule(Seconds(0.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
3280 // RX: 1 antenna
3281 Simulator::Schedule(Seconds(0.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
3282 // Send packets (2 times to get one feedback)
3283 Simulator::Schedule(Seconds(1.0),
3285 this,
3286 apDevice.Get(0),
3287 staDevice.Get(0)->GetAddress());
3288 Simulator::Schedule(Seconds(1.1),
3290 this,
3291 apDevice.Get(0),
3292 staDevice.Get(0)->GetAddress());
3293 // Selected NSS should be 1 since both TX and RX support a single antenna
3294 Simulator::Schedule(Seconds(1.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3295 // Selected rate should be VHT-MCS 2 because of settings and distance between TX and RX
3296 Simulator::Schedule(Seconds(1.2),
3298 this,
3299 VhtPhy::GetVhtMcs2());
3300
3301 // TX: 1 antenna
3302 Simulator::Schedule(Seconds(1.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
3303 // RX: 2 antennas, but only supports 1 spatial stream
3304 Simulator::Schedule(Seconds(1.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
3305 // Send packets (2 times to get one feedback)
3306 Simulator::Schedule(Seconds(2.0),
3308 this,
3309 apDevice.Get(0),
3310 staDevice.Get(0)->GetAddress());
3311 Simulator::Schedule(Seconds(2.1),
3313 this,
3314 apDevice.Get(0),
3315 staDevice.Get(0)->GetAddress());
3316 // Selected NSS should be 1 since both TX and RX support a single antenna
3317 Simulator::Schedule(Seconds(2.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3318 // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR
3319 // improvement of about 3dB
3320 Simulator::Schedule(Seconds(2.2),
3322 this,
3323 VhtPhy::GetVhtMcs3());
3324
3325 // TX: 1 antenna
3326 Simulator::Schedule(Seconds(2.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
3327 // RX: 2 antennas, and supports 2 spatial streams
3328 Simulator::Schedule(Seconds(2.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
3329 // Send packets (2 times to get one feedback)
3330 Simulator::Schedule(Seconds(3.0),
3332 this,
3333 apDevice.Get(0),
3334 staDevice.Get(0)->GetAddress());
3335 Simulator::Schedule(Seconds(3.1),
3337 this,
3338 apDevice.Get(0),
3339 staDevice.Get(0)->GetAddress());
3340 // Selected NSS should be 1 since TX supports a single antenna
3341 Simulator::Schedule(Seconds(3.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3342 // Selected rate should be as previously
3343 Simulator::Schedule(Seconds(3.2),
3345 this,
3346 VhtPhy::GetVhtMcs3());
3347
3348 // TX: 2 antennas, but only supports 1 spatial stream
3349 Simulator::Schedule(Seconds(3.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
3350 // RX: 1 antenna
3351 Simulator::Schedule(Seconds(3.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
3352 // Send packets (2 times to get one feedback)
3353 Simulator::Schedule(Seconds(4.0),
3355 this,
3356 apDevice.Get(0),
3357 staDevice.Get(0)->GetAddress());
3358 Simulator::Schedule(Seconds(4.1),
3360 this,
3361 apDevice.Get(0),
3362 staDevice.Get(0)->GetAddress());
3363 // Selected NSS should be 1 since both TX and RX support a single antenna
3364 Simulator::Schedule(Seconds(4.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3365 // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario
3366 // (more antennas at TX does not result in SNR improvement in AWGN channel)
3367 Simulator::Schedule(Seconds(4.2),
3369 this,
3370 VhtPhy::GetVhtMcs2());
3371
3372 // TX: 2 antennas, but only supports 1 spatial stream
3373 Simulator::Schedule(Seconds(4.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
3374 // RX: 2 antennas, but only supports 1 spatial stream
3375 Simulator::Schedule(Seconds(4.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
3376 // Send packets (2 times to get one feedback)
3377 Simulator::Schedule(Seconds(5.0),
3379 this,
3380 apDevice.Get(0),
3381 staDevice.Get(0)->GetAddress());
3382 Simulator::Schedule(Seconds(5.1),
3384 this,
3385 apDevice.Get(0),
3386 staDevice.Get(0)->GetAddress());
3387 // Selected NSS should be 1 since both TX and RX support a single antenna
3388 Simulator::Schedule(Seconds(5.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3389 // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR
3390 // improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN
3391 // channel)
3392 Simulator::Schedule(Seconds(5.2),
3394 this,
3395 VhtPhy::GetVhtMcs3());
3396
3397 // TX: 2 antennas, but only supports 1 spatial stream
3398 Simulator::Schedule(Seconds(5.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
3399 // RX: 2 antennas, and supports 2 spatial streams
3400 Simulator::Schedule(Seconds(5.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
3401 // Send packets (2 times to get one feedback)
3402 Simulator::Schedule(Seconds(6.0),
3404 this,
3405 apDevice.Get(0),
3406 staDevice.Get(0)->GetAddress());
3407 Simulator::Schedule(Seconds(6.1),
3409 this,
3410 apDevice.Get(0),
3411 staDevice.Get(0)->GetAddress());
3412 // Selected NSS should be 1 since TX supports a single antenna
3413 Simulator::Schedule(Seconds(6.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3414 // Selected rate should be as previously
3415 Simulator::Schedule(Seconds(6.2),
3417 this,
3418 VhtPhy::GetVhtMcs3());
3419
3420 // TX: 2 antennas, and supports 2 spatial streams
3421 Simulator::Schedule(Seconds(6.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
3422 // RX: 1 antenna
3423 Simulator::Schedule(Seconds(6.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
3424 // Send packets (2 times to get one feedback)
3425 Simulator::Schedule(Seconds(7.0),
3427 this,
3428 apDevice.Get(0),
3429 staDevice.Get(0)->GetAddress());
3430 Simulator::Schedule(Seconds(7.1),
3432 this,
3433 apDevice.Get(0),
3434 staDevice.Get(0)->GetAddress());
3435 // Selected NSS should be 1 since RX supports a single antenna
3436 Simulator::Schedule(Seconds(7.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3437 // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario
3438 // (more antennas at TX does not result in SNR improvement in AWGN channel)
3439 Simulator::Schedule(Seconds(7.2),
3441 this,
3442 VhtPhy::GetVhtMcs2());
3443
3444 // TX: 2 antennas, and supports 2 spatial streams
3445 Simulator::Schedule(Seconds(7.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
3446 // RX: 2 antennas, but only supports 1 spatial stream
3447 Simulator::Schedule(Seconds(7.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
3448 // Send packets (2 times to get one feedback)
3449 Simulator::Schedule(Seconds(8.0),
3451 this,
3452 apDevice.Get(0),
3453 staDevice.Get(0)->GetAddress());
3454 Simulator::Schedule(Seconds(8.1),
3456 this,
3457 apDevice.Get(0),
3458 staDevice.Get(0)->GetAddress());
3459 // Selected NSS should be 1 since RX supports a single antenna
3460 Simulator::Schedule(Seconds(8.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3461 // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR
3462 // improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN
3463 // channel)
3464 Simulator::Schedule(Seconds(8.2),
3466 this,
3467 VhtPhy::GetVhtMcs3());
3468
3469 // TX: 2 antennas, and supports 2 spatial streams
3470 Simulator::Schedule(Seconds(8.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
3471 // RX: 2 antennas, and supports 2 spatial streams
3472 Simulator::Schedule(Seconds(8.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
3473 // Send packets (2 times to get one feedback)
3474 Simulator::Schedule(Seconds(9.0),
3476 this,
3477 apDevice.Get(0),
3478 staDevice.Get(0)->GetAddress());
3479 Simulator::Schedule(Seconds(9.1),
3481 this,
3482 apDevice.Get(0),
3483 staDevice.Get(0)->GetAddress());
3484 // Selected NSS should be 2 since both TX and RX support 2 antennas
3485 Simulator::Schedule(Seconds(9.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 2);
3486 // Selecte rate should be the same as without diversity, as it uses 2 spatial streams so there
3487 // is no more benefits from diversity in AWGN channels
3488 Simulator::Schedule(Seconds(9.2),
3490 this,
3491 VhtPhy::GetVhtMcs2());
3492
3493 // Verify we can go back to initial situation
3494 Simulator::Schedule(Seconds(9.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
3495 Simulator::Schedule(Seconds(9.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
3496 Simulator::Schedule(Seconds(10.0),
3498 this,
3499 apDevice.Get(0),
3500 staDevice.Get(0)->GetAddress());
3501 Simulator::Schedule(Seconds(10.1), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3502 Simulator::Schedule(Seconds(10.1),
3504 this,
3505 VhtPhy::GetVhtMcs2());
3506
3507 Simulator::Stop(Seconds(10.2));
3508 Simulator::Run();
3509 Simulator::Destroy();
3510}
3511
3512//-----------------------------------------------------------------------------
3520{
3521 public:
3523
3524 private:
3535 bool CheckDataRate(HeRu::RuType ruType,
3536 std::string mcs,
3537 uint8_t nss,
3538 uint16_t guardInterval,
3539 uint16_t expectedDataRate);
3540 void DoRun() override;
3541};
3542
3544 : TestCase("Check data rates for different RU types.")
3545{
3546}
3547
3548bool
3550 std::string mcs,
3551 uint8_t nss,
3552 uint16_t guardInterval,
3553 uint16_t expectedDataRate)
3554{
3555 uint16_t approxWidth = HeRu::GetBandwidth(ruType);
3556 WifiMode mode(mcs);
3557 uint64_t dataRate = round(mode.GetDataRate(approxWidth, guardInterval, nss) / 100000.0);
3558 NS_ABORT_MSG_IF(dataRate > 65535, "Rate is way too high");
3559 if (static_cast<uint16_t>(dataRate) != expectedDataRate)
3560 {
3561 std::cerr << "RU=" << ruType << " mode=" << mode << " Nss=" << +nss
3562 << " guardInterval=" << guardInterval << " expected=" << expectedDataRate
3563 << " x100kbps"
3564 << " computed=" << static_cast<uint16_t>(dataRate) << " x100kbps" << std::endl;
3565 return false;
3566 }
3567 return true;
3568}
3569
3570void
3572{
3573 bool retval = true;
3574
3575 // 26-tone RU, browse over all MCSs, GIs and Nss's (up to 4, current max)
3576 retval = retval && CheckDataRate(HeRu::RU_26_TONE, "HeMcs0", 1, 800, 9) &&
3577 CheckDataRate(HeRu::RU_26_TONE, "HeMcs1", 1, 1600, 17) &&
3578 CheckDataRate(HeRu::RU_26_TONE, "HeMcs2", 1, 3200, 23) &&
3579 CheckDataRate(HeRu::RU_26_TONE, "HeMcs3", 1, 3200, 30) &&
3580 CheckDataRate(HeRu::RU_26_TONE, "HeMcs4", 2, 1600, 100) &&
3581 CheckDataRate(HeRu::RU_26_TONE, "HeMcs5", 3, 1600, 200) &&
3582 CheckDataRate(HeRu::RU_26_TONE, "HeMcs6", 4, 1600, 300) &&
3583 CheckDataRate(HeRu::RU_26_TONE, "HeMcs7", 4, 3200, 300) &&
3584 CheckDataRate(HeRu::RU_26_TONE, "HeMcs8", 4, 1600, 400) &&
3585 CheckDataRate(HeRu::RU_26_TONE, "HeMcs9", 4, 3200, 400) &&
3586 CheckDataRate(HeRu::RU_26_TONE, "HeMcs10", 4, 1600, 500) &&
3587 CheckDataRate(HeRu::RU_26_TONE, "HeMcs11", 4, 3200, 500);
3588
3590 retval,
3591 true,
3592 "26-tone RU data rate verification for different MCSs, GIs, and Nss's failed");
3593
3594 // Check other RU sizes
3595 retval = retval && CheckDataRate(HeRu::RU_52_TONE, "HeMcs2", 1, 1600, 50) &&
3596 CheckDataRate(HeRu::RU_106_TONE, "HeMcs9", 1, 800, 500) &&
3597 CheckDataRate(HeRu::RU_242_TONE, "HeMcs5", 1, 1600, 650) &&
3598 CheckDataRate(HeRu::RU_484_TONE, "HeMcs3", 1, 1600, 650) &&
3599 CheckDataRate(HeRu::RU_996_TONE, "HeMcs5", 1, 3200, 2450) &&
3600 CheckDataRate(HeRu::RU_2x996_TONE, "HeMcs3", 1, 3200, 2450);
3601
3602 NS_TEST_EXPECT_MSG_EQ(retval,
3603 true,
3604 "Data rate verification for RUs above 52-tone RU (included) failed");
3605}
3606
3614{
3615 public:
3616 WifiTestSuite();
3617};
3618
3620 : TestSuite("wifi-devices", UNIT)
3621{
3622 AddTestCase(new WifiTest, TestCase::QUICK);
3623 AddTestCase(new QosUtilsIsOldPacketTest, TestCase::QUICK);
3624 AddTestCase(new InterferenceHelperSequenceTest, TestCase::QUICK); // Bug 991
3626 AddTestCase(new Bug730TestCase, TestCase::QUICK); // Bug 730
3627 AddTestCase(new QosFragmentationTestCase, TestCase::QUICK);
3628 AddTestCase(new SetChannelFrequencyTest, TestCase::QUICK);
3629 AddTestCase(new Bug2222TestCase, TestCase::QUICK); // Bug 2222
3630 AddTestCase(new Bug2843TestCase, TestCase::QUICK); // Bug 2843
3631 AddTestCase(new Bug2831TestCase, TestCase::QUICK); // Bug 2831
3632 AddTestCase(new StaWifiMacScanningTestCase, TestCase::QUICK); // Bug 2399
3633 AddTestCase(new Bug2470TestCase, TestCase::QUICK); // Bug 2470
3634 AddTestCase(new Issue40TestCase, TestCase::QUICK); // Issue #40
3635 AddTestCase(new Issue169TestCase, TestCase::QUICK); // Issue #169
3636 AddTestCase(new IdealRateManagerChannelWidthTest, TestCase::QUICK);
3637 AddTestCase(new IdealRateManagerMimoTest, TestCase::QUICK);
3638 AddTestCase(new HeRuMcsDataRateTestCase, TestCase::QUICK);
3639}
3640
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1370
~Bug2222TestCase() override
Definition: wifi-test.cc:1394
uint32_t m_countInternalCollisions
count internal collisions
Definition: wifi-test.cc:1378
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1406
void TxDataFailedTrace(std::string context, Mac48Address adr)
Transmit data failed function.
Definition: wifi-test.cc:1399
Make sure that the ADDBA handshake process is protected.
Definition: wifi-test.cc:2143
void RxErrorCallback(std::string context, Ptr< const Packet > p, double snr)
Callback when packet is dropped.
Definition: wifi-test.cc:2286
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2399
uint16_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:2213
uint16_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:2210
void AddbaStateChangedCallback(std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
Callback when ADDBA state changed.
Definition: wifi-test.cc:2234
void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel)
Run subtest for this test suite.
Definition: wifi-test.cc:2310
uint16_t m_failedActionCount
Count failed ADDBA request/response.
Definition: wifi-test.cc:2205
uint16_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:2206
void RxCallback(std::string context, Ptr< const Packet > p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
Callback when packet is received.
Definition: wifi-test.cc:2261
~Bug2470TestCase() override
Definition: wifi-test.cc:2229
uint16_t m_receivedNormalMpduCount
Count received normal MPDU packets on STA.
Definition: wifi-test.cc:2203
uint16_t m_addbaNoReplyCount
Count number of times ADDBA state machine is in no_reply state.
Definition: wifi-test.cc:2212
uint16_t m_addbaPendingCount
Count number of times ADDBA state machine is in pending state.
Definition: wifi-test.cc:2208
void SendPacketBurst(uint32_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination) const
Triggers the arrival of a burst of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:2298
uint16_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:2204
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1728
uint16_t m_countOperationalChannelWidth20
count number of beacon frames announcing a 20 MHz operating channel width
Definition: wifi-test.cc:1752
void ChangeSupportedChannelWidth()
Function called to change the supported channel width at runtime.
Definition: wifi-test.cc:1772
uint16_t m_countOperationalChannelWidth40
count number of beacon frames announcing a 40 MHz operating channel width
Definition: wifi-test.cc:1754
void RxCallback(std::string context, Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
Callback triggered when a packet is received by the PHYs.
Definition: wifi-test.cc:1779
uint16_t m_assocReqCount
count number of association requests
Definition: wifi-test.cc:1750
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1747
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1811
Ptr< YansWifiPhy > m_staPhy
STA PHY.
Definition: wifi-test.cc:1748
uint16_t m_assocRespCount
count number of association responses
Definition: wifi-test.cc:1751
~Bug2831TestCase() override
Definition: wifi-test.cc:1767
Make sure that the correct channel width and center frequency have been set for OFDM basic rate trans...
Definition: wifi-test.cc:1510
void SendPacketBurst(uint8_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination) const
Triggers the arrival of a burst of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:1594
void StoreDistinctTuple(std::string context, Ptr< SpectrumSignalParameters > txParams)
Stores the distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel,...
Definition: wifi-test.cc:1558
std::vector< FreqWidthSubbandModulationTuple > m_distinctTuples
vector of distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel,...
Definition: wifi-test.cc:1524
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1606
uint16_t m_channelWidth
channel width (in MHz)
Definition: wifi-test.cc:1544
~Bug2843TestCase() override
Definition: wifi-test.cc:1553
std::tuple< double, uint16_t, uint32_t, WifiModulationClass > FreqWidthSubbandModulationTuple
A tuple of {starting frequency, channelWidth, Number of subbands in SpectrumModel,...
Definition: wifi-test.cc:1522
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:640
~Bug730TestCase() override
Definition: wifi-test.cc:665
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:670
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:679
uint32_t m_received
received
Definition: wifi-test.cc:648
Make sure that when multiple broadcast packets are queued on the same device in a short succession,...
Definition: wifi-test.cc:472
void NotifyPhyTxBegin(Ptr< const Packet > p, double txPowerW)
Notify Phy transmit begin.
Definition: wifi-test.cc:507
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:528
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:487
unsigned int m_numSentPackets
number of sent packets
Definition: wifi-test.cc:491
Time m_secondTransmissionTime
second transmission time
Definition: wifi-test.cc:490
Time m_firstTransmissionTime
first transmission time
Definition: wifi-test.cc:489
ObjectFactory m_manager
manager
Definition: wifi-test.cc:485
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:521
Data rate verification test for MCSs of different RU sizes.
Definition: wifi-test.cc:3520
bool CheckDataRate(HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate)
Compare the data rate computed for the provided combination with standard defined one.
Definition: wifi-test.cc:3549
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3571
Make sure that Ideal rate manager properly selects MCS based on the configured channel width.
Definition: wifi-test.cc:2916
WifiMode m_txMode
Store the last selected mode to send data packet.
Definition: wifi-test.cc:2954
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3002
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
Triggers the transmission of a 1000 Byte-long data packet from the source device.
Definition: wifi-test.cc:2974
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2993
void TxCallback(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2981
void ChangeChannelWidth(uint16_t channelWidth)
Change the configured channel width for all nodes.
Definition: wifi-test.cc:2967
~IdealRateManagerChannelWidthTest() override
Definition: wifi-test.cc:2962
Test to validate that Ideal rate manager properly selects TXVECTOR in scenarios where MIMO is used.
Definition: wifi-test.cc:3111
~IdealRateManagerMimoTest() override
Definition: wifi-test.cc:3168
void CheckLastSelectedNss(uint8_t expectedNss)
Check if the selected Nss is correct.
Definition: wifi-test.cc:3214
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3233
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:3202
void SetApMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for AP node.
Definition: wifi-test.cc:3173
WifiTxVector m_txVector
Store the last TXVECTOR used to transmit Data.
Definition: wifi-test.cc:3160
void SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for STA node.
Definition: wifi-test.cc:3184
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
Triggers the transmission of a 1000 Byte-long data packet from the source device.
Definition: wifi-test.cc:3195
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:3223
void SwitchCh(Ptr< WifiNetDevice > dev)
Switch channel function.
Definition: wifi-test.cc:324
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:317
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:372
ObjectFactory m_manager
manager
Definition: wifi-test.cc:306
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:308
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:331
Make sure that Ideal rate manager is able to handle non best-effort traffic.
Definition: wifi-test.cc:2759
void SendPackets(uint8_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination, uint8_t priority)
Triggers the transmission of a 1000 Byte-long data packet from the source device.
Definition: wifi-test.cc:2801
~Issue169TestCase() override
Definition: wifi-test.cc:2796
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2817
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2831
Make sure that Ideal rate manager recovers when the station is moving away from the access point.
Definition: wifi-test.cc:2527
uint16_t m_txCount
Count number of transmitted data packets.
Definition: wifi-test.cc:2561
uint16_t m_txMacFinalDataFailedCount
Count number of unsuccessfully transmitted data packets.
Definition: wifi-test.cc:2563
void RunOne(bool useAmpdu)
Run one function.
Definition: wifi-test.cc:2602
uint16_t m_rxCount
Count number of successfully received data packets.
Definition: wifi-test.cc:2560
void RxSuccessCallback(std::string context, Ptr< const Packet > p)
Callback when packet is successfully received.
Definition: wifi-test.cc:2579
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2736
void TxFinalDataFailedCallback(std::string context, Mac48Address address)
Transmit final data failed function.
Definition: wifi-test.cc:2596
void SendPackets(uint8_t numPackets, Ptr< NetDevice > sourceDevice, Address &destination)
Triggers the arrival of 1000 Byte-long packets in the source device.
Definition: wifi-test.cc:2585
~Issue40TestCase() override
Definition: wifi-test.cc:2574
Make sure that fragmentation works with QoS stations.
Definition: wifi-test.cc:779
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:840
uint32_t m_received
received packets
Definition: wifi-test.cc:787
~QosFragmentationTestCase() override
Definition: wifi-test.cc:814
uint32_t m_fragments
transmitted fragments
Definition: wifi-test.cc:788
void Transmit(std::string context, Ptr< const Packet > p, double power)
Callback invoked when PHY transmits a packet.
Definition: wifi-test.cc:828
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:819
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:239
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:246
Set Channel Frequency Test.
Definition: wifi-test.cc:935
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:956
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:964
Make sure that Wifi STA is correctly associating to the best AP (i.e., nearest from STA).
Definition: wifi-test.cc:1940
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2064
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1990
Mac48Address m_associatedApBssid
Associated AP's bssid.
Definition: wifi-test.cc:1971
~StaWifiMacScanningTestCase() override
Definition: wifi-test.cc:1979
void TurnApOff(Ptr< Node > apNode)
Turn the AP node off.
Definition: wifi-test.cc:1998
NodeContainer Setup(bool nearestApBeaconGeneration, bool staActiveProbe)
Setup test.
Definition: wifi-test.cc:2006
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1984
Wifi Test.
Definition: wifi-test.cc:100
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:139
void RunOne()
Run one function.
Definition: wifi-test.cc:183
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:202
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:122
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:132
ObjectFactory m_manager
manager
Definition: wifi-test.cc:121
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:123
Wifi Test Suite.
Definition: wifi-test.cc:3614
a polymophic address class
Definition: address.h:92
AttributeValue implementation for Boolean.
Definition: boolean.h:37
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:41
an EUI-48 address
Definition: mac48-address.h:46
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:1222
const std::optional< HtOperation > & GetHtOperation() const
Return the HT operation, if present.
Definition: mgt-headers.cc:394
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:138
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:169
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:152
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:369
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:258
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:259
State
Represents the state for this agreement.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:294
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:863
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Definition: packet.cc:131
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:979
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:305
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Ptr< T > Get() const
Definition: pointer.h:205
calculate a propagation delay.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:73
indicates whether the socket has a priority set.
Definition: socket.h:1316
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:852
size_t GetNumBands() const
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start.
Ptr< const SpectrumModel > GetSpectrumModel() const
Make it easy to create and manage PHY objects for the spectrum model.
void SetChannel(Ptr< SpectrumChannel > channel)
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
AttributeValue implementation for Ssid.
Hold variables of type string.
Definition: string.h:42
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
A suite of tests to run.
Definition: test.h:1256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:71
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: txop.cc:536
Hold an unsigned integer type.
Definition: uinteger.h:45
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:324
a (time, location) pair.
Definition: waypoint.h:36
void AddWaypoint(const Waypoint &waypoint)
helps to create WifiNetDevice objects
Definition: wifi-helper.h:325
Implements the IEEE 802.11 MAC header.
bool IsAssocReq() const
Return true if the header is an Association Request header.
bool IsBeacon() const
Return true if the header is a Beacon header.
bool IsAssocResp() const
Return true if the header is an Association Response header.
bool IsAction() const
Return true if the header is an Action header.
bool IsData() const
Return true if the Type is DATA.
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:92
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-mac.cc:423
represent a single transmission mode
Definition: wifi-mode.h:50
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:185
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:122
Hold together all Wifi-related objects.
void SetMac(const Ptr< WifiMac > mac)
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
Address GetBroadcast() const override
Ptr< WifiMac > GetMac() const
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
void SetStandard(WifiStandard standard)
Set the Wifi standard.
Ptr< WifiPhy > GetPhy() const
uint32_t GetIfIndex() const override
void SetPhy(const Ptr< WifiPhy > phy)
Address GetAddress() const override
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:163
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
Definition: wifi-helper.h:536
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
Definition: wifi-phy.cc:614
uint16_t GetChannelWidth() const
Definition: wifi-phy.cc:980
uint16_t GetFrequency() const
Definition: wifi-phy.cc:968
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:895
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
Definition: wifi-phy.cc:1004
uint8_t GetChannelNumber() const
Return current channel number.
Definition: wifi-phy.cc:974
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:575
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:587
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
Definition: wifi-phy.h:869
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:962
bool IsSet() const
Return true if a valid channel has been set, false otherwise.
hold a list of per-remote-station state.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
uint16_t GetChannelWidth() const
manage and create wifi channel objects for the YANS model.
Make it easy to create and manage PHY objects for the YANS model.
802.11 PHY layer model
Definition: yans-wifi-phy.h:48
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
void SetInterferenceHelper(const Ptr< InterferenceHelper > helper) override
Sets the interference helper.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:975
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:877
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:296
#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:144
#define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg)
Test that an actual value is less than or equal to a limit and report if not.
Definition: test.h:830
#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:251
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1362
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
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:184
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
@ WIFI_STANDARD_80211a
@ WIFI_STANDARD_80211p
@ WIFI_STANDARD_80211n
@ WIFI_STANDARD_80211g
@ WIFI_STANDARD_80211ax
@ WIFI_STANDARD_80211ac
@ WIFI_STANDARD_80211b
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Definition: wifi-phy-band.h:37
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
NodeContainer nodes
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
@ STA
Definition: wifi-mac.h:60
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:691
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:78
staDevices
Definition: third.py:91
ssid
Definition: third.py:86
channel
Definition: third.py:81
mac
Definition: third.py:85
wifi
Definition: third.py:88
apDevices
Definition: third.py:94
wifiApNode
Definition: third.py:79
mobility
Definition: third.py:96
phy
Definition: third.py:82
MpduInfo structure.
Definition: phy-entity.h:63
MpduType type
type of MPDU
Definition: phy-entity.h:64
SignalNoiseDbm structure.
Definition: phy-entity.h:56
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
static void AssignWifiRandomStreams(Ptr< WifiMac > mac, int64_t stream)
Definition: wifi-test.cc:63
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:3641