A Discrete-Event Network Simulator
API
wifi-test.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2005,2006 INRIA
4 * 2010 NICTA
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20 * Quincy Tse <quincy.tse@nicta.com.au>
21 * Sébastien Deronne <sebastien.deronne@gmail.com>
22 */
23
24#include "ns3/string.h"
25#include "ns3/yans-wifi-helper.h"
26#include "ns3/mobility-helper.h"
27#include "ns3/wifi-net-device.h"
28#include "ns3/adhoc-wifi-mac.h"
29#include "ns3/ap-wifi-mac.h"
30#include "ns3/propagation-loss-model.h"
31#include "ns3/yans-error-rate-model.h"
32#include "ns3/constant-position-mobility-model.h"
33#include "ns3/test.h"
34#include "ns3/pointer.h"
35#include "ns3/rng-seed-manager.h"
36#include "ns3/config.h"
37#include "ns3/error-model.h"
38#include "ns3/socket.h"
39#include "ns3/packet-socket-server.h"
40#include "ns3/packet-socket-client.h"
41#include "ns3/packet-socket-helper.h"
42#include "ns3/spectrum-wifi-helper.h"
43#include "ns3/multi-model-spectrum-channel.h"
44#include "ns3/wifi-spectrum-signal-parameters.h"
45#include "ns3/yans-wifi-phy.h"
46#include "ns3/mgt-headers.h"
47#include "ns3/ht-configuration.h"
48#include "ns3/wifi-ppdu.h"
49#include "ns3/wifi-psdu.h"
50#include "ns3/vht-phy.h"
51#include "ns3/waypoint-mobility-model.h"
52#include "ns3/frame-exchange-manager.h"
53#include "ns3/wifi-default-protection-manager.h"
54#include "ns3/wifi-default-ack-manager.h"
55
56using namespace ns3;
57
58//Helper function to assign streams to random variables, to control
59//randomness in the tests
60static void
62{
63 int64_t currentStream = stream;
64 PointerValue ptr;
65 if (!mac->GetQosSupported ())
66 {
67 mac->GetAttribute ("Txop", ptr);
68 Ptr<Txop> txop = ptr.Get<Txop> ();
69 currentStream += txop->AssignStreams (currentStream);
70 }
71 else
72 {
73 mac->GetAttribute ("VO_Txop", ptr);
74 Ptr<QosTxop> vo_txop = ptr.Get<QosTxop> ();
75 currentStream += vo_txop->AssignStreams (currentStream);
76
77 mac->GetAttribute ("VI_Txop", ptr);
78 Ptr<QosTxop> vi_txop = ptr.Get<QosTxop> ();
79 currentStream += vi_txop->AssignStreams (currentStream);
80
81 mac->GetAttribute ("BE_Txop", ptr);
82 Ptr<QosTxop> be_txop = ptr.Get<QosTxop> ();
83 currentStream += be_txop->AssignStreams (currentStream);
84
85 mac->GetAttribute ("BK_Txop", ptr);
86 Ptr<QosTxop> bk_txop = ptr.Get<QosTxop> ();
87 bk_txop->AssignStreams (currentStream);
88 }
89}
90
97class WifiTest : public TestCase
98{
99public:
100 WifiTest ();
101
102 void DoRun (void) override;
103
104
105private:
107 void RunOne (void);
113 void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
119
123};
124
126 : TestCase ("Wifi")
127{
128}
129
130void
132{
133 Ptr<Packet> p = Create<Packet> ();
134 dev->Send (p, dev->GetBroadcast (), 1);
135}
136
137void
139{
140 Ptr<Node> node = CreateObject<Node> ();
141 Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
142
144 mac->SetDevice (dev);
145 mac->SetAddress (Mac48Address::Allocate ());
146 mac->ConfigureStandard (WIFI_STANDARD_80211a);
147 Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager ();
148 Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
149 protectionManager->SetWifiMac (mac);
150 fem->SetProtectionManager (protectionManager);
151 Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
152 ackManager->SetWifiMac (mac);
153 fem->SetAckManager (ackManager);
154
155 Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
156 Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
157 Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
158 phy->SetErrorRateModel (error);
159 phy->SetChannel (channel);
160 phy->SetDevice (dev);
161 phy->ConfigureStandard (WIFI_STANDARD_80211a);
163
164 mobility->SetPosition (pos);
166 dev->SetMac (mac);
167 dev->SetPhy (phy);
168 dev->SetRemoteStationManager (manager);
169 node->AddDevice (dev);
170
171 Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev);
172}
173
174void
176{
177 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
179 Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
180 channel->SetPropagationDelayModel (propDelay);
181 channel->SetPropagationLossModel (propLoss);
182
183 CreateOne (Vector (0.0, 0.0, 0.0), channel);
184 CreateOne (Vector (5.0, 0.0, 0.0), channel);
185 CreateOne (Vector (5.0, 0.0, 0.0), channel);
186
187 Simulator::Stop (Seconds (10.0));
188
189 Simulator::Run ();
190 Simulator::Destroy ();
191}
192
193void
195{
196 m_mac.SetTypeId ("ns3::AdhocWifiMac");
197 m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
198
199 m_manager.SetTypeId ("ns3::ArfWifiManager");
200 RunOne ();
201 m_manager.SetTypeId ("ns3::AarfWifiManager");
202 RunOne ();
203 m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
204 RunOne ();
205 m_manager.SetTypeId ("ns3::OnoeWifiManager");
206 RunOne ();
207 m_manager.SetTypeId ("ns3::AmrrWifiManager");
208 RunOne ();
209 m_manager.SetTypeId ("ns3::IdealWifiManager");
210 RunOne ();
211
212 m_mac.SetTypeId ("ns3::AdhocWifiMac");
213 RunOne ();
214 m_mac.SetTypeId ("ns3::ApWifiMac");
215 RunOne ();
216 m_mac.SetTypeId ("ns3::StaWifiMac");
217 RunOne ();
218
219
220 m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel");
221 m_mac.SetTypeId ("ns3::AdhocWifiMac");
222 RunOne ();
223}
224
232{
233public:
234 QosUtilsIsOldPacketTest () : TestCase ("QosUtilsIsOldPacket")
235 {
236 }
237 void DoRun (void) override
238 {
239 //startingSeq=0, seqNum=2047
240 NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2047), false, "2047 is new in comparison to 0");
241 //startingSeq=0, seqNum=2048
242 NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 2048), true, "2048 is old in comparison to 0");
243 //startingSeq=2048, seqNum=0
244 NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 0), true, "0 is old in comparison to 2048");
245 //startingSeq=4095, seqNum=0
246 NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 0), false, "0 is new in comparison to 4095");
247 //startingSeq=0, seqNum=4095
248 NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (0, 4095), true, "4095 is old in comparison to 0");
249 //startingSeq=4095 seqNum=2047
250 NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (4095, 2047), true, "2047 is old in comparison to 4095");
251 //startingSeq=2048 seqNum=4095
252 NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2048, 4095), false, "4095 is new in comparison to 2048");
253 //startingSeq=2049 seqNum=0
254 NS_TEST_EXPECT_MSG_EQ (QosUtilsIsOldPacket (2049, 0), false, "0 is new in comparison to 2049");
255 }
256};
257
258
263{
264public:
266
267 void DoRun (void) override;
268
269
270private:
287 void SwitchCh (Ptr<WifiNetDevice> dev);
288
292};
293
295 : TestCase ("InterferenceHelperSequence")
296{
297}
298
299void
301{
302 Ptr<Packet> p = Create<Packet> (1000);
303 dev->Send (p, dev->GetBroadcast (), 1);
304}
305
306void
308{
309 Ptr<WifiPhy> p = dev->GetPhy ();
311}
312
315{
316 Ptr<Node> node = CreateObject<Node> ();
317 Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
318
320 mac->SetDevice (dev);
321 mac->SetAddress (Mac48Address::Allocate ());
322 mac->ConfigureStandard (WIFI_STANDARD_80211a);
323 Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager ();
324 Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
325 protectionManager->SetWifiMac (mac);
326 fem->SetProtectionManager (protectionManager);
327 Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
328 ackManager->SetWifiMac (mac);
329 fem->SetAckManager (ackManager);
330
331 Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
332 Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
333 Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
334 phy->SetErrorRateModel (error);
335 phy->SetChannel (channel);
336 phy->SetDevice (dev);
337 phy->SetMobility (mobility);
338 phy->ConfigureStandard (WIFI_STANDARD_80211a);
340
341 mobility->SetPosition (pos);
343 dev->SetMac (mac);
344 dev->SetPhy (phy);
345 dev->SetRemoteStationManager (manager);
346 node->AddDevice (dev);
347
348 return node;
349}
350
351void
353{
354 m_mac.SetTypeId ("ns3::AdhocWifiMac");
355 m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
356 m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
357
358 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
360 Ptr<MatrixPropagationLossModel> propLoss = CreateObject<MatrixPropagationLossModel> ();
361 channel->SetPropagationDelayModel (propDelay);
362 channel->SetPropagationLossModel (propLoss);
363
364 Ptr<Node> rxOnly = CreateOne (Vector (0.0, 0.0, 0.0), channel);
365 Ptr<Node> senderA = CreateOne (Vector (5.0, 0.0, 0.0), channel);
366 Ptr<Node> senderB = CreateOne (Vector (-5.0, 0.0, 0.0), channel);
367
368 propLoss->SetLoss (senderB->GetObject<MobilityModel> (), rxOnly->GetObject<MobilityModel> (), 0, true);
369 propLoss->SetDefaultLoss (999);
370
371 Simulator::Schedule (Seconds (1.0),
373 DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
374
375 Simulator::Schedule (Seconds (1.0000001),
377 DynamicCast<WifiNetDevice> (rxOnly->GetDevice (0)));
378
379 Simulator::Schedule (Seconds (5.0),
381 DynamicCast<WifiNetDevice> (senderA->GetDevice (0)));
382
383 Simulator::Schedule (Seconds (7.0),
385 DynamicCast<WifiNetDevice> (senderB->GetDevice (0)));
386
387 Simulator::Stop (Seconds (100.0));
388 Simulator::Run ();
389
390 Simulator::Destroy ();
391}
392
393//-----------------------------------------------------------------------------
445{
446public:
448
449 void DoRun (void) override;
450
451
452private:
458
462
465 unsigned int m_numSentPackets;
466
472 void NotifyPhyTxBegin (Ptr<const Packet> p, double txPowerW);
473};
474
476 : TestCase ("Test case for DCF immediate access with broadcast frames")
477{
478}
479
480void
482{
483 if (m_numSentPackets == 0)
484 {
487 }
488 else if (m_numSentPackets == 1)
489 {
491 }
492}
493
494void
496{
497 Ptr<Packet> p = Create<Packet> (1000);
498 dev->Send (p, dev->GetBroadcast (), 1);
499}
500
501void
503{
504 m_mac.SetTypeId ("ns3::AdhocWifiMac");
505 m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
506 m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
507
508 //Assign a seed and run number, and later fix the assignment of streams to
509 //WiFi random variables, so that the first backoff used is one slot
510 RngSeedManager::SetSeed (1);
511 RngSeedManager::SetRun (40); // a value of 17 will result in zero slots
512
513 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
515 Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
516 channel->SetPropagationDelayModel (propDelay);
517 channel->SetPropagationLossModel (propLoss);
518
519 Ptr<Node> txNode = CreateObject<Node> ();
520 Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
521 Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
522 txMac->SetDevice (txDev);
523 txMac->ConfigureStandard (WIFI_STANDARD_80211a);
524 Ptr<FrameExchangeManager> fem = txMac->GetFrameExchangeManager ();
525 Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
526 protectionManager->SetWifiMac (txMac);
527 fem->SetProtectionManager (protectionManager);
528 Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
529 ackManager->SetWifiMac (txMac);
530 fem->SetAckManager (ackManager);
531
532
533 //Fix the stream assignment to the Dcf Txop objects (backoffs)
534 //The below stream assignment will result in the Txop object
535 //using a backoff value of zero for this test when the
536 //Txop::EndTxNoAck() calls to StartBackoffNow()
537 AssignWifiRandomStreams (txMac, 23);
538
539 Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
540 Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
541 Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
542 txPhy->SetErrorRateModel (txError);
543 txPhy->SetChannel (channel);
544 txPhy->SetDevice (txDev);
545 txPhy->SetMobility (txMobility);
547
549
550 txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
551 txNode->AggregateObject (txMobility);
552 txMac->SetAddress (Mac48Address::Allocate ());
553 txDev->SetMac (txMac);
554 txDev->SetPhy (txPhy);
556 txNode->AddDevice (txDev);
557
561
562 Simulator::Schedule (Seconds (1.0), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
563 Simulator::Schedule (Seconds (1.0) + MicroSeconds (1), &DcfImmediateAccessBroadcastTestCase::SendOnePacket, this, txDev);
564
565 Simulator::Stop (Seconds (2.0));
566 Simulator::Run ();
567 Simulator::Destroy ();
568
569 // First packet is transmitted a DIFS after the packet is queued. A DIFS
570 // is 2 slots (2 * 9 = 18 us) plus a SIFS (16 us), i.e., 34 us
571 Time expectedFirstTransmissionTime = Seconds (1.0) + MicroSeconds (34);
572
573 //First packet has 1408 us of transmit time. Slot time is 9 us.
574 //Backoff is 1 slots. SIFS is 16 us. DIFS is 2 slots = 18 us.
575 //Should send next packet at 1408 us + (1 * 9 us) + 16 us + (2 * 9) us
576 //1451 us after the first one.
577 uint32_t expectedWait1 = 1408 + (1 * 9) + 16 + (2 * 9);
578 Time expectedSecondTransmissionTime = expectedFirstTransmissionTime + MicroSeconds (expectedWait1);
579 NS_TEST_ASSERT_MSG_EQ (m_firstTransmissionTime, expectedFirstTransmissionTime, "The first transmission time not correct!");
580
581 NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime, "The second transmission time not correct!");
582}
583
584//-----------------------------------------------------------------------------
598{
599public:
601 virtual ~Bug730TestCase ();
602
603 void DoRun (void) override;
604
605
606private:
608
615 void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
616
617};
618
620 : TestCase ("Test case for Bug 730"),
621 m_received (0)
622{
623}
624
626{
627}
628
629void
630Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr)
631{
632 if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20)))
633 {
634 m_received++;
635 }
636}
637
638
639void
641{
642 m_received = 0;
643
644 NodeContainer wifiStaNode;
645 wifiStaNode.Create (1);
646
648 wifiApNode.Create (1);
649
650 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
652 phy.SetChannel (channel.Create ());
653
655 wifi.SetStandard (WIFI_STANDARD_80211b);
656 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
657 "DataMode", StringValue ("DsssRate1Mbps"),
658 "ControlMode", StringValue ("DsssRate1Mbps"));
659
661 Ssid ssid = Ssid ("ns-3-ssid");
662 mac.SetType ("ns3::StaWifiMac",
663 "Ssid", SsidValue (ssid),
664 "ActiveProbing", BooleanValue (false));
665
667 staDevices = wifi.Install (phy, mac, wifiStaNode);
668
669 mac.SetType ("ns3::ApWifiMac",
670 "Ssid", SsidValue (ssid),
671 "BeaconGeneration", BooleanValue (true));
672
674 apDevices = wifi.Install (phy, mac, wifiApNode);
675
677 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
678
679 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
680 positionAlloc->Add (Vector (1.0, 0.0, 0.0));
681 mobility.SetPositionAllocator (positionAlloc);
682
683 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
684 mobility.Install (wifiApNode);
685 mobility.Install (wifiStaNode);
686
687 Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
688 Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
689
690 PacketSocketAddress socket;
691 socket.SetSingleDevice (sta_device->GetIfIndex ());
692 socket.SetPhysicalAddress (ap_device->GetAddress ());
693 socket.SetProtocol (1);
694
695 // give packet socket powers to nodes.
696 PacketSocketHelper packetSocket;
697 packetSocket.Install (wifiStaNode);
698 packetSocket.Install (wifiApNode);
699
700 Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
701 client->SetAttribute ("PacketSize", UintegerValue (1460));
702 client->SetRemote (socket);
703 wifiStaNode.Get (0)->AddApplication (client);
704 client->SetStartTime (Seconds (1));
705 client->SetStopTime (Seconds (51.0));
706
707 Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
708 server->SetLocal (socket);
709 wifiApNode.Get (0)->AddApplication (server);
710 server->SetStartTime (Seconds (0.0));
711 server->SetStopTime (Seconds (52.0));
712
713 Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&Bug730TestCase::Receive, this));
714
715 Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800"));
716
717 Simulator::Stop (Seconds (55));
718 Simulator::Run ();
719
720 Simulator::Destroy ();
721
722 bool result = (m_received > 0);
723 NS_TEST_ASSERT_MSG_EQ (result, true, "packet reception unexpectedly stopped after adapting fragmentation threshold!");
724}
725
726//-----------------------------------------------------------------------------
735{
736public:
738 virtual ~QosFragmentationTestCase ();
739
740 void DoRun (void) override;
741
742
743private:
746
753 void Receive (std::string context, Ptr<const Packet> p, const Address &adr);
754
761 void Transmit (std::string context, Ptr<const Packet> p, double power);
762};
763
765 : TestCase ("Test case for fragmentation with QoS stations"),
766 m_received (0),
767 m_fragments (0)
768{
769}
770
772{
773}
774
775void
777{
778 if (p->GetSize () == 1400)
779 {
780 m_received++;
781 }
782}
783
784void
785QosFragmentationTestCase::Transmit (std::string context, Ptr<const Packet> p, double power)
786{
787 WifiMacHeader hdr;
788 p->PeekHeader (hdr);
789 if (hdr.IsQosData ())
790 {
791 NS_TEST_EXPECT_MSG_LT_OR_EQ (p->GetSize (), 400, "Unexpected fragment size");
792 m_fragments++;
793 }
794}
795
796void
798{
799 NodeContainer wifiStaNode;
800 wifiStaNode.Create (1);
801
803 wifiApNode.Create (1);
804
805 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
807 phy.SetChannel (channel.Create ());
808
810 wifi.SetStandard (WIFI_STANDARD_80211n);
811 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
812 "DataMode", StringValue ("HtMcs7"));
813
815 Ssid ssid = Ssid ("ns-3-ssid");
816 mac.SetType ("ns3::StaWifiMac",
817 "Ssid", SsidValue (ssid),
818 "ActiveProbing", BooleanValue (false));
819
821 staDevices = wifi.Install (phy, mac, wifiStaNode);
822
823 mac.SetType ("ns3::ApWifiMac",
824 "Ssid", SsidValue (ssid),
825 "BeaconGeneration", BooleanValue (true));
826
828 apDevices = wifi.Install (phy, mac, wifiApNode);
829
831 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
832
833 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
834 positionAlloc->Add (Vector (1.0, 0.0, 0.0));
835 mobility.SetPositionAllocator (positionAlloc);
836
837 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
838 mobility.Install (wifiApNode);
839 mobility.Install (wifiStaNode);
840
841 Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
842 Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
843
844 // set the TXOP limit on BE AC
845 PointerValue ptr;
846 sta_device->GetMac ()->GetAttribute ("BE_Txop", ptr);
847 ptr.Get<QosTxop> ()->SetTxopLimit (MicroSeconds (3008));
848
849 PacketSocketAddress socket;
850 socket.SetSingleDevice (sta_device->GetIfIndex ());
851 socket.SetPhysicalAddress (ap_device->GetAddress ());
852 socket.SetProtocol (1);
853
854 // give packet socket powers to nodes.
855 PacketSocketHelper packetSocket;
856 packetSocket.Install (wifiStaNode);
857 packetSocket.Install (wifiApNode);
858
859 Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
860 client->SetAttribute ("PacketSize", UintegerValue (1400));
861 client->SetAttribute ("MaxPackets", UintegerValue (1));
862 client->SetRemote (socket);
863 wifiStaNode.Get (0)->AddApplication (client);
864 client->SetStartTime (Seconds (1));
865 client->SetStopTime (Seconds (3.0));
866
867 Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
868 server->SetLocal (socket);
869 wifiApNode.Get (0)->AddApplication (server);
870 server->SetStartTime (Seconds (0.0));
871 server->SetStopTime (Seconds (4.0));
872
873 Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx", MakeCallback (&QosFragmentationTestCase::Receive, this));
874
875 Config::Set ("/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("400"));
876 Config::Connect ("/NodeList/0/DeviceList/0/Phy/PhyTxBegin", MakeCallback (&QosFragmentationTestCase::Transmit, this));
877
878 Simulator::Stop (Seconds (5));
879 Simulator::Run ();
880
881 Simulator::Destroy ();
882
883 NS_TEST_ASSERT_MSG_EQ (m_received, 1, "Unexpected number of received packets");
884 NS_TEST_ASSERT_MSG_EQ (m_fragments, 4, "Unexpected number of transmitted fragments");
885}
886
894{
895public:
897
898 void DoRun (void) override;
899
900
901private:
908
909};
910
912 : TestCase ("Test case for setting WifiPhy channel and frequency")
913{
914}
915
918{
920 Ptr<WifiPhy> wp = wnd->GetPhy ();
921 return wp->GetObject<YansWifiPhy> ();
922}
923
924void
926{
927 NodeContainer wifiStaNode;
928 wifiStaNode.Create (1);
930 wifiApNode.Create (1);
931
932 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
934 phy.SetChannel (channel.Create ());
935
936 // Configure and declare other generic components of this example
937 Ssid ssid;
938 ssid = Ssid ("wifi-phy-configuration");
939 WifiMacHelper macSta;
940 macSta.SetType ("ns3::StaWifiMac",
941 "Ssid", SsidValue (ssid),
942 "ActiveProbing", BooleanValue (false));
943 NetDeviceContainer staDevice;
944 Ptr<YansWifiPhy> phySta;
945
946 // Cases taken from src/wifi/examples/wifi-phy-configuration.cc example
947 {
948 // case 0:
949 // Default configuration, without WifiHelper::SetStandard or WifiHelper
950 phySta = CreateObject<YansWifiPhy> ();
951 // The default results in an invalid configuration
952 NS_TEST_ASSERT_MSG_EQ (phySta->GetOperatingChannel ().IsSet (), false, "default configuration");
953 }
954 {
955 // case 1:
957 wifi.SetStandard (WIFI_STANDARD_80211a);
958 wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
959 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
960 phySta = GetYansWifiPhyPtr (staDevice);
961 // We expect channel 36, width 20, frequency 5180
962 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "default configuration");
963 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "default configuration");
964 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "default configuration");
965 }
966 {
967 // case 2:
969 wifi.SetStandard (WIFI_STANDARD_80211b);
970 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
971 phySta = GetYansWifiPhyPtr (staDevice);
972 // We expect channel 1, width 22, frequency 2412
973 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11b configuration");
974 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 22, "802.11b configuration");
975 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11b configuration");
976 }
977 {
978 // case 3:
980 wifi.SetStandard (WIFI_STANDARD_80211g);
981 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
982 phySta = GetYansWifiPhyPtr (staDevice);
983 // We expect channel 1, width 20, frequency 2412
984 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11g configuration");
985 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11g configuration");
986 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11g configuration");
987 }
988 {
989 // case 4:
991 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
992 wifi.SetStandard (WIFI_STANDARD_80211n);
993 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_5GHZ, 0}"));
994 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
995 phySta = GetYansWifiPhyPtr (staDevice);
996 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11n-5GHz configuration");
997 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-5GHz configuration");
998 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11n-5GHz configuration");
999 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1000 }
1001 {
1002 // case 5:
1004 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1005 wifi.SetStandard (WIFI_STANDARD_80211n);
1006 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1007 phySta = GetYansWifiPhyPtr (staDevice);
1008 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11n-2.4GHz configuration");
1009 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11n-2.4GHz configuration");
1010 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11n-2.4GHz configuration");
1011 }
1012 {
1013 // case 6:
1015 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1016 wifi.SetStandard (WIFI_STANDARD_80211ac);
1017 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1018 phySta = GetYansWifiPhyPtr (staDevice);
1019 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ac configuration");
1020 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ac configuration");
1021 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ac configuration");
1022 }
1023 {
1024 // case 7:
1025 // By default, WifiHelper will use WIFI_PHY_STANDARD_80211ax
1027 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1028 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_2_4GHZ, 0}"));
1029 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1030 phySta = GetYansWifiPhyPtr (staDevice);
1031 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 1, "802.11ax-2.4GHz configuration");
1032 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11ax-2.4GHz configuration");
1033 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2412, "802.11ax-2.4GHz configuration");
1034 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1035 }
1036 {
1037 // case 8:
1039 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1040 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1041 phySta = GetYansWifiPhyPtr (staDevice);
1042 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 42, "802.11ax-5GHz configuration");
1043 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-5GHz configuration");
1044 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5210, "802.11ax-5GHz configuration");
1045 }
1046 {
1047 // case 9:
1049 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1050 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_6GHZ, 0}"));
1051 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1052 phySta = GetYansWifiPhyPtr (staDevice);
1053 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 7, "802.11ax-6GHz configuration");
1054 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 80, "802.11ax-6GHz configuration");
1055 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5975, "802.11ax-6GHz configuration");
1056 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1057 }
1058 {
1059 // case 10:
1061 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1062 wifi.SetStandard (WIFI_STANDARD_80211p);
1063 phy.Set ("ChannelSettings", StringValue ("{0, 10, BAND_5GHZ, 0}"));
1064 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1065 phySta = GetYansWifiPhyPtr (staDevice);
1066 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 172, "802.11p 10Mhz configuration");
1067 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 10, "802.11p 10Mhz configuration");
1068 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 10Mhz configuration");
1069 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1070 }
1071 {
1072 // case 11:
1074 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1075 wifi.SetStandard (WIFI_STANDARD_80211p);
1076 phy.Set ("ChannelSettings", StringValue ("{0, 5, BAND_5GHZ, 0}"));
1077 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1078 phySta = GetYansWifiPhyPtr (staDevice);
1079 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 171, "802.11p 5Mhz configuration");
1080 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 5, "802.11p 5Mhz configuration");
1081 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5860, "802.11p 5Mhz configuration");
1082 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1083 }
1084 {
1085 // case 12:
1087 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1088 wifi.SetStandard (WIFI_STANDARD_80211n);
1089 phy.Set ("ChannelSettings", StringValue ("{44, 20, BAND_5GHZ, 0}"));
1090 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1091 phySta = GetYansWifiPhyPtr (staDevice);
1092 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 44, "802.11 5GHz configuration");
1093 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1094 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration");
1095 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1096 }
1097 {
1098 // case 13:
1100 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1101 phy.Set ("ChannelSettings", StringValue ("{44, 0, BAND_5GHZ, 0}"));
1102 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1103 phySta = GetYansWifiPhyPtr (staDevice);
1104 // Post-install reconfiguration to channel number 40
1105 std::ostringstream path;
1106 path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings";
1107 Config::Set (path.str(), StringValue ("{40, 0, BAND_5GHZ, 0}"));
1108 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1109 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1110 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1111 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1112 }
1113 {
1114 // case 14:
1116 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1117 phy.Set ("ChannelSettings", StringValue ("{44, 0, BAND_5GHZ, 0}"));
1118 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1119 phySta = GetYansWifiPhyPtr (staDevice);
1120 // Post-install reconfiguration to a 40 MHz channel
1121 std::ostringstream path;
1122 path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings";
1123 Config::Set (path.str(), StringValue ("{46, 0, BAND_5GHZ, 0}"));
1124 // Although channel 44 is configured originally for 20 MHz, we
1125 // allow it to be used for 40 MHz here
1126 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 46, "802.11 5GHz configuration");
1127 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1128 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5230, "802.11 5GHz configuration");
1129 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1130 }
1131 {
1132 // case 15:
1134 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1135 wifi.SetStandard (WIFI_STANDARD_80211n);
1136 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1137 phySta = GetYansWifiPhyPtr (staDevice);
1138 phySta->SetAttribute ("ChannelSettings", StringValue ("{3, 20, BAND_2_4GHZ, 0}"));
1139 return;
1140 // Post-install reconfiguration to a 40 MHz channel
1141 std::ostringstream path;
1142 path << "/NodeList/*/DeviceList/" << staDevice.Get(0)->GetIfIndex () << "/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings";
1143 Config::Set (path.str(), StringValue ("{4, 40, BAND_2_4GHZ, 0}"));
1144 // Although channel 44 is configured originally for 20 MHz, we
1145 // allow it to be used for 40 MHz here
1146 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 4, "802.11 5GHz configuration");
1147 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration");
1148 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 2427, "802.11 5GHz configuration");
1149 phy.Set ("ChannelSettings", StringValue ("{0, 0, BAND_UNSPECIFIED, 0}")); // restore default
1150 }
1151 {
1152 // case 16:
1154 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1155 // Test that setting Frequency to a non-standard value will throw an exception
1156 wifi.SetStandard (WIFI_STANDARD_80211n);
1157 phy.Set ("ChannelSettings", StringValue ("{44, 0, BAND_5GHZ, 0}"));
1158 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1159 phySta = GetYansWifiPhyPtr (staDevice);
1160 bool exceptionThrown = false;
1161 try
1162 {
1163 phySta->SetAttribute ("ChannelSettings", StringValue ("{45, 0, BAND_5GHZ, 0}"));
1164 }
1165 catch (const std::runtime_error&)
1166 {
1167 exceptionThrown = true;
1168 }
1169 // We expect that an exception is thrown
1170 NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1171 }
1172 {
1173 // case 17:
1175 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1176 wifi.SetStandard (WIFI_STANDARD_80211n);
1177 phy.Set ("ChannelSettings", StringValue ("{44, 0, BAND_5GHZ, 0}"));
1178 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1179 phySta = GetYansWifiPhyPtr (staDevice);
1180 // Test that setting channel to a standard value will set the
1181 // frequency correctly
1182 phySta->SetAttribute ("ChannelSettings", StringValue ("{100, 0, BAND_5GHZ, 0}"));
1183 // We expect frequency to be 5500 due to channel number being 100
1184 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 100, "802.11 5GHz configuration");
1185 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1186 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5500, "802.11 5GHz configuration");
1187 }
1188 {
1189 // case 18:
1190 // Set a wrong channel after initialization
1192 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1193 wifi.SetStandard (WIFI_STANDARD_80211n);
1194 phy.Set ("ChannelSettings", StringValue ("{44, 0, BAND_5GHZ, 0}"));
1195 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1196 phySta = GetYansWifiPhyPtr (staDevice);
1197 bool exceptionThrown = false;
1198 try
1199 {
1201 }
1202 catch (const std::runtime_error&)
1203 {
1204 exceptionThrown = true;
1205 }
1206 // We expect that an exception is thrown
1207 NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1208 }
1209 {
1210 // case 19:
1212 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1213 // Test how channel number behaves when frequency is non-standard
1214 wifi.SetStandard (WIFI_STANDARD_80211n);
1215 phy.Set ("ChannelSettings", StringValue ("{44, 0, BAND_5GHZ, 0}"));
1216 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1217 phySta = GetYansWifiPhyPtr (staDevice);
1218 bool exceptionThrown = false;
1219 try
1220 {
1221 phySta->SetAttribute ("ChannelSettings", StringValue ("{45, 0, BAND_5GHZ, 0}"));
1222 }
1223 catch (const std::runtime_error&)
1224 {
1225 exceptionThrown = true;
1226 }
1227 // We expect that an exception is thrown due to unknown channel number 45
1228 NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1229 phySta->SetAttribute ("ChannelSettings", StringValue ("{36, 0, BAND_5GHZ, 0}"));
1230 // We expect channel number to be 36 due to known center frequency 5180
1231 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1232 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1233 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1234 exceptionThrown = false;
1235 try
1236 {
1237 phySta->SetAttribute ("ChannelSettings", StringValue ("{43, 0, BAND_5GHZ, 0}"));
1238 }
1239 catch (const std::runtime_error&)
1240 {
1241 exceptionThrown = true;
1242 }
1243 // We expect that an exception is thrown due to unknown channel number 43
1244 NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1245 phySta->SetAttribute ("ChannelSettings", StringValue ("{36, 0, BAND_5GHZ, 0}"));
1246 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1247 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1248 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1249 }
1250 {
1251 // case 20:
1253 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
1254 phy.Set ("ChannelSettings", StringValue ("{40, 0, BAND_5GHZ, 0}"));
1255 wifi.SetStandard (WIFI_STANDARD_80211n);
1256 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1257 phySta = GetYansWifiPhyPtr (staDevice);
1258 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1259 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1260 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1261 // Set both channel and frequency to consistent values after initialization
1262 wifi.SetStandard (WIFI_STANDARD_80211n);
1263 staDevice = wifi.Install (phy, macSta, wifiStaNode.Get (0));
1264 phySta = GetYansWifiPhyPtr (staDevice);
1265 phySta->SetAttribute ("ChannelSettings", StringValue ("{40, 0, BAND_5GHZ, 0}"));
1266 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "802.11 5GHz configuration");
1267 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1268 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5200, "802.11 5GHz configuration");
1269
1270 phySta->SetAttribute ("ChannelSettings", StringValue ("{36, 0, BAND_5GHZ, 0}"));
1271 // We expect channel number to be 36
1272 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1273 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1274 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1275 phySta->SetAttribute ("ChannelSettings", StringValue ("{40, 0, BAND_5GHZ, 0}"));
1276 // We expect channel number to be 40
1277 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 40, "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 (), 5200, "802.11 5GHz configuration");
1280 bool exceptionThrown = false;
1281 try
1282 {
1283 phySta->SetAttribute ("ChannelSettings", StringValue ("{45, 0, BAND_5GHZ, 0}"));
1284 }
1285 catch (const std::runtime_error&)
1286 {
1287 exceptionThrown = true;
1288 }
1289 phySta->SetAttribute ("ChannelSettings", StringValue ("{36, 0, BAND_5GHZ, 0}"));
1290 // We expect channel number to be 36 and an exception to be thrown
1291 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1292 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1293 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1294 NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1295 phySta->SetAttribute ("ChannelSettings", StringValue ("{36, 0, BAND_5GHZ, 0}"));
1296 exceptionThrown = false;
1297 try
1298 {
1299 phySta->SetAttribute ("ChannelSettings", StringValue ("{43, 0, BAND_5GHZ, 0}"));
1300 }
1301 catch (const std::runtime_error&)
1302 {
1303 exceptionThrown = true;
1304 }
1305 // We expect channel number to be 36 and an exception to be thrown
1306 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelNumber (), 36, "802.11 5GHz configuration");
1307 NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 20, "802.11 5GHz configuration");
1308 NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5180, "802.11 5GHz configuration");
1309 NS_TEST_ASSERT_MSG_EQ (exceptionThrown, true, "802.11 5GHz configuration");
1310 }
1311
1312 Simulator::Destroy ();
1313}
1314
1315//-----------------------------------------------------------------------------
1324{
1325public:
1326 Bug2222TestCase ();
1327 virtual ~Bug2222TestCase ();
1328
1329 void DoRun (void) override;
1330
1331
1332private:
1334
1340 void TxDataFailedTrace (std::string context, Mac48Address adr);
1341};
1342
1344 : TestCase ("Test case for Bug 2222"),
1345 m_countInternalCollisions (0)
1346{
1347}
1348
1350{
1351}
1352
1353void
1355{
1356 //Indicate the long retry counter has been increased in the wifi remote station manager
1358}
1359
1360void
1362{
1364
1365 //Generate same backoff for AC_VI and AC_VO
1366 //The below combination will work
1367 RngSeedManager::SetSeed (1);
1368 RngSeedManager::SetRun (1);
1369 int64_t streamNumber = 100;
1370
1371 NodeContainer wifiNodes;
1372 wifiNodes.Create (2);
1373
1374 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1376 phy.SetChannel (channel.Create ());
1377
1379 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1380 "DataMode", StringValue ("OfdmRate54Mbps"),
1381 "ControlMode", StringValue ("OfdmRate24Mbps"));
1383 Ssid ssid = Ssid ("ns-3-ssid");
1384 mac.SetType ("ns3::AdhocWifiMac",
1385 "QosSupported", BooleanValue (true));
1386
1387 NetDeviceContainer wifiDevices;
1388 wifiDevices = wifi.Install (phy, mac, wifiNodes);
1389
1390 // Assign fixed streams to random variables in use
1391 wifi.AssignStreams (wifiDevices, streamNumber);
1392
1394 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1395
1396 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1397 positionAlloc->Add (Vector (10.0, 0.0, 0.0));
1398 mobility.SetPositionAllocator (positionAlloc);
1399
1400 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1401 mobility.Install (wifiNodes);
1402
1403 Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0));
1404 Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1));
1405
1406 PacketSocketAddress socket;
1407 socket.SetSingleDevice (device1->GetIfIndex ());
1408 socket.SetPhysicalAddress (device2->GetAddress ());
1409 socket.SetProtocol (1);
1410
1411 PacketSocketHelper packetSocket;
1412 packetSocket.Install (wifiNodes);
1413
1414 Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> ();
1415 clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1416 clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1417 clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI
1418 clientLowPriority->SetRemote (socket);
1419 wifiNodes.Get (0)->AddApplication (clientLowPriority);
1420 clientLowPriority->SetStartTime (Seconds (0.0));
1421 clientLowPriority->SetStopTime (Seconds (1.0));
1422
1423 Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> ();
1424 clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460));
1425 clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1));
1426 clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO
1427 clientHighPriority->SetRemote (socket);
1428 wifiNodes.Get (0)->AddApplication (clientHighPriority);
1429 clientHighPriority->SetStartTime (Seconds (0.0));
1430 clientHighPriority->SetStopTime (Seconds (1.0));
1431
1432 Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
1433 server->SetLocal (socket);
1434 wifiNodes.Get (1)->AddApplication (server);
1435 server->SetStartTime (Seconds (0.0));
1436 server->SetStopTime (Seconds (1.0));
1437
1438 Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this));
1439
1440 Simulator::Stop (Seconds (1.0));
1441 Simulator::Run ();
1442 Simulator::Destroy ();
1443
1444 NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1445}
1446
1447//-----------------------------------------------------------------------------
1461{
1462public:
1463 Bug2843TestCase ();
1464 virtual ~Bug2843TestCase ();
1465 void DoRun (void) override;
1466
1467private:
1471 typedef std::tuple<double, uint16_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1472 std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples;
1473
1480 void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1487 void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1488
1490};
1491
1493 : TestCase ("Test case for Bug 2843"),
1494 m_channelWidth (20)
1495{
1496}
1497
1499{
1500}
1501
1502void
1504{
1505 // Extract starting frequency and number of subbands
1506 Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1507 std::size_t numBands = c->GetNumBands ();
1508 double startingFreq = c->Begin ()->fl;
1509
1510 // Get channel bandwidth and modulation class
1511 Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1512
1513 Ptr<WifiPpdu> ppdu = wifiTxParams->ppdu->Copy ();
1514 WifiTxVector txVector = ppdu->GetTxVector ();
1515 m_channelWidth = txVector.GetChannelWidth ();
1516 WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1517
1518 // Build a tuple and check if seen before (if so store it)
1519 FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, m_channelWidth, numBands, modulationClass);
1520 bool found = false;
1521 for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1522 {
1523 if (*it == tupleForCurrentTx)
1524 {
1525 found = true;
1526 }
1527 }
1528 if (!found)
1529 {
1530 m_distinctTuples.push_back (tupleForCurrentTx);
1531 }
1532}
1533
1534void
1535Bug2843TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1536 Address& destination) const
1537{
1538 for (uint8_t i = 0; i < numPackets; i++)
1539 {
1540 Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
1541 sourceDevice->Send (pkt, destination, 0);
1542 }
1543}
1544
1545void
1547{
1548 uint16_t channelWidth = 40; // at least 40 MHz expected here
1549
1550 NodeContainer wifiStaNode;
1551 wifiStaNode.Create (1);
1552
1554 wifiApNode.Create (1);
1555
1556 SpectrumWifiPhyHelper spectrumPhy;
1557 Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1558 Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1559 lossModel->SetFrequency (5.190e9);
1560 spectrumChannel->AddPropagationLossModel (lossModel);
1561
1563 = CreateObject<ConstantSpeedPropagationDelayModel> ();
1564 spectrumChannel->SetPropagationDelayModel (delayModel);
1565
1566 spectrumPhy.SetChannel (spectrumChannel);
1567 spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1568 spectrumPhy.Set ("ChannelSettings", StringValue ("{38, 40, BAND_5GHZ, 0}"));
1569 spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1570 spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1571
1573 wifi.SetStandard (WIFI_STANDARD_80211ac);
1574 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1575 "DataMode", StringValue ("VhtMcs8"),
1576 "ControlMode", StringValue ("VhtMcs8"),
1577 "RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1578
1580 mac.SetType ("ns3::StaWifiMac");
1581 NetDeviceContainer staDevice;
1582 staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1583
1584 mac.SetType ("ns3::ApWifiMac");
1585 NetDeviceContainer apDevice;
1586 apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1587
1589 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1590 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1591 positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1592 mobility.SetPositionAllocator (positionAlloc);
1593
1594 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1595 mobility.Install (wifiApNode);
1596 mobility.Install (wifiStaNode);
1597
1598 // Send two 5 packet-bursts
1599 Simulator::Schedule (Seconds (0.5), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1600 Simulator::Schedule (Seconds (0.6), &Bug2843TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1601
1602 Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2843TestCase::StoreDistinctTuple, this));
1603
1604 Simulator::Stop (Seconds (0.8));
1605 Simulator::Run ();
1606
1607 Simulator::Destroy ();
1608
1609 // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1610 std::size_t numberTuples = m_distinctTuples.size ();
1611 NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1612 NS_TEST_ASSERT_MSG_EQ (std::get<0> (m_distinctTuples[0]) - 20e6, std::get<0> (m_distinctTuples[1]), "The starting frequency of the first tuple should be shifted 20 MHz to the right wrt second tuple");
1613 // Note that the first tuple should the one initiated by the beacon, i.e. non-HT OFDM (20 MHz)
1614 NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's channel width should be 20 MHz");
1615 NS_TEST_ASSERT_MSG_EQ (std::get<2> (m_distinctTuples[0]), 193, "First tuple should have 193 subbands (64+DC, 20MHz+DC, inband and 64*2 out-of-band, 20MHz on each side)");
1616 NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1617 // Second tuple
1618 NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Second tuple's channel width should be 40 MHz");
1619 NS_TEST_ASSERT_MSG_EQ (std::get<2> (m_distinctTuples[1]), 385, "Second tuple should have 385 subbands (128+DC, 40MHz+DC, inband and 128*2 out-of-band, 40MHz on each side)");
1620 NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1621}
1622
1623//-----------------------------------------------------------------------------
1636{
1637public:
1638 Bug2831TestCase ();
1639 virtual ~Bug2831TestCase ();
1640 void DoRun (void) override;
1641
1642private:
1646 void ChangeSupportedChannelWidth (void);
1653 void RxCallback (std::string context, Ptr<const Packet> p, RxPowerWattPerChannelBand rxPowersW);
1654
1657
1662};
1663
1665 : TestCase ("Test case for Bug 2831"),
1666 m_assocReqCount (0),
1667 m_assocRespCount (0),
1668 m_countOperationalChannelWidth20 (0),
1669 m_countOperationalChannelWidth40 (0)
1670{
1671}
1672
1674{
1675}
1676
1677void
1679{
1682}
1683
1684void
1686{
1687 Ptr<Packet> packet = p->Copy ();
1688 WifiMacHeader hdr;
1689 packet->RemoveHeader (hdr);
1690 if (hdr.IsAssocReq ())
1691 {
1693 }
1694 else if (hdr.IsAssocResp ())
1695 {
1697 }
1698 else if (hdr.IsBeacon ())
1699 {
1700 MgtBeaconHeader beacon;
1701 packet->RemoveHeader (beacon);
1702 HtOperation htOperation = beacon.GetHtOperation ();
1703 if (htOperation.GetStaChannelWidth () > 0)
1704 {
1706 }
1707 else
1708 {
1710 }
1711 }
1712}
1713
1714void
1716{
1717 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
1718 ObjectFactory propDelay;
1719 propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
1720 Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDelayModel> ();
1721 Ptr<PropagationLossModel> propagationLoss = CreateObject<FriisPropagationLossModel> ();
1722 channel->SetPropagationDelayModel (propagationDelay);
1723 channel->SetPropagationLossModel (propagationLoss);
1724
1725 Ptr<Node> apNode = CreateObject<Node> ();
1726 Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> ();
1728 Ptr<HtConfiguration> apHtConfiguration = CreateObject<HtConfiguration> ();
1729 apDev->SetHtConfiguration (apHtConfiguration);
1731 mac.SetTypeId ("ns3::ApWifiMac");
1732 mac.Set ("EnableBeaconJitter", BooleanValue (false));
1733 mac.Set ("QosSupported", BooleanValue (true));
1734 Ptr<WifiMac> apMac = mac.Create<WifiMac> ();
1735 apMac->SetDevice (apDev);
1736 apMac->SetAddress (Mac48Address::Allocate ());
1737 apMac->ConfigureStandard (WIFI_STANDARD_80211ax);
1738 Ptr<FrameExchangeManager> fem = apMac->GetFrameExchangeManager ();
1739 Ptr<WifiProtectionManager> protectionManager = CreateObject<WifiDefaultProtectionManager> ();
1740 protectionManager->SetWifiMac (apMac);
1741 fem->SetProtectionManager (protectionManager);
1742 Ptr<WifiAckManager> ackManager = CreateObject<WifiDefaultAckManager> ();
1743 ackManager->SetWifiMac (apMac);
1744 fem->SetAckManager (ackManager);
1745
1746 Ptr<Node> staNode = CreateObject<Node> ();
1747 Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> ();
1749 Ptr<HtConfiguration> staHtConfiguration = CreateObject<HtConfiguration> ();
1750 staDev->SetHtConfiguration (staHtConfiguration);
1751 mac.SetTypeId ("ns3::StaWifiMac");
1752 Ptr<WifiMac> staMac = mac.Create<WifiMac> ();
1753 staMac->SetDevice (staDev);
1754 staMac->SetAddress (Mac48Address::Allocate ());
1755 staMac->ConfigureStandard (WIFI_STANDARD_80211ax);
1756 fem = staMac->GetFrameExchangeManager ();
1757 protectionManager = CreateObject<WifiDefaultProtectionManager> ();
1758 protectionManager->SetWifiMac (staMac);
1759 fem->SetProtectionManager (protectionManager);
1760 ackManager = CreateObject<WifiDefaultAckManager> ();
1761 ackManager->SetWifiMac (staMac);
1762 fem->SetAckManager (ackManager);
1763
1764 Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
1765 apMobility->SetPosition (Vector (0.0, 0.0, 0.0));
1766 apNode->AggregateObject (apMobility);
1767
1768 Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
1769 m_apPhy = CreateObject<YansWifiPhy> ();
1770 m_apPhy->SetErrorRateModel (error);
1772 m_apPhy->SetMobility (apMobility);
1773 m_apPhy->SetDevice (apDev);
1776
1777 Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPositionMobilityModel> ();
1778 staMobility->SetPosition (Vector (1.0, 0.0, 0.0));
1779 staNode->AggregateObject (staMobility);
1780
1781 m_staPhy = CreateObject<YansWifiPhy> ();
1782 m_staPhy->SetErrorRateModel (error);
1784 m_staPhy->SetMobility (staMobility);
1785 m_staPhy->SetDevice (apDev);
1788
1789 apDev->SetMac (apMac);
1790 apDev->SetPhy (m_apPhy);
1791 ObjectFactory manager;
1792 manager.SetTypeId ("ns3::ConstantRateWifiManager");
1794 apNode->AddDevice (apDev);
1795
1796 staDev->SetMac (staMac);
1797 staDev->SetPhy (m_staPhy);
1799 staNode->AddDevice (staDev);
1800
1801 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this));
1802
1803 Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWidth, this);
1804
1805 Simulator::Stop (Seconds (3.0));
1806 Simulator::Run ();
1807 Simulator::Destroy ();
1808
1809 NS_TEST_ASSERT_MSG_EQ (m_assocReqCount, 2, "Second Association request not received");
1810 NS_TEST_ASSERT_MSG_EQ (m_assocRespCount, 2, "Second Association response not received");
1811 NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operational channel width before channel change");
1812 NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operational channel width after channel change");
1813}
1814
1815//-----------------------------------------------------------------------------
1832{
1833public:
1835 virtual ~StaWifiMacScanningTestCase ();
1836 void DoRun (void) override;
1837
1838private:
1844 void AssocCallback (std::string context, Mac48Address bssid);
1849 void TurnBeaconGenerationOn (Ptr<Node> apNode);
1854 void TurnApOff (Ptr<Node> apNode);
1861 NodeContainer Setup (bool nearestApBeaconGeneration, bool staActiveProbe);
1862
1864};
1865
1867 : TestCase ("Test case for StaWifiMac scanning capability")
1868{
1869}
1870
1872{
1873}
1874
1875void
1877{
1878 m_associatedApBssid = bssid;
1879}
1880
1881void
1883{
1884 Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1885 Ptr<ApWifiMac> mac = DynamicCast<ApWifiMac> (netDevice->GetMac ());
1886 mac->SetAttribute ("BeaconGeneration", BooleanValue (true));
1887}
1888
1889void
1891{
1892 Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (apNode->GetDevice (0));
1893 Ptr<WifiPhy> phy = netDevice->GetPhy ();
1894 phy->SetOffMode ();
1895}
1896
1898StaWifiMacScanningTestCase::Setup (bool nearestApBeaconGeneration, bool staActiveProbe)
1899{
1900 RngSeedManager::SetSeed (1);
1901 RngSeedManager::SetRun (1);
1902 int64_t streamNumber = 1;
1903
1904 NodeContainer apNodes;
1905 apNodes.Create (2);
1906
1907 Ptr<Node> apNodeNearest = CreateObject<Node> ();
1908 Ptr<Node> staNode = CreateObject<Node> ();
1909
1911 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
1912 phy.SetChannel (channel.Create ());
1913
1915 wifi.SetStandard (WIFI_STANDARD_80211n);
1916 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
1917
1919 NetDeviceContainer apDevice, apDeviceNearest;
1920 mac.SetType ("ns3::ApWifiMac",
1921 "BeaconGeneration", BooleanValue (true));
1922 apDevice = wifi.Install (phy, mac, apNodes);
1923 mac.SetType ("ns3::ApWifiMac",
1924 "BeaconGeneration", BooleanValue (nearestApBeaconGeneration));
1925 apDeviceNearest = wifi.Install (phy, mac, apNodeNearest);
1926
1927 NetDeviceContainer staDevice;
1928 mac.SetType ("ns3::StaWifiMac",
1929 "ActiveProbing", BooleanValue (staActiveProbe));
1930 staDevice = wifi.Install (phy, mac, staNode);
1931
1932 // Assign fixed streams to random variables in use
1933 wifi.AssignStreams (apDevice, streamNumber);
1934 wifi.AssignStreams (apDeviceNearest, streamNumber + 1);
1935 wifi.AssignStreams (staDevice, streamNumber + 2);
1936
1938 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1939 positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Furthest AP
1940 positionAlloc->Add (Vector (10.0, 0.0, 0.0)); // Second nearest AP
1941 positionAlloc->Add (Vector (5.0, 5.0, 0.0)); // Nearest AP
1942 positionAlloc->Add (Vector (6.0, 5.0, 0.0)); // STA
1943 mobility.SetPositionAllocator (positionAlloc);
1944
1945 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1946 mobility.Install (apNodes);
1947 mobility.Install (apNodeNearest);
1948 mobility.Install (staNode);
1949
1950 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc", MakeCallback (&StaWifiMacScanningTestCase::AssocCallback, this));
1951
1952 NodeContainer allNodes = NodeContainer (apNodes, apNodeNearest, staNode);
1953 return allNodes;
1954}
1955
1956void
1958{
1959 {
1960 NodeContainer nodes = Setup (false, false);
1961 Ptr<Node> nearestAp = nodes.Get (2);
1962 Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1963
1964 Simulator::Schedule (Seconds (0.05), &StaWifiMacScanningTestCase::TurnBeaconGenerationOn, this, nearestAp);
1965
1966 Simulator::Stop (Seconds (0.2));
1967 Simulator::Run ();
1968 Simulator::Destroy ();
1969
1970 NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1971 }
1973 {
1974 NodeContainer nodes = Setup (true, true);
1975 Ptr<Node> nearestAp = nodes.Get (2);
1976 Mac48Address nearestApAddr = DynamicCast<WifiNetDevice> (nearestAp->GetDevice (0))->GetMac ()->GetAddress ();
1977
1978 Simulator::Stop (Seconds (0.2));
1979 Simulator::Run ();
1980 Simulator::Destroy ();
1981
1982 NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, nearestApAddr, "STA is associated to the wrong AP");
1983 }
1985 {
1986 NodeContainer nodes = Setup (true, false);
1987 Ptr<Node> nearestAp = nodes.Get (2);
1988 Mac48Address secondNearestApAddr = DynamicCast<WifiNetDevice> (nodes.Get (1)->GetDevice (0))->GetMac ()->GetAddress ();
1989
1990 Simulator::Schedule (Seconds (0.1), &StaWifiMacScanningTestCase::TurnApOff, this, nearestAp);
1991
1992 Simulator::Stop (Seconds (1.5));
1993 Simulator::Run ();
1994 Simulator::Destroy ();
1995
1996 NS_TEST_ASSERT_MSG_EQ (m_associatedApBssid, secondNearestApAddr, "STA is associated to the wrong AP");
1997 }
1998}
1999
2000//-----------------------------------------------------------------------------
2024{
2025public:
2026 Bug2470TestCase ();
2027 virtual ~Bug2470TestCase ();
2028 void DoRun (void) override;
2029
2030private:
2039 void AddbaStateChangedCallback (std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
2050 void RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId);
2057 void RxErrorCallback (std::string context, Ptr<const Packet> p, double snr);
2064 void SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
2070 void RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel);
2071
2080};
2081
2083 : TestCase ("Test case for Bug 2470"),
2084 m_receivedNormalMpduCount (0),
2085 m_receivedAmpduCount (0),
2086 m_failedActionCount (0),
2087 m_addbaEstablishedCount (0),
2088 m_addbaPendingCount (0),
2089 m_addbaRejectedCount (0),
2090 m_addbaNoReplyCount (0),
2091 m_addbaResetCount (0)
2092{
2093}
2094
2096{
2097}
2098
2099void
2101{
2102 switch (state)
2103 {
2104 case OriginatorBlockAckAgreement::ESTABLISHED:
2106 break;
2107 case OriginatorBlockAckAgreement::PENDING:
2109 break;
2110 case OriginatorBlockAckAgreement::REJECTED:
2112 break;
2113 case OriginatorBlockAckAgreement::NO_REPLY:
2115 break;
2116 case OriginatorBlockAckAgreement::RESET:
2118 break;
2119 }
2120}
2121
2122void
2123Bug2470TestCase::RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId)
2124{
2125 Ptr<Packet> packet = p->Copy ();
2126 if (aMpdu.type != MpduType::NORMAL_MPDU)
2127 {
2129 }
2130 else
2131 {
2132 WifiMacHeader hdr;
2133 packet->RemoveHeader (hdr);
2134 if (hdr.IsData ())
2135 {
2137 }
2138 }
2139}
2140
2141void
2142Bug2470TestCase::RxErrorCallback (std::string context, Ptr<const Packet> p, double snr)
2143{
2144 Ptr<Packet> packet = p->Copy ();
2145 WifiMacHeader hdr;
2146 packet->RemoveHeader (hdr);
2147 if (hdr.IsAction ())
2148 {
2150 }
2151}
2152
2153void
2155 Address& destination) const
2156{
2157 for (uint32_t i = 0; i < numPackets; i++)
2158 {
2159 Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2160 sourceDevice->Send (pkt, destination, 0);
2161 }
2162}
2163
2164void
2166{
2167 RngSeedManager::SetSeed (1);
2168 RngSeedManager::SetRun (1);
2169 int64_t streamNumber = 200;
2170
2171 NodeContainer wifiApNode, wifiStaNode;
2172 wifiApNode.Create (1);
2173 wifiStaNode.Create (1);
2174
2176 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2177 phy.SetChannel (channel.Create ());
2178
2180 wifi.SetStandard (WIFI_STANDARD_80211n);
2181 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2182 "DataMode", StringValue ("HtMcs7"),
2183 "ControlMode", StringValue ("HtMcs7"));
2184
2186 NetDeviceContainer apDevice;
2187 phy.Set ("PostReceptionErrorModel", apErrorModel);
2188 phy.Set ("ChannelSettings", StringValue ("{36, 20, BAND_5GHZ, 0}"));
2189 mac.SetType ("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue (false));
2190 apDevice = wifi.Install (phy, mac, wifiApNode);
2191
2192 NetDeviceContainer staDevice;
2193 phy.Set ("PostReceptionErrorModel", staErrorModel);
2194 mac.SetType ("ns3::StaWifiMac");
2195 staDevice = wifi.Install (phy, mac, wifiStaNode);
2196
2197 // Assign fixed streams to random variables in use
2198 wifi.AssignStreams (apDevice, streamNumber);
2199 wifi.AssignStreams (staDevice, streamNumber);
2200
2202 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2203 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2204 positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2205 mobility.SetPositionAllocator (positionAlloc);
2206
2207 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2208 mobility.Install (wifiApNode);
2209 mobility.Install (wifiStaNode);
2210
2211 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this));
2212 Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&Bug2470TestCase::RxErrorCallback, this));
2213 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this));
2214
2215 Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2216 Simulator::Schedule (Seconds (0.5) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2217 Simulator::Schedule (Seconds (0.8), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2218 Simulator::Schedule (Seconds (0.8) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2219
2220 Simulator::Stop (Seconds (1.0));
2221 Simulator::Run ();
2222 Simulator::Destroy ();
2223}
2224
2225void
2227{
2228 // Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel
2229 // instead of ListErrorModel since packet UID is incremented between simulations. But
2230 // problem may occur because of random stream, therefore we suppress usage of RNG as
2231 // much as possible (i.e., removing beacon jitter).
2232 Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel> ();
2233 std::list<uint32_t> blackList;
2234 // Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2235 blackList.push_back (9);
2236 blackList.push_back (10);
2237 blackList.push_back (11);
2238 blackList.push_back (12);
2239 blackList.push_back (13);
2240 blackList.push_back (14);
2241 staPem->SetList (blackList);
2242
2243 {
2244 RunSubtest (PointerValue (), PointerValue (staPem));
2245 NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 6, "ADDBA request packets are not failed");
2246 // There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by normal
2247 // MPDU because of failed ADDBA handshake. For the second set, the first packet should be sent by
2248 // normal MPDU, and the rest with A-MPDU. In total we expect to receive 2 normal MPDU packets and
2249 // 8 A-MPDU packets.
2250 NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 2, "Receiving incorrect number of normal MPDU packet on subtest 1");
2251 NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 8, "Receiving incorrect number of A-MPDU packet on subtest 1");
2252
2253 NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 1");
2254 NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 1");
2255 NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 1");
2256 NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 0, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 1");
2257 NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 1");
2258 }
2259
2268
2269 Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel> ();
2270 blackList.clear ();
2271 // Block ADDBA request 4 times (== maximum number of MAC frame transmissions in the ADDBA response timeout interval)
2272 blackList.push_back (5);
2273 blackList.push_back (6);
2274 blackList.push_back (7);
2275 blackList.push_back (9);
2276 apPem->SetList (blackList);
2277
2278 {
2279 RunSubtest (PointerValue (apPem), PointerValue ());
2280 NS_TEST_ASSERT_MSG_EQ (m_failedActionCount, 4, "ADDBA response packets are not failed");
2281 // Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU packets.
2282 NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 6, "Receiving incorrect number of normal MPDU packet on subtest 2");
2283 NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 4, "Receiving incorrect number of A-MPDU packet on subtest 2");
2284
2285 NS_TEST_ASSERT_MSG_EQ (m_addbaEstablishedCount, 1, "Incorrect number of times the ADDBA state machine was in established state on subtest 2");
2286 NS_TEST_ASSERT_MSG_EQ (m_addbaPendingCount, 1, "Incorrect number of times the ADDBA state machine was in pending state on subtest 2");
2287 NS_TEST_ASSERT_MSG_EQ (m_addbaRejectedCount, 0, "Incorrect number of times the ADDBA state machine was in rejected state on subtest 2");
2288 NS_TEST_ASSERT_MSG_EQ (m_addbaNoReplyCount, 1, "Incorrect number of times the ADDBA state machine was in no_reply state on subtest 2");
2289 NS_TEST_ASSERT_MSG_EQ (m_addbaResetCount, 0, "Incorrect number of times the ADDBA state machine was in reset state on subtest 2");
2290 }
2291
2292 // TODO: In the second test set, it does not go to reset state since ADDBA response is received after timeout (NO_REPLY)
2293 // but before it does not enter RESET state. More tests should be written to verify all possible scenarios.
2294}
2295
2296//-----------------------------------------------------------------------------
2312{
2313public:
2314 Issue40TestCase ();
2315 virtual ~Issue40TestCase ();
2316 void DoRun (void) override;
2317
2318private:
2323 void RunOne (bool useAmpdu);
2324
2330 void RxSuccessCallback (std::string context, Ptr<const Packet> p);
2337 void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination);
2343 void TxFinalDataFailedCallback (std::string context, Mac48Address address);
2344
2345 uint16_t m_rxCount;
2346 uint16_t m_txCount;
2348};
2349
2351 : TestCase ("Test case for issue #40"),
2352 m_rxCount (0),
2353 m_txCount (0),
2354 m_txMacFinalDataFailedCount (0)
2355{
2356}
2357
2359{
2360}
2361
2362void
2364{
2365 m_rxCount++;
2366}
2367
2368void
2369Issue40TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination)
2370{
2371 for (uint8_t i = 0; i < numPackets; i++)
2372 {
2373 Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data
2374 sourceDevice->Send (pkt, destination, 0);
2375 m_txCount++;
2376 }
2377}
2378
2379void
2381{
2383}
2384
2385void
2387{
2388 m_rxCount = 0;
2389 m_txCount = 0;
2391
2392 RngSeedManager::SetSeed (1);
2393 RngSeedManager::SetRun (1);
2394 int64_t streamNumber = 100;
2395
2396 NodeContainer wifiApNode, wifiStaNode;
2397 wifiApNode.Create (1);
2398 wifiStaNode.Create (1);
2399
2401 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2402 phy.SetChannel (channel.Create ());
2403
2405 wifi.SetStandard (WIFI_STANDARD_80211ac);
2406 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2407
2409 NetDeviceContainer apDevice;
2410 mac.SetType ("ns3::ApWifiMac");
2411 apDevice = wifi.Install (phy, mac, wifiApNode);
2412
2413 NetDeviceContainer staDevice;
2414 mac.SetType ("ns3::StaWifiMac");
2415 staDevice = wifi.Install (phy, mac, wifiStaNode);
2416
2417 // Assign fixed streams to random variables in use
2418 wifi.AssignStreams (apDevice, streamNumber);
2419 wifi.AssignStreams (staDevice, streamNumber);
2420
2422 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2423 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2424 positionAlloc->Add (Vector (10.0, 0.0, 0.0));
2425 mobility.SetPositionAllocator (positionAlloc);
2426
2427 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2428 mobility.Install (wifiApNode);
2429
2430 mobility.SetMobilityModel("ns3::WaypointMobilityModel");
2431 mobility.Install (wifiStaNode);
2432
2433 Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxFinalDataFailed", MakeCallback (&Issue40TestCase::TxFinalDataFailedCallback, this));
2434 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/MacRx", MakeCallback (&Issue40TestCase::RxSuccessCallback, this));
2435
2436 Ptr<WaypointMobilityModel> staWaypointMobility = DynamicCast<WaypointMobilityModel>(wifiStaNode.Get(0)->GetObject<MobilityModel>());
2437 staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.0), Vector (10.0, 0.0, 0.0)));
2438 staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.5), Vector (50.0, 0.0, 0.0)));
2439
2440 if (useAmpdu)
2441 {
2442 // Disable use of BAR that are sent with the lowest modulation so that we can also reproduce the problem with A-MPDU, i.e. the lack of feedback about SNR change
2443 Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevice.Get (0));
2444 PointerValue ptr;
2445 ap_device->GetMac ()->GetAttribute ("BE_Txop", ptr);
2446 ptr.Get<QosTxop> ()->SetAttribute ("UseExplicitBarAfterMissedBlockAck", BooleanValue (false));
2447 }
2448
2449 // Transmit a first data packet before the station moves: it should be sent with a high modulation and successfully received
2450 Simulator::Schedule (Seconds (0.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2451
2452 // Transmit a second data packet once the station is away from the access point: it should be sent with the same high modulation and be unsuccessfully received
2453 Simulator::Schedule (Seconds (2.0), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2454
2455 // Keep on transmitting data packets while the station is away from the access point: it should be sent with a lower modulation and be successfully received
2456 Simulator::Schedule (Seconds (2.1), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2457 Simulator::Schedule (Seconds (2.2), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2458 Simulator::Schedule (Seconds (2.3), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2459 Simulator::Schedule (Seconds (2.4), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2460 Simulator::Schedule (Seconds (2.5), &Issue40TestCase::SendPackets, this, useAmpdu ? 2 : 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2461
2462 Simulator::Stop (Seconds (3.0));
2463 Simulator::Run ();
2464
2465 NS_TEST_ASSERT_MSG_EQ (m_txCount, (useAmpdu ? 14 : 7), "Incorrect number of transmitted packets");
2466 NS_TEST_ASSERT_MSG_EQ (m_rxCount, (useAmpdu ? 12 : 6), "Incorrect number of successfully received packets");
2467 NS_TEST_ASSERT_MSG_EQ (m_txMacFinalDataFailedCount, 1, "Incorrect number of dropped TX packets");
2468
2469 Simulator::Destroy ();
2470}
2471
2472void
2474{
2475 //Test without A-MPDU
2476 RunOne (false);
2477
2478 //Test with A-MPDU
2479 RunOne (true);
2480}
2481
2482//-----------------------------------------------------------------------------
2496{
2497public:
2499 virtual ~Issue169TestCase ();
2500 void DoRun (void) override;
2501
2502private:
2510 void SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority);
2511
2519 void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW);
2520};
2521
2523 : TestCase ("Test case for issue #169")
2524{
2525}
2526
2528{
2529}
2530
2531void
2532Issue169TestCase::SendPackets (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination, uint8_t priority)
2533{
2534 SocketPriorityTag priorityTag;
2535 priorityTag.SetPriority (priority);
2536 for (uint8_t i = 0; i < numPackets; i++)
2537 {
2538 Ptr<Packet> packet = Create<Packet> (1000); // 1000 dummy bytes of data
2539 packet->AddPacketTag (priorityTag);
2540 sourceDevice->Send (packet, destination, 0);
2541 }
2542}
2543
2544void
2545Issue169TestCase::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
2546{
2547 if (psdus.begin()->second->GetSize () >= 1000)
2548 {
2549 NS_TEST_ASSERT_MSG_EQ (txVector.GetMode ().GetModulationClass (), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Ideal rate manager selected incorrect modulation class");
2550 }
2551}
2552
2553void
2555{
2556 RngSeedManager::SetSeed (1);
2557 RngSeedManager::SetRun (1);
2558 int64_t streamNumber = 100;
2559
2560 NodeContainer wifiApNode, wifiStaNode;
2561 wifiApNode.Create (1);
2562 wifiStaNode.Create (1);
2563
2565 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2566 phy.SetChannel (channel.Create ());
2567
2569 wifi.SetStandard (WIFI_STANDARD_80211ac);
2570 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2571
2573 NetDeviceContainer apDevice;
2574 mac.SetType ("ns3::ApWifiMac");
2575 apDevice = wifi.Install (phy, mac, wifiApNode);
2576
2577 NetDeviceContainer staDevice;
2578 mac.SetType ("ns3::StaWifiMac");
2579 staDevice = wifi.Install (phy, mac, wifiStaNode);
2580
2581 // Assign fixed streams to random variables in use
2582 wifi.AssignStreams (apDevice, streamNumber);
2583 wifi.AssignStreams (staDevice, streamNumber);
2584
2586 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2587 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2588 positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2589 mobility.SetPositionAllocator (positionAlloc);
2590
2591 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2592 mobility.Install (wifiApNode);
2593 mobility.Install (wifiStaNode);
2594
2595 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&Issue169TestCase::TxCallback, this));
2596
2597 //Send best-effort packet (i.e. priority 0)
2598 Simulator::Schedule (Seconds (0.5), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 0);
2599
2600 //Send non best-effort (voice) packet (i.e. priority 6)
2601 Simulator::Schedule (Seconds (1.0), &Issue169TestCase::SendPackets, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress (), 6);
2602
2603 Simulator::Stop (Seconds (2.0));
2604 Simulator::Run ();
2605
2606 Simulator::Destroy ();
2607}
2608
2609
2610//-----------------------------------------------------------------------------
2626{
2627public:
2630 void DoRun (void) override;
2631
2632private:
2637 void ChangeChannelWidth (uint16_t channelWidth);
2638
2644 void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2645
2653 void TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW);
2654
2659 void CheckLastSelectedMode (WifiMode expectedMode);
2660
2662};
2663
2665 : TestCase ("Test case for use of channel bonding with Ideal rate manager")
2666{
2667}
2668
2670{
2671}
2672
2673void
2675{
2676 Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelSettings",
2677 StringValue ("{0, " + std::to_string (channelWidth) + ", BAND_5GHZ, 0}"));
2678}
2679
2680void
2682{
2683 Ptr<Packet> packet = Create<Packet> (1000);
2684 sourceDevice->Send (packet, destination, 0);
2685}
2686
2687void
2688IdealRateManagerChannelWidthTest::TxCallback (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
2689{
2690 if (psduMap.begin ()->second->GetSize () >= 1000)
2691 {
2692 m_txMode = txVector.GetMode ();
2693 }
2694}
2695
2696void
2698{
2699 NS_TEST_ASSERT_MSG_EQ (m_txMode, expectedMode, "Last selected WifiMode " << m_txMode << " does not match expected WifiMode " << expectedMode);
2700}
2701
2702void
2704{
2705 RngSeedManager::SetSeed (1);
2706 RngSeedManager::SetRun (1);
2707 int64_t streamNumber = 100;
2708
2709 NodeContainer wifiApNode, wifiStaNode;
2710 wifiApNode.Create (1);
2711 wifiStaNode.Create (1);
2712
2714 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2715 phy.SetChannel (channel.Create ());
2716
2718 wifi.SetStandard (WIFI_STANDARD_80211ac);
2719 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2720
2722 NetDeviceContainer apDevice;
2723 mac.SetType ("ns3::ApWifiMac");
2724 apDevice = wifi.Install (phy, mac, wifiApNode);
2725
2726 NetDeviceContainer staDevice;
2727 mac.SetType ("ns3::StaWifiMac");
2728 staDevice = wifi.Install (phy, mac, wifiStaNode);
2729
2730 // Assign fixed streams to random variables in use
2731 wifi.AssignStreams (apDevice, streamNumber);
2732 wifi.AssignStreams (staDevice, streamNumber);
2733
2735 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2736 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2737 positionAlloc->Add (Vector (50.0, 0.0, 0.0));
2738 mobility.SetPositionAllocator (positionAlloc);
2739
2740 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2741 mobility.Install (wifiApNode);
2742 mobility.Install (wifiStaNode);
2743
2744 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerChannelWidthTest::TxCallback, this));
2745
2746 //Set channel width to 80 MHz & send packet
2747 Simulator::Schedule (Seconds (0.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 80);
2748 Simulator::Schedule (Seconds (1.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2749 //Selected rate should be VHT-MCS 1
2750 Simulator::Schedule (Seconds (1.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs1 ());
2751
2752 //Set channel width to 20 MHz & send packet
2753 Simulator::Schedule (Seconds (1.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 20);
2754 Simulator::Schedule (Seconds (2.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2755 //Selected rate should be VHT-MCS 3 since SNR should be 6 dB higher than previously
2756 Simulator::Schedule (Seconds (2.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
2757
2758 //Set channel width to 40 MHz & send packet
2759 Simulator::Schedule (Seconds (2.5), &IdealRateManagerChannelWidthTest::ChangeChannelWidth, this, 40);
2760 Simulator::Schedule (Seconds (3.0), &IdealRateManagerChannelWidthTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2761 //Selected rate should be VHT-MCS 2 since SNR should be 3 dB lower than previously
2762 Simulator::Schedule (Seconds (3.1), &IdealRateManagerChannelWidthTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
2763
2764 Simulator::Stop (Seconds (3.2));
2765 Simulator::Run ();
2766
2767 Simulator::Destroy ();
2768}
2769
2770
2771//-----------------------------------------------------------------------------
2780{
2781public:
2783 virtual ~IdealRateManagerMimoTest ();
2784 void DoRun (void) override;
2785
2786private:
2792 void SetApMimoSettings (uint8_t antennas, uint8_t maxStreams);
2798 void SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams);
2804 void SendPacket (Ptr<NetDevice> sourceDevice, Address& destination);
2805
2813 void TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW);
2814
2819 void CheckLastSelectedMode (WifiMode expectedMode);
2824 void CheckLastSelectedNss (uint8_t expectedNss);
2825
2827};
2828
2830 : TestCase ("Test case for use of imbalanced MIMO settings with Ideal rate manager")
2831{
2832}
2833
2835{
2836}
2837
2838void
2839IdealRateManagerMimoTest::SetApMimoSettings (uint8_t antennas, uint8_t maxStreams)
2840{
2841 Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2842 Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2843 Config::Set ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2844}
2845
2846void
2847IdealRateManagerMimoTest::SetStaMimoSettings (uint8_t antennas, uint8_t maxStreams)
2848{
2849 Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/Antennas", UintegerValue (antennas));
2850 Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedTxSpatialStreams", UintegerValue (maxStreams));
2851 Config::Set ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/MaxSupportedRxSpatialStreams", UintegerValue (maxStreams));
2852}
2853
2854void
2856{
2857 Ptr<Packet> packet = Create<Packet> (1000);
2858 sourceDevice->Send (packet, destination, 0);
2859}
2860
2861void
2862IdealRateManagerMimoTest::TxCallback (std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
2863{
2864 if (psdus.begin ()->second->GetSize () >= 1000)
2865 {
2866 m_txVector = txVector;
2867 }
2868}
2869
2870void
2872{
2873 NS_TEST_ASSERT_MSG_EQ (m_txVector.GetNss (), expectedNss, "Last selected Nss " << m_txVector.GetNss () << " does not match expected Nss " << expectedNss);
2874}
2875
2876void
2878{
2879 NS_TEST_ASSERT_MSG_EQ (m_txVector.GetMode (), expectedMode, "Last selected WifiMode " << m_txVector.GetMode () << " does not match expected WifiMode " << expectedMode);
2880}
2881
2882void
2884{
2885 RngSeedManager::SetSeed (1);
2886 RngSeedManager::SetRun (1);
2887 int64_t streamNumber = 100;
2888
2889 NodeContainer wifiApNode, wifiStaNode;
2890 wifiApNode.Create (1);
2891 wifiStaNode.Create (1);
2892
2894 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
2895 phy.SetChannel (channel.Create ());
2896
2898 wifi.SetStandard (WIFI_STANDARD_80211ac);
2899 wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2900
2902 NetDeviceContainer apDevice;
2903 mac.SetType ("ns3::ApWifiMac");
2904 apDevice = wifi.Install (phy, mac, wifiApNode);
2905
2906 NetDeviceContainer staDevice;
2907 mac.SetType ("ns3::StaWifiMac");
2908 staDevice = wifi.Install (phy, mac, wifiStaNode);
2909
2910 // Assign fixed streams to random variables in use
2911 wifi.AssignStreams (apDevice, streamNumber);
2912 wifi.AssignStreams (staDevice, streamNumber);
2913
2915 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2916 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2917 positionAlloc->Add (Vector (40.0, 0.0, 0.0));
2918 mobility.SetPositionAllocator (positionAlloc);
2919
2920 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2921 mobility.Install (wifiApNode);
2922 mobility.Install (wifiStaNode);
2923
2924 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxPsduBegin", MakeCallback (&IdealRateManagerMimoTest::TxCallback, this));
2925
2926
2927 // TX: 1 antenna
2928 Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2929 // RX: 1 antenna
2930 Simulator::Schedule (Seconds (0.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2931 // Send packets (2 times to get one feedback)
2932 Simulator::Schedule (Seconds (1.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2933 Simulator::Schedule (Seconds (1.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2934 // Selected NSS should be 1 since both TX and RX support a single antenna
2935 Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2936 // Selected rate should be VHT-MCS 2 because of settings and distance between TX and RX
2937 Simulator::Schedule (Seconds (1.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
2938
2939
2940 // TX: 1 antenna
2941 Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2942 // RX: 2 antennas, but only supports 1 spatial stream
2943 Simulator::Schedule (Seconds (1.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2944 // Send packets (2 times to get one feedback)
2945 Simulator::Schedule (Seconds (2.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2946 Simulator::Schedule (Seconds (2.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2947 // Selected NSS should be 1 since both TX and RX support a single antenna
2948 Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2949 // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB
2950 Simulator::Schedule (Seconds (2.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
2951
2952
2953 // TX: 1 antenna
2954 Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
2955 // RX: 2 antennas, and supports 2 spatial streams
2956 Simulator::Schedule (Seconds (2.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2957 // Send packets (2 times to get one feedback)
2958 Simulator::Schedule (Seconds (3.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2959 Simulator::Schedule (Seconds (3.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2960 // Selected NSS should be 1 since TX supports a single antenna
2961 Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2962 // Selected rate should be as previously
2963 Simulator::Schedule (Seconds (3.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
2964
2965
2966 // TX: 2 antennas, but only supports 1 spatial stream
2967 Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2968 // RX: 1 antenna
2969 Simulator::Schedule (Seconds (3.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
2970 // Send packets (2 times to get one feedback)
2971 Simulator::Schedule (Seconds (4.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2972 Simulator::Schedule (Seconds (4.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2973 // Selected NSS should be 1 since both TX and RX support a single antenna
2974 Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2975 // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario (more antennas at TX does not result in SNR improvement in AWGN channel)
2976 Simulator::Schedule (Seconds (4.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
2977
2978
2979 // TX: 2 antennas, but only supports 1 spatial stream
2980 Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2981 // RX: 2 antennas, but only supports 1 spatial stream
2982 Simulator::Schedule (Seconds (4.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
2983 // Send packets (2 times to get one feedback)
2984 Simulator::Schedule (Seconds (5.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2985 Simulator::Schedule (Seconds (5.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2986 // Selected NSS should be 1 since both TX and RX support a single antenna
2987 Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
2988 // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN channel)
2989 Simulator::Schedule (Seconds (5.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
2990
2991
2992 // TX: 2 antennas, but only supports 1 spatial stream
2993 Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 1);
2994 // RX: 2 antennas, and supports 2 spatial streams
2995 Simulator::Schedule (Seconds (5.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
2996 // Send packets (2 times to get one feedback)
2997 Simulator::Schedule (Seconds (6.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2998 Simulator::Schedule (Seconds (6.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
2999 // Selected NSS should be 1 since TX supports a single antenna
3000 Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3001 // Selected rate should be as previously
3002 Simulator::Schedule (Seconds (6.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
3003
3004
3005 // TX: 2 antennas, and supports 2 spatial streams
3006 Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
3007 // RX: 1 antenna
3008 Simulator::Schedule (Seconds (6.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
3009 // Send packets (2 times to get one feedback)
3010 Simulator::Schedule (Seconds (7.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3011 Simulator::Schedule (Seconds (7.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3012 // Selected NSS should be 1 since RX supports a single antenna
3013 Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3014 // Selected rate should be VHT-MCS 2 because we do no longer have diversity in this scenario (more antennas at TX does not result in SNR improvement in AWGN channel)
3015 Simulator::Schedule (Seconds (7.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
3016
3017
3018 // TX: 2 antennas, and supports 2 spatial streams
3019 Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
3020 // RX: 2 antennas, but only supports 1 spatial stream
3021 Simulator::Schedule (Seconds (7.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 1);
3022 // Send packets (2 times to get one feedback)
3023 Simulator::Schedule (Seconds (8.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3024 Simulator::Schedule (Seconds (8.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3025 // Selected NSS should be 1 since RX supports a single antenna
3026 Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3027 // Selected rate should be increased to VHT-MCS 3 because of RX diversity resulting in SNR improvement of about 3dB (more antennas at TX does not result in SNR improvement in AWGN channel)
3028 Simulator::Schedule (Seconds (8.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs3 ());
3029
3030
3031 // TX: 2 antennas, and supports 2 spatial streams
3032 Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 2, 2);
3033 // RX: 2 antennas, and supports 2 spatial streams
3034 Simulator::Schedule (Seconds (8.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 2, 2);
3035 // Send packets (2 times to get one feedback)
3036 Simulator::Schedule (Seconds (9.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3037 Simulator::Schedule (Seconds (9.1), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3038 // Selected NSS should be 2 since both TX and RX support 2 antennas
3039 Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 2);
3040 // Selecte rate should be the same as without diversity, as it uses 2 spatial streams so there is no more benefits from diversity in AWGN channels
3041 Simulator::Schedule (Seconds (9.2), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
3042
3043
3044 // Verify we can go back to initial situation
3045 Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetApMimoSettings, this, 1, 1);
3046 Simulator::Schedule (Seconds (9.9), &IdealRateManagerMimoTest::SetStaMimoSettings, this, 1, 1);
3047 Simulator::Schedule (Seconds (10.0), &IdealRateManagerMimoTest::SendPacket, this, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
3048 Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedNss, this, 1);
3049 Simulator::Schedule (Seconds (10.1), &IdealRateManagerMimoTest::CheckLastSelectedMode, this, VhtPhy::GetVhtMcs2 ());
3050
3051 Simulator::Stop (Seconds (10.2));
3052 Simulator::Run ();
3053 Simulator::Destroy ();
3054}
3055
3056//-----------------------------------------------------------------------------
3064{
3065public:
3067
3068private:
3078 bool CheckDataRate (HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate);
3079 void DoRun (void) override;
3080};
3081
3083 : TestCase ("Check data rates for different RU types.")
3084{
3085}
3086
3087bool
3088HeRuMcsDataRateTestCase::CheckDataRate (HeRu::RuType ruType, std::string mcs, uint8_t nss, uint16_t guardInterval, uint16_t expectedDataRate)
3089{
3090 uint16_t approxWidth = HeRu::GetBandwidth (ruType);
3091 WifiMode mode (mcs);
3092 uint64_t dataRate = round (mode.GetDataRate (approxWidth, guardInterval, nss) / 100000.0);
3093 NS_ABORT_MSG_IF (dataRate > 65535, "Rate is way too high");
3094 if (static_cast<uint16_t> (dataRate) != expectedDataRate)
3095 {
3096 std::cerr << "RU=" << ruType
3097 << " mode=" << mode
3098 << " Nss=" << +nss
3099 << " guardInterval=" << guardInterval
3100 << " expected=" << expectedDataRate << " x100kbps"
3101 << " computed=" << static_cast<uint16_t> (dataRate) << " x100kbps"
3102 << std::endl;
3103 return false;
3104 }
3105 return true;
3106}
3107
3108void
3110{
3111 bool retval = true;
3112
3113 //26-tone RU, browse over all MCSs, GIs and Nss's (up to 4, current max)
3114 retval = retval
3115 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs0", 1, 800, 9)
3116 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs1", 1, 1600, 17)
3117 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs2", 1, 3200, 23)
3118 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs3", 1, 3200, 30)
3119 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs4", 2, 1600, 100)
3120 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs5", 3, 1600, 200)
3121 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs6", 4, 1600, 300)
3122 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs7", 4, 3200, 300)
3123 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs8", 4, 1600, 400)
3124 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs9", 4, 3200, 400)
3125 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs10", 4, 1600, 500)
3126 && CheckDataRate (HeRu::RU_26_TONE, "HeMcs11", 4, 3200, 500);
3127
3128 NS_TEST_EXPECT_MSG_EQ (retval, true, "26-tone RU data rate verification for different MCSs, GIs, and Nss's failed");
3129
3130 //Check other RU sizes
3131 retval = retval
3132 && CheckDataRate ( HeRu::RU_52_TONE, "HeMcs2", 1, 1600, 50)
3133 && CheckDataRate ( HeRu::RU_106_TONE, "HeMcs9", 1, 800, 500)
3134 && CheckDataRate ( HeRu::RU_242_TONE, "HeMcs5", 1, 1600, 650)
3135 && CheckDataRate ( HeRu::RU_484_TONE, "HeMcs3", 1, 1600, 650)
3136 && CheckDataRate ( HeRu::RU_996_TONE, "HeMcs5", 1, 3200, 2450)
3137 && CheckDataRate (HeRu::RU_2x996_TONE, "HeMcs3", 1, 3200, 2450);
3138
3139 NS_TEST_EXPECT_MSG_EQ (retval, true, "Data rate verification for RUs above 52-tone RU (included) failed");
3140}
3141
3149{
3150public:
3151 WifiTestSuite ();
3152};
3153
3155 : TestSuite ("wifi-devices", UNIT)
3156{
3157 AddTestCase (new WifiTest, TestCase::QUICK);
3158 AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK);
3159 AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991
3160 AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK);
3161 AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
3162 AddTestCase (new QosFragmentationTestCase, TestCase::QUICK);
3163 AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
3164 AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
3165 AddTestCase (new Bug2843TestCase, TestCase::QUICK); //Bug 2843
3166 AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831
3167 AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399
3168 AddTestCase (new Bug2470TestCase, TestCase::QUICK); //Bug 2470
3169 AddTestCase (new Issue40TestCase, TestCase::QUICK); //Issue #40
3170 AddTestCase (new Issue169TestCase, TestCase::QUICK); //Issue #169
3171 AddTestCase (new IdealRateManagerChannelWidthTest, TestCase::QUICK);
3172 AddTestCase (new IdealRateManagerMimoTest, TestCase::QUICK);
3173 AddTestCase (new HeRuMcsDataRateTestCase, TestCase::QUICK);
3174}
3175
Make sure that when virtual collision occurs the wifi remote station manager is triggered and the ret...
Definition: wifi-test.cc:1324
uint32_t m_countInternalCollisions
count internal collisions
Definition: wifi-test.cc:1333
void TxDataFailedTrace(std::string context, Mac48Address adr)
Transmit data failed function.
Definition: wifi-test.cc:1354
virtual ~Bug2222TestCase()
Definition: wifi-test.cc:1349
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1361
Make sure that the ADDBA handshake process is protected.
Definition: wifi-test.cc:2024
void RxErrorCallback(std::string context, Ptr< const Packet > p, double snr)
Callback when packet is dropped.
Definition: wifi-test.cc:2142
uint16_t m_addbaResetCount
Count number of times ADDBA state machine is in reset state.
Definition: wifi-test.cc:2079
virtual ~Bug2470TestCase()
Definition: wifi-test.cc:2095
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2226
uint16_t m_addbaRejectedCount
Count number of times ADDBA state machine is in rejected state.
Definition: wifi-test.cc:2077
void AddbaStateChangedCallback(std::string context, Time t, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
Callback when ADDBA state changed.
Definition: wifi-test.cc:2100
void RunSubtest(PointerValue apErrorModel, PointerValue staErrorModel)
Run subtest for this test suite.
Definition: wifi-test.cc:2165
uint16_t m_failedActionCount
Count failed ADDBA request/response.
Definition: wifi-test.cc:2074
uint16_t m_addbaEstablishedCount
Count number of times ADDBA state machine is in established state.
Definition: wifi-test.cc:2075
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:2123
uint16_t m_receivedNormalMpduCount
Count received normal MPDU packets on STA.
Definition: wifi-test.cc:2072
uint16_t m_addbaNoReplyCount
Count number of times ADDBA state machine is in no_reply state.
Definition: wifi-test.cc:2078
uint16_t m_addbaPendingCount
Count number of times ADDBA state machine is in pending state.
Definition: wifi-test.cc:2076
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:2154
uint16_t m_receivedAmpduCount
Count received A-MPDU packets on STA.
Definition: wifi-test.cc:2073
Make sure that the channel width and the channel number can be changed at runtime.
Definition: wifi-test.cc:1636
uint16_t m_countOperationalChannelWidth20
count number of beacon frames announcing a 20 MHz operating channel width
Definition: wifi-test.cc:1660
uint16_t m_countOperationalChannelWidth40
count number of beacon frames announcing a 40 MHz operating channel width
Definition: wifi-test.cc:1661
virtual ~Bug2831TestCase()
Definition: wifi-test.cc:1673
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1715
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:1685
uint16_t m_assocReqCount
count number of association requests
Definition: wifi-test.cc:1658
Ptr< YansWifiPhy > m_apPhy
AP PHY.
Definition: wifi-test.cc:1655
Ptr< YansWifiPhy > m_staPhy
STA PHY.
Definition: wifi-test.cc:1656
void ChangeSupportedChannelWidth(void)
Function called to change the supported channel width at runtime.
Definition: wifi-test.cc:1678
uint16_t m_assocRespCount
count number of association responses
Definition: wifi-test.cc:1659
Make sure that the correct channel width and center frequency have been set for OFDM basic rate trans...
Definition: wifi-test.cc:1461
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:1535
void StoreDistinctTuple(std::string context, Ptr< SpectrumSignalParameters > txParams)
Stores the distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel,...
Definition: wifi-test.cc:1503
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1546
std::vector< FreqWidthSubbandModulationTuple > m_distinctTuples
vector of distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel,...
Definition: wifi-test.cc:1472
uint16_t m_channelWidth
channel width (in MHz)
Definition: wifi-test.cc:1489
std::tuple< double, uint16_t, uint32_t, WifiModulationClass > FreqWidthSubbandModulationTuple
A tuple of {starting frequency, channelWidth, Number of subbands in SpectrumModel,...
Definition: wifi-test.cc:1471
virtual ~Bug2843TestCase()
Definition: wifi-test.cc:1498
Make sure that when changing the fragmentation threshold during the simulation, the TCP transmission ...
Definition: wifi-test.cc:598
virtual ~Bug730TestCase()
Definition: wifi-test.cc:625
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:630
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:640
uint32_t m_received
received
Definition: wifi-test.cc:607
Make sure that when multiple broadcast packets are queued on the same device in a short succession,...
Definition: wifi-test.cc:445
void NotifyPhyTxBegin(Ptr< const Packet > p, double txPowerW)
Notify Phy transmit begin.
Definition: wifi-test.cc:481
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:502
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:461
unsigned int m_numSentPackets
number of sent packets
Definition: wifi-test.cc:465
Time m_secondTransmissionTime
second transmission time
Definition: wifi-test.cc:464
Time m_firstTransmissionTime
first transmission time
Definition: wifi-test.cc:463
ObjectFactory m_manager
manager
Definition: wifi-test.cc:459
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:495
Data rate verification test for MCSs of different RU sizes.
Definition: wifi-test.cc:3064
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:3109
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:3088
Make sure that Ideal rate manager properly selects MCS based on the configured channel width.
Definition: wifi-test.cc:2626
WifiMode m_txMode
Store the last selected mode to send data packet.
Definition: wifi-test.cc:2661
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2703
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:2681
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2697
void TxCallback(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2688
void ChangeChannelWidth(uint16_t channelWidth)
Change the configured channel width for all nodes.
Definition: wifi-test.cc:2674
Test to validate that Ideal rate manager properly selects TXVECTOR in scenarios where MIMO is used.
Definition: wifi-test.cc:2780
void CheckLastSelectedNss(uint8_t expectedNss)
Check if the selected Nss is correct.
Definition: wifi-test.cc:2871
virtual ~IdealRateManagerMimoTest()
Definition: wifi-test.cc:2834
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2862
void SetApMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for AP node.
Definition: wifi-test.cc:2839
WifiTxVector m_txVector
Store the last TXVECTOR used to transmit Data.
Definition: wifi-test.cc:2826
void SetStaMimoSettings(uint8_t antennas, uint8_t maxStreams)
Change the configured MIMO settings for STA node.
Definition: wifi-test.cc:2847
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:2855
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2883
void CheckLastSelectedMode(WifiMode expectedMode)
Check if the selected WifiMode is correct.
Definition: wifi-test.cc:2877
void SwitchCh(Ptr< WifiNetDevice > dev)
Switch channel function.
Definition: wifi-test.cc:307
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:352
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:300
ObjectFactory m_manager
manager
Definition: wifi-test.cc:289
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:291
Ptr< Node > CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:314
Make sure that Ideal rate manager is able to handle non best-effort traffic.
Definition: wifi-test.cc:2496
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:2532
void TxCallback(std::string context, WifiConstPsduMap psdus, WifiTxVector txVector, double txPowerW)
Callback that indicates a PSDU is being transmitted.
Definition: wifi-test.cc:2545
virtual ~Issue169TestCase()
Definition: wifi-test.cc:2527
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2554
Make sure that Ideal rate manager recovers when the station is moving away from the access point.
Definition: wifi-test.cc:2312
uint16_t m_txCount
Count number of transmitted data packets.
Definition: wifi-test.cc:2346
uint16_t m_txMacFinalDataFailedCount
Count number of unsuccessfully transmitted data packets.
Definition: wifi-test.cc:2347
void RunOne(bool useAmpdu)
Run one function.
Definition: wifi-test.cc:2386
uint16_t m_rxCount
Count number of successfully received data packets.
Definition: wifi-test.cc:2345
void RxSuccessCallback(std::string context, Ptr< const Packet > p)
Callback when packet is successfully received.
Definition: wifi-test.cc:2363
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:2473
virtual ~Issue40TestCase()
Definition: wifi-test.cc:2358
void TxFinalDataFailedCallback(std::string context, Mac48Address address)
Transmit final data failed function.
Definition: wifi-test.cc:2380
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:2369
Make sure that fragmentation works with QoS stations.
Definition: wifi-test.cc:735
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:797
uint32_t m_received
received packets
Definition: wifi-test.cc:744
virtual ~QosFragmentationTestCase()
Definition: wifi-test.cc:771
uint32_t m_fragments
transmitted fragments
Definition: wifi-test.cc:745
void Transmit(std::string context, Ptr< const Packet > p, double power)
Callback invoked when PHY transmits a packet.
Definition: wifi-test.cc:785
void Receive(std::string context, Ptr< const Packet > p, const Address &adr)
Receive function.
Definition: wifi-test.cc:776
Qos Utils Is Old Packet Test.
Definition: wifi-test.cc:232
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:237
Set Channel Frequency Test.
Definition: wifi-test.cc:894
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:925
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc) const
Get yans wifi phy function.
Definition: wifi-test.cc:917
Make sure that Wifi STA is correctly associating to the best AP (i.e., nearest from STA).
Definition: wifi-test.cc:1832
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:1957
void TurnBeaconGenerationOn(Ptr< Node > apNode)
Turn beacon generation on the AP node.
Definition: wifi-test.cc:1882
Mac48Address m_associatedApBssid
Associated AP's bssid.
Definition: wifi-test.cc:1863
virtual ~StaWifiMacScanningTestCase()
Definition: wifi-test.cc:1871
void TurnApOff(Ptr< Node > apNode)
Turn the AP node off.
Definition: wifi-test.cc:1890
NodeContainer Setup(bool nearestApBeaconGeneration, bool staActiveProbe)
Setup test.
Definition: wifi-test.cc:1898
void AssocCallback(std::string context, Mac48Address bssid)
Callback function on STA assoc event.
Definition: wifi-test.cc:1876
Wifi Test.
Definition: wifi-test.cc:98
void CreateOne(Vector pos, Ptr< YansWifiChannel > channel)
Create one function.
Definition: wifi-test.cc:138
ObjectFactory m_mac
MAC.
Definition: wifi-test.cc:121
void RunOne(void)
Run one function.
Definition: wifi-test.cc:175
void SendOnePacket(Ptr< WifiNetDevice > dev)
Send one packet function.
Definition: wifi-test.cc:131
ObjectFactory m_manager
manager
Definition: wifi-test.cc:120
ObjectFactory m_propDelay
propagation delay
Definition: wifi-test.cc:122
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-test.cc:194
Wifi Test Suite.
Definition: wifi-test.cc:3149
a polymophic address class
Definition: address.h:91
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:41
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:42
The HT Operation Information Element.
Definition: ht-operation.h:51
uint8_t GetStaChannelWidth(void) const
Return the STA channel width.
an EUI-48 address
Definition: mac48-address.h:44
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:862
HtOperation GetHtOperation(void) const
Return the HT operation.
Definition: mgt-headers.cc:262
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.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
virtual Address GetAddress(void) const =0
virtual uint32_t GetIfIndex(void) const =0
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:159
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:144
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:364
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
Instantiate subclasses of ns3::Object.
Ptr< Object > Create(void) 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(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
State
Represents the state for this agreement.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:956
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
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(void) const
Definition: pointer.h:201
calculate a propagation delay.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:72
indicates whether the socket has a priority set.
Definition: socket.h:1309
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:842
size_t GetNumBands() const
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start.
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:41
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:65
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: txop.cc:309
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:324
a (time, location) pair.
Definition: waypoint.h:36
void AddWaypoint(const Waypoint &waypoint)
helps to create WifiNetDevice objects
Definition: wifi-helper.h:323
Implements the IEEE 802.11 MAC header.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
bool IsAction(void) const
Return true if the header is an Action header.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
bool IsData(void) const
Return true if the Type is DATA.
bool IsBeacon(void) const
Return true if the header is a Beacon header.
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:85
represent a single transmission mode
Definition: wifi-mode.h:48
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:177
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:114
Hold together all Wifi-related objects.
void SetMac(const Ptr< WifiMac > mac)
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
Ptr< WifiMac > GetMac(void) const
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Address GetAddress(void) const override
Address GetBroadcast(void) const override
Ptr< WifiPhy > GetPhy(void) const
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
uint32_t GetIfIndex(void) const override
void SetStandard(WifiStandard standard)
Set the Wifi standard.
void SetPhy(const Ptr< WifiPhy > phy)
void SetErrorRateModel(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Definition: wifi-helper.cc:147
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:141
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:895
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:883
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:818
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:913
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:526
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:538
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
Definition: wifi-phy.h:832
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:901
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:889
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:557
bool IsSet(void) const
Return true if a valid channel has been set, false otherwise.
hold a list of per-remote-station state.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
uint16_t GetChannelWidth(void) const
manage and create wifi channel objects for the YANS model.
Make it easy to create and manage PHY objects for the YANS model.
802.11 PHY layer model
Definition: yans-wifi-phy.h:48
void SetChannel(const Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:839
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
#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:141
#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:785
#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:240
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1260
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
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:178
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
@ WIFI_STANDARD_80211a
@ WIFI_STANDARD_80211p
@ WIFI_STANDARD_80211n
@ WIFI_STANDARD_80211g
@ WIFI_STANDARD_80211ax
@ WIFI_STANDARD_80211ac
@ WIFI_STANDARD_80211b
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Definition: wifi-phy-band.h:37
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
address
Definition: first.py:44
nodes
Definition: first.py:32
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
staDevices
Definition: third.py:102
ssid
Definition: third.py:97
channel
Definition: third.py:92
mac
Definition: third.py:96
wifi
Definition: third.py:99
apDevices
Definition: third.py:105
wifiApNode
Definition: third.py:90
mobility
Definition: third.py:107
phy
Definition: third.py:93
MpduInfo structure.
Definition: phy-entity.h:60
MpduType type
type of MPDU
Definition: phy-entity.h:61
SignalNoiseDbm structure.
Definition: phy-entity.h:53
static void AssignWifiRandomStreams(Ptr< WifiMac > mac, int64_t stream)
Definition: wifi-test.cc:61
static WifiTestSuite g_wifiTestSuite
the test suite
Definition: wifi-test.cc:3176