A Discrete-Event Network Simulator
API
yans-wifi-helper.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  * Sébastien Deronne <sebastien.deronne@gmail.com>
19  */
20 
21 #include "yans-wifi-helper.h"
22 
23 #include "ns3/error-rate-model.h"
24 #include "ns3/frame-capture-model.h"
25 #include "ns3/interference-helper.h"
26 #include "ns3/log.h"
27 #include "ns3/names.h"
28 #include "ns3/preamble-detection-model.h"
29 #include "ns3/propagation-delay-model.h"
30 #include "ns3/propagation-loss-model.h"
31 #include "ns3/wifi-net-device.h"
32 #include "ns3/yans-wifi-phy.h"
33 
34 namespace ns3
35 {
36 
37 NS_LOG_COMPONENT_DEFINE("YansWifiHelper");
38 
40 {
41 }
42 
45 {
46  YansWifiChannelHelper helper;
47  helper.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
48  helper.AddPropagationLoss("ns3::LogDistancePropagationLossModel");
49  return helper;
50 }
51 
54 {
55  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel>();
57  for (std::vector<ObjectFactory>::const_iterator i = m_propagationLoss.begin();
58  i != m_propagationLoss.end();
59  ++i)
60  {
62  if (prev)
63  {
64  prev->SetNext(cur);
65  }
66  if (m_propagationLoss.begin() == i)
67  {
68  channel->SetPropagationLossModel(cur);
69  }
70  prev = cur;
71  }
73  channel->SetPropagationDelayModel(delay);
74  return channel;
75 }
76 
77 int64_t
79 {
80  return c->AssignStreams(stream);
81 }
82 
84  : WifiPhyHelper(1), // YANS phy is not used for 11be devices
85  m_channel(nullptr)
86 {
87  m_phy.at(0).SetTypeId("ns3::YansWifiPhy");
88  SetInterferenceHelper("ns3::InterferenceHelper");
89  SetErrorRateModel("ns3::TableBasedErrorRateModel");
90 }
91 
92 void
94 {
96 }
97 
98 void
99 YansWifiPhyHelper::SetChannel(std::string channelName)
100 {
101  Ptr<YansWifiChannel> channel = Names::Find<YansWifiChannel>(channelName);
102  m_channel = channel;
103 }
104 
105 std::vector<Ptr<WifiPhy>>
107 {
108  Ptr<YansWifiPhy> phy = m_phy.at(0).Create<YansWifiPhy>();
110  phy->SetInterferenceHelper(interference);
111  Ptr<ErrorRateModel> error = m_errorRateModel.at(0).Create<ErrorRateModel>();
112  phy->SetErrorRateModel(error);
113  if (m_frameCaptureModel.at(0).IsTypeIdSet())
114  {
115  auto frameCapture = m_frameCaptureModel.at(0).Create<FrameCaptureModel>();
116  phy->SetFrameCaptureModel(frameCapture);
117  }
118  if (m_preambleDetectionModel.at(0).IsTypeIdSet())
119  {
120  auto preambleDetection = m_preambleDetectionModel.at(0).Create<PreambleDetectionModel>();
121  phy->SetPreambleDetectionModel(preambleDetection);
122  }
123  phy->SetChannel(m_channel);
124  phy->SetDevice(device);
125  return std::vector<Ptr<WifiPhy>>({phy});
126 }
127 
128 } // namespace ns3
the interface for Wifi's error models
the interface for Wifi's frame capture models
handles interference calculations
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
the interface for Wifi's preamble detection models
calculate a propagation delay.
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
create PHY objects
Definition: wifi-helper.h:50
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
Definition: wifi-helper.h:551
void SetInterferenceHelper(std::string type, Args &&... args)
Helper function used to set the interference helper.
Definition: wifi-helper.h:543
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
std::vector< ObjectFactory > m_phy
PHY object.
Definition: wifi-helper.h:239
std::vector< ObjectFactory > m_errorRateModel
error rate model
Definition: wifi-helper.h:241
ObjectFactory m_interferenceHelper
interference helper
Definition: wifi-helper.h:240
manage and create wifi channel objects for the YANS model.
ObjectFactory m_propagationDelay
propagation delay model
int64_t AssignStreams(Ptr< YansWifiChannel > c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the channel.
YansWifiChannelHelper()
Create a channel helper without any parameter set.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
void SetPropagationDelay(std::string name, Ts &&... args)
void AddPropagationLoss(std::string name, Ts &&... args)
Ptr< YansWifiChannel > Create() const
std::vector< ObjectFactory > m_propagationLoss
vector of propagation loss models
Ptr< YansWifiChannel > m_channel
YANS wifi channel.
YansWifiPhyHelper()
Create a PHY helper.
std::vector< Ptr< WifiPhy > > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const override
void SetChannel(Ptr< YansWifiChannel > channel)
802.11 PHY layer model
Definition: yans-wifi-phy.h:48
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:81
phy
Definition: third.py:82
uint32_t prev