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-standards.h"
15
16#include <map>
17
18namespace ns3
19{
20
21class WifiMac;
22class WifiNetDevice;
23
24/**
25 * @brief create MAC layers for a ns3::WifiNetDevice.
26 *
27 * This class can create MACs of type ns3::ApWifiMac, ns3::StaWifiMac and ns3::AdhocWifiMac.
28 * Its purpose is to allow a WifiHelper to configure and install WifiMac objects on a collection
29 * of nodes. The WifiMac objects themselves are mainly composed of TxMiddle, RxMiddle,
30 * ChannelAccessManager, FrameExchangeManager, WifiRemoteStationManager, MpduAggregator and
31 * MsduAggregartor objects, so this helper offers the opportunity to configure attribute values away
32 * from their default values, on a per-NodeContainer basis. By default, it creates an Adhoc MAC
33 * layer without QoS. Typically, it is used to set type and attribute values, then hand this object
34 * over to the WifiHelper that finishes the job of installing.
35 *
36 * This class may be further subclassed (WaveMacHelper is an example of this).
37 *
38 */
40{
41 public:
42 /**
43 * Create a WifiMacHelper to make life easier for people who want to
44 * work with Wifi MAC layers.
45 */
47 /**
48 * Destroy a WifiMacHelper.
49 */
50 virtual ~WifiMacHelper();
51
52 /**
53 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
54 * @param type the type of ns3::WifiMac to create.
55 * @param args A sequence of name-value pairs of the attributes to set.
56 *
57 * All the attributes specified in this method should exist
58 * in the requested MAC.
59 */
60 template <typename... Args>
61 void SetType(std::string type, Args&&... args);
62
63 /**
64 * Helper function used to create and set the Txop object.
65 *
66 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
67 * @param args A sequence of name-value pairs of the attributes to set.
68 */
69 template <typename... Args>
70 void SetDcf(Args&&... args);
71
72 /**
73 * Helper function used to create and set the QosTxop object corresponding to the given AC.
74 *
75 * @param aci the AC index
76 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
77 * @param args A sequence of name-value pairs of the attributes to set.
78 */
79 template <typename... Args>
80 void SetEdca(AcIndex aci, Args&&... args);
81
82 /**
83 * Helper function used to set the Channel Access Manager object.
84 *
85 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
86 * @param args A sequence of name-value pairs of the attributes to set.
87 */
88 template <typename... Args>
89 void SetChannelAccessManager(Args&&... args);
90
91 /**
92 * Helper function used to set the Frame Exchange Manager object.
93 *
94 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
95 * @param args A sequence of name-value pairs of the attributes to set.
96 */
97 template <typename... Args>
98 void SetFrameExchangeManager(Args&&... args);
99
100 /**
101 * Helper function used to set the Association Manager.
102 *
103 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
104 * @param type the type of Association Manager
105 * @param args A sequence of name-value pairs of the attributes to set.
106 */
107 template <typename... Args>
108 void SetAssocManager(std::string type, Args&&... args);
109
110 /**
111 * Helper function used to set the MAC queue scheduler.
112 *
113 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
114 * @param type the type of MAC queue scheduler
115 * @param args A sequence of name-value pairs of the attributes to set.
116 */
117 template <typename... Args>
118 void SetMacQueueScheduler(std::string type, Args&&... args);
119
120 /**
121 * Helper function used to set the Protection Manager.
122 *
123 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
124 * @param type the type of Protection Manager
125 * @param args A sequence of name-value pairs of the attributes to set.
126 */
127 template <typename... Args>
128 void SetProtectionManager(std::string type, Args&&... args);
129
130 /**
131 * Helper function used to set the Acknowledgment Manager.
132 *
133 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
134 * @param type the type of Acknowledgment Manager
135 * @param args A sequence of name-value pairs of the attributes to set.
136 */
137 template <typename... Args>
138 void SetAckManager(std::string type, Args&&... args);
139
140 /**
141 * Helper function used to set the Multi User Scheduler that can be aggregated
142 * to an HE AP's MAC.
143 *
144 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
145 * @param type the type of Multi User Scheduler
146 * @param args A sequence of name-value pairs of the attributes to set.
147 */
148 template <typename... Args>
149 void SetMultiUserScheduler(std::string type, Args&&... args);
150
151 /**
152 * Helper function used to set the EMLSR Manager that can be installed on an EHT non-AP MLD.
153 *
154 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
155 * @param type the type of EMLSR Manager
156 * @param args A sequence of name-value pairs of the attributes to set.
157 */
158 template <typename... Args>
159 void SetEmlsrManager(std::string type, Args&&... args);
160
161 /**
162 * Helper function used to set the AP EMLSR Manager that can be installed on an EHT AP MLD.
163 *
164 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
165 * @param type the type of AP EMLSR Manager
166 * @param args A sequence of name-value pairs of the attributes to set.
167 */
168 template <typename... Args>
169 void SetApEmlsrManager(std::string type, Args&&... args);
170
171 /**
172 * Helper function used to set the GCR Manager that can be installed on a QoS AP.
173 *
174 * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
175 * @param type the type of GCR Manager
176 * @param args A sequence of name-value pairs of the attributes to set.
177 */
178 template <typename... Args>
179 void SetGcrManager(std::string type, Args&&... args);
180
181 /**
182 * @param device the device within which the MAC object will reside
183 * @param standard the standard to configure during installation
184 * @returns a new MAC object.
185 *
186 * This allows the ns3::WifiHelper class to create MAC objects from ns3::WifiHelper::Install.
187 */
188 virtual Ptr<WifiMac> Create(Ptr<WifiNetDevice> device, WifiStandard standard) const;
189
190 protected:
191 ObjectFactory m_mac; ///< MAC object factory
192 ObjectFactory m_dcf; ///< Txop (DCF) object factory
193 std::map<AcIndex, ObjectFactory, std::greater<>> m_edca; ///< QosTxop (EDCA) object factories
194 ObjectFactory m_channelAccessManager; ///< Channel Access Manager object factory
195 ObjectFactory m_frameExchangeManager; ///< Frame Exchange Manager object factory
196 ObjectFactory m_assocManager; ///< Association Manager
197 ObjectFactory m_queueScheduler; ///< MAC queue scheduler
198 ObjectFactory m_protectionManager; ///< Factory to create a protection manager
199 ObjectFactory m_ackManager; ///< Factory to create an acknowledgment manager
200 ObjectFactory m_muScheduler; ///< Multi-user Scheduler object factory
201 ObjectFactory m_emlsrManager; ///< EMLSR Manager object factory
202 ObjectFactory m_apEmlsrManager; ///< AP EMLSR Manager object factory
203 ObjectFactory m_gcrManager; ///< GCR Manager object factory
204};
205
206} // namespace ns3
207
208/***************************************************************
209 * Implementation of the templates declared above.
210 ***************************************************************/
211
212namespace ns3
213{
214
215template <typename... Args>
216void
217WifiMacHelper::SetType(std::string type, Args&&... args)
218{
219 m_mac.SetTypeId(type);
220 m_mac.Set(args...);
221}
222
223template <typename... Args>
224void
226{
227 m_dcf.Set(args...);
228}
229
230template <typename... Args>
231void
232WifiMacHelper::SetEdca(AcIndex aci, Args&&... args)
233{
234 auto it = m_edca.find(aci);
235 NS_ASSERT_MSG(it != m_edca.cend(), "No object factory for " << aci);
236 it->second.Set(args...);
237}
238
239template <typename... Args>
240void
245
246template <typename... Args>
247void
252
253template <typename... Args>
254void
255WifiMacHelper::SetAssocManager(std::string type, Args&&... args)
256{
258 m_assocManager.Set(args...);
259}
260
261template <typename... Args>
262void
263WifiMacHelper::SetMacQueueScheduler(std::string type, Args&&... args)
264{
266 m_queueScheduler.Set(args...);
267}
268
269template <typename... Args>
270void
271WifiMacHelper::SetProtectionManager(std::string type, Args&&... args)
272{
274 m_protectionManager.Set(args...);
275}
276
277template <typename... Args>
278void
279WifiMacHelper::SetAckManager(std::string type, Args&&... args)
280{
282 m_ackManager.Set(args...);
283}
284
285template <typename... Args>
286void
287WifiMacHelper::SetMultiUserScheduler(std::string type, Args&&... args)
288{
290 m_muScheduler.Set(args...);
291}
292
293template <typename... Args>
294void
295WifiMacHelper::SetEmlsrManager(std::string type, Args&&... args)
296{
298 m_emlsrManager.Set(args...);
299}
300
301template <typename... Args>
302void
303WifiMacHelper::SetApEmlsrManager(std::string type, Args&&... args)
304{
306 m_apEmlsrManager.Set(args...);
307}
308
309template <typename... Args>
310void
311WifiMacHelper::SetGcrManager(std::string type, Args&&... args)
312{
314 m_gcrManager.Set(args...);
315}
316
317} // namespace ns3
318
319#endif /* WIFI_MAC_HELPER_H */
Instantiate subclasses of ns3::Object.
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 MAC layers for a ns3::WifiNetDevice.
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.
virtual ~WifiMacHelper()
Destroy a WifiMacHelper.
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.
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.
#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:75
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:62
Every class exported by the ns3 library is enclosed in the ns3 namespace.