A Discrete-Event Network Simulator
API
mesh-helper.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008,2009 IITP RAS
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Kirill Andreev <andreev@iitp.ru>
18  * Pavel Boyko <boyko@iitp.ru>
19  */
20 
21 #ifndef MESH_HELPER_H
22 #define MESH_HELPER_H
23 
24 #include "mesh-stack-installer.h"
25 
26 #include "ns3/object-factory.h"
27 #include "ns3/qos-utils.h"
28 #include "ns3/wifi-standards.h"
29 
30 namespace ns3
31 {
32 
33 class NetDeviceContainer;
34 class WifiPhyHelper;
35 class WifiNetDevice;
36 class NodeContainer;
37 
44 {
45  public:
49  MeshHelper();
50 
54  ~MeshHelper();
55 
61  static MeshHelper Default();
62 
72  template <typename... Ts>
73  void SetMacType(Ts&&... args);
84  template <typename... Ts>
85  void SetRemoteStationManager(std::string type, Ts&&... args);
90  void SetStandard(WifiStandard standard);
91 
93  // void SetMeshId (std::string s);
101  {
104  };
105 
115  void SetNumberOfInterfaces(uint32_t nInterfaces);
116 
125  NetDeviceContainer Install(const WifiPhyHelper& phyHelper, NodeContainer c) const;
133  template <typename... Ts>
134  void SetStackInstaller(std::string type, Ts&&... args);
135 
142  void Report(const ns3::Ptr<ns3::NetDevice>& device, std::ostream& os);
143 
148  void ResetStats(const ns3::Ptr<ns3::NetDevice>& device);
160  int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
161 
165  static void EnableLogComponents();
166 
167  private:
175  Ptr<Node> node,
176  uint16_t channelId) const;
177  uint32_t m_nInterfaces;
181 
182  // Interface factory
187 };
188 
189 /***************************************************************
190  * Implementation of the templates declared above.
191  ***************************************************************/
192 
193 template <typename... Ts>
194 void
196 {
197  m_mac.SetTypeId("ns3::MeshWifiInterfaceMac");
198  m_mac.Set(std::forward<Ts>(args)...);
199 }
200 
201 template <typename... Ts>
202 void
204 {
205  m_stationManager = ObjectFactory(type, std::forward<Ts>(args)...);
206 }
207 
208 template <typename... Ts>
209 void
211 {
213  m_stackFactory.Set(std::forward<Ts>(args)...);
215  if (!m_stack)
216  {
217  NS_FATAL_ERROR("Stack has not been created: " << type);
218  }
219 }
220 
221 } // namespace ns3
222 
223 #endif /* MESH_HELPER_H */
Helper to create IEEE 802.11s mesh networks.
Definition: mesh-helper.h:44
void SetRemoteStationManager(std::string type, Ts &&... args)
Set the remote station manager type and Attributes.
Definition: mesh-helper.h:203
void SetStandard(WifiStandard standard)
Set standard.
Definition: mesh-helper.cc:108
ObjectFactory m_stackFactory
stack factory
Definition: mesh-helper.h:180
Ptr< WifiNetDevice > CreateInterface(const WifiPhyHelper &phyHelper, Ptr< Node > node, uint16_t channelId) const
Definition: mesh-helper.cc:114
Ptr< MeshStack > m_stack
stack
Definition: mesh-helper.h:179
~MeshHelper()
Destroy a MeshHelper.
Definition: mesh-helper.cc:45
uint32_t m_nInterfaces
number of interfaces
Definition: mesh-helper.h:177
ObjectFactory m_stationManager
the station manager
Definition: mesh-helper.h:184
void SetSpreadInterfaceChannels(ChannelPolicy policy)
set the channel policy
Definition: mesh-helper.cc:51
ObjectFactory m_ackPolicySelector[4]
ack policy selector for all ACs
Definition: mesh-helper.h:185
ObjectFactory m_mac
the MAC
Definition: mesh-helper.h:183
ChannelPolicy m_spreadChannelPolicy
spread channel policy
Definition: mesh-helper.h:178
void SetStackInstaller(std::string type, Ts &&... args)
Set the MeshStack type to use.
Definition: mesh-helper.h:210
static void EnableLogComponents()
Helper to enable all MeshPointDevice log components with one statement.
Definition: mesh-helper.cc:238
MeshHelper()
Construct a MeshHelper used to make life easier when creating 802.11s networks.
Definition: mesh-helper.cc:37
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: mesh-helper.cc:178
static MeshHelper Default()
Set the helper to the default values for the MAC type, remote station manager and channel policy.
Definition: mesh-helper.cc:98
void SetMacType(Ts &&... args)
Set the Mac Attributes.
Definition: mesh-helper.h:195
NetDeviceContainer Install(const WifiPhyHelper &phyHelper, NodeContainer c) const
Install 802.11s mesh device & protocols on given node list.
Definition: mesh-helper.cc:63
ChannelPolicy
Spread/not spread frequency channels of MP interfaces.
Definition: mesh-helper.h:101
WifiStandard m_standard
standard
Definition: mesh-helper.h:186
void ResetStats(const ns3::Ptr< ns3::NetDevice > &device)
Reset statistics.
Definition: mesh-helper.cc:169
void Report(const ns3::Ptr< ns3::NetDevice > &device, std::ostream &os)
Print statistics.
Definition: mesh-helper.cc:156
void SetNumberOfInterfaces(uint32_t nInterfaces)
Set a number of interfaces in a mesh network.
Definition: mesh-helper.cc:57
Prototype for class, which helps to install MAC-layer routing stack to ns3::MeshPointDevice.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
create PHY objects
Definition: wifi-helper.h:49
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
Every class exported by the ns3 library is enclosed in the ns3 namespace.