A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
34namespace ns3
35{
36
37NS_LOG_COMPONENT_DEFINE("YansWifiHelper");
38
40{
41}
42
45{
47 helper.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
48 helper.AddPropagationLoss("ns3::LogDistancePropagationLossModel");
49 return helper;
50}
51
54{
55 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel>();
57 for (auto i = m_propagationLoss.begin(); i != m_propagationLoss.end(); ++i)
58 {
60 if (prev)
61 {
62 prev->SetNext(cur);
63 }
64 if (m_propagationLoss.begin() == i)
65 {
66 channel->SetPropagationLossModel(cur);
67 }
68 prev = cur;
69 }
71 channel->SetPropagationDelayModel(delay);
72 return channel;
73}
74
75int64_t
77{
78 return c->AssignStreams(stream);
79}
80
82 : WifiPhyHelper(1), // YANS phy is not used for 11be devices
83 m_channel(nullptr)
84{
85 m_phys.front().SetTypeId("ns3::YansWifiPhy");
86 SetInterferenceHelper("ns3::InterferenceHelper");
87 SetErrorRateModel("ns3::TableBasedErrorRateModel");
88}
89
90void
92{
93 m_channel = channel;
94}
95
96void
97YansWifiPhyHelper::SetChannel(std::string channelName)
98{
99 Ptr<YansWifiChannel> channel = Names::Find<YansWifiChannel>(channelName);
100 m_channel = channel;
101}
102
103std::vector<Ptr<WifiPhy>>
105{
106 Ptr<YansWifiPhy> phy = m_phys.front().Create<YansWifiPhy>();
108 phy->SetInterferenceHelper(interference);
109 Ptr<ErrorRateModel> error = m_errorRateModel.front().Create<ErrorRateModel>();
110 phy->SetErrorRateModel(error);
111 if (m_frameCaptureModel.front().IsTypeIdSet())
112 {
113 auto frameCapture = m_frameCaptureModel.front().Create<FrameCaptureModel>();
114 phy->SetFrameCaptureModel(frameCapture);
115 }
116 if (m_preambleDetectionModel.front().IsTypeIdSet())
117 {
118 auto preambleDetection = m_preambleDetectionModel.front().Create<PreambleDetectionModel>();
119 phy->SetPreambleDetectionModel(preambleDetection);
120 }
121 phy->SetChannel(m_channel);
122 phy->SetDevice(device);
123 return std::vector<Ptr<WifiPhy>>({phy});
124}
125
126} // 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:77
create PHY objects
Definition: wifi-helper.h:49
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:241
std::vector< ObjectFactory > m_preambleDetectionModel
preamble detection model
Definition: wifi-helper.h:242
std::vector< ObjectFactory > m_phys
PHY objects.
Definition: wifi-helper.h:238
std::vector< ObjectFactory > m_errorRateModel
error rate model
Definition: wifi-helper.h:240
ObjectFactory m_interferenceHelper
interference helper
Definition: wifi-helper.h:239
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.
uint32_t prev