A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: Mirko Banchi <mk.banchi@gmail.com>
21  */
22 #include "wifi-helper.h"
23 #include "ns3/wifi-net-device.h"
24 #include "ns3/wifi-mac.h"
25 #include "ns3/regular-wifi-mac.h"
26 #include "ns3/dca-txop.h"
27 #include "ns3/edca-txop-n.h"
28 #include "ns3/minstrel-wifi-manager.h"
29 #include "ns3/ap-wifi-mac.h"
30 #include "ns3/wifi-phy.h"
31 #include "ns3/wifi-remote-station-manager.h"
32 #include "ns3/wifi-channel.h"
33 #include "ns3/yans-wifi-channel.h"
34 #include "ns3/propagation-delay-model.h"
35 #include "ns3/propagation-loss-model.h"
36 #include "ns3/mobility-model.h"
37 #include "ns3/log.h"
38 #include "ns3/config.h"
39 #include "ns3/pointer.h"
40 #include "ns3/simulator.h"
41 #include "ns3/names.h"
42 
43 NS_LOG_COMPONENT_DEFINE ("WifiHelper");
44 
45 namespace ns3 {
46 
48 {
49 }
50 
52 {
53 }
54 
56 {
57 }
58 
60  : m_standard (WIFI_PHY_STANDARD_80211a)
61 {
62 }
63 
66 {
67  WifiHelper helper;
68  helper.SetRemoteStationManager ("ns3::ArfWifiManager");
69  return helper;
70 }
71 
72 void
74  std::string n0, const AttributeValue &v0,
75  std::string n1, const AttributeValue &v1,
76  std::string n2, const AttributeValue &v2,
77  std::string n3, const AttributeValue &v3,
78  std::string n4, const AttributeValue &v4,
79  std::string n5, const AttributeValue &v5,
80  std::string n6, const AttributeValue &v6,
81  std::string n7, const AttributeValue &v7)
82 {
85  m_stationManager.Set (n0, v0);
86  m_stationManager.Set (n1, v1);
87  m_stationManager.Set (n2, v2);
88  m_stationManager.Set (n3, v3);
89  m_stationManager.Set (n4, v4);
90  m_stationManager.Set (n5, v5);
91  m_stationManager.Set (n6, v6);
92  m_stationManager.Set (n7, v7);
93 }
94 
95 void
97 {
98  m_standard = standard;
99 }
100 
103  const WifiMacHelper &macHelper, NodeContainer c) const
104 {
106  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
107  {
108  Ptr<Node> node = *i;
109  Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
111  Ptr<WifiMac> mac = macHelper.Create ();
112  Ptr<WifiPhy> phy = phyHelper.Create (node, device);
113  mac->SetAddress (Mac48Address::Allocate ());
116  device->SetMac (mac);
117  device->SetPhy (phy);
118  device->SetRemoteStationManager (manager);
119  node->AddDevice (device);
120  devices.Add (device);
121  NS_LOG_DEBUG ("node=" << node << ", mob=" << node->GetObject<MobilityModel> ());
122  }
123  return devices;
124 }
125 
128  const WifiMacHelper &mac, Ptr<Node> node) const
129 {
130  return Install (phy, mac, NodeContainer (node));
131 }
132 
135  const WifiMacHelper &mac, std::string nodeName) const
136 {
137  Ptr<Node> node = Names::Find<Node> (nodeName);
138  return Install (phy, mac, NodeContainer (node));
139 }
140 
141 void
143 {
144  LogComponentEnable ("Aarfcd", LOG_LEVEL_ALL);
145  LogComponentEnable ("AdhocWifiMac", LOG_LEVEL_ALL);
146  LogComponentEnable ("AmrrWifiRemoteStation", LOG_LEVEL_ALL);
147  LogComponentEnable ("ApWifiMac", LOG_LEVEL_ALL);
148  LogComponentEnable ("ns3::ArfWifiManager", LOG_LEVEL_ALL);
150  LogComponentEnable ("DcaTxop", LOG_LEVEL_ALL);
151  LogComponentEnable ("DcfManager", LOG_LEVEL_ALL);
152  LogComponentEnable ("DsssErrorRateModel", LOG_LEVEL_ALL);
153  LogComponentEnable ("EdcaTxopN", LOG_LEVEL_ALL);
154  LogComponentEnable ("InterferenceHelper", LOG_LEVEL_ALL);
156  LogComponentEnable ("MacLow", LOG_LEVEL_ALL);
157  LogComponentEnable ("MacRxMiddle", LOG_LEVEL_ALL);
158  LogComponentEnable ("MsduAggregator", LOG_LEVEL_ALL);
159  LogComponentEnable ("MsduStandardAggregator", LOG_LEVEL_ALL);
160  LogComponentEnable ("NistErrorRateModel", LOG_LEVEL_ALL);
161  LogComponentEnable ("OnoeWifiRemoteStation", LOG_LEVEL_ALL);
162  LogComponentEnable ("PropagationLossModel", LOG_LEVEL_ALL);
163  LogComponentEnable ("RegularWifiMac", LOG_LEVEL_ALL);
164  LogComponentEnable ("RraaWifiManager", LOG_LEVEL_ALL);
165  LogComponentEnable ("StaWifiMac", LOG_LEVEL_ALL);
166  LogComponentEnable ("SupportedRates", LOG_LEVEL_ALL);
167  LogComponentEnable ("WifiChannel", LOG_LEVEL_ALL);
168  LogComponentEnable ("WifiPhyStateHelper", LOG_LEVEL_ALL);
169  LogComponentEnable ("WifiPhy", LOG_LEVEL_ALL);
170  LogComponentEnable ("WifiRemoteStationManager", LOG_LEVEL_ALL);
171  LogComponentEnable ("YansErrorRateModel", LOG_LEVEL_ALL);
172  LogComponentEnable ("YansWifiChannel", LOG_LEVEL_ALL);
173  LogComponentEnable ("YansWifiPhy", LOG_LEVEL_ALL);
174 }
175 
176 int64_t
178 {
179  int64_t currentStream = stream;
180  Ptr<NetDevice> netDevice;
181  for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i)
182  {
183  netDevice = (*i);
184  Ptr<WifiNetDevice> wifi = DynamicCast<WifiNetDevice> (netDevice);
185  if (wifi)
186  {
187  // Handle any random numbers in the PHY objects.
188  currentStream += wifi->GetPhy ()->AssignStreams (currentStream);
189 
190  // Handle any random numbers in the station managers.
191  Ptr<WifiRemoteStationManager> manager = wifi->GetRemoteStationManager ();
192  Ptr<MinstrelWifiManager> minstrel = DynamicCast<MinstrelWifiManager> (manager);
193  if (minstrel)
194  {
195  currentStream += minstrel->AssignStreams (currentStream);
196  }
197 
198  // Handle any random numbers in the MAC objects.
199  Ptr<WifiMac> mac = wifi->GetMac ();
200  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
201  if (rmac)
202  {
203  PointerValue ptr;
204  rmac->GetAttribute ("DcaTxop", ptr);
205  Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
206  currentStream += dcaTxop->AssignStreams (currentStream);
207 
208  rmac->GetAttribute ("VO_EdcaTxopN", ptr);
209  Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
210  currentStream += vo_edcaTxopN->AssignStreams (currentStream);
211 
212  rmac->GetAttribute ("VI_EdcaTxopN", ptr);
213  Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
214  currentStream += vi_edcaTxopN->AssignStreams (currentStream);
215 
216  rmac->GetAttribute ("BE_EdcaTxopN", ptr);
217  Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
218  currentStream += be_edcaTxopN->AssignStreams (currentStream);
219 
220  rmac->GetAttribute ("BK_EdcaTxopN", ptr);
221  Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
222  currentStream += bk_edcaTxopN->AssignStreams (currentStream);
223 
224  // if an AP, handle any beacon jitter
225  Ptr<ApWifiMac> apmac = DynamicCast<ApWifiMac> (rmac);
226  if (apmac)
227  {
228  currentStream += apmac->AssignStreams (currentStream);
229  }
230  }
231  }
232  }
233  return (currentStream - stream);
234 }
235 
236 } // namespace ns3
virtual ~WifiPhyHelper()
Definition: wifi-helper.cc:47
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Ptr< T > Get(void) const
Definition: pointer.h:148
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
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:73
virtual ~WifiHelper()
Definition: wifi-helper.cc:55
Hold a value for an Attribute.
Definition: attribute.h:56
create PHY objects
Definition: wifi-helper.h:46
virtual Ptr< WifiMac > Create(void) const =0
void SetTypeId(TypeId tid)
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:88
NS_LOG_COMPONENT_DEFINE("WifiHelper")
WifiHelper()
Create a Wifi helper in an empty state: all its parameters must be set before calling ns3::WifiHelper...
Definition: wifi-helper.cc:59
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wifi-helper.cc:102
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:84
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
Ptr< Object > Create(void) const
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:96
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:177
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
hold a list of per-remote-station state.
OFDM PHY for the 5 GHz band (Clause 17)
keep track of a set of node pointers.
hold objects of type Ptr
Definition: pointer.h:33
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void Set(std::string name, const AttributeValue &value)
ObjectFactory m_stationManager
Definition: wifi-helper.h:193
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const =0
create MAC objects
Definition: wifi-helper.h:68
instantiate subclasses of ns3::Object.
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
Definition: wifi-helper.cc:142
uint32_t AddDevice(Ptr< NetDevice > device)
Definition: node.cc:118
virtual ~WifiMacHelper()
Definition: wifi-helper.cc:51
std::vector< Ptr< NetDevice > >::const_iterator Iterator
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
enum WifiPhyStandard m_standard
Definition: wifi-helper.h:194
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
Ptr< T > GetObject(void) const
Definition: object.h:361
void LogComponentEnable(char const *name, enum LogLevel level)
Definition: log.cc:311
static WifiHelper Default(void)
Definition: wifi-helper.cc:65