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