A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-mac-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#ifndef WIFI_MAC_HELPER_H
10#define WIFI_MAC_HELPER_H
11
12#include "ns3/object-factory.h"
13#include "ns3/qos-utils.h"
14#include "ns3/wifi-export.h"
15#include "ns3/wifi-standards.h"
16
17#include <map>
18
19namespace ns3
20{
21
22class WifiMac;
23class WifiNetDevice;
24
25/**
26 * @brief create MAC layers for a ns3::WifiNetDevice.
27 *
28 * This class can create MACs of type ns3::ApWifiMac, ns3::StaWifiMac and ns3::AdhocWifiMac.
29 * Its purpose is to allow a WifiHelper to configure and install WifiMac objects on a collection
30 * of nodes. The WifiMac objects themselves are mainly composed of TxMiddle, RxMiddle,
31 * ChannelAccessManager, FrameExchangeManager, WifiRemoteStationManager, MpduAggregator and
32 * MsduAggregartor objects, so this helper offers the opportunity to configure attribute values away
33 * from their default values, on a per-NodeContainer basis. By default, it creates an Adhoc MAC
34 * layer without QoS. Typically, it is used to set type and attribute values, then hand this object
35 * over to the WifiHelper that finishes the job of installing.
36 *
37 * This class may be further subclassed (WaveMacHelper is an example of this).
38 *
39 */
40class WIFI_EXPORT WifiMacHelper
41{
42 public:
43 /**
44 * Create a WifiMacHelper to make life easier for people who want to
45 * work with Wifi MAC layers.
46 */
48 /**
49 * Destroy a WifiMacHelper.
50 */
51 virtual ~WifiMacHelper();
52
53 /**
54 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
55 * @param type the type of ns3::WifiMac to create.
56 * @param args A sequence of name-value pairs of the attributes to set.
57 *
58 * All the attributes specified in this method should exist
59 * in the requested MAC.
60 */
61 template <typename... Args>
62 void SetType(std::string type, Args&&... args);
63
64 /**
65 * Helper function used to create and set the Txop object.
66 *
67 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
68 * @param args A sequence of name-value pairs of the attributes to set.
69 */
70 template <typename... Args>
71 void SetDcf(Args&&... args);
72
73 /**
74 * Helper function used to create and set the QosTxop object corresponding to the given AC.
75 *
76 * @param aci the AC index
77 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
78 * @param args A sequence of name-value pairs of the attributes to set.
79 */
80 template <typename... Args>
81 void SetEdca(AcIndex aci, Args&&... args);
82
83 /**
84 * Helper function used to set the Channel Access Manager object.
85 *
86 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
87 * @param args A sequence of name-value pairs of the attributes to set.
88 */
89 template <typename... Args>
90 void SetChannelAccessManager(Args&&... args);
91
92 /**
93 * Helper function used to set the Frame Exchange Manager object.
94 *
95 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
96 * @param args A sequence of name-value pairs of the attributes to set.
97 */
98 template <typename... Args>
99 void SetFrameExchangeManager(Args&&... args);
100
101 /**
102 * Helper function used to set the Association Manager.
103 *
104 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
105 * @param type the type of Association Manager
106 * @param args A sequence of name-value pairs of the attributes to set.
107 */
108 template <typename... Args>
109 void SetAssocManager(std::string type, Args&&... args);
110
111 /**
112 * Helper function used to set the MAC queue scheduler.
113 *
114 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
115 * @param type the type of MAC queue scheduler
116 * @param args A sequence of name-value pairs of the attributes to set.
117 */
118 template <typename... Args>
119 void SetMacQueueScheduler(std::string type, Args&&... args);
120
121 /**
122 * Helper function used to set the Protection Manager.
123 *
124 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
125 * @param type the type of Protection Manager
126 * @param args A sequence of name-value pairs of the attributes to set.
127 */
128 template <typename... Args>
129 void SetProtectionManager(std::string type, Args&&... args);
130
131 /**
132 * Helper function used to set the Acknowledgment Manager.
133 *
134 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
135 * @param type the type of Acknowledgment Manager
136 * @param args A sequence of name-value pairs of the attributes to set.
137 */
138 template <typename... Args>
139 void SetAckManager(std::string type, Args&&... args);
140
141 /**
142 * Helper function used to set the Power Save Manager.
143 *
144 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
145 * @param type the type of Power Save Manager
146 * @param args A sequence of name-value pairs of the attributes to set.
147 */
148 template <typename... Args>
149 void SetPowerSaveManager(std::string type, Args&&... args);
150
151 /**
152 * Helper function used to set the Multi User Scheduler that can be aggregated
153 * to an HE AP's MAC.
154 *
155 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
156 * @param type the type of Multi User Scheduler
157 * @param args A sequence of name-value pairs of the attributes to set.
158 */
159 template <typename... Args>
160 void SetMultiUserScheduler(std::string type, Args&&... args);
161
162 /**
163 * Helper function used to set the EMLSR Manager that can be installed on an EHT non-AP MLD.
164 *
165 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
166 * @param type the type of EMLSR Manager
167 * @param args A sequence of name-value pairs of the attributes to set.
168 */
169 template <typename... Args>
170 void SetEmlsrManager(std::string type, Args&&... args);
171
172 /**
173 * Helper function used to set the AP EMLSR Manager that can be installed on an EHT AP MLD.
174 *
175 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
176 * @param type the type of AP EMLSR Manager
177 * @param args A sequence of name-value pairs of the attributes to set.
178 */
179 template <typename... Args>
180 void SetApEmlsrManager(std::string type, Args&&... args);
181
182 /**
183 * Helper function used to set the GCR Manager that can be installed on a QoS AP.
184 *
185 * @tparam Args @deduced Template type parameter pack for the sequence of name-value pairs.
186 * @param type the type of GCR Manager
187 * @param args A sequence of name-value pairs of the attributes to set.
188 */
189 template <typename... Args>
190 void SetGcrManager(std::string type, Args&&... args);
191
192 /**
193 * @param device the device within which the MAC object will reside
194 * @param standard the standard to configure during installation
195 * @returns a new MAC object.
196 *
197 * This allows the ns3::WifiHelper class to create MAC objects from ns3::WifiHelper::Install.
198 */
199 virtual Ptr<WifiMac> Create(Ptr<WifiNetDevice> device, WifiStandard standard) const;
200
201 protected:
202 ObjectFactory m_mac; ///< MAC object factory
203 ObjectFactory m_dcf; ///< Txop (DCF) object factory
204 std::map<AcIndex, ObjectFactory, std::greater<>> m_edca; ///< QosTxop (EDCA) object factories
205 ObjectFactory m_channelAccessManager; ///< Channel Access Manager object factory
206 ObjectFactory m_frameExchangeManager; ///< Frame Exchange Manager object factory
207 ObjectFactory m_assocManager; ///< Association Manager
208 ObjectFactory m_queueScheduler; ///< MAC queue scheduler
209 ObjectFactory m_protectionManager; ///< Factory to create a protection manager
210 ObjectFactory m_ackManager; ///< Factory to create an acknowledgment manager
211 ObjectFactory m_powerSaveManager; ///< Factory to create a power save manager
212 ObjectFactory m_muScheduler; ///< Multi-user Scheduler object factory
213 ObjectFactory m_emlsrManager; ///< EMLSR Manager object factory
214 ObjectFactory m_apEmlsrManager; ///< AP EMLSR Manager object factory
215 ObjectFactory m_gcrManager; ///< GCR Manager object factory
216};
217
218} // namespace ns3
219
220/***************************************************************
221 * Implementation of the templates declared above.
222 ***************************************************************/
223
224namespace ns3
225{
226
227template <typename... Args>
228void
229WifiMacHelper::SetType(std::string type, Args&&... args)
230{
231 m_mac.SetTypeId(type);
232 m_mac.Set(args...);
233}
234
235template <typename... Args>
236void
238{
239 m_dcf.Set(args...);
240}
241
242template <typename... Args>
243void
244WifiMacHelper::SetEdca(AcIndex aci, Args&&... args)
245{
246 auto it = m_edca.find(aci);
247 NS_ASSERT_MSG(it != m_edca.cend(), "No object factory for " << aci);
248 it->second.Set(args...);
249}
250
251template <typename... Args>
252void
254{
255 m_channelAccessManager.Set(args...);
256}
257
258template <typename... Args>
259void
261{
262 m_frameExchangeManager.Set(args...);
263}
264
265template <typename... Args>
266void
267WifiMacHelper::SetAssocManager(std::string type, Args&&... args)
268{
269 m_assocManager.SetTypeId(type);
270 m_assocManager.Set(args...);
271}
272
273template <typename... Args>
274void
275WifiMacHelper::SetMacQueueScheduler(std::string type, Args&&... args)
276{
277 m_queueScheduler.SetTypeId(type);
278 m_queueScheduler.Set(args...);
279}
280
281template <typename... Args>
282void
283WifiMacHelper::SetProtectionManager(std::string type, Args&&... args)
284{
285 m_protectionManager.SetTypeId(type);
286 m_protectionManager.Set(args...);
287}
288
289template <typename... Args>
290void
291WifiMacHelper::SetAckManager(std::string type, Args&&... args)
292{
293 m_ackManager.SetTypeId(type);
294 m_ackManager.Set(args...);
295}
296
297template <typename... Args>
298void
299WifiMacHelper::SetPowerSaveManager(std::string type, Args&&... args)
300{
301 m_powerSaveManager.SetTypeId(type);
302 m_powerSaveManager.Set(args...);
303}
304
305template <typename... Args>
306void
307WifiMacHelper::SetMultiUserScheduler(std::string type, Args&&... args)
308{
309 m_muScheduler.SetTypeId(type);
310 m_muScheduler.Set(args...);
311}
312
313template <typename... Args>
314void
315WifiMacHelper::SetEmlsrManager(std::string type, Args&&... args)
316{
317 m_emlsrManager.SetTypeId(type);
318 m_emlsrManager.Set(args...);
319}
320
321template <typename... Args>
322void
323WifiMacHelper::SetApEmlsrManager(std::string type, Args&&... args)
324{
325 m_apEmlsrManager.SetTypeId(type);
326 m_apEmlsrManager.Set(args...);
327}
328
329template <typename... Args>
330void
331WifiMacHelper::SetGcrManager(std::string type, Args&&... args)
332{
333 m_gcrManager.SetTypeId(type);
334 m_gcrManager.Set(args...);
335}
336
337} // namespace ns3
338
339#endif /* WIFI_MAC_HELPER_H */
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
ObjectFactory m_apEmlsrManager
AP EMLSR Manager object factory.
void SetChannelAccessManager(Args &&... args)
Helper function used to set the Channel Access Manager object.
void SetDcf(Args &&... args)
Helper function used to create and set the Txop object.
std::map< AcIndex, ObjectFactory, std::greater<> > m_edca
QosTxop (EDCA) object factories.
ObjectFactory m_mac
MAC object factory.
void SetGcrManager(std::string type, Args &&... args)
Helper function used to set the GCR Manager that can be installed on a QoS AP.
ObjectFactory m_queueScheduler
MAC queue scheduler.
void SetAckManager(std::string type, Args &&... args)
Helper function used to set the Acknowledgment Manager.
void SetFrameExchangeManager(Args &&... args)
Helper function used to set the Frame Exchange Manager object.
void SetPowerSaveManager(std::string type, Args &&... args)
Helper function used to set the Power Save Manager.
virtual Ptr< WifiMac > Create(Ptr< WifiNetDevice > device, WifiStandard standard) const
ObjectFactory m_protectionManager
Factory to create a protection manager.
ObjectFactory m_muScheduler
Multi-user Scheduler object factory.
void SetProtectionManager(std::string type, Args &&... args)
Helper function used to set the Protection Manager.
void SetMacQueueScheduler(std::string type, Args &&... args)
Helper function used to set the MAC queue scheduler.
ObjectFactory m_assocManager
Association Manager.
void SetEdca(AcIndex aci, Args &&... args)
Helper function used to create and set the QosTxop object corresponding to the given AC.
WifiMacHelper()
Create a WifiMacHelper to make life easier for people who want to work with Wifi MAC layers.
void SetApEmlsrManager(std::string type, Args &&... args)
Helper function used to set the AP EMLSR Manager that can be installed on an EHT AP MLD.
ObjectFactory m_emlsrManager
EMLSR Manager object factory.
ObjectFactory m_dcf
Txop (DCF) object factory.
ObjectFactory m_powerSaveManager
Factory to create a power save manager.
void SetAssocManager(std::string type, Args &&... args)
Helper function used to set the Association Manager.
void SetMultiUserScheduler(std::string type, Args &&... args)
Helper function used to set the Multi User Scheduler that can be aggregated to an HE AP's MAC.
void SetEmlsrManager(std::string type, Args &&... args)
Helper function used to set the EMLSR Manager that can be installed on an EHT non-AP MLD.
ObjectFactory m_ackManager
Factory to create an acknowledgment manager.
void SetType(std::string type, Args &&... args)
ObjectFactory m_frameExchangeManager
Frame Exchange Manager object factory.
ObjectFactory m_channelAccessManager
Channel Access Manager object factory.
ObjectFactory m_gcrManager
GCR Manager object factory.
base class for all MAC-level wifi objects.
Definition wifi-mac.h:117
Hold together all Wifi-related objects.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:76
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:64
Every class exported by the ns3 library is enclosed in the ns3 namespace.