A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 * Copyright (c) 2009 MIRKO BANCHI
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
8 * Mirko Banchi <mk.banchi@gmail.com>
9 */
10
11#include "wifi-helper.h"
12
13#include "ns3/ampdu-subframe-header.h"
14#include "ns3/ap-wifi-mac.h"
15#include "ns3/config.h"
16#include "ns3/eht-configuration.h"
17#include "ns3/he-configuration.h"
18#include "ns3/ht-configuration.h"
19#include "ns3/log.h"
20#include "ns3/mobility-model.h"
21#include "ns3/names.h"
22#include "ns3/net-device-queue-interface.h"
23#include "ns3/obss-pd-algorithm.h"
24#include "ns3/pointer.h"
25#include "ns3/qos-txop.h"
26#include "ns3/qos-utils.h"
27#include "ns3/radiotap-header.h"
28#include "ns3/sta-wifi-mac.h"
29#include "ns3/vht-configuration.h"
30#include "ns3/wifi-mac-queue.h"
31#include "ns3/wifi-mac-trailer.h"
32
33#include <memory>
34
35namespace ns3
36{
37
38NS_LOG_COMPONENT_DEFINE("WifiHelper");
39
40/**
41 * ASCII trace PHY transmit sink with context
42 * \param stream the output stream
43 * \param context the context name
44 * \param p the packet
45 * \param mode the wifi mode
46 * \param preamble the wifi preamble
47 * \param txLevel the transmit power level
48 */
49static void
51 std::string context,
53 WifiMode mode,
54 WifiPreamble preamble,
55 uint8_t txLevel)
56{
57 NS_LOG_FUNCTION(stream << context << p << mode << preamble << txLevel);
58 auto pCopy = p->Copy();
60 pCopy->RemoveTrailer(fcs);
61 *stream->GetStream() << "t " << Simulator::Now().GetSeconds() << " " << context << " " << mode
62 << " " << *pCopy << " " << fcs << std::endl;
63}
64
65/**
66 * ASCII trace PHY transmit sink without context
67 * \param stream the output stream
68 * \param p the packet
69 * \param mode the wifi mode
70 * \param preamble the wifi preamble
71 * \param txLevel the transmit power level
72 */
73static void
76 WifiMode mode,
77 WifiPreamble preamble,
78 uint8_t txLevel)
79{
80 NS_LOG_FUNCTION(stream << p << mode << preamble << txLevel);
81 auto pCopy = p->Copy();
83 pCopy->RemoveTrailer(fcs);
84 *stream->GetStream() << "t " << Simulator::Now().GetSeconds() << " " << mode << " " << *pCopy
85 << " " << fcs << std::endl;
86}
87
88/**
89 * ASCII trace PHY receive sink with context
90 * \param stream the output stream
91 * \param context the context name
92 * \param p the packet
93 * \param snr the SNR
94 * \param mode the wifi mode
95 * \param preamble the wifi preamble
96 */
97static void
99 std::string context,
101 double snr,
102 WifiMode mode,
103 WifiPreamble preamble)
104{
105 NS_LOG_FUNCTION(stream << context << p << snr << mode << preamble);
106 auto pCopy = p->Copy();
107 WifiMacTrailer fcs;
108 pCopy->RemoveTrailer(fcs);
109 *stream->GetStream() << "r " << Simulator::Now().GetSeconds() << " " << mode << " " << context
110 << " " << *pCopy << " " << fcs << std::endl;
111}
112
113/**
114 * ASCII trace PHY receive sink without context
115 * \param stream the output stream
116 * \param p the packet
117 * \param snr the SNR
118 * \param mode the wifi mode
119 * \param preamble the wifi preamble
120 */
121static void
124 double snr,
125 WifiMode mode,
126 WifiPreamble preamble)
127{
128 NS_LOG_FUNCTION(stream << p << snr << mode << preamble);
129 auto pCopy = p->Copy();
130 WifiMacTrailer fcs;
131 pCopy->RemoveTrailer(fcs);
132 *stream->GetStream() << "r " << Simulator::Now().GetSeconds() << " " << mode << " " << *pCopy
133 << " " << fcs << std::endl;
134}
135
137 : m_pcapDlt{PcapHelper::DLT_IEEE802_11},
138 m_pcapType{PcapCaptureType::PCAP_PER_PHY}
139{
140 NS_ABORT_IF(nLinks == 0);
141 m_phys.resize(nLinks);
142 m_errorRateModel.resize(nLinks);
143 m_frameCaptureModel.resize(nLinks);
144 m_preambleDetectionModel.resize(nLinks);
145
146 SetPreambleDetectionModel("ns3::ThresholdPreambleDetectionModel");
147}
148
152
153void
154WifiPhyHelper::Set(std::string name, const AttributeValue& v)
155{
156 for (auto& phy : m_phys)
157 {
158 phy.Set(name, v);
159 }
160}
161
162void
163WifiPhyHelper::Set(uint8_t linkId, std::string name, const AttributeValue& v)
164{
165 m_phys.at(linkId).Set(name, v);
166}
167
168void
174
176WifiPhyHelper::GetOrCreatePcapFile(const std::shared_ptr<PcapFilesInfo>& info, uint8_t phyId)
177{
178 uint8_t fileIdx;
179 switch (info->pcapType)
180 {
182 fileIdx = 0;
183 break;
185 fileIdx = phyId;
186 break;
188 if (const auto linkId = info->device->GetMac()->GetLinkForPhy(phyId))
189 {
190 fileIdx = *linkId;
191 break;
192 }
193 return nullptr;
194 default:
195 NS_ABORT_MSG("Unexpected PCAP capture type");
196 return nullptr;
197 }
198
199 if (!info->files.contains(fileIdx))
200 {
201 // file does not exist yet, create it
202 auto tmp = info->commonFilename;
203
204 // find the last point in the filename
205 auto pos = info->commonFilename.find_last_of('.');
206 // if not found, set pos to filename size
207 pos = (pos == std::string::npos) ? info->commonFilename.size() : pos;
208
209 // insert PHY/link ID only for multi-link devices, unless a single PCAP is generated for the
210 // device
211 if ((info->device->GetNPhys() > 1) && (info->pcapType != PcapCaptureType::PCAP_PER_DEVICE))
212 {
213 tmp.insert(pos, "-" + std::to_string(fileIdx));
214 }
215
216 PcapHelper pcapHelper;
217 auto file = pcapHelper.CreateFile(tmp, std::ios::out, info->pcapDlt);
218 info->files.emplace(fileIdx, file);
219 }
220
221 return info->files.at(fileIdx);
222}
223
224void
225WifiPhyHelper::PcapSniffTxEvent(const std::shared_ptr<PcapFilesInfo>& info,
226 uint8_t phyId,
227 Ptr<const Packet> packet,
228 uint16_t channelFreqMhz,
229 WifiTxVector txVector,
230 MpduInfo aMpdu,
231 uint16_t staId)
232{
233 auto file = GetOrCreatePcapFile(info, phyId);
234 if (!file)
235 {
236 return;
237 }
238 switch (info->pcapDlt)
239 {
241 file->Write(Simulator::Now(), packet);
242 return;
244 NS_FATAL_ERROR("PcapSniffTxEvent(): DLT_PRISM_HEADER not implemented");
245 return;
246 }
248 Ptr<Packet> p = packet->Copy();
249 RadiotapHeader header;
250 GetRadiotapHeader(header, p, channelFreqMhz, txVector, aMpdu, staId);
251 p->AddHeader(header);
252 file->Write(Simulator::Now(), p);
253 return;
254 }
255 default:
256 NS_ABORT_MSG("PcapSniffTxEvent(): Unexpected data link type " << info->pcapDlt);
257 }
258}
259
260void
261WifiPhyHelper::PcapSniffRxEvent(const std::shared_ptr<PcapFilesInfo>& info,
262 uint8_t phyId,
263 Ptr<const Packet> packet,
264 uint16_t channelFreqMhz,
265 WifiTxVector txVector,
266 MpduInfo aMpdu,
267 SignalNoiseDbm signalNoise,
268 uint16_t staId)
269{
270 auto file = GetOrCreatePcapFile(info, phyId);
271 if (!file)
272 {
273 return;
274 }
275 switch (info->pcapDlt)
276 {
278 file->Write(Simulator::Now(), packet);
279 return;
281 NS_FATAL_ERROR("PcapSniffRxEvent(): DLT_PRISM_HEADER not implemented");
282 return;
283 }
285 Ptr<Packet> p = packet->Copy();
286 RadiotapHeader header;
287 GetRadiotapHeader(header, p, channelFreqMhz, txVector, aMpdu, staId, signalNoise);
288 p->AddHeader(header);
289 file->Write(Simulator::Now(), p);
290 return;
291 }
292 default:
293 NS_ABORT_MSG("PcapSniffRxEvent(): Unexpected data link type " << info->pcapDlt);
294 }
295}
296
297void
299 Ptr<Packet> packet,
300 uint16_t channelFreqMhz,
301 WifiTxVector txVector,
302 MpduInfo aMpdu,
303 uint16_t staId,
304 SignalNoiseDbm signalNoise)
305{
306 header.SetAntennaSignalPower(signalNoise.signal);
307 header.SetAntennaNoisePower(signalNoise.noise);
308 GetRadiotapHeader(header, packet, channelFreqMhz, txVector, aMpdu, staId);
309}
310
311void
313 Ptr<Packet> packet,
314 uint16_t channelFreqMhz,
315 WifiTxVector txVector,
316 MpduInfo aMpdu,
317 uint16_t staId)
318{
319 WifiPreamble preamble = txVector.GetPreambleType();
320
321 uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE;
322 header.SetTsft(Simulator::Now().GetMicroSeconds());
323
324 // Our capture includes the FCS, so we set the flag to say so.
326
327 if (preamble == WIFI_PREAMBLE_SHORT)
328 {
330 }
331
332 if (txVector.GetGuardInterval().GetNanoSeconds() == 400)
333 {
335 }
336
337 header.SetFrameFlags(frameFlags);
338
339 uint64_t rate = 0;
340 if (txVector.GetMode(staId).GetModulationClass() != WIFI_MOD_CLASS_HT &&
341 txVector.GetMode(staId).GetModulationClass() != WIFI_MOD_CLASS_VHT &&
342 txVector.GetMode(staId).GetModulationClass() != WIFI_MOD_CLASS_HE)
343 {
344 rate = txVector.GetMode(staId).GetDataRate(txVector.GetChannelWidth(),
345 txVector.GetGuardInterval(),
346 1) *
347 txVector.GetNss(staId) / 500000;
348 header.SetRate(static_cast<uint8_t>(rate));
349 }
350
351 uint16_t channelFlags = 0;
352 switch (rate)
353 {
354 case 2: // 1Mbps
355 case 4: // 2Mbps
356 case 10: // 5Mbps
357 case 22: // 11Mbps
358 channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK;
359 break;
360 default:
361 channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM;
362 break;
363 }
364
365 if (channelFreqMhz < 2500)
366 {
368 }
369 else
370 {
372 }
373
374 header.SetChannelFrequencyAndFlags(channelFreqMhz, channelFlags);
375
376 if (txVector.GetMode(staId).GetModulationClass() == WIFI_MOD_CLASS_HT)
377 {
378 uint8_t mcsKnown = RadiotapHeader::MCS_KNOWN_NONE;
379 uint8_t mcsFlags = RadiotapHeader::MCS_FLAGS_NONE;
380
382
384 if (txVector.GetChannelWidth() == 40)
385 {
387 }
388
390 if (txVector.GetGuardInterval().GetNanoSeconds() == 400)
391 {
393 }
394
396
398 if (txVector.GetNess() & 0x01) // bit 1
399 {
401 }
402 if (txVector.GetNess() & 0x02) // bit 2
403 {
405 }
406
407 mcsKnown |= RadiotapHeader::MCS_KNOWN_FEC_TYPE; // only BCC is currently supported
408
410 if (txVector.IsStbc())
411 {
413 }
414
415 header.SetMcsFields(mcsKnown, mcsFlags, txVector.GetMode(staId).GetMcsValue());
416 }
417
418 if (txVector.IsAggregation())
419 {
420 uint16_t ampduStatusFlags = RadiotapHeader::A_MPDU_STATUS_NONE;
422 /* For PCAP file, MPDU Delimiter and Padding should be removed by the MAC Driver */
424 uint32_t extractedLength;
425 packet->RemoveHeader(hdr);
426 extractedLength = hdr.GetLength();
427 packet = packet->CreateFragment(0, static_cast<uint32_t>(extractedLength));
428 if (aMpdu.type == LAST_MPDU_IN_AGGREGATE || (hdr.GetEof() && hdr.GetLength() > 0))
429 {
430 ampduStatusFlags |= RadiotapHeader::A_MPDU_STATUS_LAST;
431 }
432 header.SetAmpduStatus(aMpdu.mpduRefNumber, ampduStatusFlags, 1 /*CRC*/);
433 }
434
435 if (txVector.GetMode(staId).GetModulationClass() == WIFI_MOD_CLASS_VHT)
436 {
437 uint16_t vhtKnown = RadiotapHeader::VHT_KNOWN_NONE;
438 uint8_t vhtFlags = RadiotapHeader::VHT_FLAGS_NONE;
439 uint8_t vhtBandwidth = 0;
440 uint8_t vhtMcsNss[4] = {0, 0, 0, 0};
441 uint8_t vhtCoding = 0;
442 uint8_t vhtGroupId = 0;
443 uint16_t vhtPartialAid = 0;
444
446 if (txVector.IsStbc())
447 {
449 }
450
452 if (txVector.GetGuardInterval().GetNanoSeconds() == 400)
453 {
455 }
456
457 vhtKnown |= RadiotapHeader::VHT_KNOWN_BEAMFORMED; // Beamforming is currently not supported
458
460 // not all bandwidth values are currently supported
461 if (txVector.GetChannelWidth() == 40)
462 {
463 vhtBandwidth = 1;
464 }
465 else if (txVector.GetChannelWidth() == 80)
466 {
467 vhtBandwidth = 4;
468 }
469 else if (txVector.GetChannelWidth() == 160)
470 {
471 vhtBandwidth = 11;
472 }
473
474 // only SU PPDUs are currently supported
475 vhtMcsNss[0] |= (txVector.GetNss(staId) & 0x0f);
476 vhtMcsNss[0] |= ((txVector.GetMode(staId).GetMcsValue() << 4) & 0xf0);
477
478 header.SetVhtFields(vhtKnown,
479 vhtFlags,
480 vhtBandwidth,
481 vhtMcsNss,
482 vhtCoding,
483 vhtGroupId,
484 vhtPartialAid);
485 }
486
487 if (txVector.GetMode(staId).GetModulationClass() == WIFI_MOD_CLASS_HE)
488 {
492 if (preamble == WIFI_PREAMBLE_HE_ER_SU)
493 {
495 }
496 else if (preamble == WIFI_PREAMBLE_HE_MU)
497 {
500 }
501 else if (preamble == WIFI_PREAMBLE_HE_TB)
502 {
504 }
505
506 uint16_t data2 = RadiotapHeader::HE_DATA2_GI_KNOWN;
507 if (preamble == WIFI_PREAMBLE_HE_MU || preamble == WIFI_PREAMBLE_HE_TB)
508 {
510 // HeRu indices start at 1 whereas RadioTap starts at 0
511 data2 |= (((txVector.GetHeMuUserInfo(staId).ru.GetIndex() - 1) << 8) & 0x3f00);
512 data2 |= (((!txVector.GetHeMuUserInfo(staId).ru.GetPrimary80MHz()) << 15) & 0x8000);
513 }
514
515 uint16_t data3 = 0;
516 data3 |= (txVector.GetBssColor() & 0x003f);
517 data3 |= ((txVector.GetMode(staId).GetMcsValue() << 8) & 0x0f00);
518
519 uint16_t data4 = 0;
520 if (preamble == WIFI_PREAMBLE_HE_MU)
521 {
522 data4 |= ((staId << 4) & 0x7ff0);
523 }
524
525 uint16_t data5 = 0;
526 if (preamble == WIFI_PREAMBLE_HE_MU || preamble == WIFI_PREAMBLE_HE_TB)
527 {
528 HeRu::RuType ruType = txVector.GetHeMuUserInfo(staId).ru.GetRuType();
529 switch (ruType)
530 {
531 case HeRu::RU_26_TONE:
533 break;
534 case HeRu::RU_52_TONE:
536 break;
539 break;
542 break;
545 break;
548 break;
551 break;
552 default:
553 NS_ABORT_MSG("Unexpected RU type");
554 }
555 }
556 else if (txVector.GetChannelWidth() == 40)
557 {
559 }
560 else if (txVector.GetChannelWidth() == 80)
561 {
563 }
564 else if (txVector.GetChannelWidth() == 160)
565 {
567 }
568 if (txVector.GetGuardInterval().GetNanoSeconds() == 1600)
569 {
571 }
572 else if (txVector.GetGuardInterval().GetNanoSeconds() == 3200)
573 {
575 }
576
577 header.SetHeFields(data1, data2, data3, data4, data5, 0);
578 }
579
580 if (preamble == WIFI_PREAMBLE_HE_MU)
581 {
582 // TODO: fill in fields (everything is set to 0 so far)
583 std::array<uint8_t, 4> ruChannel1;
584 std::array<uint8_t, 4> ruChannel2;
585 header.SetHeMuFields(0, 0, ruChannel1, ruChannel2);
586 header.SetHeMuPerUserFields(0, 0, 0, 0);
587 }
588}
589
590void
592{
593 switch (dlt)
594 {
595 case DLT_IEEE802_11:
597 return;
598 case DLT_PRISM_HEADER:
600 return;
603 return;
604 default:
605 NS_ABORT_MSG("WifiPhyHelper::SetPcapFormat(): Unexpected format");
606 }
607}
608
611{
612 return m_pcapDlt;
613}
614
615void
620
623{
624 return m_pcapType;
625}
626
627void
630 bool promiscuous,
631 bool explicitFilename)
632{
633 NS_LOG_FUNCTION(this << prefix << nd << promiscuous << explicitFilename);
634
635 // All of the Pcap enable functions vector through here including the ones
636 // that are wandering through all of devices on perhaps all of the nodes in
637 // the system. We can only deal with devices of type WifiNetDevice.
638 Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice>();
639 if (!device)
640 {
641 NS_LOG_INFO("WifiHelper::EnablePcapInternal(): Device "
642 << &device << " not of type ns3::WifiNetDevice");
643 return;
644 }
645
646 NS_ABORT_MSG_IF(device->GetPhys().empty(),
647 "WifiPhyHelper::EnablePcapInternal(): Phy layer in WifiNetDevice must be set");
648
649 PcapHelper pcapHelper;
650 std::string filename;
651 if (explicitFilename)
652 {
653 filename = prefix;
654 }
655 else
656 {
657 filename = pcapHelper.GetFilenameFromDevice(prefix, device);
658 }
659
660 auto info = std::make_shared<PcapFilesInfo>(filename, m_pcapDlt, m_pcapType, device);
661 for (auto& phy : device->GetPhys())
662 {
663 phy->TraceConnectWithoutContext(
664 "MonitorSnifferTx",
665 MakeBoundCallback(&WifiPhyHelper::PcapSniffTxEvent, info, phy->GetPhyId()));
666 phy->TraceConnectWithoutContext(
667 "MonitorSnifferRx",
668 MakeBoundCallback(&WifiPhyHelper::PcapSniffRxEvent, info, phy->GetPhyId()));
669 }
670}
671
672void
674 std::string prefix,
676 bool explicitFilename)
677{
678 // All of the ASCII enable functions vector through here including the ones
679 // that are wandering through all of devices on perhaps all of the nodes in
680 // the system. We can only deal with devices of type WifiNetDevice.
681 Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice>();
682 if (!device)
683 {
684 NS_LOG_INFO("WifiHelper::EnableAsciiInternal(): Device "
685 << device << " not of type ns3::WifiNetDevice");
686 return;
687 }
688
689 // Our trace sinks are going to use packet printing, so we have to make sure
690 // that is turned on.
692
693 uint32_t nodeid = nd->GetNode()->GetId();
694 uint32_t deviceid = nd->GetIfIndex();
695 std::ostringstream oss;
696
697 // If we are not provided an OutputStreamWrapper, we are expected to create
698 // one using the usual trace filename conventions and write our traces
699 // without a context since there will be one file per context and therefore
700 // the context would be redundant.
701 if (!stream)
702 {
703 // Set up an output stream object to deal with private ofstream copy
704 // constructor and lifetime issues. Let the helper decide the actual
705 // name of the file given the prefix.
706 AsciiTraceHelper asciiTraceHelper;
707
708 std::string filename;
709 if (explicitFilename)
710 {
711 filename = prefix;
712 }
713 else
714 {
715 filename = asciiTraceHelper.GetFilenameFromDevice(prefix, device);
716 }
717
718 // find the last point in the filename
719 auto pos = filename.find_last_of('.');
720 // if not found, set pos to filename size
721 pos = (pos == std::string::npos) ? filename.size() : pos;
722
723 for (uint8_t linkId = 0; linkId < device->GetNPhys(); linkId++)
724 {
725 std::string tmp = filename;
726 if (device->GetNPhys() > 1)
727 {
728 // insert LinkId only for multi-link devices
729 tmp.insert(pos, "-" + std::to_string(linkId));
730 }
731 auto theStream = asciiTraceHelper.CreateFileStream(tmp);
732 // We could go poking through the PHY and the state looking for the
733 // correct trace source, but we can let Config deal with that with
734 // some search cost. Since this is presumably happening at topology
735 // creation time, it doesn't seem much of a price to pay.
736 oss.str("");
737 oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid
738 << "/$ns3::WifiNetDevice/Phys/" << +linkId << "/State/RxOk";
740 oss.str(),
742
743 oss.str("");
744 oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid
745 << "/$ns3::WifiNetDevice/Phys/" << +linkId << "/State/Tx";
747 oss.str(),
749 }
750
751 return;
752 }
753
754 // If we are provided an OutputStreamWrapper, we are expected to use it, and
755 // to provide a context. We are free to come up with our own context if we
756 // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
757 // compatibility and simplicity, we just use Config::Connect and let it deal
758 // with coming up with a context.
759 oss.str("");
760 oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid
761 << "/$ns3::WifiNetDevice/Phy/State/RxOk";
763
764 oss.str("");
765 oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid
766 << "/$ns3::WifiNetDevice/Phy/State/Tx";
768}
769
773
775 : m_standard(WIFI_STANDARD_80211ax),
776 m_selectQueueCallback(&SelectQueueByDSField),
777 m_enableFlowControl(true)
778{
779 SetRemoteStationManager("ns3::IdealWifiManager");
780 m_htConfig.SetTypeId("ns3::HtConfiguration");
781 m_vhtConfig.SetTypeId("ns3::VhtConfiguration");
782 m_heConfig.SetTypeId("ns3::HeConfiguration");
783 m_ehtConfig.SetTypeId("ns3::EhtConfiguration");
784}
785
786namespace
787{
788/// Map strings to WifiStandard enum values
789const std::unordered_map<std::string, WifiStandard> WIFI_STANDARDS_NAME_MAP{
790 // clang-format off
791 {"802.11a", WIFI_STANDARD_80211a},
792 {"11a", WIFI_STANDARD_80211a},
793
794 {"802.11b", WIFI_STANDARD_80211b},
795 {"11b", WIFI_STANDARD_80211b},
796
797 {"802.11g", WIFI_STANDARD_80211g},
798 {"11g", WIFI_STANDARD_80211g},
799
800 {"802.11p", WIFI_STANDARD_80211p},
801 {"11p", WIFI_STANDARD_80211p},
802
803 {"802.11n", WIFI_STANDARD_80211n},
804 {"11n", WIFI_STANDARD_80211n},
805 {"HT", WIFI_STANDARD_80211n},
806
807 {"802.11ac", WIFI_STANDARD_80211ac},
808 {"11ac", WIFI_STANDARD_80211ac},
809 {"VHT", WIFI_STANDARD_80211ac},
810
811 {"802.11ad", WIFI_STANDARD_80211ad},
812 {"11ad", WIFI_STANDARD_80211ad},
813
814 {"802.11ax", WIFI_STANDARD_80211ax},
815 {"11ax", WIFI_STANDARD_80211ax},
816 {"HE", WIFI_STANDARD_80211ax},
817
818 {"802.11be", WIFI_STANDARD_80211be},
819 {"11be", WIFI_STANDARD_80211be},
820 {"EHT", WIFI_STANDARD_80211be},
821 // clang-format on
822};
823} // namespace
824
825void
827{
828 m_standard = standard;
829}
830
831void
832WifiHelper::SetStandard(const std::string& standard)
833{
834 NS_ABORT_MSG_IF(!WIFI_STANDARDS_NAME_MAP.contains(standard),
835 "Specified Wi-Fi standard " << standard << " is currently not supported");
836 SetStandard(WIFI_STANDARDS_NAME_MAP.at(standard));
837}
838
839void
844
845void
850
853 const WifiMacHelper& macHelper,
855 NodeContainer::Iterator last) const
856{
857 NetDeviceContainer devices;
858 for (auto i = first; i != last; ++i)
859 {
860 Ptr<Node> node = *i;
862 node->AddDevice(device);
863 device->SetStandard(m_standard);
865 {
866 NS_FATAL_ERROR("No standard specified!");
867 return devices;
868 }
870 {
871 auto htConfiguration = m_htConfig.Create<HtConfiguration>();
872 device->SetHtConfiguration(htConfiguration);
873 }
875 {
876 // Create the VHT Configuration object even if the PHY band is 2.4GHz
877 // (WifiNetDevice::GetVhtConfiguration() checks the PHY band being used).
878 // This approach allows us not to worry about deleting this object when
879 // the PHY band is switched from 5GHz to 2.4GHz and creating this object
880 // when the PHY band is switched from 2.4GHz to 5GHz.
881 auto vhtConfiguration = m_vhtConfig.Create<VhtConfiguration>();
882 device->SetVhtConfiguration(vhtConfiguration);
883 }
885 {
886 auto heConfiguration = m_heConfig.Create<HeConfiguration>();
887 device->SetHeConfiguration(heConfiguration);
888 }
890 {
891 auto ehtConfiguration = m_ehtConfig.Create<EhtConfiguration>();
892 device->SetEhtConfiguration(ehtConfiguration);
893 }
894 std::vector<Ptr<WifiRemoteStationManager>> managers;
895 std::vector<Ptr<WifiPhy>> phys = phyHelper.Create(node, device);
896 device->SetPhys(phys);
897 // if only one remote station manager model was provided, replicate it for all the links
898 auto stationManagers = m_stationManager;
899 if (stationManagers.size() == 1 && phys.size() > 1)
900 {
901 stationManagers.resize(phys.size(), stationManagers[0]);
902 }
903 NS_ABORT_MSG_IF(stationManagers.size() != phys.size(),
904 "Number of station manager models ("
905 << stationManagers.size() << ") does not match the number of links ("
906 << phys.size() << ")");
907 for (std::size_t i = 0; i < phys.size(); i++)
908 {
909 phys[i]->ConfigureStandard(m_standard);
910 managers.push_back(stationManagers[i].Create<WifiRemoteStationManager>());
911 }
912 device->SetRemoteStationManagers(managers);
913 Ptr<WifiMac> mac = macHelper.Create(device, m_standard);
915 {
917 device->AggregateObject(obssPdAlgorithm);
918 obssPdAlgorithm->ConnectWifiNetDevice(device);
919 }
920 devices.Add(device);
921 NS_LOG_DEBUG("node=" << node << ", mob=" << node->GetObject<MobilityModel>());
923 {
925 BooleanValue qosSupported;
927
928 mac->GetAttributeFailSafe("QosSupported", qosSupported);
929 if (qosSupported.Get())
930 {
932 UintegerValue(4));
933 for (auto& ac : {AC_BE, AC_BK, AC_VI, AC_VO})
934 {
935 Ptr<QosTxop> qosTxop = mac->GetQosTxop(ac);
936 wmq = qosTxop->GetWifiMacQueue();
937 ndqi->GetTxQueue(static_cast<std::size_t>(ac))->ConnectQueueTraces(wmq);
938 }
939 ndqi->SetSelectQueueCallback(m_selectQueueCallback);
940 }
941 else
942 {
944
945 wmq = mac->GetTxop()->GetWifiMacQueue();
946 ndqi->GetTxQueue(0)->ConnectQueueTraces(wmq);
947 }
948 device->AggregateObject(ndqi);
949 }
950 }
951 return devices;
952}
953
956 const WifiMacHelper& macHelper,
957 NodeContainer c) const
958{
959 return Install(phyHelper, macHelper, c.Begin(), c.End());
960}
961
963WifiHelper::Install(const WifiPhyHelper& phy, const WifiMacHelper& mac, Ptr<Node> node) const
964{
965 return Install(phy, mac, NodeContainer(node));
966}
967
969WifiHelper::Install(const WifiPhyHelper& phy, const WifiMacHelper& mac, std::string nodeName) const
970{
971 Ptr<Node> node = Names::Find<Node>(nodeName);
972 return Install(phy, mac, NodeContainer(node));
973}
974
975void
977{
980
981 LogComponentEnable("AarfWifiManager", logLevel);
982 LogComponentEnable("AarfcdWifiManager", logLevel);
983 LogComponentEnable("AdhocWifiMac", logLevel);
984 LogComponentEnable("AdvancedApEmlsrManager", logLevel);
985 LogComponentEnable("AdvancedEmlsrManager", logLevel);
986 LogComponentEnable("AmrrWifiManager", logLevel);
987 LogComponentEnable("ApEmlsrManager", logLevel);
988 LogComponentEnable("ApWifiMac", logLevel);
989 LogComponentEnable("AparfWifiManager", logLevel);
990 LogComponentEnable("ArfWifiManager", logLevel);
991 LogComponentEnable("BlockAckAgreement", logLevel);
992 LogComponentEnable("BlockAckManager", logLevel);
993 LogComponentEnable("CaraWifiManager", logLevel);
994 LogComponentEnable("ChannelAccessManager", logLevel);
995 LogComponentEnable("ConstantObssPdAlgorithm", logLevel);
996 LogComponentEnable("ConstantRateWifiManager", logLevel);
997 LogComponentEnable("DefaultApEmlsrManager", logLevel);
998 LogComponentEnable("DefaultEmlsrManager", logLevel);
999 LogComponentEnable("DsssErrorRateModel", logLevel);
1000 LogComponentEnable("DsssPhy", logLevel);
1001 LogComponentEnable("DsssPpdu", logLevel);
1002 LogComponentEnable("EhtFrameExchangeManager", logLevel);
1003 LogComponentEnable("EhtPhy", logLevel);
1004 LogComponentEnable("EhtPpdu", logLevel);
1005 LogComponentEnable("EmlsrManager", logLevel);
1006 LogComponentEnable("ErpOfdmPhy", logLevel);
1007 LogComponentEnable("ErpOfdmPpdu", logLevel);
1008 LogComponentEnable("FrameExchangeManager", logLevel);
1009 LogComponentEnable("HeConfiguration", logLevel);
1010 LogComponentEnable("HeFrameExchangeManager", logLevel);
1011 LogComponentEnable("HePhy", logLevel);
1012 LogComponentEnable("HePpdu", logLevel);
1013 LogComponentEnable("HtConfiguration", logLevel);
1014 LogComponentEnable("HtFrameExchangeManager", logLevel);
1015 LogComponentEnable("HtPhy", logLevel);
1016 LogComponentEnable("HtPpdu", logLevel);
1017 LogComponentEnable("IdealWifiManager", logLevel);
1018 LogComponentEnable("InterferenceHelper", logLevel);
1019 LogComponentEnable("MacRxMiddle", logLevel);
1020 LogComponentEnable("MacTxMiddle", logLevel);
1021 LogComponentEnable("MinstrelHtWifiManager", logLevel);
1022 LogComponentEnable("MinstrelWifiManager", logLevel);
1023 LogComponentEnable("MpduAggregator", logLevel);
1024 LogComponentEnable("MsduAggregator", logLevel);
1025 LogComponentEnable("MultiUserScheduler", logLevel);
1026 LogComponentEnable("NistErrorRateModel", logLevel);
1027 LogComponentEnable("ObssPdAlgorithm", logLevel);
1028 LogComponentEnable("OfdmPhy", logLevel);
1029 LogComponentEnable("OfdmPpdu", logLevel);
1030 LogComponentEnable("OnoeWifiManager", logLevel);
1031 LogComponentEnable("OriginatorBlockAckAgreement", logLevel);
1032 LogComponentEnable("ParfWifiManager", logLevel);
1033 LogComponentEnable("PhyEntity", logLevel);
1034 LogComponentEnable("QosFrameExchangeManager", logLevel);
1035 LogComponentEnable("QosTxop", logLevel);
1036 LogComponentEnable("RecipientBlockAckAgreement", logLevel);
1037 LogComponentEnable("RrMultiUserScheduler", logLevel);
1038 LogComponentEnable("RraaWifiManager", logLevel);
1039 LogComponentEnable("RrpaaWifiManager", logLevel);
1040 LogComponentEnable("SimpleFrameCaptureModel", logLevel);
1041 LogComponentEnable("SpectrumWifiPhy", logLevel);
1042 LogComponentEnable("StaWifiMac", logLevel);
1043 LogComponentEnable("SupportedRates", logLevel);
1044 LogComponentEnable("TableBasedErrorRateModel", logLevel);
1045 LogComponentEnable("ThompsonSamplingWifiManager", logLevel);
1046 LogComponentEnable("ThresholdPreambleDetectionModel", logLevel);
1047 LogComponentEnable("Txop", logLevel);
1048 LogComponentEnable("VhtConfiguration", logLevel);
1049 LogComponentEnable("VhtFrameExchangeManager", logLevel);
1050 LogComponentEnable("VhtPhy", logLevel);
1051 LogComponentEnable("VhtPpdu", logLevel);
1052 LogComponentEnable("WifiAckManager", logLevel);
1053 LogComponentEnable("WifiAssocManager", logLevel);
1054 LogComponentEnable("WifiDefaultAckManager", logLevel);
1055 LogComponentEnable("WifiDefaultAssocManager", logLevel);
1056 LogComponentEnable("WifiDefaultProtectionManager", logLevel);
1057 LogComponentEnable("WifiMac", logLevel);
1058 LogComponentEnable("WifiMacQueue", logLevel);
1059 LogComponentEnable("WifiMpdu", logLevel);
1060 LogComponentEnable("WifiNetDevice", logLevel);
1061 LogComponentEnable("WifiPhyStateHelper", logLevel);
1062 LogComponentEnable("WifiPhyOperatingChannel", logLevel);
1063 LogComponentEnable("WifiPhy", logLevel);
1064 LogComponentEnable("WifiPpdu", logLevel);
1065 LogComponentEnable("WifiProtectionManager", logLevel);
1066 LogComponentEnable("WifiPsdu", logLevel);
1067 LogComponentEnable("WifiRadioEnergyModel", logLevel);
1068 LogComponentEnable("WifiRemoteStationManager", logLevel);
1069 LogComponentEnable("WifiSpectrumPhyInterface", logLevel);
1070 LogComponentEnable("WifiSpectrumSignalParameters", logLevel);
1071 LogComponentEnable("WifiSpectrumValueHelper", logLevel);
1072 LogComponentEnable("WifiTxCurrentModel", logLevel);
1073 LogComponentEnable("WifiTxParameters", logLevel);
1074 LogComponentEnable("WifiTxTimer", logLevel);
1075 LogComponentEnable("YansErrorRateModel", logLevel);
1076 LogComponentEnable("YansWifiChannel", logLevel);
1077 LogComponentEnable("YansWifiPhy", logLevel);
1078
1079 LogComponentEnable("Athstats", logLevel);
1080 LogComponentEnable("WifiHelper", logLevel);
1081 LogComponentEnable("SpectrumWifiHelper", logLevel);
1082 LogComponentEnable("YansWifiHelper", logLevel);
1083}
1084
1085int64_t
1087{
1088 int64_t currentStream = stream;
1089 Ptr<NetDevice> netDevice;
1090 for (auto i = c.Begin(); i != c.End(); ++i)
1091 {
1092 netDevice = (*i);
1093 if (auto wifi = DynamicCast<WifiNetDevice>(netDevice))
1094 {
1095 // Handle any random numbers in the PHY objects.
1096 for (auto& phy : wifi->GetPhys())
1097 {
1098 currentStream += phy->AssignStreams(currentStream);
1099 }
1100
1101 // Handle any random numbers in the station managers.
1102 for (auto& manager : wifi->GetRemoteStationManagers())
1103 {
1104 currentStream += manager->AssignStreams(currentStream);
1105 }
1106
1107 // Handle any random numbers in the MAC objects.
1108 auto mac = wifi->GetMac();
1109 PointerValue ptr;
1110 if (!mac->GetQosSupported())
1111 {
1112 mac->GetAttribute("Txop", ptr);
1113 auto txop = ptr.Get<Txop>();
1114 currentStream += txop->AssignStreams(currentStream);
1115 }
1116 else
1117 {
1118 mac->GetAttribute("VO_Txop", ptr);
1119 auto vo_txop = ptr.Get<QosTxop>();
1120 currentStream += vo_txop->AssignStreams(currentStream);
1121
1122 mac->GetAttribute("VI_Txop", ptr);
1123 auto vi_txop = ptr.Get<QosTxop>();
1124 currentStream += vi_txop->AssignStreams(currentStream);
1125
1126 mac->GetAttribute("BE_Txop", ptr);
1127 auto be_txop = ptr.Get<QosTxop>();
1128 currentStream += be_txop->AssignStreams(currentStream);
1129
1130 mac->GetAttribute("BK_Txop", ptr);
1131 auto bk_txop = ptr.Get<QosTxop>();
1132 currentStream += bk_txop->AssignStreams(currentStream);
1133 }
1134
1135 // if an AP, handle any beacon jitter
1136 if (auto apMac = DynamicCast<ApWifiMac>(mac); apMac)
1137 {
1138 currentStream += apMac->AssignStreams(currentStream);
1139 }
1140 // if a STA, handle any probe request jitter
1141 if (auto staMac = DynamicCast<StaWifiMac>(mac); staMac)
1142 {
1143 currentStream += staMac->AssignStreams(currentStream);
1144 }
1145 }
1146 }
1147 return (currentStream - stream);
1148}
1149
1150} // namespace ns3
Headers for A-MPDU subframes.
uint16_t GetLength() const
Return the length field.
bool GetEof() const
Return the EOF field.
Manage ASCII trace files for device models.
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the ascii trace helper figure out a reasonable filename to use for an ascii trace file associated...
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
Hold a value for an Attribute.
Definition attribute.h:59
bool Get() const
Definition boolean.cc:44
EHT configuration.
HE configuration.
std::size_t GetIndex() const
Get the RU index.
Definition he-ru.cc:454
RuType GetRuType() const
Get the RU type.
Definition he-ru.cc:447
bool GetPrimary80MHz() const
Get the primary 80 MHz flag.
Definition he-ru.cc:461
RuType
The different HE Resource Unit (RU) types.
Definition he-ru.h:32
@ RU_26_TONE
Definition he-ru.h:33
@ RU_484_TONE
Definition he-ru.h:37
@ RU_996_TONE
Definition he-ru.h:38
@ RU_106_TONE
Definition he-ru.h:35
@ RU_52_TONE
Definition he-ru.h:34
@ RU_242_TONE
Definition he-ru.h:36
@ RU_2x996_TONE
Definition he-ru.h:39
HT configuration.
Keep track of the current position and velocity of an object.
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition names.h:443
holds a vector of ns3::NetDevice pointers
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
keep track of a set of node pointers.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
bool IsTypeIdSet() const
Check if the ObjectFactory has been configured with a TypeId.
OBSS PD algorithm interface.
static void EnablePrinting()
Enable printing packets metadata.
Definition packet.cc:585
Manage pcap files for device models.
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the pcap helper figure out a reasonable filename to use for a pcap file associated with a device.
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, DataLinkType dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
DataLinkType
This enumeration holds the data link types that will be written to the pcap file.
AttributeValue implementation for Pointer.
Ptr< T > Get() const
Definition pointer.h:223
Smart pointer class similar to boost::intrusive_ptr.
Handles the packet queue and stores DCF/EDCA access parameters (one Txop per AC).
Definition qos-txop.h:52
Radiotap header implementation.
void SetMcsFields(uint8_t known, uint8_t flags, uint8_t mcs)
Set the MCS fields.
@ CHANNEL_FLAG_OFDM
OFDM channel.
@ CHANNEL_FLAG_CCK
CCK channel.
@ CHANNEL_FLAG_SPECTRUM_5GHZ
5 GHz spectrum channel
@ CHANNEL_FLAG_SPECTRUM_2GHZ
2 GHz spectrum channel
@ VHT_KNOWN_NONE
No flags set.
@ VHT_KNOWN_BANDWIDTH
Bandwidth known.
@ VHT_KNOWN_STBC
Space-time block coding (1 if all spatial streams of all users have STBC, 0 otherwise).
@ VHT_KNOWN_GUARD_INTERVAL
Guard interval.
@ VHT_KNOWN_BEAMFORMED
Beamformed known/applicable (this flag should be set to zero for MU PPDUs).
void SetChannelFrequencyAndFlags(uint16_t frequency, uint16_t flags)
Set the transmit/receive channel frequency and flags.
@ FRAME_FLAG_SHORT_PREAMBLE
Frame sent/received with short preamble.
@ FRAME_FLAG_SHORT_GUARD
Frame used short guard interval (HT)
@ FRAME_FLAG_FCS_INCLUDED
Frame includes FCS.
@ FRAME_FLAG_NONE
No flags set.
@ HE_DATA2_RU_OFFSET_KNOWN
RU allocation offset known.
void SetRate(uint8_t rate)
Set the transmit/receive channel frequency in units of megahertz.
void SetVhtFields(uint16_t known, uint8_t flags, uint8_t bandwidth, uint8_t mcs_nss[4], uint8_t coding, uint8_t group_id, uint16_t partial_aid)
Set the VHT fields.
void SetAntennaSignalPower(double signal)
Set the RF signal power at the antenna as a decibel difference from an arbitrary, fixed reference.
void SetTsft(uint64_t tsft)
Set the Time Synchronization Function Timer (TSFT) value.
@ VHT_FLAGS_NONE
No flags set.
@ VHT_FLAGS_STBC
Set if all spatial streams of all users have space-time block coding.
@ VHT_FLAGS_GUARD_INTERVAL
Short guard interval.
void SetHeFields(uint16_t data1, uint16_t data2, uint16_t data3, uint16_t data4, uint16_t data5, uint16_t data6)
Set the HE fields.
@ MCS_FLAGS_NESS_BIT_0
Ness - bit 0 (LSB) of Number of extension spatial streams.
@ MCS_FLAGS_NONE
Default: 20 MHz, long guard interval, mixed HT format and BCC FEC type.
@ MCS_FLAGS_STBC_STREAMS
STBC enabled.
@ MCS_FLAGS_GUARD_INTERVAL
Short guard interval.
@ HE_DATA1_FORMAT_TRIG
HE TRIG PPDU format.
@ HE_DATA1_FORMAT_MU
HE MU PPDU format.
@ HE_DATA1_BSS_COLOR_KNOWN
BSS Color known.
@ HE_DATA1_FORMAT_EXT_SU
HE EXT SU PPDU format.
@ HE_DATA1_DATA_MCS_KNOWN
data MCS known
@ HE_DATA1_SPTL_REUSE2_KNOWN
Spatial Reuse 2 known (HE TRIG PPDU format), STA-ID known (HE MU PPDU format)
@ HE_DATA1_BW_RU_ALLOC_KNOWN
data BW/RU allocation known
void SetAmpduStatus(uint32_t referenceNumber, uint16_t flags, uint8_t crc)
Set the A-MPDU status fields.
void SetHeMuPerUserFields(uint16_t perUser1, uint16_t perUser2, uint8_t perUserPosition, uint8_t perUserKnown)
Set the HE MU per user fields.
@ A_MPDU_STATUS_NONE
No flags set.
@ A_MPDU_STATUS_LAST_KNOWN
Last subframe is known (should be set for all subframes in an A-MPDU)
@ A_MPDU_STATUS_LAST
This frame is the last subframe.
@ MCS_KNOWN_FEC_TYPE
FEC type.
@ MCS_KNOWN_GUARD_INTERVAL
Guard interval.
@ MCS_KNOWN_NONE
No flags set.
@ MCS_KNOWN_BANDWIDTH
Bandwidth.
@ MCS_KNOWN_NESS_BIT_1
Ness data - bit 1 (MSB) of Number of extension spatial streams.
@ MCS_KNOWN_HT_FORMAT
HT format.
@ MCS_KNOWN_NESS
Ness known (Number of extension spatial streams)
@ MCS_KNOWN_INDEX
MCS index known.
@ MCS_KNOWN_STBC
STBC known.
void SetHeMuFields(uint16_t flags1, uint16_t flags2, const std::array< uint8_t, 4 > &ruChannel1, const std::array< uint8_t, 4 > &ruChannel2)
Set the HE MU fields.
void SetAntennaNoisePower(double noise)
Set the RF noise power at the antenna as a decibel difference from an arbitrary, fixed reference.
@ HE_DATA5_DATA_BW_RU_ALLOC_26T
26-tone RU allocation
@ HE_DATA5_DATA_BW_RU_ALLOC_484T
484-tone RU allocation
@ HE_DATA5_DATA_BW_RU_ALLOC_40MHZ
40 MHz data Bandwidth
@ HE_DATA5_DATA_BW_RU_ALLOC_2x996T
2x996-tone RU allocation
@ HE_DATA5_DATA_BW_RU_ALLOC_242T
242-tone RU allocation
@ HE_DATA5_DATA_BW_RU_ALLOC_52T
52-tone RU allocation
@ HE_DATA5_DATA_BW_RU_ALLOC_160MHZ
160 MHz data Bandwidth
@ HE_DATA5_DATA_BW_RU_ALLOC_106T
106-tone RU allocation
@ HE_DATA5_DATA_BW_RU_ALLOC_996T
996-tone RU allocation
@ HE_DATA5_DATA_BW_RU_ALLOC_80MHZ
80 MHz data Bandwidth
void SetFrameFlags(uint8_t flags)
Set the frame flags of the transmitted or received frame.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:407
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:392
Handles the packet queue and stores DCF/EDCA access parameters (one Txop per AC).
Definition txop.h:56
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition txop.cc:674
Hold an unsigned integer type.
Definition uinteger.h:34
VHT configuration.
virtual ~WifiHelper()
void SetRemoteStationManager(std::string type, Args &&... args)
Helper function used to set the station manager.
ObjectFactory m_htConfig
HT configuration.
ObjectFactory m_obssPdAlgorithm
OBSS_PD algorithm.
ObjectFactory m_ehtConfig
EHT configuration.
ObjectFactory m_vhtConfig
VHT configuration.
static void EnableLogComponents(LogLevel logLevel=LOG_LEVEL_ALL)
Helper to enable all WifiNetDevice log components with one statement.
void SetSelectQueueCallback(SelectQueueCallback f)
std::vector< ObjectFactory > m_stationManager
station manager
WifiStandard m_standard
wifi standard
static int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the PHY and MAC aspects ...
virtual void SetStandard(WifiStandard standard)
ObjectFactory m_heConfig
HE configuration.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
void DisableFlowControl()
Disable flow control only if you know what you are doing.
SelectQueueCallback m_selectQueueCallback
select queue callback
bool m_enableFlowControl
whether to enable flow control
WifiHelper()
Create a Wifi helper in an empty state: all its parameters must be set before calling ns3::WifiHelper...
std::function< std::size_t(Ptr< QueueItem >)> SelectQueueCallback
Callback invoked to determine the MAC queue selected for a given packet.
create MAC layers for a ns3::WifiNetDevice.
virtual Ptr< WifiMac > Create(Ptr< WifiNetDevice > device, WifiStandard standard) const
Implements the IEEE 802.11 MAC trailer.
represent a single transmission mode
Definition wifi-mode.h:40
WifiModulationClass GetModulationClass() const
Definition wifi-mode.cc:174
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:111
uint8_t GetMcsValue() const
Definition wifi-mode.cc:152
Hold together all Wifi-related objects.
create PHY objects
Definition wifi-helper.h:39
void SetPcapCaptureType(PcapCaptureType type)
Set the PCAP capture type to be used.
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ASCII trace output on the indicated net device.
WifiPhyHelper(uint8_t nLinks=1)
Constructor.
static void PcapSniffTxEvent(const std::shared_ptr< PcapFilesInfo > &info, uint8_t phyId, Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, uint16_t staId=SU_STA_ID)
void Set(std::string name, const AttributeValue &v)
~WifiPhyHelper() override
void DisablePreambleDetectionModel()
Disable the preamble detection model on all links.
void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output the indicated net device.
PcapHelper::DataLinkType m_pcapDlt
PCAP data link type.
std::vector< ObjectFactory > m_frameCaptureModel
frame capture model
std::vector< ObjectFactory > m_preambleDetectionModel
preamble detection model
PcapHelper::DataLinkType GetPcapDataLinkType() const
Get the data link type of PCAP traces to be used.
PcapCaptureType m_pcapType
PCAP capture type.
PcapCaptureType GetPcapCaptureType() const
Get the PCAP capture type to be used.
std::vector< ObjectFactory > m_phys
PHY objects.
static void PcapSniffRxEvent(const std::shared_ptr< PcapFilesInfo > &info, uint8_t phyId, Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId=SU_STA_ID)
void SetPreambleDetectionModel(std::string type, Args &&... args)
Helper function used to set the preamble detection model.
static Ptr< PcapFileWrapper > GetOrCreatePcapFile(const std::shared_ptr< PcapFilesInfo > &info, uint8_t phyId)
Get the PCAP file to write to from a list of PCAP files indexed by PHY ID.
SupportedPcapDataLinkTypes
An enumeration of the pcap data link types (DLTs) which this helper supports.
@ DLT_IEEE802_11
IEEE 802.11 Wireless LAN headers on packets.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
@ DLT_PRISM_HEADER
Include Prism monitor mode information.
std::vector< ObjectFactory > m_errorRateModel
error rate model
virtual std::vector< Ptr< WifiPhy > > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const =0
PcapCaptureType
An enumeration of the PCAP capture types.
@ PCAP_PER_PHY
Single capture file per PHY.
@ PCAP_PER_DEVICE
Single capture file per device.
@ PCAP_PER_LINK
Single capture file per link.
static void GetRadiotapHeader(RadiotapHeader &header, Ptr< Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, uint16_t staId)
Get the Radiotap header for a transmitted packet.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint8_t GetBssColor() const
Get the BSS color.
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.
bool IsStbc() const
Check if STBC is used or not.
WifiPreamble GetPreambleType() const
HeMuUserInfo GetHeMuUserInfo(uint16_t staId) const
Get the HE MU user-specific transmission information for the given STA-ID.
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.
MHz_u GetChannelWidth() const
bool IsAggregation() const
Checks whether the PSDU contains A-MPDU.
Time GetGuardInterval() const
uint8_t GetNess() const
void Connect(std::string path, const CallbackBase &cb)
Definition config.cc:967
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition config.cc:943
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition abort.h:65
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Definition callback.h:745
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
uint8_t SelectQueueByDSField(Ptr< QueueItem > item)
Determine the TX queue for a given packet.
Definition qos-utils.cc:227
@ WIFI_STANDARD_80211a
@ WIFI_STANDARD_80211ad
@ WIFI_STANDARD_80211p
@ WIFI_STANDARD_80211be
@ WIFI_STANDARD_80211n
@ WIFI_STANDARD_80211g
@ WIFI_STANDARD_80211ax
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_STANDARD_80211ac
@ WIFI_STANDARD_80211b
@ WIFI_PREAMBLE_HE_ER_SU
@ WIFI_PREAMBLE_HE_TB
@ WIFI_PREAMBLE_HE_MU
@ WIFI_PREAMBLE_SHORT
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ AC_BE
Best Effort.
Definition qos-utils.h:64
@ AC_VO
Voice.
Definition qos-utils.h:70
@ AC_VI
Video.
Definition qos-utils.h:68
@ AC_BK
Background.
Definition qos-utils.h:66
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
Definition wifi-types.h:53
Definition first.py:1
const std::unordered_map< std::string, WifiStandard > WIFI_STANDARDS_NAME_MAP
Map strings to WifiStandard enum values.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition log.cc:291
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
static void AsciiPhyReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, double snr, WifiMode mode, WifiPreamble preamble)
ASCII trace PHY receive sink without context.
LogLevel
Logging severity classes and levels.
Definition log.h:83
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
Definition log.h:108
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
Definition log.h:109
static void AsciiPhyReceiveSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, double snr, WifiMode mode, WifiPreamble preamble)
ASCII trace PHY receive sink with context.
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
Definition log.cc:309
static void AsciiPhyTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
ASCII trace PHY transmit sink with context.
static void AsciiPhyTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
ASCII trace PHY transmit sink without context.
HeRu::RuSpec ru
RU specification.
MpduInfo structure.
Definition wifi-types.h:65
MpduType type
type of MPDU
Definition wifi-types.h:66
uint32_t mpduRefNumber
MPDU ref number.
Definition wifi-types.h:67
SignalNoiseDbm structure.
Definition wifi-types.h:58
dBm_u noise
noise power
Definition wifi-types.h:60
dBm_u signal
signal strength
Definition wifi-types.h:59