A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
25
26#include "ns3/object-factory.h"
27#include "ns3/qos-utils.h"
28#include "ns3/wifi-standards.h"
29
30namespace ns3
31{
32
33class NetDeviceContainer;
34class WifiPhyHelper;
35class WifiNetDevice;
36class NodeContainer;
37
38/**
39 * \ingroup dot11s
40 *
41 * \brief Helper to create IEEE 802.11s mesh networks
42 */
44{
45 public:
46 /**
47 * Construct a MeshHelper used to make life easier when creating 802.11s networks.
48 */
49 MeshHelper();
50
51 /**
52 * Destroy a MeshHelper.
53 */
55
56 /**
57 * \brief Set the helper to the default values for the MAC type, remote
58 * station manager and channel policy.
59 * \returns the default MeshHelper
60 */
61 static MeshHelper Default();
62
63 /**
64 * \brief Set the Mac Attributes.
65 *
66 * All the attributes specified in this method should exist
67 * in the requested mac.
68 *
69 * \tparam Ts \deduced Argument types
70 * \param [in] args Name and AttributeValue pairs to set.
71 */
72 template <typename... Ts>
73 void SetMacType(Ts&&... args);
74 /**
75 * \brief Set the remote station manager type and Attributes.
76 *
77 * All the attributes specified in this method should exist
78 * in the requested station manager.
79 *
80 * \tparam Ts \deduced Argument types
81 * \param type the type of remote station manager to use.
82 * \param [in] args Name and AttributeValue pairs to set.
83 */
84 template <typename... Ts>
85 void SetRemoteStationManager(std::string type, Ts&&... args);
86 /**
87 * Set standard
88 * \param standard the wifi phy standard
89 */
90 void SetStandard(WifiStandard standard);
91
92 /// \todo SetMeshId
93 // void SetMeshId (std::string s);
94 /**
95 * \brief Spread/not spread frequency channels of MP interfaces.
96 *
97 * If set to true different non-overlapping 20MHz frequency
98 * channels will be assigned to different mesh point interfaces.
99 */
101 {
104 };
105
106 /**
107 * \brief set the channel policy
108 * \param policy the channel policy
109 */
111 /**
112 * \brief Set a number of interfaces in a mesh network
113 * \param nInterfaces is the number of interfaces
114 */
115 void SetNumberOfInterfaces(uint32_t nInterfaces);
116
117 /**
118 * \brief Install 802.11s mesh device & protocols on given node list
119 *
120 * \param phyHelper Wifi PHY helper
121 * \param c List of nodes to install
122 *
123 * \return list of created mesh point devices, see MeshPointDevice
124 */
125 NetDeviceContainer Install(const WifiPhyHelper& phyHelper, NodeContainer c) const;
126 /**
127 * \brief Set the MeshStack type to use.
128 *
129 * \tparam Ts \deduced Argument types
130 * \param type the type of ns3::MeshStack.
131 * \param [in] args Name and AttributeValue pairs to set.
132 */
133 template <typename... Ts>
134 void SetStackInstaller(std::string type, Ts&&... args);
135
136 /**
137 * \brief Print statistics.
138 *
139 * \param device the net device
140 * \param os the output stream
141 */
142 void Report(const ns3::Ptr<ns3::NetDevice>& device, std::ostream& os);
143
144 /**
145 * \brief Reset statistics.
146 * \param device the net device
147 */
148 void ResetStats(const ns3::Ptr<ns3::NetDevice>& device);
149 /**
150 * Assign a fixed random variable stream number to the random variables
151 * used by this model. Return the number of streams (possibly zero) that
152 * have been assigned. The Install() method of this helper
153 * should have previously been called by the user.
154 *
155 * \param stream first stream index to use
156 * \param c NetDeviceContainer of the set of devices for which the mesh devices
157 * should be modified to use a fixed stream
158 * \return the number of stream indices assigned by this helper
159 */
160 int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
161
162 /**
163 * Helper to enable all MeshPointDevice log components with one statement
164 */
165 static void EnableLogComponents();
166
167 private:
168 /**
169 * \param phyHelper
170 * \param node
171 * \param channelId
172 * \returns a WifiNetDevice with ready-to-use interface
173 */
175 Ptr<Node> node,
176 uint16_t channelId) const;
177 uint32_t m_nInterfaces; ///< number of interfaces
178 ChannelPolicy m_spreadChannelPolicy; ///< spread channel policy
180 ObjectFactory m_stackFactory; ///< stack factory
181
182 // Interface factory
183 ObjectFactory m_mac; ///< the MAC
184 ObjectFactory m_stationManager; ///< the station manager
185 ObjectFactory m_ackPolicySelector[4]; ///< ack policy selector for all ACs
187};
188
189/***************************************************************
190 * Implementation of the templates declared above.
191 ***************************************************************/
192
193template <typename... Ts>
194void
196{
197 m_mac.SetTypeId("ns3::MeshWifiInterfaceMac");
198 m_mac.Set(std::forward<Ts>(args)...);
199}
200
201template <typename... Ts>
202void
203MeshHelper::SetRemoteStationManager(std::string type, Ts&&... args)
204{
205 m_stationManager = ObjectFactory(type, std::forward<Ts>(args)...);
206}
207
208template <typename... Ts>
209void
210MeshHelper::SetStackInstaller(std::string type, Ts&&... args)
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 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.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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.