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 * \param device the device within which the MAC object will reside
173 * \param standard the standard to configure during installation
174 * \returns a new MAC object.
175 *
176 * This allows the ns3::WifiHelper class to create MAC objects from ns3::WifiHelper::Install.
177 */
178 virtual Ptr<WifiMac> Create(Ptr<WifiNetDevice> device, WifiStandard standard) const;
179
180 protected:
181 ObjectFactory m_mac; ///< MAC object factory
182 ObjectFactory m_dcf; ///< Txop (DCF) object factory
183 std::map<AcIndex, ObjectFactory, std::greater<>> m_edca; ///< QosTxop (EDCA) object factories
184 ObjectFactory m_channelAccessManager; ///< Channel Access Manager object factory
185 ObjectFactory m_frameExchangeManager; ///< Frame Exchange Manager object factory
186 ObjectFactory m_assocManager; ///< Association Manager
187 ObjectFactory m_queueScheduler; ///< MAC queue scheduler
188 ObjectFactory m_protectionManager; ///< Factory to create a protection manager
189 ObjectFactory m_ackManager; ///< Factory to create an acknowledgment manager
190 ObjectFactory m_muScheduler; ///< Multi-user Scheduler object factory
191 ObjectFactory m_emlsrManager; ///< EMLSR Manager object factory
192 ObjectFactory m_apEmlsrManager; ///< AP EMLSR Manager object factory
193};
194
195} // namespace ns3
196
197/***************************************************************
198 * Implementation of the templates declared above.
199 ***************************************************************/
200
201namespace ns3
202{
203
204template <typename... Args>
205void
206WifiMacHelper::SetType(std::string type, Args&&... args)
207{
208 m_mac.SetTypeId(type);
209 m_mac.Set(args...);
210}
211
212template <typename... Args>
213void
215{
216 m_dcf.Set(args...);
217}
218
219template <typename... Args>
220void
221WifiMacHelper::SetEdca(AcIndex aci, Args&&... args)
222{
223 auto it = m_edca.find(aci);
224 NS_ASSERT_MSG(it != m_edca.cend(), "No object factory for " << aci);
225 it->second.Set(args...);
226}
227
228template <typename... Args>
229void
234
235template <typename... Args>
236void
241
242template <typename... Args>
243void
244WifiMacHelper::SetAssocManager(std::string type, Args&&... args)
245{
247 m_assocManager.Set(args...);
248}
249
250template <typename... Args>
251void
252WifiMacHelper::SetMacQueueScheduler(std::string type, Args&&... args)
253{
255 m_queueScheduler.Set(args...);
256}
257
258template <typename... Args>
259void
260WifiMacHelper::SetProtectionManager(std::string type, Args&&... args)
261{
263 m_protectionManager.Set(args...);
264}
265
266template <typename... Args>
267void
268WifiMacHelper::SetAckManager(std::string type, Args&&... args)
269{
271 m_ackManager.Set(args...);
272}
273
274template <typename... Args>
275void
276WifiMacHelper::SetMultiUserScheduler(std::string type, Args&&... args)
277{
279 m_muScheduler.Set(args...);
280}
281
282template <typename... Args>
283void
284WifiMacHelper::SetEmlsrManager(std::string type, Args&&... args)
285{
287 m_emlsrManager.Set(args...);
288}
289
290template <typename... Args>
291void
292WifiMacHelper::SetApEmlsrManager(std::string type, Args&&... args)
293{
295 m_apEmlsrManager.Set(args...);
296}
297
298} // namespace ns3
299
300#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.
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.
#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.