A Discrete-Event Network Simulator
API
wifi-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 * Copyright (c) 2009 MIRKO BANCHI
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * Mirko Banchi <mk.banchi@gmail.com>
20 */
21
22#ifndef WIFI_HELPER_H
23#define WIFI_HELPER_H
24
25#include "wifi-mac-helper.h"
26
27#include "ns3/deprecated.h"
28#include "ns3/qos-utils.h"
29#include "ns3/trace-helper.h"
30#include "ns3/wifi-phy.h"
31
32#include <functional>
33#include <vector>
34
35namespace ns3
36{
37
38class WifiNetDevice;
39class Node;
40class RadiotapHeader;
41class QueueItem;
42
50{
51 public:
57 WifiPhyHelper(uint8_t nLinks = 1);
58 ~WifiPhyHelper() override;
59
69 virtual std::vector<Ptr<WifiPhy>> Create(Ptr<Node> node, Ptr<WifiNetDevice> device) const = 0;
70
77 void Set(std::string name, const AttributeValue& v);
78
86 void Set(uint8_t linkId, std::string name, const AttributeValue& v);
87
95 template <typename... Args>
96 void SetInterferenceHelper(std::string type, Args&&... args);
97
105 template <typename... Args>
106 void SetErrorRateModel(std::string type, Args&&... args);
107
116 template <typename... Args>
117 void SetErrorRateModel(uint8_t linkId, std::string type, Args&&... args);
118
126 template <typename... Args>
127 void SetFrameCaptureModel(std::string type, Args&&... args);
128
138 template <typename... Args>
139 void SetFrameCaptureModel(uint8_t linkId, std::string type, Args&&... args);
140
148 template <typename... Args>
149 void SetPreambleDetectionModel(std::string type, Args&&... args);
150
160 template <typename... Args>
161 void SetPreambleDetectionModel(uint8_t linkId, std::string type, Args&&... args);
162
167
174 {
181 };
182
193
202
203 protected:
215 Ptr<const Packet> packet,
216 uint16_t channelFreqMhz,
217 WifiTxVector txVector,
218 MpduInfo aMpdu,
219 uint16_t staId = SU_STA_ID);
232 Ptr<const Packet> packet,
233 uint16_t channelFreqMhz,
234 WifiTxVector txVector,
235 MpduInfo aMpdu,
236 SignalNoiseDbm signalNoise,
237 uint16_t staId = SU_STA_ID);
238
239 std::vector<ObjectFactory> m_phy;
241 std::vector<ObjectFactory> m_errorRateModel;
242 std::vector<ObjectFactory> m_frameCaptureModel;
243 std::vector<ObjectFactory> m_preambleDetectionModel;
244
245 private:
256 static void GetRadiotapHeader(RadiotapHeader& header,
257 Ptr<Packet> packet,
258 uint16_t channelFreqMhz,
259 WifiTxVector txVector,
260 MpduInfo aMpdu,
261 uint16_t staId);
262
274 static void GetRadiotapHeader(RadiotapHeader& header,
275 Ptr<Packet> packet,
276 uint16_t channelFreqMhz,
277 WifiTxVector txVector,
278 MpduInfo aMpdu,
279 uint16_t staId,
280 SignalNoiseDbm signalNoise);
281
293 void EnablePcapInternal(std::string prefix,
295 bool promiscuous,
296 bool explicitFilename) override;
297
310 std::string prefix,
312 bool explicitFilename) override;
313
315};
316
325{
326 public:
327 virtual ~WifiHelper();
328
337 WifiHelper();
338
346 template <typename... Args>
347 void SetRemoteStationManager(std::string type, Args&&... args);
348
356 template <typename... Args>
357 void SetObssPdAlgorithm(std::string type, Args&&... args);
358
360 typedef std::function<std::size_t(Ptr<QueueItem>)> SelectQueueCallback;
361
369
378 void DisableFlowControl();
379
388 const WifiMacHelper& mac,
390 NodeContainer::Iterator last) const;
398 const WifiMacHelper& mac,
399 NodeContainer c) const;
407 const WifiMacHelper& mac,
408 Ptr<Node> node) const;
416 const WifiMacHelper& mac,
417 std::string nodeName) const;
442 virtual void SetStandard(WifiStandard standard);
443
451 template <typename... Args>
452 void ConfigHtOptions(Args&&... args);
453
461 template <typename... Args>
462 void ConfigVhtOptions(Args&&... args);
463
471 template <typename... Args>
472 void ConfigHeOptions(Args&&... args);
473
481 template <typename... Args>
482 void ConfigEhtOptions(Args&&... args);
483
487 static void EnableLogComponents();
488
503 int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
504
505 protected:
515};
516
517} // namespace ns3
518
519/***************************************************************
520 * Implementation of the templates declared above.
521 ***************************************************************/
522
523namespace ns3
524{
525
526template <typename... Args>
527void
529{
532}
533
534template <typename... Args>
535void
537{
538 for (std::size_t linkId = 0; linkId < m_phy.size(); linkId++)
539 {
540 SetErrorRateModel(linkId, type, std::forward<Args>(args)...);
541 }
542}
543
544template <typename... Args>
545void
546WifiPhyHelper::SetErrorRateModel(uint8_t linkId, std::string type, Args&&... args)
547{
548 m_errorRateModel.at(linkId).SetTypeId(type);
549 m_errorRateModel.at(linkId).Set(args...);
550}
551
552template <typename... Args>
553void
555{
556 for (std::size_t linkId = 0; linkId < m_phy.size(); linkId++)
557 {
558 SetFrameCaptureModel(linkId, type, std::forward<Args>(args)...);
559 }
560}
561
562template <typename... Args>
563void
564WifiPhyHelper::SetFrameCaptureModel(uint8_t linkId, std::string type, Args&&... args)
565{
566 m_frameCaptureModel.at(linkId).SetTypeId(type);
567 m_frameCaptureModel.at(linkId).Set(args...);
568}
569
570template <typename... Args>
571void
573{
574 for (std::size_t linkId = 0; linkId < m_phy.size(); linkId++)
575 {
576 SetPreambleDetectionModel(linkId, type, std::forward<Args>(args)...);
577 }
578}
579
580template <typename... Args>
581void
582WifiPhyHelper::SetPreambleDetectionModel(uint8_t linkId, std::string type, Args&&... args)
583{
584 m_preambleDetectionModel.at(linkId).SetTypeId(type);
585 m_preambleDetectionModel.at(linkId).Set(args...);
586}
587
588template <typename... Args>
589void
591{
594}
595
596template <typename... Args>
597void
599{
602}
603
604template <typename... Args>
605void
607{
608 m_htConfig.Set(args...);
609}
610
611template <typename... Args>
612void
614{
615 m_vhtConfig.Set(args...);
616}
617
618template <typename... Args>
619void
621{
622 m_heConfig.Set(args...);
623}
624
625template <typename... Args>
626void
628{
629 m_ehtConfig.Set(args...);
630}
631
632} // namespace ns3
633
634#endif /* WIFI_HELPER_H */
double f(double x, void *params)
Definition: 80211b.c:71
Base class providing common user-level ascii trace operations for helpers representing net devices.
Definition: trace-helper.h:728
Hold a value for an Attribute.
Definition: attribute.h:70
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.
Definition: trace-helper.h:623
DataLinkType
This enumeration holds the data link types that will be written to the pcap file.
Definition: trace-helper.h:51
Radiotap header implementation.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:325
virtual ~WifiHelper()
Definition: wifi-helper.cc:721
void SetRemoteStationManager(std::string type, Args &&... args)
Helper function used to set the station manager.
Definition: wifi-helper.h:590
void ConfigEhtOptions(Args &&... args)
Helper function used to configure the EHT options listed as attributes of the EhtConfiguration class.
Definition: wifi-helper.h:627
void SetObssPdAlgorithm(std::string type, Args &&... args)
Helper function used to set the OBSS-PD algorithm.
Definition: wifi-helper.h:598
void ConfigHtOptions(Args &&... args)
Helper function used to configure the HT options listed as attributes of the HtConfiguration class.
Definition: wifi-helper.h:606
ObjectFactory m_htConfig
HT configuration.
Definition: wifi-helper.h:508
void ConfigHeOptions(Args &&... args)
Helper function used to configure the HE options listed as attributes of the HeConfiguration class.
Definition: wifi-helper.h:620
ObjectFactory m_obssPdAlgorithm
OBSS_PD algorithm.
Definition: wifi-helper.h:513
ObjectFactory m_ehtConfig
EHT configuration.
Definition: wifi-helper.h:511
void ConfigVhtOptions(Args &&... args)
Helper function used to configure the VHT options listed as attributes of the VhtConfiguration class.
Definition: wifi-helper.h:613
ObjectFactory m_vhtConfig
VHT configuration.
Definition: wifi-helper.h:509
ObjectFactory m_stationManager
station manager
Definition: wifi-helper.h:506
void SetSelectQueueCallback(SelectQueueCallback f)
Definition: wifi-helper.cc:750
WifiStandard m_standard
wifi standard
Definition: wifi-helper.h:507
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 ...
Definition: wifi-helper.cc:971
virtual void SetStandard(WifiStandard standard)
Definition: wifi-helper.cc:738
ObjectFactory m_heConfig
HE configuration.
Definition: wifi-helper.h:510
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Definition: wifi-helper.cc:756
void DisableFlowControl()
Disable flow control only if you know what you are doing.
Definition: wifi-helper.cc:744
SelectQueueCallback m_selectQueueCallback
select queue callback
Definition: wifi-helper.h:512
static void EnableLogComponents()
Helper to enable all WifiNetDevice log components with one statement.
Definition: wifi-helper.cc:870
bool m_enableFlowControl
whether to enable flow control
Definition: wifi-helper.h:514
WifiHelper()
Create a Wifi helper in an empty state: all its parameters must be set before calling ns3::WifiHelper...
Definition: wifi-helper.cc:725
std::function< std::size_t(Ptr< QueueItem >)> SelectQueueCallback
Callback invoked to determine the MAC queue selected for a given packet.
Definition: wifi-helper.h:360
create MAC layers for a ns3::WifiNetDevice.
create PHY objects
Definition: wifi-helper.h:50
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
Definition: wifi-helper.cc:543
void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ASCII trace output on the indicated net device.
Definition: wifi-helper.cc:624
WifiPhyHelper(uint8_t nLinks=1)
Constructor.
Definition: wifi-helper.cc:146
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:163
~WifiPhyHelper() override
Definition: wifi-helper.cc:158
void DisablePreambleDetectionModel()
Disable the preamble detection model on all links.
Definition: wifi-helper.cc:178
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
Definition: wifi-helper.h:536
void SetInterferenceHelper(std::string type, Args &&... args)
Helper function used to set the interference helper.
Definition: wifi-helper.h:528
void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output the indicated net device.
Definition: wifi-helper.cc:568
PcapHelper::DataLinkType m_pcapDlt
PCAP data link type.
Definition: wifi-helper.h:314
std::vector< ObjectFactory > m_frameCaptureModel
frame capture model
Definition: wifi-helper.h:242
std::vector< ObjectFactory > m_preambleDetectionModel
preamble detection model
Definition: wifi-helper.h:243
PcapHelper::DataLinkType GetPcapDataLinkType() const
Get the data link type of PCAP traces to be used.
Definition: wifi-helper.cc:562
static void PcapSniffRxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId=SU_STA_ID)
Definition: wifi-helper.cc:218
void SetFrameCaptureModel(std::string type, Args &&... args)
Helper function used to set the frame capture model.
Definition: wifi-helper.h:554
std::vector< ObjectFactory > m_phy
PHY object.
Definition: wifi-helper.h:239
void SetPreambleDetectionModel(std::string type, Args &&... args)
Helper function used to set the preamble detection model.
Definition: wifi-helper.h:572
static void PcapSniffTxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, uint16_t staId=SU_STA_ID)
Definition: wifi-helper.cc:187
SupportedPcapDataLinkTypes
An enumeration of the pcap data link types (DLTs) which this helper supports.
Definition: wifi-helper.h:174
@ DLT_IEEE802_11
IEEE 802.11 Wireless LAN headers on packets.
Definition: wifi-helper.h:175
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
Definition: wifi-helper.h:179
@ DLT_PRISM_HEADER
Include Prism monitor mode information.
Definition: wifi-helper.h:177
std::vector< ObjectFactory > m_errorRateModel
error rate model
Definition: wifi-helper.h:241
virtual std::vector< Ptr< WifiPhy > > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const =0
ObjectFactory m_interferenceHelper
interference helper
Definition: wifi-helper.h:240
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.
Definition: wifi-helper.cc:264
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.
mac
Definition: third.py:85
phy
Definition: third.py:82
MpduInfo structure.
Definition: phy-entity.h:63
SignalNoiseDbm structure.
Definition: phy-entity.h:56
#define SU_STA_ID
Definition: wifi-mode.h:34