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  : m_standard (WIFI_PHY_STANDARD_80211a)
58 {
59  SetRemoteStationManager ("ns3::ArfWifiManager");
60 }
61 
64 {
65  WifiHelper helper;
66  helper.SetRemoteStationManager ("ns3::ArfWifiManager");
67  return helper;
68 }
69 
70 void
72  std::string n0, const AttributeValue &v0,
73  std::string n1, const AttributeValue &v1,
74  std::string n2, const AttributeValue &v2,
75  std::string n3, const AttributeValue &v3,
76  std::string n4, const AttributeValue &v4,
77  std::string n5, const AttributeValue &v5,
78  std::string n6, const AttributeValue &v6,
79  std::string n7, const AttributeValue &v7)
80 {
83  m_stationManager.Set (n0, v0);
84  m_stationManager.Set (n1, v1);
85  m_stationManager.Set (n2, v2);
86  m_stationManager.Set (n3, v3);
87  m_stationManager.Set (n4, v4);
88  m_stationManager.Set (n5, v5);
89  m_stationManager.Set (n6, v6);
90  m_stationManager.Set (n7, v7);
91 }
92 
93 void
95 {
96  m_standard = standard;
97 }
98 
101  const WifiMacHelper &macHelper, NodeContainer c) const
102 {
104  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
105  {
106  Ptr<Node> node = *i;
107  Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
109  Ptr<WifiMac> mac = macHelper.Create ();
110  Ptr<WifiPhy> phy = phyHelper.Create (node, device);
111  mac->SetAddress (Mac48Address::Allocate ());
114  device->SetMac (mac);
115  device->SetPhy (phy);
116  device->SetRemoteStationManager (manager);
117  node->AddDevice (device);
118  devices.Add (device);
119  NS_LOG_DEBUG ("node=" << node << ", mob=" << node->GetObject<MobilityModel> ());
120  }
121  return devices;
122 }
123 
126  const WifiMacHelper &mac, Ptr<Node> node) const
127 {
128  return Install (phy, mac, NodeContainer (node));
129 }
130 
133  const WifiMacHelper &mac, std::string nodeName) const
134 {
135  Ptr<Node> node = Names::Find<Node> (nodeName);
136  return Install (phy, mac, NodeContainer (node));
137 }
138 
139 void
141 {
142  LogComponentEnable ("Aarfcd", LOG_LEVEL_ALL);
143  LogComponentEnable ("AdhocWifiMac", LOG_LEVEL_ALL);
144  LogComponentEnable ("AmrrWifiRemoteStation", LOG_LEVEL_ALL);
145  LogComponentEnable ("ApWifiMac", LOG_LEVEL_ALL);
146  LogComponentEnable ("ArfWifiManager", LOG_LEVEL_ALL);
148  LogComponentEnable ("DcaTxop", LOG_LEVEL_ALL);
149  LogComponentEnable ("DcfManager", LOG_LEVEL_ALL);
150  LogComponentEnable ("DsssErrorRateModel", LOG_LEVEL_ALL);
151  LogComponentEnable ("EdcaTxopN", LOG_LEVEL_ALL);
152  LogComponentEnable ("InterferenceHelper", LOG_LEVEL_ALL);
154  LogComponentEnable ("MacLow", LOG_LEVEL_ALL);
155  LogComponentEnable ("MacRxMiddle", LOG_LEVEL_ALL);
156  LogComponentEnable ("MsduAggregator", LOG_LEVEL_ALL);
157  LogComponentEnable ("MsduStandardAggregator", LOG_LEVEL_ALL);
158  LogComponentEnable ("NistErrorRateModel", LOG_LEVEL_ALL);
159  LogComponentEnable ("OnoeWifiRemoteStation", LOG_LEVEL_ALL);
160  LogComponentEnable ("PropagationLossModel", LOG_LEVEL_ALL);
161  LogComponentEnable ("RegularWifiMac", LOG_LEVEL_ALL);
162  LogComponentEnable ("RraaWifiManager", LOG_LEVEL_ALL);
163  LogComponentEnable ("StaWifiMac", LOG_LEVEL_ALL);
164  LogComponentEnable ("SupportedRates", LOG_LEVEL_ALL);
165  LogComponentEnable ("WifiChannel", LOG_LEVEL_ALL);
166  LogComponentEnable ("WifiPhyStateHelper", LOG_LEVEL_ALL);
167  LogComponentEnable ("WifiPhy", LOG_LEVEL_ALL);
168  LogComponentEnable ("WifiRemoteStationManager", LOG_LEVEL_ALL);
169  LogComponentEnable ("YansErrorRateModel", LOG_LEVEL_ALL);
170  LogComponentEnable ("YansWifiChannel", LOG_LEVEL_ALL);
171  LogComponentEnable ("YansWifiPhy", LOG_LEVEL_ALL);
172 }
173 
174 int64_t
176 {
177  int64_t currentStream = stream;
178  Ptr<NetDevice> netDevice;
179  for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i)
180  {
181  netDevice = (*i);
182  Ptr<WifiNetDevice> wifi = DynamicCast<WifiNetDevice> (netDevice);
183  if (wifi)
184  {
185  //Handle any random numbers in the PHY objects.
186  currentStream += wifi->GetPhy ()->AssignStreams (currentStream);
187 
188  //Handle any random numbers in the station managers.
189  Ptr<WifiRemoteStationManager> manager = wifi->GetRemoteStationManager ();
190  Ptr<MinstrelWifiManager> minstrel = DynamicCast<MinstrelWifiManager> (manager);
191  if (minstrel)
192  {
193  currentStream += minstrel->AssignStreams (currentStream);
194  }
195 
196  //Handle any random numbers in the MAC objects.
197  Ptr<WifiMac> mac = wifi->GetMac ();
198  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
199  if (rmac)
200  {
201  PointerValue ptr;
202  rmac->GetAttribute ("DcaTxop", ptr);
203  Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
204  currentStream += dcaTxop->AssignStreams (currentStream);
205 
206  rmac->GetAttribute ("VO_EdcaTxopN", ptr);
207  Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
208  currentStream += vo_edcaTxopN->AssignStreams (currentStream);
209 
210  rmac->GetAttribute ("VI_EdcaTxopN", ptr);
211  Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
212  currentStream += vi_edcaTxopN->AssignStreams (currentStream);
213 
214  rmac->GetAttribute ("BE_EdcaTxopN", ptr);
215  Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
216  currentStream += be_edcaTxopN->AssignStreams (currentStream);
217 
218  rmac->GetAttribute ("BK_EdcaTxopN", ptr);
219  Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
220  currentStream += bk_edcaTxopN->AssignStreams (currentStream);
221 
222  //if an AP, handle any beacon jitter
223  Ptr<ApWifiMac> apmac = DynamicCast<ApWifiMac> (rmac);
224  if (apmac)
225  {
226  currentStream += apmac->AssignStreams (currentStream);
227  }
228  }
229  }
230  }
231  return (currentStream - stream);
232 }
233 
234 } //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:71
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:455
virtual ~WifiHelper()
Definition: wifi-helper.cc:52
Hold a value for an Attribute.
Definition: attribute.h:68
create PHY objects
Definition: wifi-helper.h:47
static WifiHelper Default(void) NS_DEPRECATED
Definition: wifi-helper.cc:63
#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:76
WifiHelper()
Create a Wifi helper in an empty state: all its parameters must be set before calling ns3::WifiHelper...
Definition: wifi-helper.cc:56
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wifi-helper.cc:100
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:85
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:94
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:175
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:207
create MAC layers for a ns3::WifiNetDevice.
virtual Ptr< WifiMac > Create(void) const
Instantiate subclasses of ns3::Object.
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
Definition: wifi-helper.cc:140
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:128
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:208
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