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 p20Index the index of the primary20 channel
319 * @param txVector the TXVECTOR
320 * @param aMpdu the A-MPDU information
321 * @param staId the STA-ID
322 */
323 static void GetRadiotapHeader(RadiotapHeader& header,
324 Ptr<Packet> packet,
325 uint16_t channelFreqMhz,
326 uint8_t p20Index,
327 const WifiTxVector& txVector,
328 MpduInfo aMpdu,
329 uint16_t staId);
330
331 /**
332 * Get the Radiotap header for a received packet.
333 *
334 * @param header the radiotap header to be filled in
335 * @param packet the packet
336 * @param channelFreqMhz the channel frequency
337 * @param p20Index the index of the primary20 channel
338 * @param txVector the TXVECTOR
339 * @param aMpdu the A-MPDU information
340 * @param staId the STA-ID
341 * @param signalNoise the rx signal and noise information
342 */
343 static void GetRadiotapHeader(RadiotapHeader& header,
344 Ptr<Packet> packet,
345 uint16_t channelFreqMhz,
346 uint8_t p20Index,
347 const WifiTxVector& txVector,
348 MpduInfo aMpdu,
349 uint16_t staId,
350 SignalNoiseDbm signalNoise);
351
352 /**
353 * @brief Enable pcap output the indicated net device.
354 *
355 * NetDevice-specific implementation mechanism for hooking the trace and
356 * writing to the trace file.
357 *
358 * @param prefix Filename prefix to use for pcap files.
359 * @param nd Net device for which you want to enable tracing.
360 * @param promiscuous If true capture all possible packets available at the device.
361 * @param explicitFilename Treat the prefix as an explicit filename if true
362 */
363 void EnablePcapInternal(std::string prefix,
365 bool promiscuous,
366 bool explicitFilename) override;
367
368 /**
369 * @brief Enable ASCII trace output on the indicated net device.
370 *
371 * NetDevice-specific implementation mechanism for hooking the trace and
372 * writing to the trace file.
373 *
374 * @param stream The output stream object to use when logging ASCII traces.
375 * @param prefix Filename prefix to use for ASCII trace files.
376 * @param nd Net device for which you want to enable tracing.
377 * @param explicitFilename Treat the prefix as an explicit filename if true
378 */
380 std::string prefix,
382 bool explicitFilename) override;
383
384 PcapHelper::DataLinkType m_pcapDlt; ///< PCAP data link type
385 PcapCaptureType m_pcapType; ///< PCAP capture type
386};
387
388/**
389 * @brief helps to create WifiNetDevice objects
390 *
391 * This class can help to create a large set of similar
392 * WifiNetDevice objects and to configure a large set of
393 * their attributes during creation.
394 */
396{
397 public:
398 virtual ~WifiHelper();
399
400 /**
401 * Create a Wifi helper in an empty state: all its parameters
402 * must be set before calling ns3::WifiHelper::Install
403 *
404 * The default state is defined as being an Adhoc MAC layer with an ARF rate control algorithm
405 * and both objects using their default attribute values.
406 * By default, configure MAC and PHY for 802.11ax.
407 */
408 WifiHelper();
409
410 /**
411 * Helper function used to set the station manager
412 *
413 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
414 * @param type the type of station manager
415 * @param args A sequence of name-value pairs of the attributes to set.
416 */
417 template <typename... Args>
418 void SetRemoteStationManager(std::string type, Args&&... args);
419
420 /**
421 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
422 * @param linkId ID of the link to configure (>0 only for 11be devices)
423 * @param type the type of the preamble detection model to set.
424 * @param args A sequence of name-value pairs of the attributes to set.
425 *
426 * Set the remote station manager model and its attributes to use for the given link.
427 * If the helper stored a remote station manager model for the first N links only
428 * (corresponding to link IDs from 0 to N-1) and the given linkId is M >= N, then a
429 * remote station manager model using the given attributes is configured for all links
430 * with ID from N to M.
431 */
432 template <typename... Args>
433 void SetRemoteStationManager(uint8_t linkId, std::string type, Args&&... args);
434
435 /**
436 * Helper function used to set the OBSS-PD algorithm
437 *
438 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
439 * @param type the type of OBSS-PD algorithm
440 * @param args A sequence of name-value pairs of the attributes to set.
441 */
442 template <typename... Args>
443 void SetObssPdAlgorithm(std::string type, Args&&... args);
444
445 /// Callback invoked to determine the MAC queue selected for a given packet
446 typedef std::function<std::size_t(Ptr<QueueItem>)> SelectQueueCallback;
447
448 /**
449 * @param f the select queue callback
450 *
451 * Set the select queue callback to set on the NetDevice queue interface aggregated
452 * to the WifiNetDevice, in case WifiMac with QoS enabled is used
453 */
455
456 /**
457 * Disable flow control only if you know what you are doing. By disabling
458 * flow control, this NetDevice will be sent packets even if there is no
459 * room for them (such packets will be likely dropped by this NetDevice).
460 * Also, any queue disc installed on this NetDevice will have no effect,
461 * as every packet enqueued to the traffic control layer queue disc will
462 * be immediately dequeued.
463 */
464 void DisableFlowControl();
465
466 /**
467 * @param phy the PHY helper to create PHY objects
468 * @param mac the MAC helper to create MAC objects
469 * @param first lower bound on the set of nodes on which a wifi device must be created
470 * @param last upper bound on the set of nodes on which a wifi device must be created
471 * @returns a device container which contains all the devices created by this method.
472 */
473 NetDeviceContainer virtual Install(const WifiPhyHelper& phy,
474 const WifiMacHelper& mac,
476 NodeContainer::Iterator last) const;
477 /**
478 * @param phy the PHY helper to create PHY objects
479 * @param mac the MAC helper to create MAC objects
480 * @param c the set of nodes on which a wifi device must be created
481 * @returns a device container which contains all the devices created by this method.
482 */
483 virtual NetDeviceContainer Install(const WifiPhyHelper& phy,
484 const WifiMacHelper& mac,
485 NodeContainer c) const;
486 /**
487 * @param phy the PHY helper to create PHY objects
488 * @param mac the MAC helper to create MAC objects
489 * @param node the node on which a wifi device must be created
490 * @returns a device container which contains all the devices created by this method.
491 */
492 virtual NetDeviceContainer Install(const WifiPhyHelper& phy,
493 const WifiMacHelper& mac,
494 Ptr<Node> node) const;
495 /**
496 * @param phy the PHY helper to create PHY objects
497 * @param mac the MAC helper to create MAC objects
498 * @param nodeName the name of node on which a wifi device must be created
499 * @returns a device container which contains all the devices created by this method.
500 */
501 virtual NetDeviceContainer Install(const WifiPhyHelper& phy,
502 const WifiMacHelper& mac,
503 std::string nodeName) const;
504 /**
505 * @param standard the standard to configure during installation
506 *
507 * This method sets standards-compliant defaults for WifiMac
508 * parameters such as SIFS time, slot time, timeout values, etc.,
509 * based on the standard selected. It results in
510 * WifiMac::ConfigureStandard(standard) being called on each
511 * installed MAC object.
512 *
513 * The default standard of 802.11ax will be applied if SetStandard()
514 * is not called.
515 *
516 * Note that WifiMac::ConfigureStandard () will overwrite certain
517 * defaults in the attribute system, so if a user wants to manipulate
518 * any default values affected by ConfigureStandard() while using this
519 * helper, the user should use a post-install configuration such as
520 * Config::Set() on any objects that this helper creates, such as:
521 * @code
522 * Config::Set ("/NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Mac/Slot", TimeValue (MicroSeconds
523 * (slot))); \endcode
524 *
525 * \sa WifiMac::ConfigureStandard
526 * \sa Config::Set
527 */
528 virtual void SetStandard(WifiStandard standard);
529
530 /**
531 * @param standard String representation of the Wi-Fi standard
532 *
533 * This method overloads WifiHelper::SetStandard(WifiStandard standard) by allowing
534 * selected string names. For example, the strings "802.11ax", "11ax", and "HE"
535 * are equivalent and map to WIFI_STANDARD_80211ax. See the documentation of the specified
536 * function to see how it interacts with attribute configuration.
537 * \sa WifiHelper::SetStandard(WifiStandard standard)
538 */
539 void SetStandard(const std::string& standard);
540
541 /**
542 * Helper function used to configure the HT options listed as attributes of
543 * the HtConfiguration class.
544 *
545 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
546 * @param args A sequence of name-value pairs of the attributes to set.
547 */
548 template <typename... Args>
549 void ConfigHtOptions(Args&&... args);
550
551 /**
552 * Helper function used to configure the VHT options listed as attributes of
553 * the VhtConfiguration class.
554 *
555 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
556 * @param args A sequence of name-value pairs of the attributes to set.
557 */
558 template <typename... Args>
559 void ConfigVhtOptions(Args&&... args);
560
561 /**
562 * Helper function used to configure the HE options listed as attributes of
563 * the HeConfiguration class.
564 *
565 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
566 * @param args A sequence of name-value pairs of the attributes to set.
567 */
568 template <typename... Args>
569 void ConfigHeOptions(Args&&... args);
570
571 /**
572 * Helper function used to configure the EHT options listed as attributes of
573 * the EhtConfiguration class.
574 *
575 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
576 * @param args A sequence of name-value pairs of the attributes to set.
577 */
578 template <typename... Args>
579 void ConfigEhtOptions(Args&&... args);
580
581 /**
582 * Helper to enable all WifiNetDevice log components with one statement
583 * @param logLevel (optional) log level setting
584 */
585 static void EnableLogComponents(LogLevel logLevel = LOG_LEVEL_ALL);
586
587 /**
588 * Assign a fixed random variable stream number to the random variables
589 * used by the PHY and MAC aspects of the Wifi models. Each device in
590 * container c has fixed stream numbers assigned to its random variables.
591 * The Wifi channel (e.g. propagation loss model) is excluded.
592 * Return the number of streams (possibly zero) that
593 * have been assigned. The Install() method should have previously been
594 * called by the user.
595 *
596 * @param c NetDeviceContainer of the set of net devices for which the
597 * WifiNetDevice should be modified to use fixed streams
598 * @param stream first stream index to use
599 * @return the number of stream indices assigned by this helper
600 */
601 static int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
602
603 protected:
604 mutable std::vector<ObjectFactory> m_stationManager; ///< station manager
605 WifiStandard m_standard; ///< wifi standard
606 ObjectFactory m_htConfig; ///< HT configuration
607 ObjectFactory m_vhtConfig; ///< VHT configuration
608 ObjectFactory m_heConfig; ///< HE configuration
609 ObjectFactory m_ehtConfig; ///< EHT configuration
610 SelectQueueCallback m_selectQueueCallback; ///< select queue callback
611 ObjectFactory m_obssPdAlgorithm; ///< OBSS_PD algorithm
612 bool m_enableFlowControl; //!< whether to enable flow control
613};
614
615} // namespace ns3
616
617/***************************************************************
618 * Implementation of the templates declared above.
619 ***************************************************************/
620
621namespace ns3
622{
623
624template <typename... Args>
625void
626WifiPhyHelper::SetInterferenceHelper(std::string type, Args&&... args)
627{
629 m_interferenceHelper.Set(args...);
630}
631
632template <typename... Args>
633void
634WifiPhyHelper::SetErrorRateModel(std::string type, Args&&... args)
635{
636 for (std::size_t linkId = 0; linkId < m_phys.size(); linkId++)
637 {
638 SetErrorRateModel(linkId, type, std::forward<Args>(args)...);
639 }
640}
641
642template <typename... Args>
643void
644WifiPhyHelper::SetErrorRateModel(uint8_t linkId, std::string type, Args&&... args)
645{
646 m_errorRateModel.at(linkId).SetTypeId(type);
647 m_errorRateModel.at(linkId).Set(args...);
648}
649
650template <typename... Args>
651void
652WifiPhyHelper::SetFrameCaptureModel(std::string type, Args&&... args)
653{
654 for (std::size_t linkId = 0; linkId < m_phys.size(); linkId++)
655 {
656 SetFrameCaptureModel(linkId, type, std::forward<Args>(args)...);
657 }
658}
659
660template <typename... Args>
661void
662WifiPhyHelper::SetFrameCaptureModel(uint8_t linkId, std::string type, Args&&... args)
663{
664 m_frameCaptureModel.at(linkId).SetTypeId(type);
665 m_frameCaptureModel.at(linkId).Set(args...);
666}
667
668template <typename... Args>
669void
670WifiPhyHelper::SetPreambleDetectionModel(std::string type, Args&&... args)
671{
672 for (std::size_t linkId = 0; linkId < m_phys.size(); linkId++)
673 {
674 SetPreambleDetectionModel(linkId, type, std::forward<Args>(args)...);
675 }
676}
677
678template <typename... Args>
679void
680WifiPhyHelper::SetPreambleDetectionModel(uint8_t linkId, std::string type, Args&&... args)
681{
682 m_preambleDetectionModel.at(linkId).SetTypeId(type);
683 m_preambleDetectionModel.at(linkId).Set(args...);
684}
685
686template <typename... Args>
687void
688WifiHelper::SetRemoteStationManager(std::string type, Args&&... args)
689{
690 SetRemoteStationManager(0, type, std::forward<Args>(args)...);
691}
692
693template <typename... Args>
694void
695WifiHelper::SetRemoteStationManager(uint8_t linkId, std::string type, Args&&... args)
696{
697 if (m_stationManager.size() > linkId)
698 {
699 m_stationManager[linkId] = ObjectFactory(type, std::forward<Args>(args)...);
700 }
701 else
702 {
703 m_stationManager.resize(linkId + 1, ObjectFactory(type, std::forward<Args>(args)...));
704 }
705}
706
707template <typename... Args>
708void
709WifiHelper::SetObssPdAlgorithm(std::string type, Args&&... args)
710{
712 m_obssPdAlgorithm.Set(args...);
713}
714
715template <typename... Args>
716void
718{
719 m_htConfig.Set(args...);
720}
721
722template <typename... Args>
723void
725{
726 m_vhtConfig.Set(args...);
727}
728
729template <typename... Args>
730void
732{
733 m_heConfig.Set(args...);
734}
735
736template <typename... Args>
737void
739{
740 m_ehtConfig.Set(args...);
741}
742
743} // namespace ns3
744
745#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.
static void GetRadiotapHeader(RadiotapHeader &header, Ptr< Packet > packet, uint16_t channelFreqMhz, uint8_t p20Index, const WifiTxVector &txVector, MpduInfo aMpdu, uint16_t staId)
Get the Radiotap header for a transmitted packet.
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
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