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/error-rate-model.h"
27 #include "ns3/frame-capture-model.h"
28 #include "ns3/preamble-detection-model.h"
29 #include "ns3/yans-wifi-phy.h"
30 #include "ns3/wifi-net-device.h"
31 #include "yans-wifi-helper.h"
32 
33 namespace ns3 {
34 
35 NS_LOG_COMPONENT_DEFINE ("YansWifiHelper");
36 
38 {
39 }
40 
43 {
44  YansWifiChannelHelper helper;
45  helper.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
46  helper.AddPropagationLoss ("ns3::LogDistancePropagationLossModel");
47  return helper;
48 }
49 
50 void
52  std::string n0, const AttributeValue &v0,
53  std::string n1, const AttributeValue &v1,
54  std::string n2, const AttributeValue &v2,
55  std::string n3, const AttributeValue &v3,
56  std::string n4, const AttributeValue &v4,
57  std::string n5, const AttributeValue &v5,
58  std::string n6, const AttributeValue &v6,
59  std::string n7, const AttributeValue &v7)
60 {
61  ObjectFactory factory;
62  factory.SetTypeId (type);
63  factory.Set (n0, v0);
64  factory.Set (n1, v1);
65  factory.Set (n2, v2);
66  factory.Set (n3, v3);
67  factory.Set (n4, v4);
68  factory.Set (n5, v5);
69  factory.Set (n6, v6);
70  factory.Set (n7, v7);
71  m_propagationLoss.push_back (factory);
72 }
73 
74 void
76  std::string n0, const AttributeValue &v0,
77  std::string n1, const AttributeValue &v1,
78  std::string n2, const AttributeValue &v2,
79  std::string n3, const AttributeValue &v3,
80  std::string n4, const AttributeValue &v4,
81  std::string n5, const AttributeValue &v5,
82  std::string n6, const AttributeValue &v6,
83  std::string n7, const AttributeValue &v7)
84 {
85  ObjectFactory factory;
86  factory.SetTypeId (type);
87  factory.Set (n0, v0);
88  factory.Set (n1, v1);
89  factory.Set (n2, v2);
90  factory.Set (n3, v3);
91  factory.Set (n4, v4);
92  factory.Set (n5, v5);
93  factory.Set (n6, v6);
94  factory.Set (n7, v7);
95  m_propagationDelay = factory;
96 }
97 
100 {
101  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
103  for (std::vector<ObjectFactory>::const_iterator i = m_propagationLoss.begin (); i != m_propagationLoss.end (); ++i)
104  {
105  Ptr<PropagationLossModel> cur = (*i).Create<PropagationLossModel> ();
106  if (prev != 0)
107  {
108  prev->SetNext (cur);
109  }
110  if (m_propagationLoss.begin () == i)
111  {
112  channel->SetPropagationLossModel (cur);
113  }
114  prev = cur;
115  }
117  channel->SetPropagationDelayModel (delay);
118  return channel;
119 }
120 
121 int64_t
123 {
124  return c->AssignStreams (stream);
125 }
126 
128  : m_channel (0)
129 {
130  m_phy.SetTypeId ("ns3::YansWifiPhy");
131  SetErrorRateModel ("ns3::TableBasedErrorRateModel");
132 }
133 
134 void
136 {
137  m_channel = channel;
138 }
139 
140 void
141 YansWifiPhyHelper::SetChannel (std::string channelName)
142 {
143  Ptr<YansWifiChannel> channel = Names::Find<YansWifiChannel> (channelName);
144  m_channel = channel;
145 }
146 
149 {
152  phy->SetErrorRateModel (error);
154  {
155  auto frameCapture = m_frameCaptureModel.Create<FrameCaptureModel> ();
156  phy->SetFrameCaptureModel (frameCapture);
157  }
159  {
160  auto preambleDetection = m_preambleDetectionModel.Create<PreambleDetectionModel> ();
161  phy->SetPreambleDetectionModel (preambleDetection);
162  }
163  phy->SetChannel (m_channel);
164  phy->SetDevice (device);
165  return phy;
166 }
167 
168 } //namespace ns3
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::YansWifiChannelHelper::Default
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
Definition: yans-wifi-helper.cc:42
ns3::YansWifiChannelHelper::SetPropagationDelay
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())
Definition: yans-wifi-helper.cc:75
ns3::YansWifiChannelHelper::AssignStreams
int64_t AssignStreams(Ptr< YansWifiChannel > c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the channel.
Definition: yans-wifi-helper.cc:122
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::YansWifiPhyHelper::YansWifiPhyHelper
YansWifiPhyHelper()
Create a PHY helper.
Definition: yans-wifi-helper.cc:127
ns3::PropagationDelayModel
calculate a propagation delay.
Definition: propagation-delay-model.h:38
ns3::AttributeValue
Hold a value for an Attribute.
Definition: attribute.h:69
third.channel
channel
Definition: third.py:92
ns3::WifiPhyHelper::m_errorRateModel
ObjectFactory m_errorRateModel
error rate model
Definition: wifi-helper.h:237
ns3::PropagationLossModel
Models the propagation loss through a transmission medium.
Definition: propagation-loss-model.h:50
ns3::YansWifiChannelHelper::AddPropagationLoss
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())
Definition: yans-wifi-helper.cc:51
ns3::WifiPhyHelper::m_preambleDetectionModel
ObjectFactory m_preambleDetectionModel
preamble detection model
Definition: wifi-helper.h:239
ns3::ObjectFactory::IsTypeIdSet
bool IsTypeIdSet(void) const
Check if the ObjectFactory has been configured with a TypeId.
Definition: object-factory.cc:58
ns3::WifiPhyHelper::SetErrorRateModel
void SetErrorRateModel(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())
Definition: wifi-helper.cc:146
ns3::YansWifiPhyHelper::SetChannel
void SetChannel(Ptr< YansWifiChannel > channel)
Definition: yans-wifi-helper.cc:135
ns3::PreambleDetectionModel
the interface for Wifi's preamble detection models
Definition: preamble-detection-model.h:34
ns3::YansWifiPhyHelper::Create
Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const override
Definition: yans-wifi-helper.cc:148
yans-wifi-helper.h
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
prev
uint32_t prev
Definition: tcp-bbr-example.cc:67
ns3::YansWifiChannelHelper::Create
Ptr< YansWifiChannel > Create(void) const
Definition: yans-wifi-helper.cc:99
ns3::FrameCaptureModel
the interface for Wifi's frame capture models
Definition: frame-capture-model.h:37
ns3::WifiPhyHelper::m_frameCaptureModel
ObjectFactory m_frameCaptureModel
frame capture model
Definition: wifi-helper.h:238
ns3::YansWifiPhyHelper::m_channel
Ptr< YansWifiChannel > m_channel
YANS wifi channel.
Definition: yans-wifi-helper.h:191
ns3::ObjectFactory
Instantiate subclasses of ns3::Object.
Definition: object-factory.h:48
ns3::ErrorRateModel
the interface for Wifi's error models
Definition: error-rate-model.h:35
ns3::YansWifiChannelHelper::m_propagationDelay
ObjectFactory m_propagationDelay
propagation delay model
Definition: yans-wifi-helper.h:146
ns3::WifiPhyHelper::m_phy
ObjectFactory m_phy
PHY object.
Definition: wifi-helper.h:236
ns3::YansWifiChannelHelper::m_propagationLoss
std::vector< ObjectFactory > m_propagationLoss
vector of propagation loss models
Definition: yans-wifi-helper.h:145
ns3::ObjectFactory::Set
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Definition: object-factory.h:223
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition: object-factory.cc:40
ns3::YansWifiPhy
802.11 PHY layer model
Definition: yans-wifi-phy.h:48
ns3::YansWifiChannelHelper
manage and create wifi channel objects for the YANS model.
Definition: yans-wifi-helper.h:37
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Definition: object-factory.cc:98
ns3::YansWifiChannelHelper::YansWifiChannelHelper
YansWifiChannelHelper()
Create a channel helper without any parameter set.
Definition: yans-wifi-helper.cc:37
third.phy
phy
Definition: third.py:93