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 * 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: Sébastien Deronne <sebastien.deronne@gmail.com>
18 */
19
20#ifndef WIFI_MAC_HELPER_H
21#define WIFI_MAC_HELPER_H
22
23#include "ns3/object-factory.h"
24#include "ns3/qos-utils.h"
25#include "ns3/wifi-standards.h"
26
27#include <map>
28
29namespace ns3
30{
31
32class WifiMac;
33class WifiNetDevice;
34
35/**
36 * \brief create MAC layers for a ns3::WifiNetDevice.
37 *
38 * This class can create MACs of type ns3::ApWifiMac, ns3::StaWifiMac and ns3::AdhocWifiMac.
39 * Its purpose is to allow a WifiHelper to configure and install WifiMac objects on a collection
40 * of nodes. The WifiMac objects themselves are mainly composed of TxMiddle, RxMiddle,
41 * ChannelAccessManager, FrameExchangeManager, WifiRemoteStationManager, MpduAggregator and
42 * MsduAggregartor objects, so this helper offers the opportunity to configure attribute values away
43 * from their default values, on a per-NodeContainer basis. By default, it creates an Adhoc MAC
44 * layer without QoS. Typically, it is used to set type and attribute values, then hand this object
45 * over to the WifiHelper that finishes the job of installing.
46 *
47 * This class may be further subclassed (WaveMacHelper is an example of this).
48 *
49 */
51{
52 public:
53 /**
54 * Create a WifiMacHelper to make life easier for people who want to
55 * work with Wifi MAC layers.
56 */
58 /**
59 * Destroy a WifiMacHelper.
60 */
61 virtual ~WifiMacHelper();
62
63 /**
64 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
65 * \param type the type of ns3::WifiMac to create.
66 * \param args A sequence of name-value pairs of the attributes to set.
67 *
68 * All the attributes specified in this method should exist
69 * in the requested MAC.
70 */
71 template <typename... Args>
72 void SetType(std::string type, Args&&... args);
73
74 /**
75 * Helper function used to create and set the Txop object.
76 *
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 SetDcf(Args&&... args);
82
83 /**
84 * Helper function used to create and set the QosTxop object corresponding to the given AC.
85 *
86 * \param aci the AC index
87 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
88 * \param args A sequence of name-value pairs of the attributes to set.
89 */
90 template <typename... Args>
91 void SetEdca(AcIndex aci, Args&&... args);
92
93 /**
94 * Helper function used to set the Channel Access Manager object.
95 *
96 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
97 * \param args A sequence of name-value pairs of the attributes to set.
98 */
99 template <typename... Args>
100 void SetChannelAccessManager(Args&&... args);
101
102 /**
103 * Helper function used to set the Frame Exchange Manager object.
104 *
105 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
106 * \param args A sequence of name-value pairs of the attributes to set.
107 */
108 template <typename... Args>
109 void SetFrameExchangeManager(Args&&... args);
110
111 /**
112 * Helper function used to set the Association Manager.
113 *
114 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
115 * \param type the type of Association Manager
116 * \param args A sequence of name-value pairs of the attributes to set.
117 */
118 template <typename... Args>
119 void SetAssocManager(std::string type, Args&&... args);
120
121 /**
122 * Helper function used to set the MAC queue scheduler.
123 *
124 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
125 * \param type the type of MAC queue scheduler
126 * \param args A sequence of name-value pairs of the attributes to set.
127 */
128 template <typename... Args>
129 void SetMacQueueScheduler(std::string type, Args&&... args);
130
131 /**
132 * Helper function used to set the Protection Manager.
133 *
134 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
135 * \param type the type of Protection Manager
136 * \param args A sequence of name-value pairs of the attributes to set.
137 */
138 template <typename... Args>
139 void SetProtectionManager(std::string type, Args&&... args);
140
141 /**
142 * Helper function used to set the Acknowledgment Manager.
143 *
144 * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs.
145 * \param type the type of Acknowledgment Manager
146 * \param args A sequence of name-value pairs of the attributes to set.
147 */
148 template <typename... Args>
149 void SetAckManager(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 * \param device the device within which the MAC object will reside
174 * \param standard the standard to configure during installation
175 * \returns a new MAC object.
176 *
177 * This allows the ns3::WifiHelper class to create MAC objects from ns3::WifiHelper::Install.
178 */
179 virtual Ptr<WifiMac> Create(Ptr<WifiNetDevice> device, WifiStandard standard) const;
180
181 protected:
182 ObjectFactory m_mac; ///< MAC object factory
183 ObjectFactory m_dcf; ///< Txop (DCF) object factory
184 std::map<AcIndex, ObjectFactory, std::greater<>> m_edca; ///< QosTxop (EDCA) object factories
185 ObjectFactory m_channelAccessManager; ///< Channel Access Manager object factory
186 ObjectFactory m_frameExchangeManager; ///< Frame Exchange Manager object factory
187 ObjectFactory m_assocManager; ///< Association Manager
188 ObjectFactory m_queueScheduler; ///< MAC queue scheduler
189 ObjectFactory m_protectionManager; ///< Factory to create a protection manager
190 ObjectFactory m_ackManager; ///< Factory to create an acknowledgment manager
191 ObjectFactory m_muScheduler; ///< Multi-user Scheduler object factory
192 ObjectFactory m_emlsrManager; ///< 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
231{
233}
234
235template <typename... Args>
236void
238{
240}
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
290} // namespace ns3
291
292#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.
Definition: ptr.h:77
create MAC layers for a ns3::WifiNetDevice.
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.
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:86
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:73
Every class exported by the ns3 library is enclosed in the ns3 namespace.