A Discrete-Event Network Simulator
API
wifi-helper.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #ifndef WIFI_HELPER_H
24 #define WIFI_HELPER_H
25 
26 #include "ns3/trace-helper.h"
27 #include "ns3/wifi-phy.h"
28 #include "ns3/qos-utils.h"
29 #include "ns3/deprecated.h"
30 #include "wifi-mac-helper.h"
31 #include <functional>
32 
33 namespace ns3 {
34 
35 class WifiNetDevice;
36 class Node;
37 class RadiotapHeader;
38 class QueueItem;
39 
48 {
49 public:
50  WifiPhyHelper ();
51  virtual ~WifiPhyHelper ();
52 
62  virtual Ptr<WifiPhy> Create (Ptr<Node> node, Ptr<WifiNetDevice> device) const = 0;
63 
70  void Set (std::string name, const AttributeValue &v);
71 
79  template <typename... Args>
80  void SetInterferenceHelper (std::string type, Args&&... args);
81 
89  template <typename... Args>
90  void SetErrorRateModel (std::string type, Args&&... args);
91 
99  template <typename... Args>
100  void SetFrameCaptureModel (std::string type, Args&&... args);
101 
109  template <typename... Args>
110  void SetPreambleDetectionModel (std::string type, Args&&... args);
111 
116 
123  {
127  };
128 
139 
148 
149 
150 protected:
162  Ptr<const Packet> packet,
163  uint16_t channelFreqMhz,
164  WifiTxVector txVector,
165  MpduInfo aMpdu,
166  uint16_t staId = SU_STA_ID);
179  Ptr<const Packet> packet,
180  uint16_t channelFreqMhz,
181  WifiTxVector txVector,
182  MpduInfo aMpdu,
183  SignalNoiseDbm signalNoise,
184  uint16_t staId = SU_STA_ID);
185 
191 
192 
193 private:
204  static void GetRadiotapHeader (RadiotapHeader &header,
205  Ptr<Packet> packet,
206  uint16_t channelFreqMhz,
207  WifiTxVector txVector,
208  MpduInfo aMpdu,
209  uint16_t staId);
210 
222  static void GetRadiotapHeader (RadiotapHeader &header,
223  Ptr<Packet> packet,
224  uint16_t channelFreqMhz,
225  WifiTxVector txVector,
226  MpduInfo aMpdu,
227  uint16_t staId,
228  SignalNoiseDbm signalNoise);
229 
241  virtual void EnablePcapInternal (std::string prefix,
242  Ptr<NetDevice> nd,
243  bool promiscuous,
244  bool explicitFilename) override;
245 
257  virtual void EnableAsciiInternal (Ptr<OutputStreamWrapper> stream,
258  std::string prefix,
259  Ptr<NetDevice> nd,
260  bool explicitFilename) override;
261 
263 };
264 
265 
274 {
275 public:
276  virtual ~WifiHelper ();
277 
286  WifiHelper ();
287 
295  template <typename... Args>
296  void SetRemoteStationManager (std::string type, Args&&... args);
297 
305  template <typename... Args>
306  void SetObssPdAlgorithm (std::string type, Args&&... args);
307 
309  typedef std::function<std::size_t (Ptr<QueueItem>)> SelectQueueCallback;
310 
318 
327  void DisableFlowControl (void);
328 
337  virtual Install (const WifiPhyHelper &phy,
338  const WifiMacHelper &mac,
340  NodeContainer::Iterator last) const;
348  const WifiMacHelper &mac, NodeContainer c) const;
356  const WifiMacHelper &mac, Ptr<Node> node) const;
364  const WifiMacHelper &mac, std::string nodeName) const;
389  virtual void SetStandard (WifiStandard standard);
390 
394  static void EnableLogComponents (void);
395 
410  int64_t AssignStreams (NetDeviceContainer c, int64_t stream);
411 
412 
413 protected:
420 };
421 
422 } //namespace ns3
423 
424 /***************************************************************
425  * Implementation of the templates declared above.
426  ***************************************************************/
427 
428 namespace ns3 {
429 
430 template <typename... Args>
431 void
432 WifiPhyHelper::SetInterferenceHelper (std::string type, Args&&... args)
433 {
435  m_interferenceHelper.Set (args...);
436 }
437 
438 template <typename... Args>
439 void
440 WifiPhyHelper::SetErrorRateModel (std::string type, Args&&... args)
441 {
443  m_errorRateModel.Set (args...);
444 }
445 
446 template <typename... Args>
447 void
448 WifiPhyHelper::SetFrameCaptureModel (std::string type, Args&&... args)
449 {
451  m_frameCaptureModel.Set (args...);
452 }
453 
454 template <typename... Args>
455 void
456 WifiPhyHelper::SetPreambleDetectionModel (std::string type, Args&&... args)
457 {
459  m_preambleDetectionModel.Set (args...);
460 }
461 
462 template <typename... Args>
463 void
464 WifiHelper::SetRemoteStationManager (std::string type, Args&&... args)
465 {
467  m_stationManager.Set (args...);
468 }
469 
470 template <typename... Args>
471 void
472 WifiHelper::SetObssPdAlgorithm (std::string type, Args&&... args)
473 {
475  m_obssPdAlgorithm.Set (args...);
476 }
477 
478 } // namespace ns3
479 
480 #endif /* WIFI_HELPER_H */
double f(double x, void *params)
Definition: 80211b.c:70
Base class providing common user-level ascii trace operations for helpers representing net devices.
Definition: trace-helper.h:643
Hold a value for an Attribute.
Definition: attribute.h:69
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:554
DataLinkType
This enumeration holds the data link types that will be written to the pcap file.
Definition: trace-helper.h:50
Radiotap header implementation.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:274
virtual ~WifiHelper()
Definition: wifi-helper.cc:654
void SetRemoteStationManager(std::string type, Args &&... args)
Helper function used to set the station manager.
Definition: wifi-helper.h:464
void SetObssPdAlgorithm(std::string type, Args &&... args)
Helper function used to set the OBSS-PD algorithm.
Definition: wifi-helper.h:472
ObjectFactory m_ackPolicySelector[4]
ack policy selector for all ACs
Definition: wifi-helper.h:415
ObjectFactory m_obssPdAlgorithm
OBSS_PD algorithm.
Definition: wifi-helper.h:418
ObjectFactory m_stationManager
station manager
Definition: wifi-helper.h:414
void SetSelectQueueCallback(SelectQueueCallback f)
Definition: wifi-helper.cc:679
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
Definition: wifi-helper.cc:792
WifiStandard m_standard
wifi standard
Definition: wifi-helper.h:416
void DisableFlowControl(void)
Disable flow control only if you know what you are doing.
Definition: wifi-helper.cc:673
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:889
virtual void SetStandard(WifiStandard standard)
Definition: wifi-helper.cc:667
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Definition: wifi-helper.cc:685
SelectQueueCallback m_selectQueueCallback
select queue callback
Definition: wifi-helper.h:417
std::function< std::size_t(Ptr< QueueItem >)> SelectQueueCallback
Callback invoked to determine the MAC queue selected for a given packet.
Definition: wifi-helper.h:309
bool m_enableFlowControl
whether to enable flow control
Definition: wifi-helper.h:419
WifiHelper()
Create a Wifi helper in an empty state: all its parameters must be set before calling ns3::WifiHelper...
Definition: wifi-helper.cc:658
create MAC layers for a ns3::WifiNetDevice.
create PHY objects
Definition: wifi-helper.h:48
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
Definition: wifi-helper.cc:518
virtual 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:579
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:154
void DisablePreambleDetectionModel()
Disable the preamble detection model.
Definition: wifi-helper.cc:160
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
Definition: wifi-helper.h:440
void SetInterferenceHelper(std::string type, Args &&... args)
Helper function used to set the interference helper.
Definition: wifi-helper.h:432
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output the indicated net device.
Definition: wifi-helper.cc:543
PcapHelper::DataLinkType m_pcapDlt
PCAP data link type.
Definition: wifi-helper.h:262
ObjectFactory m_frameCaptureModel
frame capture model
Definition: wifi-helper.h:189
virtual ~WifiPhyHelper()
Definition: wifi-helper.cc:149
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:200
void SetFrameCaptureModel(std::string type, Args &&... args)
Helper function used to set the frame capture model.
Definition: wifi-helper.h:448
ObjectFactory m_preambleDetectionModel
preamble detection model
Definition: wifi-helper.h:190
ObjectFactory m_errorRateModel
error rate model
Definition: wifi-helper.h:188
void SetPreambleDetectionModel(std::string type, Args &&... args)
Helper function used to set the preamble detection model.
Definition: wifi-helper.h:456
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:166
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const =0
SupportedPcapDataLinkTypes
An enumeration of the pcap data link types (DLTs) which this helper supports.
Definition: wifi-helper.h:123
@ DLT_IEEE802_11
IEEE 802.11 Wireless LAN headers on packets.
Definition: wifi-helper.h:124
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
Definition: wifi-helper.h:126
@ DLT_PRISM_HEADER
Include Prism monitor mode information.
Definition: wifi-helper.h:125
ObjectFactory m_interferenceHelper
interference helper
Definition: wifi-helper.h:187
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:250
ObjectFactory m_phy
PHY object.
Definition: wifi-helper.h:186
PcapHelper::DataLinkType GetPcapDataLinkType(void) const
Get the data link type of PCAP traces to be used.
Definition: wifi-helper.cc:537
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:99
phy
Definition: third.py:93
MpduInfo structure.
Definition: phy-entity.h:60
SignalNoiseDbm structure.
Definition: phy-entity.h:53
#define SU_STA_ID
Definition: wifi-mode.h:32