A Discrete-Event Network Simulator
API
yans-wifi-helper.cc
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 *
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 * S├ębastien Deronne <sebastien.deronne@gmail.com>
20 */
21
22#include "ns3/log.h"
23#include "ns3/names.h"
24#include "ns3/propagation-loss-model.h"
25#include "ns3/propagation-delay-model.h"
26#include "ns3/interference-helper.h"
27#include "ns3/error-rate-model.h"
28#include "ns3/frame-capture-model.h"
29#include "ns3/preamble-detection-model.h"
30#include "ns3/yans-wifi-phy.h"
31#include "ns3/wifi-net-device.h"
32#include "yans-wifi-helper.h"
33
34namespace ns3 {
35
36NS_LOG_COMPONENT_DEFINE ("YansWifiHelper");
37
39{
40}
41
44{
46 helper.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
47 helper.AddPropagationLoss ("ns3::LogDistancePropagationLossModel");
48 return helper;
49}
50
51void
53 std::string n0, const AttributeValue &v0,
54 std::string n1, const AttributeValue &v1,
55 std::string n2, const AttributeValue &v2,
56 std::string n3, const AttributeValue &v3,
57 std::string n4, const AttributeValue &v4,
58 std::string n5, const AttributeValue &v5,
59 std::string n6, const AttributeValue &v6,
60 std::string n7, const AttributeValue &v7)
61{
62 ObjectFactory factory;
63 factory.SetTypeId (type);
64 factory.Set (n0, v0);
65 factory.Set (n1, v1);
66 factory.Set (n2, v2);
67 factory.Set (n3, v3);
68 factory.Set (n4, v4);
69 factory.Set (n5, v5);
70 factory.Set (n6, v6);
71 factory.Set (n7, v7);
72 m_propagationLoss.push_back (factory);
73}
74
75void
77 std::string n0, const AttributeValue &v0,
78 std::string n1, const AttributeValue &v1,
79 std::string n2, const AttributeValue &v2,
80 std::string n3, const AttributeValue &v3,
81 std::string n4, const AttributeValue &v4,
82 std::string n5, const AttributeValue &v5,
83 std::string n6, const AttributeValue &v6,
84 std::string n7, const AttributeValue &v7)
85{
86 ObjectFactory factory;
87 factory.SetTypeId (type);
88 factory.Set (n0, v0);
89 factory.Set (n1, v1);
90 factory.Set (n2, v2);
91 factory.Set (n3, v3);
92 factory.Set (n4, v4);
93 factory.Set (n5, v5);
94 factory.Set (n6, v6);
95 factory.Set (n7, v7);
96 m_propagationDelay = factory;
97}
98
101{
102 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
104 for (std::vector<ObjectFactory>::const_iterator i = m_propagationLoss.begin (); i != m_propagationLoss.end (); ++i)
105 {
107 if (prev != 0)
108 {
109 prev->SetNext (cur);
110 }
111 if (m_propagationLoss.begin () == i)
112 {
113 channel->SetPropagationLossModel (cur);
114 }
115 prev = cur;
116 }
118 channel->SetPropagationDelayModel (delay);
119 return channel;
120}
121
122int64_t
124{
125 return c->AssignStreams (stream);
126}
127
129 : WifiPhyHelper (1), // YANS phy is not used for 11be devices
130 m_channel (0)
131{
132 m_phy.at (0).SetTypeId ("ns3::YansWifiPhy");
133 SetInterferenceHelper ("ns3::InterferenceHelper");
134 SetErrorRateModel ("ns3::TableBasedErrorRateModel");
135}
136
137void
139{
141}
142
143void
144YansWifiPhyHelper::SetChannel (std::string channelName)
145{
146 Ptr<YansWifiChannel> channel = Names::Find<YansWifiChannel> (channelName);
148}
149
150std::vector<Ptr<WifiPhy>>
152{
153 Ptr<YansWifiPhy> phy = m_phy.at (0).Create<YansWifiPhy> ();
155 phy->SetInterferenceHelper (interference);
156 Ptr<ErrorRateModel> error = m_errorRateModel.at (0).Create<ErrorRateModel> ();
157 phy->SetErrorRateModel (error);
158 if (m_frameCaptureModel.at (0).IsTypeIdSet ())
159 {
160 auto frameCapture = m_frameCaptureModel.at (0).Create<FrameCaptureModel> ();
161 phy->SetFrameCaptureModel (frameCapture);
162 }
163 if (m_preambleDetectionModel.at (0).IsTypeIdSet ())
164 {
165 auto preambleDetection = m_preambleDetectionModel.at (0).Create<PreambleDetectionModel> ();
166 phy->SetPreambleDetectionModel (preambleDetection);
167 }
168 phy->SetChannel (m_channel);
169 phy->SetDevice (device);
170 return std::vector<Ptr<WifiPhy>> ({phy});
171}
172
173} //namespace ns3
Hold a value for an Attribute.
Definition: attribute.h:69
the interface for Wifi's error models
the interface for Wifi's frame capture models
handles interference calculations
Instantiate subclasses of ns3::Object.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
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:74
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:531
void SetInterferenceHelper(std::string type, Args &&... args)
Helper function used to set the interference helper.
Definition: wifi-helper.h:523
std::vector< ObjectFactory > m_frameCaptureModel
frame capture model
Definition: wifi-helper.h:237
std::vector< ObjectFactory > m_preambleDetectionModel
preamble detection model
Definition: wifi-helper.h:238
std::vector< ObjectFactory > m_phy
PHY object.
Definition: wifi-helper.h:234
std::vector< ObjectFactory > m_errorRateModel
error rate model
Definition: wifi-helper.h:236
ObjectFactory m_interferenceHelper
interference helper
Definition: wifi-helper.h:235
manage and create wifi channel objects for the YANS model.
ObjectFactory m_propagationDelay
propagation delay model
void SetPropagationDelay(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Ptr< YansWifiChannel > Create(void) const
void AddPropagationLoss(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
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.
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:205
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:83
phy
Definition: third.py:84
uint32_t prev