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/yans-wifi-phy.h"
28 #include "yans-wifi-helper.h"
29 
30 namespace ns3 {
31 
32 NS_LOG_COMPONENT_DEFINE ("YansWifiHelper");
33 
35 {
36 }
37 
40 {
41  YansWifiChannelHelper helper;
42  helper.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
43  helper.AddPropagationLoss ("ns3::LogDistancePropagationLossModel");
44  return helper;
45 }
46 
47 void
49  std::string n0, const AttributeValue &v0,
50  std::string n1, const AttributeValue &v1,
51  std::string n2, const AttributeValue &v2,
52  std::string n3, const AttributeValue &v3,
53  std::string n4, const AttributeValue &v4,
54  std::string n5, const AttributeValue &v5,
55  std::string n6, const AttributeValue &v6,
56  std::string n7, const AttributeValue &v7)
57 {
58  ObjectFactory factory;
59  factory.SetTypeId (type);
60  factory.Set (n0, v0);
61  factory.Set (n1, v1);
62  factory.Set (n2, v2);
63  factory.Set (n3, v3);
64  factory.Set (n4, v4);
65  factory.Set (n5, v5);
66  factory.Set (n6, v6);
67  factory.Set (n7, v7);
68  m_propagationLoss.push_back (factory);
69 }
70 
71 void
73  std::string n0, const AttributeValue &v0,
74  std::string n1, const AttributeValue &v1,
75  std::string n2, const AttributeValue &v2,
76  std::string n3, const AttributeValue &v3,
77  std::string n4, const AttributeValue &v4,
78  std::string n5, const AttributeValue &v5,
79  std::string n6, const AttributeValue &v6,
80  std::string n7, const AttributeValue &v7)
81 {
82  ObjectFactory factory;
83  factory.SetTypeId (type);
84  factory.Set (n0, v0);
85  factory.Set (n1, v1);
86  factory.Set (n2, v2);
87  factory.Set (n3, v3);
88  factory.Set (n4, v4);
89  factory.Set (n5, v5);
90  factory.Set (n6, v6);
91  factory.Set (n7, v7);
92  m_propagationDelay = factory;
93 }
94 
97 {
98  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
100  for (std::vector<ObjectFactory>::const_iterator i = m_propagationLoss.begin (); i != m_propagationLoss.end (); ++i)
101  {
102  Ptr<PropagationLossModel> cur = (*i).Create<PropagationLossModel> ();
103  if (prev != 0)
104  {
105  prev->SetNext (cur);
106  }
107  if (m_propagationLoss.begin () == i)
108  {
109  channel->SetPropagationLossModel (cur);
110  }
111  prev = cur;
112  }
114  channel->SetPropagationDelayModel (delay);
115  return channel;
116 }
117 
118 int64_t
120 {
121  return c->AssignStreams (stream);
122 }
123 
125  : m_channel (0)
126 {
127  m_phy.SetTypeId ("ns3::YansWifiPhy");
128 }
129 
132 {
133  YansWifiPhyHelper helper;
134  helper.SetErrorRateModel ("ns3::NistErrorRateModel");
135  return helper;
136 }
137 
138 void
140 {
141  m_channel = channel;
142 }
143 
144 void
145 YansWifiPhyHelper::SetChannel (std::string channelName)
146 {
147  Ptr<YansWifiChannel> channel = Names::Find<YansWifiChannel> (channelName);
148  m_channel = channel;
149 }
150 
153 {
156  phy->SetErrorRateModel (error);
157  phy->SetChannel (m_channel);
158  phy->SetDevice (device);
159  return phy;
160 }
161 
162 } //namespace ns3
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())
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
void SetNext(Ptr< PropagationLossModel > next)
Enables a chain of loss models to act on the signal.
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
Hold a value for an Attribute.
Definition: attribute.h:68
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
ObjectFactory m_errorRateModel
error rate model
Definition: wifi-helper.h:168
YansWifiChannelHelper()
Create a channel helper without any parameter set.
the interface for Wifi&#39;s error models
Ptr< YansWifiChannel > Create(void) const
channel
Definition: third.py:85
phy
Definition: third.py:86
void SetChannel(Ptr< YansWifiChannel > channel)
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
calculate a propagation delay.
YansWifiPhyHelper()
Create a phy helper without any parameter set.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:47
Ptr< YansWifiChannel > m_channel
yans wifi channel
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
manage and create wifi channel objects for the yans model.
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:140
ObjectFactory m_propagationDelay
propagation delay model
ObjectFactory m_phy
PHY object.
Definition: wifi-helper.h:167
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const
Instantiate subclasses of ns3::Object.
Models the propagation loss through a transmission medium.
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())
std::vector< ObjectFactory > m_propagationLoss
vector of propagation loss models
int64_t AssignStreams(Ptr< YansWifiChannel > c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the channel.