A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-helper.h
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#ifndef WIFI_HELPER_H
12#define WIFI_HELPER_H
13
14#include "wifi-mac-helper.h"
15
16#include "ns3/qos-utils.h"
17#include "ns3/trace-helper.h"
18#include "ns3/wifi-net-device.h"
19#include "ns3/wifi-phy.h"
20
21#include <functional>
22#include <map>
23#include <vector>
24
25namespace ns3
26{
27
28class Node;
29class RadiotapHeader;
30class QueueItem;
31
32/**
33 * \brief create PHY objects
34 *
35 * This base class must be implemented by new PHY implementation which wish to integrate
36 * with the \ref ns3::WifiHelper class.
37 */
39{
40 public:
41 /**
42 * Constructor
43 *
44 * \param nLinks the number of links to configure (>1 only for 11be devices)
45 */
46 WifiPhyHelper(uint8_t nLinks = 1);
47 ~WifiPhyHelper() override;
48
49 /**
50 * \param node the node on which the PHY object(s) will reside
51 * \param device the device within which the PHY object(s) will reside
52 *
53 * \returns new PHY objects.
54 *
55 * Subclasses must implement this method to allow the ns3::WifiHelper class
56 * to create PHY objects from ns3::WifiHelper::Install.
57 */
58 virtual std::vector<Ptr<WifiPhy>> Create(Ptr<Node> node, Ptr<WifiNetDevice> device) const = 0;
59
60 /**
61 * \param name the name of the attribute to set
62 * \param v the value of the attribute
63 *
64 * Set an attribute of all the underlying PHY object.
65 */
66 void Set(std::string name, const AttributeValue& v);
67
68 /**
69 * \param name the name of the attribute to set
70 * \param v the value of the attribute
71 * \param linkId ID of the link to configure (>0 only for 11be devices)
72 *
73 * Set an attribute of the given underlying PHY object.
74 */
75 void Set(uint8_t linkId, std::string name, const AttributeValue& v);
76
77 /**
78 * Helper function used to set the interference helper.
79 *
80 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
81 * \param type the type of interference helper
82 * \param args A sequence of name-value pairs of the attributes to set.
83 */
84 template <typename... Args>
85 void SetInterferenceHelper(std::string type, Args&&... args);
86
87 /**
88 * Helper function used to set the error rate model.
89 *
90 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
91 * \param type the type of error rate model
92 * \param args A sequence of name-value pairs of the attributes to set.
93 */
94 template <typename... Args>
95 void SetErrorRateModel(std::string type, Args&&... args);
96
97 /**
98 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
99 * \param linkId ID of the link to configure (>0 only for 11be devices)
100 * \param type the type of the error rate model to set.
101 * \param args A sequence of name-value pairs of the attributes to set.
102 *
103 * Set the error rate model and its attributes to use for the given link when Install is called.
104 */
105 template <typename... Args>
106 void SetErrorRateModel(uint8_t linkId, std::string type, Args&&... args);
107
108 /**
109 * Helper function used to set the frame capture model.
110 *
111 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
112 * \param type the type of frame capture model
113 * \param args A sequence of name-value pairs of the attributes to set.
114 */
115 template <typename... Args>
116 void SetFrameCaptureModel(std::string type, Args&&... args);
117
118 /**
119 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
120 * \param linkId ID of the link to configure (>0 only for 11be devices)
121 * \param type the type of the frame capture model to set.
122 * \param args A sequence of name-value pairs of the attributes to set.
123 *
124 * Set the frame capture model and its attributes to use for the given link when Install is
125 * called.
126 */
127 template <typename... Args>
128 void SetFrameCaptureModel(uint8_t linkId, std::string type, Args&&... args);
129
130 /**
131 * Helper function used to set the preamble detection model.
132 *
133 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
134 * \param type the type of preamble detection model
135 * \param args A sequence of name-value pairs of the attributes to set.
136 */
137 template <typename... Args>
138 void SetPreambleDetectionModel(std::string type, Args&&... args);
139
140 /**
141 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
142 * \param linkId ID of the link to configure (>0 only for 11be devices)
143 * \param type the type of the preamble detection model to set.
144 * \param args A sequence of name-value pairs of the attributes to set.
145 *
146 * Set the preamble detection model and its attributes to use for the given link when Install is
147 * called.
148 */
149 template <typename... Args>
150 void SetPreambleDetectionModel(uint8_t linkId, std::string type, Args&&... args);
151
152 /**
153 * Disable the preamble detection model on all links.
154 */
156
157 /**
158 * An enumeration of the pcap data link types (DLTs) which this helper
159 * supports. See http://wiki.wireshark.org/Development/LibpcapFileFormat
160 * for more information on these formats.
161 */
163 {
165 PcapHelper::DLT_IEEE802_11, /**< IEEE 802.11 Wireless LAN headers on packets */
167 PcapHelper::DLT_PRISM_HEADER, /**< Include Prism monitor mode information */
169 PcapHelper::DLT_IEEE802_11_RADIO /**< Include Radiotap link layer information */
170 };
171
172 /**
173 * An enumeration of the PCAP capture types.
174 * The PCAP capture type only matters for multi-link devices.
175 */
177 {
178 PCAP_PER_DEVICE, /**< Single capture file per device */
179 PCAP_PER_PHY, /**< Single capture file per PHY */
180 PCAP_PER_LINK, /**< Single capture file per link */
181 };
182
183 /**
184 * structure holding the information about PCAP files generated for a given device
185 */
187 {
188 /**
189 * Constructor
190 *
191 * \param filename the common file name of the PCAP files
192 * \param dlt the selected data link type of the pcap file
193 * \param type the selected PCAP capture type
194 * \param dev the WifiNetDevice for which the PCAP files are generated
195 */
196 PcapFilesInfo(const std::string& filename,
200 : commonFilename{filename},
201 pcapDlt{dlt},
202 pcapType{type},
203 device{dev},
204 files{}
205 {
206 }
207
208 std::string commonFilename; ///< common file name of the PCAP files
209 PcapHelper::DataLinkType pcapDlt; ///< the selected data link type of the pcap file
210 WifiPhyHelper::PcapCaptureType pcapType; ///< the selected PCAP capture type
211 Ptr<WifiNetDevice> device; ///< the WifiNetDevice for which the PCAP files are generated
212 std::map<uint8_t, Ptr<PcapFileWrapper>> files; ///< PCAP files indexed by PHY ID
213 };
214
215 /**
216 * Set the data link type of PCAP traces to be used. This function has to be
217 * called before EnablePcap(), so that the header of the pcap file can be
218 * written correctly.
219 *
220 * \see SupportedPcapDataLinkTypes
221 *
222 * \param dlt The data link type of the pcap file (and packets) to be used
223 */
225
226 /**
227 * Get the data link type of PCAP traces to be used.
228 *
229 * \see SupportedPcapDataLinkTypes
230 *
231 * \returns The data link type of the pcap file (and packets) to be used
232 */
234
235 /**
236 * Set the PCAP capture type to be used. This function has to be called before EnablePcap().
237 *
238 * \see PcapCaptureType
239 *
240 * \param type The PCAP capture type
241 */
243
244 /**
245 * Get the PCAP capture type to be used.
246 *
247 * \see PcapCaptureType
248 *
249 * \return The PCAP capture type to be used
250 */
252
253 protected:
254 /**
255 * \param info the information needed to write to the correct PCAP file
256 * \param phyId the ID of the PHY that raised the event
257 * \param packet the packet
258 * \param channelFreqMhz the channel frequency
259 * \param txVector the TXVECTOR
260 * \param aMpdu the A-MPDU information
261 * \param staId the STA-ID (only used for MU)
262 *
263 * Handle TX pcap.
264 */
265 static void PcapSniffTxEvent(const std::shared_ptr<PcapFilesInfo>& info,
266 uint8_t phyId,
267 Ptr<const Packet> packet,
268 uint16_t channelFreqMhz,
269 WifiTxVector txVector,
270 MpduInfo aMpdu,
271 uint16_t staId = SU_STA_ID);
272 /**
273 * \param info the information needed to write to the correct PCAP file
274 * \param phyId the ID of the PHY that raised the event
275 * \param packet the packet
276 * \param channelFreqMhz the channel frequency
277 * \param txVector the TXVECTOR
278 * \param aMpdu the A-MPDU information
279 * \param signalNoise the RX signal and noise information
280 * \param staId the STA-ID (only used for MU)
281 *
282 * Handle RX pcap.
283 */
284 static void PcapSniffRxEvent(const std::shared_ptr<PcapFilesInfo>& info,
285 uint8_t phyId,
286 Ptr<const Packet> packet,
287 uint16_t channelFreqMhz,
288 WifiTxVector txVector,
289 MpduInfo aMpdu,
290 SignalNoiseDbm signalNoise,
291 uint16_t staId = SU_STA_ID);
292
293 std::vector<ObjectFactory> m_phys; ///< PHY objects
294 ObjectFactory m_interferenceHelper; ///< interference helper
295 std::vector<ObjectFactory> m_errorRateModel; ///< error rate model
296 std::vector<ObjectFactory> m_frameCaptureModel; ///< frame capture model
297 std::vector<ObjectFactory> m_preambleDetectionModel; ///< preamble detection model
298
299 private:
300 /**
301 * Get the PCAP file to write to from a list of PCAP files indexed by PHY ID.
302 * If PCAP files are generated per link, it might create a new file if a link
303 * has swapped to a new ID.
304 *
305 * \param info the information needed to write to the correct PCAP file
306 * \param phyId the ID of the PHY that raised the event
307 * \return the PCAP file to write to
308 */
309 static Ptr<PcapFileWrapper> GetOrCreatePcapFile(const std::shared_ptr<PcapFilesInfo>& info,
310 uint8_t phyId);
311
312 /**
313 * Get the Radiotap header for a transmitted packet.
314 *
315 * \param header the radiotap header to be filled in
316 * \param packet the packet
317 * \param channelFreqMhz the channel frequency
318 * \param txVector the TXVECTOR
319 * \param aMpdu the A-MPDU information
320 * \param staId the STA-ID
321 */
322 static void GetRadiotapHeader(RadiotapHeader& header,
323 Ptr<Packet> packet,
324 uint16_t channelFreqMhz,
325 WifiTxVector txVector,
326 MpduInfo aMpdu,
327 uint16_t staId);
328
329 /**
330 * Get the Radiotap header for a received packet.
331 *
332 * \param header the radiotap header to be filled in
333 * \param packet the packet
334 * \param channelFreqMhz the channel frequency
335 * \param txVector the TXVECTOR
336 * \param aMpdu the A-MPDU information
337 * \param staId the STA-ID
338 * \param signalNoise the rx signal and noise information
339 */
340 static void GetRadiotapHeader(RadiotapHeader& header,
341 Ptr<Packet> packet,
342 uint16_t channelFreqMhz,
343 WifiTxVector txVector,
344 MpduInfo aMpdu,
345 uint16_t staId,
346 SignalNoiseDbm signalNoise);
347
348 /**
349 * \brief Enable pcap output the indicated net device.
350 *
351 * NetDevice-specific implementation mechanism for hooking the trace and
352 * writing to the trace file.
353 *
354 * \param prefix Filename prefix to use for pcap files.
355 * \param nd Net device for which you want to enable tracing.
356 * \param promiscuous If true capture all possible packets available at the device.
357 * \param explicitFilename Treat the prefix as an explicit filename if true
358 */
359 void EnablePcapInternal(std::string prefix,
361 bool promiscuous,
362 bool explicitFilename) override;
363
364 /**
365 * \brief Enable ASCII trace output on the indicated net device.
366 *
367 * NetDevice-specific implementation mechanism for hooking the trace and
368 * writing to the trace file.
369 *
370 * \param stream The output stream object to use when logging ASCII traces.
371 * \param prefix Filename prefix to use for ASCII trace files.
372 * \param nd Net device for which you want to enable tracing.
373 * \param explicitFilename Treat the prefix as an explicit filename if true
374 */
376 std::string prefix,
378 bool explicitFilename) override;
379
380 PcapHelper::DataLinkType m_pcapDlt; ///< PCAP data link type
381 PcapCaptureType m_pcapType; ///< PCAP capture type
382};
383
384/**
385 * \brief helps to create WifiNetDevice objects
386 *
387 * This class can help to create a large set of similar
388 * WifiNetDevice objects and to configure a large set of
389 * their attributes during creation.
390 */
392{
393 public:
394 virtual ~WifiHelper();
395
396 /**
397 * Create a Wifi helper in an empty state: all its parameters
398 * must be set before calling ns3::WifiHelper::Install
399 *
400 * The default state is defined as being an Adhoc MAC layer with an ARF rate control algorithm
401 * and both objects using their default attribute values.
402 * By default, configure MAC and PHY for 802.11ax.
403 */
404 WifiHelper();
405
406 /**
407 * Helper function used to set the station manager
408 *
409 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
410 * \param type the type of station manager
411 * \param args A sequence of name-value pairs of the attributes to set.
412 */
413 template <typename... Args>
414 void SetRemoteStationManager(std::string type, Args&&... args);
415
416 /**
417 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
418 * \param linkId ID of the link to configure (>0 only for 11be devices)
419 * \param type the type of the preamble detection model to set.
420 * \param args A sequence of name-value pairs of the attributes to set.
421 *
422 * Set the remote station manager model and its attributes to use for the given link.
423 * If the helper stored a remote station manager model for the first N links only
424 * (corresponding to link IDs from 0 to N-1) and the given linkId is M >= N, then a
425 * remote station manager model using the given attributes is configured for all links
426 * with ID from N to M.
427 */
428 template <typename... Args>
429 void SetRemoteStationManager(uint8_t linkId, std::string type, Args&&... args);
430
431 /**
432 * Helper function used to set the OBSS-PD algorithm
433 *
434 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
435 * \param type the type of OBSS-PD algorithm
436 * \param args A sequence of name-value pairs of the attributes to set.
437 */
438 template <typename... Args>
439 void SetObssPdAlgorithm(std::string type, Args&&... args);
440
441 /// Callback invoked to determine the MAC queue selected for a given packet
442 typedef std::function<std::size_t(Ptr<QueueItem>)> SelectQueueCallback;
443
444 /**
445 * \param f the select queue callback
446 *
447 * Set the select queue callback to set on the NetDevice queue interface aggregated
448 * to the WifiNetDevice, in case WifiMac with QoS enabled is used
449 */
451
452 /**
453 * Disable flow control only if you know what you are doing. By disabling
454 * flow control, this NetDevice will be sent packets even if there is no
455 * room for them (such packets will be likely dropped by this NetDevice).
456 * Also, any queue disc installed on this NetDevice will have no effect,
457 * as every packet enqueued to the traffic control layer queue disc will
458 * be immediately dequeued.
459 */
460 void DisableFlowControl();
461
462 /**
463 * \param phy the PHY helper to create PHY objects
464 * \param mac the MAC helper to create MAC objects
465 * \param first lower bound on the set of nodes on which a wifi device must be created
466 * \param last upper bound on the set of nodes on which a wifi device must be created
467 * \returns a device container which contains all the devices created by this method.
468 */
469 NetDeviceContainer virtual Install(const WifiPhyHelper& phy,
470 const WifiMacHelper& mac,
472 NodeContainer::Iterator last) const;
473 /**
474 * \param phy the PHY helper to create PHY objects
475 * \param mac the MAC helper to create MAC objects
476 * \param c the set of nodes on which a wifi device must be created
477 * \returns a device container which contains all the devices created by this method.
478 */
479 virtual NetDeviceContainer Install(const WifiPhyHelper& phy,
480 const WifiMacHelper& mac,
481 NodeContainer c) const;
482 /**
483 * \param phy the PHY helper to create PHY objects
484 * \param mac the MAC helper to create MAC objects
485 * \param node the node on which a wifi device must be created
486 * \returns a device container which contains all the devices created by this method.
487 */
488 virtual NetDeviceContainer Install(const WifiPhyHelper& phy,
489 const WifiMacHelper& mac,
490 Ptr<Node> node) const;
491 /**
492 * \param phy the PHY helper to create PHY objects
493 * \param mac the MAC helper to create MAC objects
494 * \param nodeName the name of node on which a wifi device must be created
495 * \returns a device container which contains all the devices created by this method.
496 */
497 virtual NetDeviceContainer Install(const WifiPhyHelper& phy,
498 const WifiMacHelper& mac,
499 std::string nodeName) const;
500 /**
501 * \param standard the standard to configure during installation
502 *
503 * This method sets standards-compliant defaults for WifiMac
504 * parameters such as SIFS time, slot time, timeout values, etc.,
505 * based on the standard selected. It results in
506 * WifiMac::ConfigureStandard(standard) being called on each
507 * installed MAC object.
508 *
509 * The default standard of 802.11ax will be applied if SetStandard()
510 * is not called.
511 *
512 * Note that WifiMac::ConfigureStandard () will overwrite certain
513 * defaults in the attribute system, so if a user wants to manipulate
514 * any default values affected by ConfigureStandard() while using this
515 * helper, the user should use a post-install configuration such as
516 * Config::Set() on any objects that this helper creates, such as:
517 * \code
518 * Config::Set ("/NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Mac/Slot", TimeValue (MicroSeconds
519 * (slot))); \endcode
520 *
521 * \sa WifiMac::ConfigureStandard
522 * \sa Config::Set
523 */
524 virtual void SetStandard(WifiStandard standard);
525
526 /**
527 * \param standard String representation of the Wi-Fi standard
528 *
529 * This method overloads WifiHelper::SetStandard(WifiStandard standard) by allowing
530 * selected string names. For example, the strings "802.11ax", "11ax", and "HE"
531 * are equivalent and map to WIFI_STANDARD_80211ax. See the documentation of the specified
532 * function to see how it interacts with attribute configuration.
533 * \sa WifiHelper::SetStandard(WifiStandard standard)
534 */
535 void SetStandard(const std::string& standard);
536
537 /**
538 * Helper function used to configure the HT options listed as attributes of
539 * the HtConfiguration class.
540 *
541 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
542 * \param args A sequence of name-value pairs of the attributes to set.
543 */
544 template <typename... Args>
545 void ConfigHtOptions(Args&&... args);
546
547 /**
548 * Helper function used to configure the VHT options listed as attributes of
549 * the VhtConfiguration class.
550 *
551 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
552 * \param args A sequence of name-value pairs of the attributes to set.
553 */
554 template <typename... Args>
555 void ConfigVhtOptions(Args&&... args);
556
557 /**
558 * Helper function used to configure the HE options listed as attributes of
559 * the HeConfiguration class.
560 *
561 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
562 * \param args A sequence of name-value pairs of the attributes to set.
563 */
564 template <typename... Args>
565 void ConfigHeOptions(Args&&... args);
566
567 /**
568 * Helper function used to configure the EHT options listed as attributes of
569 * the EhtConfiguration class.
570 *
571 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
572 * \param args A sequence of name-value pairs of the attributes to set.
573 */
574 template <typename... Args>
575 void ConfigEhtOptions(Args&&... args);
576
577 /**
578 * Helper to enable all WifiNetDevice log components with one statement
579 * \param logLevel (optional) log level setting
580 */
581 static void EnableLogComponents(LogLevel logLevel = LOG_LEVEL_ALL);
582
583 /**
584 * Assign a fixed random variable stream number to the random variables
585 * used by the PHY and MAC aspects of the Wifi models. Each device in
586 * container c has fixed stream numbers assigned to its random variables.
587 * The Wifi channel (e.g. propagation loss model) is excluded.
588 * Return the number of streams (possibly zero) that
589 * have been assigned. The Install() method should have previously been
590 * called by the user.
591 *
592 * \param c NetDeviceContainer of the set of net devices for which the
593 * WifiNetDevice should be modified to use fixed streams
594 * \param stream first stream index to use
595 * \return the number of stream indices assigned by this helper
596 */
597 static int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
598
599 protected:
600 mutable std::vector<ObjectFactory> m_stationManager; ///< station manager
601 WifiStandard m_standard; ///< wifi standard
602 ObjectFactory m_htConfig; ///< HT configuration
603 ObjectFactory m_vhtConfig; ///< VHT configuration
604 ObjectFactory m_heConfig; ///< HE configuration
605 ObjectFactory m_ehtConfig; ///< EHT configuration
606 SelectQueueCallback m_selectQueueCallback; ///< select queue callback
607 ObjectFactory m_obssPdAlgorithm; ///< OBSS_PD algorithm
608 bool m_enableFlowControl; //!< whether to enable flow control
609};
610
611} // namespace ns3
612
613/***************************************************************
614 * Implementation of the templates declared above.
615 ***************************************************************/
616
617namespace ns3
618{
619
620template <typename... Args>
621void
622WifiPhyHelper::SetInterferenceHelper(std::string type, Args&&... args)
623{
625 m_interferenceHelper.Set(args...);
626}
627
628template <typename... Args>
629void
630WifiPhyHelper::SetErrorRateModel(std::string type, Args&&... args)
631{
632 for (std::size_t linkId = 0; linkId < m_phys.size(); linkId++)
633 {
634 SetErrorRateModel(linkId, type, std::forward<Args>(args)...);
635 }
636}
637
638template <typename... Args>
639void
640WifiPhyHelper::SetErrorRateModel(uint8_t linkId, std::string type, Args&&... args)
641{
642 m_errorRateModel.at(linkId).SetTypeId(type);
643 m_errorRateModel.at(linkId).Set(args...);
644}
645
646template <typename... Args>
647void
648WifiPhyHelper::SetFrameCaptureModel(std::string type, Args&&... args)
649{
650 for (std::size_t linkId = 0; linkId < m_phys.size(); linkId++)
651 {
652 SetFrameCaptureModel(linkId, type, std::forward<Args>(args)...);
653 }
654}
655
656template <typename... Args>
657void
658WifiPhyHelper::SetFrameCaptureModel(uint8_t linkId, std::string type, Args&&... args)
659{
660 m_frameCaptureModel.at(linkId).SetTypeId(type);
661 m_frameCaptureModel.at(linkId).Set(args...);
662}
663
664template <typename... Args>
665void
666WifiPhyHelper::SetPreambleDetectionModel(std::string type, Args&&... args)
667{
668 for (std::size_t linkId = 0; linkId < m_phys.size(); linkId++)
669 {
670 SetPreambleDetectionModel(linkId, type, std::forward<Args>(args)...);
671 }
672}
673
674template <typename... Args>
675void
676WifiPhyHelper::SetPreambleDetectionModel(uint8_t linkId, std::string type, Args&&... args)
677{
678 m_preambleDetectionModel.at(linkId).SetTypeId(type);
679 m_preambleDetectionModel.at(linkId).Set(args...);
680}
681
682template <typename... Args>
683void
684WifiHelper::SetRemoteStationManager(std::string type, Args&&... args)
685{
686 SetRemoteStationManager(0, type, std::forward<Args>(args)...);
687}
688
689template <typename... Args>
690void
691WifiHelper::SetRemoteStationManager(uint8_t linkId, std::string type, Args&&... args)
692{
693 if (m_stationManager.size() > linkId)
694 {
695 m_stationManager[linkId] = ObjectFactory(type, std::forward<Args>(args)...);
696 }
697 else
698 {
699 m_stationManager.resize(linkId + 1, ObjectFactory(type, std::forward<Args>(args)...));
700 }
701}
702
703template <typename... Args>
704void
705WifiHelper::SetObssPdAlgorithm(std::string type, Args&&... args)
706{
708 m_obssPdAlgorithm.Set(args...);
709}
710
711template <typename... Args>
712void
714{
715 m_htConfig.Set(args...);
716}
717
718template <typename... Args>
719void
721{
722 m_vhtConfig.Set(args...);
723}
724
725template <typename... Args>
726void
728{
729 m_heConfig.Set(args...);
730}
731
732template <typename... Args>
733void
735{
736 m_ehtConfig.Set(args...);
737}
738
739} // namespace ns3
740
741#endif /* WIFI_HELPER_H */
Base class providing common user-level ascii trace operations for helpers representing net devices.
Hold a value for an Attribute.
Definition attribute.h:59
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Instantiate subclasses of ns3::Object.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Base class providing common user-level pcap operations for helpers representing net devices.
DataLinkType
This enumeration holds the data link types that will be written to the pcap file.
Smart pointer class similar to boost::intrusive_ptr.
Radiotap header implementation.
helps to create WifiNetDevice objects
virtual ~WifiHelper()
void SetRemoteStationManager(std::string type, Args &&... args)
Helper function used to set the station manager.
void ConfigEhtOptions(Args &&... args)
Helper function used to configure the EHT options listed as attributes of the EhtConfiguration class.
void SetObssPdAlgorithm(std::string type, Args &&... args)
Helper function used to set the OBSS-PD algorithm.
void ConfigHtOptions(Args &&... args)
Helper function used to configure the HT options listed as attributes of the HtConfiguration class.
ObjectFactory m_htConfig
HT configuration.
void ConfigHeOptions(Args &&... args)
Helper function used to configure the HE options listed as attributes of the HeConfiguration class.
ObjectFactory m_obssPdAlgorithm
OBSS_PD algorithm.
ObjectFactory m_ehtConfig
EHT configuration.
void ConfigVhtOptions(Args &&... args)
Helper function used to configure the VHT options listed as attributes of the VhtConfiguration class.
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.
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 SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
void SetInterferenceHelper(std::string type, Args &&... args)
Helper function used to set the interference helper.
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.
void SetFrameCaptureModel(std::string type, Args &&... args)
Helper function used to set the frame capture model.
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.
ObjectFactory m_interferenceHelper
interference helper
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...
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
Definition first.py:1
Every class exported by the ns3 library is enclosed in the ns3 namespace.
LogLevel
Logging severity classes and levels.
Definition log.h:83
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:105
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
Definition wifi-mode.h:24
MpduInfo structure.
Definition wifi-types.h:65
SignalNoiseDbm structure.
Definition wifi-types.h:58
structure holding the information about PCAP files generated for a given device
std::string commonFilename
common file name of the PCAP files
WifiPhyHelper::PcapCaptureType pcapType
the selected PCAP capture type
Ptr< WifiNetDevice > device
the WifiNetDevice for which the PCAP files are generated
std::map< uint8_t, Ptr< PcapFileWrapper > > files
PCAP files indexed by PHY ID.
PcapFilesInfo(const std::string &filename, PcapHelper::DataLinkType dlt, WifiPhyHelper::PcapCaptureType type, Ptr< WifiNetDevice > dev)
Constructor.
PcapHelper::DataLinkType pcapDlt
the selected data link type of the pcap file