A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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);
177 node->AggregateObject(mobility);
178
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
196
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:
294 Ptr<Node> CreateOne(Vector pos, Ptr<YansWifiChannel> channel);
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();
327 p->SetOperatingChannel(WifiPhy::ChannelTuple{40, 0, (int)(WIFI_PHY_BAND_5GHZ), 0});
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);
366 node->AggregateObject(mobility);
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
396 this,
397 DynamicCast<WifiNetDevice>(senderB->GetDevice(0)));
398
399 Simulator::Schedule(Seconds(1.0000001),
401 this,
402 DynamicCast<WifiNetDevice>(rxOnly->GetDevice(0)));
403
406 this,
407 DynamicCast<WifiNetDevice>(senderA->GetDevice(0)));
408
411 this,
412 DynamicCast<WifiNetDevice>(senderB->GetDevice(0)));
413
414 Simulator::Stop(Seconds(100.0));
416
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
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);
557 txPhy->ConfigureStandard(WIFI_STANDARD_80211a);
558
559 txPhy->TraceConnectWithoutContext(
560 "PhyTxBegin",
562
563 txMobility->SetPosition(Vector(0.0, 0.0, 0.0));
564 txNode->AggregateObject(txMobility);
565 txDev->SetPhy(txPhy);
566 txDev->SetRemoteStationManager(m_manager.Create<WifiRemoteStationManager>());
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
595 this,
596 txDev);
599 this,
600 txDev);
601
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
686 NodeContainer wifiApNode;
687 wifiApNode.Create(1);
688
691 phy.SetChannel(channel.Create());
692
693 WifiHelper wifi;
694 wifi.SetStandard(WIFI_STANDARD_80211b);
695 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
696 "DataMode",
697 StringValue("DsssRate1Mbps"),
698 "ControlMode",
699 StringValue("DsssRate1Mbps"));
700
701 WifiMacHelper mac;
702 Ssid ssid = Ssid("ns-3-ssid");
703 mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid), "ActiveProbing", BooleanValue(false));
704
705 NetDeviceContainer staDevices;
706 staDevices = wifi.Install(phy, mac, wifiStaNode);
707
708 mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid), "BeaconGeneration", BooleanValue(true));
709
710 NetDeviceContainer apDevices;
711 apDevices = wifi.Install(phy, mac, wifiApNode);
712
713 MobilityHelper mobility;
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
755 "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold",
756 StringValue("800"));
757
760
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
845 NodeContainer wifiApNode;
846 wifiApNode.Create(1);
847
850 phy.SetChannel(channel.Create());
851
852 WifiHelper wifi;
853 wifi.SetStandard(WIFI_STANDARD_80211n);
854 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode", StringValue("HtMcs7"));
855
856 WifiMacHelper mac;
857 Ssid ssid = Ssid("ns-3-ssid");
858 mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid), "ActiveProbing", BooleanValue(false));
859
860 NetDeviceContainer staDevices;
861 staDevices = wifi.Install(phy, mac, wifiStaNode);
862
863 mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid), "BeaconGeneration", BooleanValue(true));
864
865 NetDeviceContainer apDevices;
866 apDevices = wifi.Install(phy, mac, wifiApNode);
867
868 MobilityHelper mobility;
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
921
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);
968 NodeContainer wifiApNode;
969 wifiApNode.Create(1);
970
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",
981 SsidValue(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
993 NS_TEST_ASSERT_MSG_EQ(phySta->GetOperatingChannel().IsSet(),
994 false,
995 "default configuration");
996 }
997 {
998 // case 1:
999 WifiHelper wifi;
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:
1011 WifiHelper wifi;
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:
1022 WifiHelper wifi;
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:
1033 WifiHelper wifi;
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:
1046 WifiHelper wifi;
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:
1057 WifiHelper wifi;
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
1069 WifiHelper wifi;
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:
1081 WifiHelper wifi;
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:
1091 WifiHelper wifi;
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(), 5985, "802.11ax-6GHz configuration");
1099 phy.Set("ChannelSettings", StringValue("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1100 }
1101 {
1102 // case 10:
1103 WifiHelper wifi;
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:
1116 WifiHelper wifi;
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:
1129 WifiHelper wifi;
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:
1142 WifiHelper wifi;
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:
1159 WifiHelper wifi;
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:
1178 WifiHelper wifi;
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:
1199 WifiHelper wifi;
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:
1220 WifiHelper wifi;
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
1237 WifiHelper wifi;
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 {
1246 phySta->SetOperatingChannel(WifiPhy::ChannelTuple{99, 40, WIFI_PHY_BAND_5GHZ, 0});
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:
1257 WifiHelper wifi;
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:
1298 WifiHelper wifi;
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
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
1414 int64_t streamNumber = 100;
1415
1416 NodeContainer wifiNodes;
1417 wifiNodes.Create(2);
1418
1421 phy.SetChannel(channel.Create());
1422
1423 WifiHelper wifi;
1424 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
1425 "DataMode",
1426 StringValue("OfdmRate54Mbps"),
1427 "ControlMode",
1428 StringValue("OfdmRate24Mbps"));
1429 WifiMacHelper mac;
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
1439 MobilityHelper mobility;
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
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
1561 Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel();
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
1613 NodeContainer wifiApNode;
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
1632 WifiHelper wifi;
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
1642 WifiMacHelper mac;
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
1651 MobilityHelper mobility;
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
1664 this,
1665 5,
1666 apDevice.Get(0),
1667 staDevice.Get(0)->GetAddress());
1670 this,
1671 5,
1672 apDevice.Get(0),
1673 staDevice.Get(0)->GetAddress());
1674
1675 Config::Connect("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams",
1677
1680
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)");
1700 WifiModulationClass::WIFI_MOD_CLASS_OFDM,
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)");
1711 WifiModulationClass::WIFI_MOD_CLASS_VHT,
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);
1824 apDev->SetStandard(WIFI_STANDARD_80211ax);
1825 Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration>();
1826 apDev->SetHtConfiguration(apHtConfiguration);
1827 ObjectFactory manager;
1828 manager.SetTypeId("ns3::ConstantRateWifiManager");
1829 apDev->SetRemoteStationManager(manager.Create<WifiRemoteStationManager>());
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);
1841 m_apPhy->SetChannel(channel);
1842 m_apPhy->SetMobility(apMobility);
1843 m_apPhy->SetDevice(apDev);
1846
1847 ObjectFactory mac;
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);
1868 staDev->SetStandard(WIFI_STANDARD_80211ax);
1869 Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration>();
1870 staDev->SetHtConfiguration(staHtConfiguration);
1871 staDev->SetRemoteStationManager(manager.Create<WifiRemoteStationManager>());
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);
1882 m_staPhy->SetChannel(channel);
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
1908
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{
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
2020 phy.SetChannel(channel.Create());
2021
2022 WifiHelper wifi;
2023 wifi.SetStandard(WIFI_STANDARD_80211n);
2024 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager");
2025
2026 WifiMacHelper mac;
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
2043 MobilityHelper mobility;
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
2074 this,
2075 nearestAp);
2076
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
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
2108
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,
2171 void TxCallback(Ptr<ListErrorModel> rxErrorModel,
2172 std::string context,
2173 WifiConstPsduMap psduMap,
2174 WifiTxVector txVector,
2175 double txPowerW);
2176
2187 void RxCallback(std::string context,
2189 uint16_t channelFreqMhz,
2190 WifiTxVector txVector,
2191 MpduInfo aMpdu,
2192 SignalNoiseDbm signalNoise,
2193 uint16_t staId);
2200 void RxErrorCallback(std::string context, Ptr<const Packet> p, double snr);
2207 void SendPacketBurst(uint32_t numPackets,
2208 Ptr<NetDevice> sourceDevice,
2209 Address& destination) const;
2214 void RunSubtest(TypeOfStation rcvErrorType);
2215
2222 uint16_t
2224 uint16_t
2227};
2228
2230 : TestCase("Test case for Bug 2470"),
2231 m_receivedNormalMpduCount(0),
2232 m_receivedAmpduCount(0),
2233 m_failedActionCount(0),
2234 m_addbaEstablishedCount(0),
2235 m_addbaPendingCount(0),
2236 m_addbaRejectedCount(0),
2237 m_addbaNoReplyCount(0),
2238 m_addbaResetCount(0)
2239{
2240}
2241
2243{
2244}
2245
2246void
2248 Time t,
2249 Mac48Address recipient,
2250 uint8_t tid,
2252{
2253 switch (state)
2254 {
2257 break;
2260 break;
2263 break;
2266 break;
2269 break;
2270 }
2271}
2272
2273void
2275 std::string context,
2276 WifiConstPsduMap psduMap,
2277 WifiTxVector txVector,
2278 double txPowerW)
2279{
2280 auto psdu = psduMap.begin()->second;
2281
2282 // The sender is transmitting an ADDBA_REQUEST or ADDBA_RESPONSE frame. If this is
2283 // the first attempt at establishing a BA agreement (i.e., before the second set of packets
2284 // is generated), make the reception of the frame fail at the receiver.
2285 if (psdu->GetHeader(0).GetType() == WIFI_MAC_MGT_ACTION && Simulator::Now() < Seconds(0.8))
2286 {
2287 auto uid = psdu->GetPayload(0)->GetUid();
2288 rxErrorModel->SetList({uid});
2289 }
2290}
2291
2292void
2295 uint16_t channelFreqMhz,
2296 WifiTxVector txVector,
2297 MpduInfo aMpdu,
2298 SignalNoiseDbm signalNoise,
2299 uint16_t staId)
2300{
2301 Ptr<Packet> packet = p->Copy();
2302 if (aMpdu.type != MpduType::NORMAL_MPDU)
2303 {
2305 }
2306 else
2307 {
2308 WifiMacHeader hdr;
2309 packet->RemoveHeader(hdr);
2310 if (hdr.IsData())
2311 {
2313 }
2314 }
2315}
2316
2317void
2318Bug2470TestCase::RxErrorCallback(std::string context, Ptr<const Packet> p, double snr)
2319{
2320 Ptr<Packet> packet = p->Copy();
2321 WifiMacHeader hdr;
2322 packet->RemoveHeader(hdr);
2323 if (hdr.IsAction())
2324 {
2326 }
2327}
2328
2329void
2331 Ptr<NetDevice> sourceDevice,
2332 Address& destination) const
2333{
2334 for (uint32_t i = 0; i < numPackets; i++)
2335 {
2336 Ptr<Packet> pkt = Create<Packet>(1000); // 1000 dummy bytes of data
2337 sourceDevice->Send(pkt, destination, 0);
2338 }
2339}
2340
2341void
2343{
2346 int64_t streamNumber = 200;
2347
2348 NodeContainer wifiApNode;
2349 NodeContainer wifiStaNode;
2350 wifiApNode.Create(1);
2351 wifiStaNode.Create(1);
2352
2355 phy.SetChannel(channel.Create());
2356
2357 WifiHelper wifi;
2358 wifi.SetStandard(WIFI_STANDARD_80211n);
2359 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
2360 "DataMode",
2361 StringValue("HtMcs7"),
2362 "ControlMode",
2363 StringValue("HtMcs7"));
2364
2365 WifiMacHelper mac;
2366 NetDeviceContainer apDevice;
2367 phy.Set("ChannelSettings", StringValue("{36, 20, BAND_5GHZ, 0}"));
2368 mac.SetType("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue(false));
2369 apDevice = wifi.Install(phy, mac, wifiApNode);
2370
2371 NetDeviceContainer staDevice;
2372 mac.SetType("ns3::StaWifiMac");
2373 staDevice = wifi.Install(phy, mac, wifiStaNode);
2374
2375 // Assign fixed streams to random variables in use
2376 wifi.AssignStreams(apDevice, streamNumber);
2377 wifi.AssignStreams(staDevice, streamNumber);
2378
2379 MobilityHelper mobility;
2380 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
2381 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
2382 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
2383 mobility.SetPositionAllocator(positionAlloc);
2384
2385 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
2386 mobility.Install(wifiApNode);
2387 mobility.Install(wifiStaNode);
2388
2389 auto rxErrorModel = CreateObject<ListErrorModel>();
2390 Ptr<WifiMac> wifiMac;
2391 switch (rcvErrorType)
2392 {
2393 case AP:
2394 wifiMac = DynamicCast<WifiNetDevice>(apDevice.Get(0))->GetMac();
2395 break;
2396 case STA:
2397 wifiMac = DynamicCast<WifiNetDevice>(staDevice.Get(0))->GetMac();
2398 break;
2399 default:
2400 NS_ABORT_MSG("Station type " << +rcvErrorType << " cannot be used here");
2401 }
2402 wifiMac->GetWifiPhy(0)->SetPostReceptionErrorModel(rxErrorModel);
2403
2405 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx",
2407 Config::Connect("/NodeList/*/DeviceList/*/Phy/State/RxError",
2409 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/BE_Txop/"
2410 "BlockAckManager/AgreementState",
2412 Config::Connect("/NodeList/" + std::to_string(rcvErrorType == STA ? 0 /* AP */ : 1 /* STA */) +
2413 "/DeviceList/*/$ns3::WifiNetDevice/Phys/0/PhyTxPsduBegin",
2414 MakeCallback(&Bug2470TestCase::TxCallback, this).Bind(rxErrorModel));
2415
2418 this,
2419 1,
2420 apDevice.Get(0),
2421 staDevice.Get(0)->GetAddress());
2424 this,
2425 4,
2426 apDevice.Get(0),
2427 staDevice.Get(0)->GetAddress());
2430 this,
2431 1,
2432 apDevice.Get(0),
2433 staDevice.Get(0)->GetAddress());
2436 this,
2437 4,
2438 apDevice.Get(0),
2439 staDevice.Get(0)->GetAddress());
2440
2444}
2445
2446void
2448{
2449 {
2450 RunSubtest(STA);
2451 NS_TEST_ASSERT_MSG_EQ(m_failedActionCount, 7, "ADDBA request packets are not failed");
2452 // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by
2453 // normal MPDU because of failed ADDBA handshake. For the second set, the first packet
2454 // should be sent by normal MPDU, and the rest with A-MPDU. In total we expect to receive 6
2455 // normal MPDU packets and 4 A-MPDU packet.
2457 6,
2458 "Receiving incorrect number of normal MPDU packet on subtest 1");
2460 4,
2461 "Receiving incorrect number of A-MPDU packets on subtest 1");
2462
2464 1,
2465 "Incorrect number of times the ADDBA state machine was in "
2466 "established state on subtest 1");
2469 2,
2470 "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2473 0,
2474 "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2477 1,
2478 "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2481 1,
2482 "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2483 }
2484
2493
2494 {
2495 RunSubtest(AP);
2496 NS_TEST_ASSERT_MSG_EQ(m_failedActionCount, 7, "ADDBA response packets are not failed");
2497 // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU
2498 // packets.
2500 6,
2501 "Receiving incorrect number of normal MPDU packet on subtest 2");
2503 4,
2504 "Receiving incorrect number of A-MPDU packet on subtest 2");
2505
2507 1,
2508 "Incorrect number of times the ADDBA state machine was in "
2509 "established state on subtest 2");
2512 2,
2513 "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2516 0,
2517 "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2520 1,
2521 "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2524 1,
2525 "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2526 }
2527
2528 // TODO: In the second test set, it does not go to reset state since ADDBA response is received
2529 // after timeout (NO_REPLY) but before it does not enter RESET state. More tests should be
2530 // written to verify all possible scenarios.
2531}
2532
2533//-----------------------------------------------------------------------------
2549{
2550 public:
2552 ~Issue40TestCase() override;
2553 void DoRun() override;
2554
2555 private:
2560 void RunOne(bool useAmpdu);
2561
2567 void RxSuccessCallback(std::string context, Ptr<const Packet> p);
2574 void SendPackets(uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination);
2580 void TxFinalDataFailedCallback(std::string context, Mac48Address address);
2581
2582 uint16_t m_rxCount;
2583 uint16_t m_txCount;
2584 uint16_t
2586};
2587
2589 : TestCase("Test case for issue #40"),
2590 m_rxCount(0),
2591 m_txCount(0),
2592 m_txMacFinalDataFailedCount(0)
2593{
2594}
2595
2597{
2598}
2599
2600void
2602{
2603 m_rxCount++;
2604}
2605
2606void
2607Issue40TestCase::SendPackets(uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination)
2608{
2609 for (uint8_t i = 0; i < numPackets; i++)
2610 {
2611 Ptr<Packet> pkt = Create<Packet>(1000); // 1000 dummy bytes of data
2612 sourceDevice->Send(pkt, destination, 0);
2613 m_txCount++;
2614 }
2615}
2616
2617void
2619{
2621}
2622
2623void
2625{
2626 m_rxCount = 0;
2627 m_txCount = 0;
2629
2632 int64_t streamNumber = 100;
2633
2634 NodeContainer wifiApNode;
2635 NodeContainer wifiStaNode;
2636 wifiApNode.Create(1);
2637 wifiStaNode.Create(1);
2638
2641 phy.SetChannel(channel.Create());
2642
2643 WifiHelper wifi;
2644 wifi.SetStandard(WIFI_STANDARD_80211ac);
2645 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
2646
2647 WifiMacHelper mac;
2648 NetDeviceContainer apDevice;
2649 mac.SetType("ns3::ApWifiMac");
2650 apDevice = wifi.Install(phy, mac, wifiApNode);
2651
2652 NetDeviceContainer staDevice;
2653 mac.SetType("ns3::StaWifiMac");
2654 staDevice = wifi.Install(phy, mac, wifiStaNode);
2655
2656 // Assign fixed streams to random variables in use
2657 wifi.AssignStreams(apDevice, streamNumber);
2658 wifi.AssignStreams(staDevice, streamNumber);
2659
2660 MobilityHelper mobility;
2661 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
2662 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
2663 positionAlloc->Add(Vector(10.0, 0.0, 0.0));
2664 mobility.SetPositionAllocator(positionAlloc);
2665
2666 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
2667 mobility.Install(wifiApNode);
2668
2669 mobility.SetMobilityModel("ns3::WaypointMobilityModel");
2670 mobility.Install(wifiStaNode);
2671
2672 Config::Connect("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxFinalDataFailed",
2674 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/MacRx",
2676
2677 Ptr<WaypointMobilityModel> staWaypointMobility =
2678 DynamicCast<WaypointMobilityModel>(wifiStaNode.Get(0)->GetObject<MobilityModel>());
2679 staWaypointMobility->AddWaypoint(Waypoint(Seconds(1.0), Vector(10.0, 0.0, 0.0)));
2680 staWaypointMobility->AddWaypoint(Waypoint(Seconds(1.5), Vector(50.0, 0.0, 0.0)));
2681
2682 if (useAmpdu)
2683 {
2684 // Disable use of BAR that are sent with the lowest modulation so that we can also reproduce
2685 // the problem with A-MPDU, i.e. the lack of feedback about SNR change
2686 Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice>(apDevice.Get(0));
2687 PointerValue ptr;
2688 ap_device->GetMac()->GetAttribute("BE_Txop", ptr);
2689 ptr.Get<QosTxop>()->SetAttribute("UseExplicitBarAfterMissedBlockAck", BooleanValue(false));
2690 }
2691
2692 // Transmit a first data packet before the station moves: it should be sent with a high
2693 // modulation and successfully received
2696 this,
2697 useAmpdu ? 2 : 1,
2698 apDevice.Get(0),
2699 staDevice.Get(0)->GetAddress());
2700
2701 // Transmit a second data packet once the station is away from the access point: it should be
2702 // sent with the same high modulation and be unsuccessfuly received
2705 this,
2706 useAmpdu ? 2 : 1,
2707 apDevice.Get(0),
2708 staDevice.Get(0)->GetAddress());
2709
2710 // Keep on transmitting data packets while the station is away from the access point: it should
2711 // be sent with a lower modulation and be successfully received
2714 this,
2715 useAmpdu ? 2 : 1,
2716 apDevice.Get(0),
2717 staDevice.Get(0)->GetAddress());
2720 this,
2721 useAmpdu ? 2 : 1,
2722 apDevice.Get(0),
2723 staDevice.Get(0)->GetAddress());
2726 this,
2727 useAmpdu ? 2 : 1,
2728 apDevice.Get(0),
2729 staDevice.Get(0)->GetAddress());
2732 this,
2733 useAmpdu ? 2 : 1,
2734 apDevice.Get(0),
2735 staDevice.Get(0)->GetAddress());
2738 this,
2739 useAmpdu ? 2 : 1,
2740 apDevice.Get(0),
2741 staDevice.Get(0)->GetAddress());
2742
2745
2747 (useAmpdu ? 14 : 7),
2748 "Incorrect number of transmitted packets");
2750 (useAmpdu ? 12 : 6),
2751 "Incorrect number of successfully received packets");
2752 NS_TEST_ASSERT_MSG_EQ(m_txMacFinalDataFailedCount, 1, "Incorrect number of dropped TX packets");
2753
2755}
2756
2757void
2759{
2760 // Test without A-MPDU
2761 RunOne(false);
2762
2763 // Test with A-MPDU
2764 RunOne(true);
2765}
2766
2767//-----------------------------------------------------------------------------
2781{
2782 public:
2784 ~Issue169TestCase() override;
2785 void DoRun() override;
2786
2787 private:
2795 void SendPackets(uint8_t numPackets,
2796 Ptr<NetDevice> sourceDevice,
2797 Address& destination,
2798 uint8_t priority);
2799
2807 void TxCallback(std::string context,
2808 WifiConstPsduMap psdus,
2809 WifiTxVector txVector,
2810 double txPowerW);
2811};
2812
2814 : TestCase("Test case for issue #169")
2815{
2816}
2817
2819{
2820}
2821
2822void
2824 Ptr<NetDevice> sourceDevice,
2825 Address& destination,
2826 uint8_t priority)
2827{
2828 SocketPriorityTag priorityTag;
2829 priorityTag.SetPriority(priority);
2830 for (uint8_t i = 0; i < numPackets; i++)
2831 {
2832 Ptr<Packet> packet = Create<Packet>(1000); // 1000 dummy bytes of data
2833 packet->AddPacketTag(priorityTag);
2834 sourceDevice->Send(packet, destination, 0);
2835 }
2836}
2837
2838void
2840 WifiConstPsduMap psdus,
2841 WifiTxVector txVector,
2842 double txPowerW)
2843{
2844 if (psdus.begin()->second->GetSize() >= 1000)
2845 {
2847 WifiModulationClass::WIFI_MOD_CLASS_VHT,
2848 "Ideal rate manager selected incorrect modulation class");
2849 }
2850}
2851
2852void
2854{
2857 int64_t streamNumber = 100;
2858
2859 NodeContainer wifiApNode;
2860 NodeContainer wifiStaNode;
2861 wifiApNode.Create(1);
2862 wifiStaNode.Create(1);
2863
2866 phy.SetChannel(channel.Create());
2867
2868 WifiHelper wifi;
2869 wifi.SetStandard(WIFI_STANDARD_80211ac);
2870 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
2871
2872 WifiMacHelper mac;
2873 NetDeviceContainer apDevice;
2874 mac.SetType("ns3::ApWifiMac");
2875 apDevice = wifi.Install(phy, mac, wifiApNode);
2876
2877 NetDeviceContainer staDevice;
2878 mac.SetType("ns3::StaWifiMac");
2879 staDevice = wifi.Install(phy, mac, wifiStaNode);
2880
2881 // Assign fixed streams to random variables in use
2882 wifi.AssignStreams(apDevice, streamNumber);
2883 wifi.AssignStreams(staDevice, streamNumber);
2884
2885 MobilityHelper mobility;
2886 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
2887 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
2888 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
2889 mobility.SetPositionAllocator(positionAlloc);
2890
2891 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
2892 mobility.Install(wifiApNode);
2893 mobility.Install(wifiStaNode);
2894
2895 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin",
2897
2898 // Send best-effort packet (i.e. priority 0)
2901 this,
2902 1,
2903 apDevice.Get(0),
2904 staDevice.Get(0)->GetAddress(),
2905 0);
2906
2907 // Send non best-effort (voice) packet (i.e. priority 6)
2910 this,
2911 1,
2912 apDevice.Get(0),
2913 staDevice.Get(0)->GetAddress(),
2914 6);
2915
2918
2920}
2921
2922//-----------------------------------------------------------------------------
2938{
2939 public:
2942 void DoRun() override;
2943
2944 private:
2949 void ChangeChannelWidth(uint16_t channelWidth);
2950
2956 void SendPacket(Ptr<NetDevice> sourceDevice, Address& destination);
2957
2965 void TxCallback(std::string context,
2966 WifiConstPsduMap psduMap,
2967 WifiTxVector txVector,
2968 double txPowerW);
2969
2974 void CheckLastSelectedMode(WifiMode expectedMode);
2975
2977};
2978
2980 : TestCase("Test case for use of channel bonding with Ideal rate manager")
2981{
2982}
2983
2985{
2986}
2987
2988void
2990{
2991 Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelSettings",
2992 StringValue("{0, " + std::to_string(channelWidth) + ", BAND_5GHZ, 0}"));
2993}
2994
2995void
2997{
2998 Ptr<Packet> packet = Create<Packet>(1000);
2999 sourceDevice->Send(packet, destination, 0);
3000}
3001
3002void
3004 WifiConstPsduMap psduMap,
3005 WifiTxVector txVector,
3006 double txPowerW)
3007{
3008 if (psduMap.begin()->second->GetSize() >= 1000)
3009 {
3010 m_txMode = txVector.GetMode();
3011 }
3012}
3013
3014void
3016{
3018 expectedMode,
3019 "Last selected WifiMode "
3020 << m_txMode << " does not match expected WifiMode " << expectedMode);
3021}
3022
3023void
3025{
3028 int64_t streamNumber = 100;
3029
3030 NodeContainer wifiApNode;
3031 NodeContainer wifiStaNode;
3032 wifiApNode.Create(1);
3033 wifiStaNode.Create(1);
3034
3037 phy.SetChannel(channel.Create());
3038
3039 WifiHelper wifi;
3040 wifi.SetStandard(WIFI_STANDARD_80211ac);
3041 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
3042
3043 WifiMacHelper mac;
3044 NetDeviceContainer apDevice;
3045 mac.SetType("ns3::ApWifiMac");
3046 apDevice = wifi.Install(phy, mac, wifiApNode);
3047
3048 NetDeviceContainer staDevice;
3049 mac.SetType("ns3::StaWifiMac");
3050 staDevice = wifi.Install(phy, mac, wifiStaNode);
3051
3052 // Assign fixed streams to random variables in use
3053 wifi.AssignStreams(apDevice, streamNumber);
3054 wifi.AssignStreams(staDevice, streamNumber);
3055
3056 MobilityHelper mobility;
3057 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
3058 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
3059 positionAlloc->Add(Vector(50.0, 0.0, 0.0));
3060 mobility.SetPositionAllocator(positionAlloc);
3061
3062 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
3063 mobility.Install(wifiApNode);
3064 mobility.Install(wifiStaNode);
3065
3066 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin",
3068
3069 // Set channel width to 80 MHz & send packet
3072 this,
3073 80);
3076 this,
3077 apDevice.Get(0),
3078 staDevice.Get(0)->GetAddress());
3079 // Selected rate should be VHT-MCS 1
3082 this,
3084
3085 // Set channel width to 20 MHz & send packet
3088 this,
3089 20);
3092 this,
3093 apDevice.Get(0),
3094 staDevice.Get(0)->GetAddress());
3095 // Selected rate should be VHT-MCS 3 since SNR should be 6 dB higher than previously
3098 this,
3100
3101 // Set channel width to 40 MHz & send packet
3104 this,
3105 40);
3108 this,
3109 apDevice.Get(0),
3110 staDevice.Get(0)->GetAddress());
3111 // Selected rate should be VHT-MCS 2 since SNR should be 3 dB lower than previously
3114 this,
3116
3119
3121}
3122
3123//-----------------------------------------------------------------------------
3133{
3134 public:
3136 ~IdealRateManagerMimoTest() override;
3137 void DoRun() override;
3138
3139 private:
3145 void SetApMimoSettings(uint8_t antennas, uint8_t maxStreams);
3151 void SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams);
3157 void SendPacket(Ptr<NetDevice> sourceDevice, Address& destination);
3158
3166 void TxCallback(std::string context,
3167 WifiConstPsduMap psdus,
3168 WifiTxVector txVector,
3169 double txPowerW);
3170
3175 void CheckLastSelectedMode(WifiMode expectedMode);
3180 void CheckLastSelectedNss(uint8_t expectedNss);
3181
3183};
3184
3186 : TestCase("Test case for use of imbalanced MIMO settings with Ideal rate manager")
3187{
3188}
3189
3191{
3192}
3193
3194void
3195IdealRateManagerMimoTest::SetApMimoSettings(uint8_t antennas, uint8_t maxStreams)
3196{
3197 Config::Set("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas",
3198 UintegerValue(antennas));
3199 Config::Set("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams",
3200 UintegerValue(maxStreams));
3201 Config::Set("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams",
3202 UintegerValue(maxStreams));
3203}
3204
3205void
3206IdealRateManagerMimoTest::SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams)
3207{
3208 Config::Set("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas",
3209 UintegerValue(antennas));
3210 Config::Set("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams",
3211 UintegerValue(maxStreams));
3212 Config::Set("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams",
3213 UintegerValue(maxStreams));
3214}
3215
3216void
3218{
3219 Ptr<Packet> packet = Create<Packet>(1000);
3220 sourceDevice->Send(packet, destination, 0);
3221}
3222
3223void
3225 WifiConstPsduMap psdus,
3226 WifiTxVector txVector,
3227 double txPowerW)
3228{
3229 if (psdus.begin()->second->GetSize() >= 1000)
3230 {
3231 m_txVector = txVector;
3232 }
3233}
3234
3235void
3237{
3239 expectedNss,
3240 "Last selected Nss " << m_txVector.GetNss()
3241 << " does not match expected Nss " << expectedNss);
3242}
3243
3244void
3246{
3248 expectedMode,
3249 "Last selected WifiMode " << m_txVector.GetMode()
3250 << " does not match expected WifiMode "
3251 << expectedMode);
3252}
3253
3254void
3256{
3259 int64_t streamNumber = 100;
3260
3261 NodeContainer wifiApNode;
3262 NodeContainer wifiStaNode;
3263 wifiApNode.Create(1);
3264 wifiStaNode.Create(1);
3265
3268 phy.SetChannel(channel.Create());
3269
3270 WifiHelper wifi;
3271 wifi.SetStandard(WIFI_STANDARD_80211ac);
3272 wifi.SetRemoteStationManager("ns3::IdealWifiManager");
3273
3274 WifiMacHelper mac;
3275 NetDeviceContainer apDevice;
3276 mac.SetType("ns3::ApWifiMac");
3277 apDevice = wifi.Install(phy, mac, wifiApNode);
3278
3279 NetDeviceContainer staDevice;
3280 mac.SetType("ns3::StaWifiMac");
3281 staDevice = wifi.Install(phy, mac, wifiStaNode);
3282
3283 // Assign fixed streams to random variables in use
3284 wifi.AssignStreams(apDevice, streamNumber);
3285 wifi.AssignStreams(staDevice, streamNumber);
3286
3287 MobilityHelper mobility;
3288 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
3289 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
3290 positionAlloc->Add(Vector(40.0, 0.0, 0.0));
3291 mobility.SetPositionAllocator(positionAlloc);
3292
3293 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
3294 mobility.Install(wifiApNode);
3295 mobility.Install(wifiStaNode);
3296
3297 Config::Connect("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin",
3299
3300 // TX: 1 antenna
3302 // RX: 1 antenna
3304 // Send packets (2 times to get one feedback)
3307 this,
3308 apDevice.Get(0),
3309 staDevice.Get(0)->GetAddress());
3312 this,
3313 apDevice.Get(0),
3314 staDevice.Get(0)->GetAddress());
3315 // Selected NSS should be 1 since both TX and RX support a single antenna
3317 // Selected rate should be VHT-MCS 2 because of settings and distance between TX and RX
3320 this,
3322
3323 // TX: 1 antenna
3325 // RX: 2 antennas, but only supports 1 spatial stream
3327 // Send packets (2 times to get one feedback)
3330 this,
3331 apDevice.Get(0),
3332 staDevice.Get(0)->GetAddress());
3335 this,
3336 apDevice.Get(0),
3337 staDevice.Get(0)->GetAddress());
3338 // Selected NSS should be 1 since both TX and RX support a single antenna
3340 // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR
3341 // improvement of about 3dB
3344 this,
3346
3347 // TX: 1 antenna
3349 // RX: 2 antennas, and supports 2 spatial streams
3351 // Send packets (2 times to get one feedback)
3354 this,
3355 apDevice.Get(0),
3356 staDevice.Get(0)->GetAddress());
3359 this,
3360 apDevice.Get(0),
3361 staDevice.Get(0)->GetAddress());
3362 // Selected NSS should be 1 since TX supports a single antenna
3364 // Selected rate should be as previously
3367 this,
3369
3370 // TX: 2 antennas, but only supports 1 spatial stream
3372 // RX: 1 antenna
3374 // Send packets (2 times to get one feedback)
3377 this,
3378 apDevice.Get(0),
3379 staDevice.Get(0)->GetAddress());
3382 this,
3383 apDevice.Get(0),
3384 staDevice.Get(0)->GetAddress());
3385 // Selected NSS should be 1 since both TX and RX support a single antenna
3387 // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario
3388 // (more antennas at TX does not result in SNR improvement in AWGN channel)
3391 this,
3393
3394 // TX: 2 antennas, but only supports 1 spatial stream
3396 // RX: 2 antennas, but only supports 1 spatial stream
3398 // Send packets (2 times to get one feedback)
3401 this,
3402 apDevice.Get(0),
3403 staDevice.Get(0)->GetAddress());
3406 this,
3407 apDevice.Get(0),
3408 staDevice.Get(0)->GetAddress());
3409 // Selected NSS should be 1 since both TX and RX support a single antenna
3411 // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR
3412 // improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN
3413 // channel)
3416 this,
3418
3419 // TX: 2 antennas, but only supports 1 spatial stream
3421 // RX: 2 antennas, and supports 2 spatial streams
3423 // Send packets (2 times to get one feedback)
3426 this,
3427 apDevice.Get(0),
3428 staDevice.Get(0)->GetAddress());
3431 this,
3432 apDevice.Get(0),
3433 staDevice.Get(0)->GetAddress());
3434 // Selected NSS should be 1 since TX supports a single antenna
3436 // Selected rate should be as previously
3439 this,
3441
3442 // TX: 2 antennas, and supports 2 spatial streams
3444 // RX: 1 antenna
3446 // Send packets (2 times to get one feedback)
3449 this,
3450 apDevice.Get(0),
3451 staDevice.Get(0)->GetAddress());
3454 this,
3455 apDevice.Get(0),
3456 staDevice.Get(0)->GetAddress());
3457 // Selected NSS should be 1 since RX supports a single antenna
3459 // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario
3460 // (more antennas at TX does not result in SNR improvement in AWGN channel)
3463 this,
3465
3466 // TX: 2 antennas, and supports 2 spatial streams
3468 // RX: 2 antennas, but only supports 1 spatial stream
3470 // Send packets (2 times to get one feedback)
3473 this,
3474 apDevice.Get(0),
3475 staDevice.Get(0)->GetAddress());
3478 this,
3479 apDevice.Get(0),
3480 staDevice.Get(0)->GetAddress());
3481 // Selected NSS should be 1 since RX supports a single antenna
3483 // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR
3484 // improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN
3485 // channel)
3488 this,
3490
3491 // TX: 2 antennas, and supports 2 spatial streams
3493 // RX: 2 antennas, and supports 2 spatial streams
3495 // Send packets (2 times to get one feedback)
3498 this,
3499 apDevice.Get(0),
3500 staDevice.Get(0)->GetAddress());
3503 this,
3504 apDevice.Get(0),
3505 staDevice.Get(0)->GetAddress());
3506 // Selected NSS should be 2 since both TX and RX support 2 antennas
3508 // Selected rate should be the same as without diversity, as it uses 2 spatial streams so there
3509 // is no more benefits from diversity in AWGN channels
3512 this,
3514
3515 // Verify we can go back to initial situation
3520 this,
3521 apDevice.Get(0),
3522 staDevice.Get(0)->GetAddress());
3526 this,
3528
3529 Simulator::Stop(Seconds(10.2));
3532}
3533
3534//-----------------------------------------------------------------------------
3542{
3543 public:
3545
3546 private:
3557 bool CheckDataRate(HeRu::RuType ruType,
3558 std::string mcs,
3559 uint8_t nss,
3560 uint16_t guardInterval,
3561 uint16_t expectedDataRate);
3562 void DoRun() override;
3563};
3564
3566 : TestCase("Check data rates for different RU types.")
3567{
3568}
3569
3570bool
3572 std::string mcs,
3573 uint8_t nss,
3574 uint16_t guardInterval,
3575 uint16_t expectedDataRate)
3576{
3577 uint16_t approxWidth = HeRu::GetBandwidth(ruType);
3578 WifiMode mode(mcs);
3579 uint64_t dataRate = round(mode.GetDataRate(approxWidth, guardInterval, nss) / 100000.0);
3580 NS_ABORT_MSG_IF(dataRate > 65535, "Rate is way too high");
3581 if (static_cast<uint16_t>(dataRate) != expectedDataRate)
3582 {
3583 std::cerr << "RU=" << ruType << " mode=" << mode << " Nss=" << +nss
3584 << " guardInterval=" << guardInterval << " expected=" << expectedDataRate
3585 << " x100kbps"
3586 << " computed=" << static_cast<uint16_t>(dataRate) << " x100kbps" << std::endl;
3587 return false;
3588 }
3589 return true;
3590}
3591
3592void
3594{
3595 bool retval = true;
3596
3597 // 26-tone RU, browse over all MCSs, GIs and Nss's (up to 4, current max)
3598 retval = retval && CheckDataRate(HeRu::RU_26_TONE, "HeMcs0", 1, 800, 9) &&
3599 CheckDataRate(HeRu::RU_26_TONE, "HeMcs1", 1, 1600, 17) &&
3600 CheckDataRate(HeRu::RU_26_TONE, "HeMcs2", 1, 3200, 23) &&
3601 CheckDataRate(HeRu::RU_26_TONE, "HeMcs3", 1, 3200, 30) &&
3602 CheckDataRate(HeRu::RU_26_TONE, "HeMcs4", 2, 1600, 100) &&
3603 CheckDataRate(HeRu::RU_26_TONE, "HeMcs5", 3, 1600, 200) &&
3604 CheckDataRate(HeRu::RU_26_TONE, "HeMcs6", 4, 1600, 300) &&
3605 CheckDataRate(HeRu::RU_26_TONE, "HeMcs7", 4, 3200, 300) &&
3606 CheckDataRate(HeRu::RU_26_TONE, "HeMcs8", 4, 1600, 400) &&
3607 CheckDataRate(HeRu::RU_26_TONE, "HeMcs9", 4, 3200, 400) &&
3608 CheckDataRate(HeRu::RU_26_TONE, "HeMcs10", 4, 1600, 500) &&
3609 CheckDataRate(HeRu::RU_26_TONE, "HeMcs11", 4, 3200, 500);
3610
3612 retval,
3613 true,
3614 "26-tone RU data rate verification for different MCSs, GIs, and Nss's failed");
3615
3616 // Check other RU sizes
3617 retval = retval && CheckDataRate(HeRu::RU_52_TONE, "HeMcs2", 1, 1600, 50) &&
3618 CheckDataRate(HeRu::RU_106_TONE, "HeMcs9", 1, 800, 500) &&
3619 CheckDataRate(HeRu::RU_242_TONE, "HeMcs5", 1, 1600, 650) &&
3620 CheckDataRate(HeRu::RU_484_TONE, "HeMcs3", 1, 1600, 650) &&
3621 CheckDataRate(HeRu::RU_996_TONE, "HeMcs5", 1, 3200, 2450) &&
3622 CheckDataRate(HeRu::RU_2x996_TONE, "HeMcs3", 1, 3200, 2450);
3623
3624 NS_TEST_EXPECT_MSG_EQ(retval,
3625 true,
3626 "Data rate verification for RUs above 52-tone RU (included) failed");
3627}
3628
3636{
3637 public:
3638 WifiTestSuite();
3639};
3640
3642 : TestSuite("wifi-devices", UNIT)
3643{
3656 AddTestCase(new Issue40TestCase, TestCase::QUICK); // Issue #40
3657 AddTestCase(new Issue169TestCase, TestCase::QUICK); // Issue #169
3661}
3662
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:2318
void RunSubtest(TypeOfStation rcvErrorType)
Run subtest for this test suite.
Definition: wifi-test.cc:2342
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2447
uint16_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:2226
uint16_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:2223
void AddbaStateChangedCallback(std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
Callback when ADDBA state changed.
Definition: wifi-test.cc:2247
uint16_t m_failedActionCount
Count failed ADDBA request/response.
Definition: wifi-test.cc:2218
void TxCallback(Ptr< ListErrorModel > rxErrorModel, std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback when a frame is transmitted.
Definition: wifi-test.cc:2274
uint16_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:2219
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:2293
~Bug2470TestCase() override
Definition: wifi-test.cc:2242
uint16_t m_receivedNormalMpduCount
Count received normal MPDU packets on STA.
Definition: wifi-test.cc:2216
uint16_t m_addbaNoReplyCount
Count number of times ADDBA state machine is in no_reply state.
Definition: wifi-test.cc:2225
uint16_t m_addbaPendingCount
Count number of times ADDBA state machine is in pending state.
Definition: wifi-test.cc:2221
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:2330
uint16_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:2217
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:3542
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:3571
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3593
Make sure that Ideal rate manager properly selects MCS based on the configured channel width.
Definition: wifi-test.cc:2938
WifiMode m_txMode
Store the last selected mode to send data packet.
Definition: wifi-test.cc:2976
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3024
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:2996
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:3015
void TxCallback(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:3003
void ChangeChannelWidth(uint16_t channelWidth)
Change the configured channel width for all nodes.
Definition: wifi-test.cc:2989
~IdealRateManagerChannelWidthTest() override
Definition: wifi-test.cc:2984
Test to validate that Ideal rate manager properly selects TXVECTOR in scenarios where MIMO is used.
Definition: wifi-test.cc:3133
~IdealRateManagerMimoTest() override
Definition: wifi-test.cc:3190
void CheckLastSelectedNss(uint8_t expectedNss)
Check if the selected Nss is correct.
Definition: wifi-test.cc:3236
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3255
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:3224
void SetApMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for AP node.
Definition: wifi-test.cc:3195
WifiTxVector m_txVector
Store the last TXVECTOR used to transmit Data.
Definition: wifi-test.cc:3182
void SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for STA node.
Definition: wifi-test.cc:3206
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:3217
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:3245
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:2781
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:2823
~Issue169TestCase() override
Definition: wifi-test.cc:2818
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2839
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2853
Make sure that Ideal rate manager recovers when the station is moving away from the access point.
Definition: wifi-test.cc:2549
uint16_t m_txCount
Count number of transmitted data packets.
Definition: wifi-test.cc:2583
uint16_t m_txMacFinalDataFailedCount
Count number of unsuccessfuly transmitted data packets.
Definition: wifi-test.cc:2585
void RunOne(bool useAmpdu)
Run one function.
Definition: wifi-test.cc:2624
uint16_t m_rxCount
Count number of successfully received data packets.
Definition: wifi-test.cc:2582
void RxSuccessCallback(std::string context, Ptr< const Packet > p)
Callback when packet is successfully received.
Definition: wifi-test.cc:2601
void DoRun() override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2758
void TxFinalDataFailedCallback(std::string context, Mac48Address address)
Transmit final data failed function.
Definition: wifi-test.cc:2618
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:2607
~Issue40TestCase() override
Definition: wifi-test.cc:2596
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:3636
a polymophic address class
Definition: address.h:100
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
static uint16_t GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
Definition: he-ru.cc:744
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:41
@ RU_26_TONE
Definition: he-ru.h:42
@ RU_484_TONE
Definition: he-ru.h:46
@ RU_996_TONE
Definition: he-ru.h:47
@ RU_106_TONE
Definition: he-ru.h:44
@ RU_52_TONE
Definition: he-ru.h:43
@ RU_242_TONE
Definition: he-ru.h:45
@ RU_2x996_TONE
Definition: he-ru.h:48
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address Allocate()
Allocate a new Mac48Address.
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:1257
const std::optional< HtOperation > & GetHtOperation() const
Return the HT operation, if present.
Definition: mgt-headers.cc:397
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 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
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
State
Represents the state for this agreement.
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:206
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
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:568
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
static void Run()
Run the simulation.
Definition: simulator.cc:176
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:184
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
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:56
encapsulates test code
Definition: test.h:1060
@ QUICK
Fast test.
Definition: test.h:1065
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
Hold an unsigned integer type.
Definition: uinteger.h:45
static WifiMode GetVhtMcs3()
Return MCS 3 from VHT MCS values.
static WifiMode GetVhtMcs1()
Return MCS 1 from VHT MCS values.
static WifiMode GetVhtMcs2()
Return MCS 2 from VHT MCS values.
a (time, location) pair.
Definition: waypoint.h:36
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:94
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-mac.cc:424
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 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:551
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
Definition: wifi-phy.cc:632
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:941
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:1062
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:600
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:612
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
Definition: wifi-phy.h:870
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.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
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(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:49
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#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:1360
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
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:186
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
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< void, Ptr< const WifiPsdu > > RxErrorCallback
Callback if PSDU unsuccessfuly received.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
TypeOfStation
Enumeration for type of station.
Definition: wifi-mac.h:61
@ STA
Definition: wifi-mac.h:62
@ AP
Definition: wifi-mac.h:63
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:707
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:78
@ WIFI_MAC_MGT_ACTION
MpduInfo structure.
Definition: phy-entity.h:63
MpduType type
type of MPDU
Definition: phy-entity.h:64
SignalNoiseDbm structure.
Definition: phy-entity.h:56
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:3663