A Discrete-Event Network Simulator
API
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  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #include "wifi-helper.h"
24 #include "ns3/wifi-net-device.h"
25 #include "ns3/wifi-mac.h"
26 #include "ns3/regular-wifi-mac.h"
27 #include "ns3/dca-txop.h"
28 #include "ns3/edca-txop-n.h"
29 #include "ns3/minstrel-wifi-manager.h"
30 #include "ns3/ap-wifi-mac.h"
31 #include "ns3/wifi-phy.h"
32 #include "ns3/wifi-remote-station-manager.h"
33 #include "ns3/wifi-channel.h"
34 #include "ns3/yans-wifi-channel.h"
35 #include "ns3/propagation-delay-model.h"
36 #include "ns3/propagation-loss-model.h"
37 #include "ns3/mobility-model.h"
38 #include "ns3/log.h"
39 #include "ns3/config.h"
40 #include "ns3/pointer.h"
41 #include "ns3/simulator.h"
42 #include "ns3/names.h"
43 
44 namespace ns3 {
45 
46 NS_LOG_COMPONENT_DEFINE ("WifiHelper");
47 
49 {
50 }
51 
53 {
54 }
55 
57 {
58 }
59 
61  : m_standard (WIFI_PHY_STANDARD_80211a)
62 {
63 }
64 
67 {
68  WifiHelper helper;
69  helper.SetRemoteStationManager ("ns3::ArfWifiManager");
70  return helper;
71 }
72 
73 void
75  std::string n0, const AttributeValue &v0,
76  std::string n1, const AttributeValue &v1,
77  std::string n2, const AttributeValue &v2,
78  std::string n3, const AttributeValue &v3,
79  std::string n4, const AttributeValue &v4,
80  std::string n5, const AttributeValue &v5,
81  std::string n6, const AttributeValue &v6,
82  std::string n7, const AttributeValue &v7)
83 {
86  m_stationManager.Set (n0, v0);
87  m_stationManager.Set (n1, v1);
88  m_stationManager.Set (n2, v2);
89  m_stationManager.Set (n3, v3);
90  m_stationManager.Set (n4, v4);
91  m_stationManager.Set (n5, v5);
92  m_stationManager.Set (n6, v6);
93  m_stationManager.Set (n7, v7);
94 }
95 
96 void
98 {
99  m_standard = standard;
100 }
101 
104  const WifiMacHelper &macHelper, NodeContainer c) const
105 {
107  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
108  {
109  Ptr<Node> node = *i;
110  Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
112  Ptr<WifiMac> mac = macHelper.Create ();
113  Ptr<WifiPhy> phy = phyHelper.Create (node, device);
114  mac->SetAddress (Mac48Address::Allocate ());
117  device->SetMac (mac);
118  device->SetPhy (phy);
119  device->SetRemoteStationManager (manager);
120  node->AddDevice (device);
121  devices.Add (device);
122  NS_LOG_DEBUG ("node=" << node << ", mob=" << node->GetObject<MobilityModel> ());
123  }
124  return devices;
125 }
126 
129  const WifiMacHelper &mac, Ptr<Node> node) const
130 {
131  return Install (phy, mac, NodeContainer (node));
132 }
133 
136  const WifiMacHelper &mac, std::string nodeName) const
137 {
138  Ptr<Node> node = Names::Find<Node> (nodeName);
139  return Install (phy, mac, NodeContainer (node));
140 }
141 
142 void
144 {
145  LogComponentEnable ("Aarfcd", LOG_LEVEL_ALL);
146  LogComponentEnable ("AdhocWifiMac", LOG_LEVEL_ALL);
147  LogComponentEnable ("AmrrWifiRemoteStation", LOG_LEVEL_ALL);
148  LogComponentEnable ("ApWifiMac", LOG_LEVEL_ALL);
149  LogComponentEnable ("ArfWifiManager", LOG_LEVEL_ALL);
151  LogComponentEnable ("DcaTxop", LOG_LEVEL_ALL);
152  LogComponentEnable ("DcfManager", LOG_LEVEL_ALL);
153  LogComponentEnable ("DsssErrorRateModel", LOG_LEVEL_ALL);
154  LogComponentEnable ("EdcaTxopN", LOG_LEVEL_ALL);
155  LogComponentEnable ("InterferenceHelper", LOG_LEVEL_ALL);
157  LogComponentEnable ("MacLow", LOG_LEVEL_ALL);
158  LogComponentEnable ("MacRxMiddle", LOG_LEVEL_ALL);
159  LogComponentEnable ("MsduAggregator", LOG_LEVEL_ALL);
160  LogComponentEnable ("MsduStandardAggregator", LOG_LEVEL_ALL);
161  LogComponentEnable ("NistErrorRateModel", LOG_LEVEL_ALL);
162  LogComponentEnable ("OnoeWifiRemoteStation", LOG_LEVEL_ALL);
163  LogComponentEnable ("PropagationLossModel", LOG_LEVEL_ALL);
164  LogComponentEnable ("RegularWifiMac", LOG_LEVEL_ALL);
165  LogComponentEnable ("RraaWifiManager", LOG_LEVEL_ALL);
166  LogComponentEnable ("StaWifiMac", LOG_LEVEL_ALL);
167  LogComponentEnable ("SupportedRates", LOG_LEVEL_ALL);
168  LogComponentEnable ("WifiChannel", LOG_LEVEL_ALL);
169  LogComponentEnable ("WifiPhyStateHelper", LOG_LEVEL_ALL);
170  LogComponentEnable ("WifiPhy", LOG_LEVEL_ALL);
171  LogComponentEnable ("WifiRemoteStationManager", LOG_LEVEL_ALL);
172  LogComponentEnable ("YansErrorRateModel", LOG_LEVEL_ALL);
173  LogComponentEnable ("YansWifiChannel", LOG_LEVEL_ALL);
174  LogComponentEnable ("YansWifiPhy", LOG_LEVEL_ALL);
175 }
176 
177 int64_t
179 {
180  int64_t currentStream = stream;
181  Ptr<NetDevice> netDevice;
182  for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i)
183  {
184  netDevice = (*i);
185  Ptr<WifiNetDevice> wifi = DynamicCast<WifiNetDevice> (netDevice);
186  if (wifi)
187  {
188  //Handle any random numbers in the PHY objects.
189  currentStream += wifi->GetPhy ()->AssignStreams (currentStream);
190 
191  //Handle any random numbers in the station managers.
192  Ptr<WifiRemoteStationManager> manager = wifi->GetRemoteStationManager ();
193  Ptr<MinstrelWifiManager> minstrel = DynamicCast<MinstrelWifiManager> (manager);
194  if (minstrel)
195  {
196  currentStream += minstrel->AssignStreams (currentStream);
197  }
198 
199  //Handle any random numbers in the MAC objects.
200  Ptr<WifiMac> mac = wifi->GetMac ();
201  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
202  if (rmac)
203  {
204  PointerValue ptr;
205  rmac->GetAttribute ("DcaTxop", ptr);
206  Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
207  currentStream += dcaTxop->AssignStreams (currentStream);
208 
209  rmac->GetAttribute ("VO_EdcaTxopN", ptr);
210  Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
211  currentStream += vo_edcaTxopN->AssignStreams (currentStream);
212 
213  rmac->GetAttribute ("VI_EdcaTxopN", ptr);
214  Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
215  currentStream += vi_edcaTxopN->AssignStreams (currentStream);
216 
217  rmac->GetAttribute ("BE_EdcaTxopN", ptr);
218  Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
219  currentStream += be_edcaTxopN->AssignStreams (currentStream);
220 
221  rmac->GetAttribute ("BK_EdcaTxopN", ptr);
222  Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
223  currentStream += bk_edcaTxopN->AssignStreams (currentStream);
224 
225  //if an AP, handle any beacon jitter
226  Ptr<ApWifiMac> apmac = DynamicCast<ApWifiMac> (rmac);
227  if (apmac)
228  {
229  currentStream += apmac->AssignStreams (currentStream);
230  }
231  }
232  }
233  }
234  return (currentStream - stream);
235 }
236 
237 } //namespace ns3
virtual ~WifiPhyHelper()
Definition: wifi-helper.cc:48
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Ptr< T > Get(void) const
Definition: pointer.h:194
tuple devices
Definition: first.py:32
virtual void ConfigureStandard(enum WifiPhyStandard standard)=0
Configure the PHY-level parameters for different Wi-Fi standard.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
void SetRemoteStationManager(std::string type, 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:74
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:455
virtual ~WifiHelper()
Definition: wifi-helper.cc:56
Hold a value for an Attribute.
Definition: attribute.h:68
create PHY objects
Definition: wifi-helper.h:47
virtual Ptr< WifiMac > Create(void) const =0
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:96
WifiHelper()
Create a Wifi helper in an empty state: all its parameters must be set before calling ns3::WifiHelper...
Definition: wifi-helper.cc:60
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wifi-helper.cc:103
Keep track of the current position and velocity of an object.
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:82
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:351
tuple phy
Definition: third.py:86
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:97
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the Phy and Mac aspects ...
Definition: wifi-helper.cc:178
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
tuple mac
Definition: third.py:92
hold a list of per-remote-station state.
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr.
Definition: pointer.h:36
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
ObjectFactory m_stationManager
Definition: wifi-helper.h:220
create MAC objects
Definition: wifi-helper.h:75
Instantiate subclasses of ns3::Object.
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
Definition: wifi-helper.cc:143
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const =0
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:121
virtual ~WifiMacHelper()
Definition: wifi-helper.cc:52
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
enum WifiPhyStandard m_standard
Definition: wifi-helper.h:221
Print everything.
Definition: log.h:112
tuple wifi
Definition: third.py:89
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
handle packet fragmentation and retransmissions.
Definition: dca-txop.h:67
static WifiHelper Default(void)
Definition: wifi-helper.cc:66