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  : m_standard (WIFI_PHY_STANDARD_80211a)
57 {
58 }
59 
62 {
63  WifiHelper helper;
64  helper.SetRemoteStationManager ("ns3::ArfWifiManager");
65  return helper;
66 }
67 
68 void
70  std::string n0, const AttributeValue &v0,
71  std::string n1, const AttributeValue &v1,
72  std::string n2, const AttributeValue &v2,
73  std::string n3, const AttributeValue &v3,
74  std::string n4, const AttributeValue &v4,
75  std::string n5, const AttributeValue &v5,
76  std::string n6, const AttributeValue &v6,
77  std::string n7, const AttributeValue &v7)
78 {
81  m_stationManager.Set (n0, v0);
82  m_stationManager.Set (n1, v1);
83  m_stationManager.Set (n2, v2);
84  m_stationManager.Set (n3, v3);
85  m_stationManager.Set (n4, v4);
86  m_stationManager.Set (n5, v5);
87  m_stationManager.Set (n6, v6);
88  m_stationManager.Set (n7, v7);
89 }
90 
91 void
93 {
94  m_standard = standard;
95 }
96 
99  const WifiMacHelper &macHelper, NodeContainer c) const
100 {
102  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
103  {
104  Ptr<Node> node = *i;
105  Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
107  Ptr<WifiMac> mac = macHelper.Create ();
108  Ptr<WifiPhy> phy = phyHelper.Create (node, device);
109  mac->SetAddress (Mac48Address::Allocate ());
112  device->SetMac (mac);
113  device->SetPhy (phy);
114  device->SetRemoteStationManager (manager);
115  node->AddDevice (device);
116  devices.Add (device);
117  NS_LOG_DEBUG ("node=" << node << ", mob=" << node->GetObject<MobilityModel> ());
118  }
119  return devices;
120 }
121 
124  const WifiMacHelper &mac, Ptr<Node> node) const
125 {
126  return Install (phy, mac, NodeContainer (node));
127 }
128 
131  const WifiMacHelper &mac, std::string nodeName) const
132 {
133  Ptr<Node> node = Names::Find<Node> (nodeName);
134  return Install (phy, mac, NodeContainer (node));
135 }
136 
137 void
139 {
140  LogComponentEnable ("Aarfcd", LOG_LEVEL_ALL);
141  LogComponentEnable ("AdhocWifiMac", LOG_LEVEL_ALL);
142  LogComponentEnable ("AmrrWifiRemoteStation", LOG_LEVEL_ALL);
143  LogComponentEnable ("ApWifiMac", LOG_LEVEL_ALL);
144  LogComponentEnable ("ns3::ArfWifiManager", LOG_LEVEL_ALL);
146  LogComponentEnable ("DcaTxop", LOG_LEVEL_ALL);
147  LogComponentEnable ("DcfManager", LOG_LEVEL_ALL);
148  LogComponentEnable ("DsssErrorRateModel", LOG_LEVEL_ALL);
149  LogComponentEnable ("EdcaTxopN", LOG_LEVEL_ALL);
150  LogComponentEnable ("InterferenceHelper", LOG_LEVEL_ALL);
152  LogComponentEnable ("MacLow", LOG_LEVEL_ALL);
153  LogComponentEnable ("MacRxMiddle", LOG_LEVEL_ALL);
154  LogComponentEnable ("MsduAggregator", LOG_LEVEL_ALL);
155  LogComponentEnable ("MsduStandardAggregator", LOG_LEVEL_ALL);
156  LogComponentEnable ("NistErrorRateModel", LOG_LEVEL_ALL);
157  LogComponentEnable ("OnoeWifiRemoteStation", LOG_LEVEL_ALL);
158  LogComponentEnable ("PropagationLossModel", LOG_LEVEL_ALL);
159  LogComponentEnable ("RegularWifiMac", LOG_LEVEL_ALL);
160  LogComponentEnable ("RraaWifiManager", LOG_LEVEL_ALL);
161  LogComponentEnable ("StaWifiMac", LOG_LEVEL_ALL);
162  LogComponentEnable ("SupportedRates", LOG_LEVEL_ALL);
163  LogComponentEnable ("WifiChannel", LOG_LEVEL_ALL);
164  LogComponentEnable ("WifiPhyStateHelper", LOG_LEVEL_ALL);
165  LogComponentEnable ("WifiPhy", LOG_LEVEL_ALL);
166  LogComponentEnable ("WifiRemoteStationManager", LOG_LEVEL_ALL);
167  LogComponentEnable ("YansErrorRateModel", LOG_LEVEL_ALL);
168  LogComponentEnable ("YansWifiChannel", LOG_LEVEL_ALL);
169  LogComponentEnable ("YansWifiPhy", LOG_LEVEL_ALL);
170 }
171 
172 int64_t
174 {
175  int64_t currentStream = stream;
176  Ptr<NetDevice> netDevice;
177  for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i)
178  {
179  netDevice = (*i);
180  Ptr<WifiNetDevice> wifi = DynamicCast<WifiNetDevice> (netDevice);
181  if (wifi)
182  {
183  // Handle any random numbers in the PHY objects.
184  currentStream += wifi->GetPhy ()->AssignStreams (currentStream);
185 
186  // Handle any random numbers in the station managers.
187  Ptr<WifiRemoteStationManager> manager = wifi->GetRemoteStationManager ();
188  Ptr<MinstrelWifiManager> minstrel = DynamicCast<MinstrelWifiManager> (manager);
189  if (minstrel)
190  {
191  currentStream += minstrel->AssignStreams (currentStream);
192  }
193 
194  // Handle any random numbers in the MAC objects.
195  Ptr<WifiMac> mac = wifi->GetMac ();
196  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
197  if (rmac)
198  {
199  PointerValue ptr;
200  rmac->GetAttribute ("DcaTxop", ptr);
201  Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
202  currentStream += dcaTxop->AssignStreams (currentStream);
203 
204  rmac->GetAttribute ("VO_EdcaTxopN", ptr);
205  Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
206  currentStream += vo_edcaTxopN->AssignStreams (currentStream);
207 
208  rmac->GetAttribute ("VI_EdcaTxopN", ptr);
209  Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
210  currentStream += vi_edcaTxopN->AssignStreams (currentStream);
211 
212  rmac->GetAttribute ("BE_EdcaTxopN", ptr);
213  Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
214  currentStream += be_edcaTxopN->AssignStreams (currentStream);
215 
216  rmac->GetAttribute ("BK_EdcaTxopN", ptr);
217  Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
218  currentStream += bk_edcaTxopN->AssignStreams (currentStream);
219 
220  // if an AP, handle any beacon jitter
221  Ptr<ApWifiMac> apmac = DynamicCast<ApWifiMac> (rmac);
222  if (apmac)
223  {
224  currentStream += apmac->AssignStreams (currentStream);
225  }
226  }
227  }
228  }
229  return (currentStream - stream);
230 }
231 
232 } // 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
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:69
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")
NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wifi-helper.cc:98
Keep track of the current position and velocity of an object.
static Mac48Address Allocate(void)
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
void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:92
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Definition: wifi-helper.cc:173
int64_t AssignStreams(int64_t stream)
hold a list of per-remote-station state.
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:191
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)
Definition: wifi-helper.cc:138
uint32_t AddDevice(Ptr< NetDevice > device)
Definition: node.cc:117
virtual ~WifiMacHelper()
Definition: wifi-helper.cc:51
std::vector< Ptr< NetDevice > >::const_iterator Iterator
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
enum WifiPhyStandard m_standard
Definition: wifi-helper.h:192
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
handle packet fragmentation and retransmissions.This class implements the packet fragmentation and re...
Definition: dca-txop.h:67
Ptr< T > GetObject(void) const
Definition: object.h:360
void LogComponentEnable(char const *name, enum LogLevel level)
Definition: log.cc:311
static WifiHelper Default(void)
Definition: wifi-helper.cc:61