A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-mac-queue-scheduler.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
9#ifndef WIFI_MAC_QUEUE_SCHEDULER_H
10#define WIFI_MAC_QUEUE_SCHEDULER_H
11
12#include "qos-utils.h"
14
15#include "ns3/object.h"
16
17#include <bitset>
18#include <optional>
19
20namespace ns3
21{
22
23class WifiMpdu;
24class WifiMac;
25
26/**
27 * @ingroup wifi
28 *
29 * Enumeration of the reasons to block container queues.
30 */
42
43/**
44 * @brief Stream insertion operator.
45 *
46 * @param os the stream
47 * @param reason the reason to block container queues
48 * @returns a reference to the stream
49 */
50inline std::ostream&
51operator<<(std::ostream& os, WifiQueueBlockedReason reason)
52{
53 switch (reason)
54 {
56 return (os << "WAITING_ADDBA_RESP");
58 return (os << "POWER_SAVE_MODE");
60 return (os << "USING_OTHER_EMLSR_LINK");
62 return (os << "WAITING_EMLSR_TRANSITION_DELAY");
64 return (os << "TID_NOT_MAPPED");
66 return (os << "WAIT_UNTIL_DTIM");
68 return (os << "TX_GROUP_AFTER_DTIM");
70 return (os << "REASONS_COUNT");
71 default:
72 NS_ABORT_MSG("Unknown queue blocked reason");
73 return (os << "unknown");
74 }
75}
76
77/**
78 * @ingroup wifi
79 *
80 * WifiMacQueueScheduler is an abstract base class defining the public interface
81 * for a wifi MAC queue scheduler.
82 */
84{
85 public:
86 /**
87 * @brief Get the type ID.
88 * @return the object TypeId
89 */
90 static TypeId GetTypeId();
91
92 /**
93 * Set the wifi MAC.
94 *
95 * @param mac the wifi MAC
96 */
97 virtual void SetWifiMac(Ptr<WifiMac> mac);
98
99 /**
100 * Get the next queue to serve, which is guaranteed to contain at least an MPDU whose lifetime
101 * has not expired. Queues containing MPDUs that cannot be sent over the given link, if any, or
102 * on any link, otherwise, are ignored if and only if <i>skipBlockedQueues</i> is true.
103 *
104 * @param ac the Access Category that we want to serve
105 * @param linkId the ID of the link on which MPDUs contained in the returned queue must be
106 * allowed to be sent
107 * @param skipBlockedQueues whether queues containing MPDUs that cannot be sent over the given
108 * link, if any, or on any link, otherwise, must be ignored
109 * @return the ID of the selected container queue (if any)
110 */
111 virtual std::optional<WifiContainerQueueId> GetNext(AcIndex ac,
112 std::optional<uint8_t> linkId,
113 bool skipBlockedQueues = true) = 0;
114 /**
115 * Get the next queue to serve after the given one. The returned queue is guaranteed to contain
116 * at least an MPDU whose lifetime has not expired. Queues containing MPDUs that cannot be sent
117 * over the given link, if any, or on any link, otherwise, are ignored if and only if
118 * <i>skipBlockedQueues</i> is true.
119 *
120 * @param ac the Access Category that we want to serve
121 * @param linkId the ID of the link on which MPDUs contained in the returned queue must be
122 * allowed to be sent
123 * @param prevQueueId the ID of the container queue served previously
124 * @param skipBlockedQueues whether queues containing MPDUs that cannot be sent over the given
125 * link, if any, or on any link, otherwise, must be ignored
126 * @return the ID of the selected container queue (if any)
127 */
128 virtual std::optional<WifiContainerQueueId> GetNext(AcIndex ac,
129 std::optional<uint8_t> linkId,
130 const WifiContainerQueueId& prevQueueId,
131 bool skipBlockedQueues = true) = 0;
132
133 /**
134 * Get the list of the IDs of the links the given MPDU (belonging to the given
135 * Access Category) can be sent over.
136 *
137 * @param ac the given Access Category
138 * @param mpdu the given MPDU
139 * @param ignoredReasons list of reasons for blocking a link that are ignored
140 * @return the list of the IDs of the links the given MPDU can be sent over
141 */
142 virtual std::list<uint8_t> GetLinkIds(
143 AcIndex ac,
145 const std::list<WifiQueueBlockedReason>& ignoredReasons = {}) = 0;
146
147 /**
148 * Block the given set of links for the container queues of the given types and
149 * Access Category that hold frames having the given Receiver Address (RA),
150 * Transmitter Address (TA) and TID (if needed) for the given reason, such that
151 * frames in these queues are not transmitted on the given set of links.
152 *
153 * @param reason the reason for blocking the queues
154 * @param ac the given Access Category
155 * @param types the types of the queues to block
156 * @param rxAddress the Receiver Address (RA) of the frames
157 * @param txAddress the Transmitter Address (TA) of the frames
158 * @param tids the TIDs optionally identifying the queues to block
159 * @param linkIds set of links to block (empty to block all setup links)
160 */
162 AcIndex ac,
163 const std::list<WifiContainerQueueType>& types,
164 const Mac48Address& rxAddress,
165 const Mac48Address& txAddress,
166 const std::set<uint8_t>& tids = {},
167 const std::set<uint8_t>& linkIds = {}) = 0;
168 /**
169 * Unblock the given set of links for the container queues of the given types and
170 * Access Category that hold frames having the given Receiver Address (RA),
171 * Transmitter Address (TA) and TID (if needed) for the given reason, such that
172 * frames in these queues can be transmitted on the given set of links.
173 *
174 * @param reason the reason for unblocking the queues
175 * @param ac the given Access Category
176 * @param types the types of the queues to unblock
177 * @param rxAddress the Receiver Address (RA) of the frames
178 * @param txAddress the Transmitter Address (TA) of the frames
179 * @param tids the TIDs optionally identifying the queues to unblock
180 * @param linkIds set of links to unblock (empty to unblock all setup links)
181 */
183 AcIndex ac,
184 const std::list<WifiContainerQueueType>& types,
185 const Mac48Address& rxAddress,
186 const Mac48Address& txAddress,
187 const std::set<uint8_t>& tids = {},
188 const std::set<uint8_t>& linkIds = {}) = 0;
189
190 /**
191 * Block the given set of links for all the container queues of the given receiver
192 * address types for the given reason.
193 *
194 * @param reason the reason for blocking the queues
195 * @param linkIds set of links to block (empty to block all setup links)
196 * @param addrTypes set of receiver address types (empty to block all types)
197 */
199 const std::set<uint8_t>& linkIds = {},
200 const std::set<WifiRcvAddr>& addrTypes = {}) = 0;
201
202 /**
203 * Unblock the given set of links for all the container queues of the given receiver
204 * address types for the given reason.
205 *
206 * @param reason the reason for unblocking the queues
207 * @param linkIds set of links to unblock (empty to unblock all setup links)
208 * @param addrTypes set of receiver address types (empty to unblock all types)
209 */
211 const std::set<uint8_t>& linkIds = {},
212 const std::set<WifiRcvAddr>& addrTypes = {}) = 0;
213
214 /**
215 * Return whether all the container queues of the given receiver address type (if different
216 * than COUNT, or of any receiver address type, otherwise) are blocked for the given link for
217 * the given reason (if different than REASONS_COUNT, or for any reason, otherwise).
218 *
219 * @param linkId the ID of the given link
220 * @param addrType receiver address types (empty to block all types)
221 * @param reason the reason to check (if different than REASONS_COUNT)
222 * @return whether all the container queues are blocked for the given link
223 */
225 uint8_t linkId,
228
229 /// Bitset identifying the reasons to block individual links for a container queue
230 using Mask = std::bitset<static_cast<std::size_t>(WifiQueueBlockedReason::REASONS_COUNT)>;
231
232 /**
233 * Get the mask associated with the given container queue indicating whether the given link
234 * is blocked and for which reason, provided that the given container queue exists and has
235 * a mask for the given link.
236 *
237 * @param ac the given Access Category
238 * @param queueId the ID of the given container queue
239 * @param linkId the ID of the given link
240 * @return the mask associated with the given container queue for the given link
241 */
242 virtual std::optional<Mask> GetQueueLinkMask(AcIndex ac,
243 const WifiContainerQueueId& queueId,
244 uint8_t linkId) = 0;
245
246 /**
247 * Check whether an MPDU has to be dropped before enqueuing the given MPDU.
248 *
249 * @param ac the Access Category of the MPDU being enqueued
250 * @param mpdu the MPDU to enqueue
251 * @return a pointer to the MPDU to drop, if any, or a null pointer, otherwise
252 */
254 /**
255 * Notify the scheduler that the given MPDU has been enqueued by the given Access
256 * Category. The container queue in which the MPDU has been enqueued must be
257 * assigned a priority value.
258 *
259 * @param ac the Access Category of the enqueued MPDU
260 * @param mpdu the enqueued MPDU
261 */
262 virtual void NotifyEnqueue(AcIndex ac, Ptr<WifiMpdu> mpdu) = 0;
263 /**
264 * Notify the scheduler that the given list of MPDUs have been dequeued by the
265 * given Access Category. The container queues which became empty after dequeuing
266 * the MPDUs are removed from the sorted list of queues.
267 *
268 * @param ac the Access Category of the dequeued MPDUs
269 * @param mpdus the list of dequeued MPDUs
270 */
271 virtual void NotifyDequeue(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
272 /**
273 * Notify the scheduler that the given list of MPDUs have been removed by the
274 * given Access Category. The container queues which became empty after removing
275 * the MPDUs are removed from the sorted list of queues.
276 *
277 * @param ac the Access Category of the removed MPDUs
278 * @param mpdus the list of removed MPDUs
279 */
280 virtual void NotifyRemove(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
281
282 protected:
283 void DoDispose() override;
284
285 /**
286 * Get the wifi MAC.
287 *
288 * @return the wifi MAC
289 */
290 Ptr<WifiMac> GetMac() const;
291
292 private:
293 Ptr<WifiMac> m_mac; //!< MAC layer
294};
295
296} // namespace ns3
297
298#endif /* WIFI_MAC_QUEUE_SCHEDULER_H */
an EUI-48 address
Object()
Caller graph was not generated because of its size.
Definition object.cc:93
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
a unique identifier for an interface.
Definition type-id.h:50
base class for all MAC-level wifi objects.
Definition wifi-mac.h:90
WifiMacQueueScheduler is an abstract base class defining the public interface for a wifi MAC queue sc...
virtual void NotifyRemove(AcIndex ac, const std::list< Ptr< WifiMpdu > > &mpdus)=0
Notify the scheduler that the given list of MPDUs have been removed by the given Access Category.
virtual void SetWifiMac(Ptr< WifiMac > mac)
Set the wifi MAC.
Ptr< WifiMac > GetMac() const
Get the wifi MAC.
virtual void UnblockQueues(WifiQueueBlockedReason reason, AcIndex ac, const std::list< WifiContainerQueueType > &types, const Mac48Address &rxAddress, const Mac48Address &txAddress, const std::set< uint8_t > &tids={}, const std::set< uint8_t > &linkIds={})=0
Unblock the given set of links for the container queues of the given types and Access Category that h...
std::bitset< static_cast< std::size_t >(WifiQueueBlockedReason::REASONS_COUNT)> Mask
Bitset identifying the reasons to block individual links for a container queue.
virtual void BlockAllQueues(WifiQueueBlockedReason reason, const std::set< uint8_t > &linkIds={}, const std::set< WifiRcvAddr > &addrTypes={})=0
Block the given set of links for all the container queues of the given receiver address types for the...
virtual std::optional< WifiContainerQueueId > GetNext(AcIndex ac, std::optional< uint8_t > linkId, bool skipBlockedQueues=true)=0
Get the next queue to serve, which is guaranteed to contain at least an MPDU whose lifetime has not e...
virtual void BlockQueues(WifiQueueBlockedReason reason, AcIndex ac, const std::list< WifiContainerQueueType > &types, const Mac48Address &rxAddress, const Mac48Address &txAddress, const std::set< uint8_t > &tids={}, const std::set< uint8_t > &linkIds={})=0
Block the given set of links for the container queues of the given types and Access Category that hol...
virtual std::list< uint8_t > GetLinkIds(AcIndex ac, Ptr< const WifiMpdu > mpdu, const std::list< WifiQueueBlockedReason > &ignoredReasons={})=0
Get the list of the IDs of the links the given MPDU (belonging to the given Access Category) can be s...
virtual Ptr< WifiMpdu > HasToDropBeforeEnqueue(AcIndex ac, Ptr< WifiMpdu > mpdu)=0
Check whether an MPDU has to be dropped before enqueuing the given MPDU.
virtual void NotifyDequeue(AcIndex ac, const std::list< Ptr< WifiMpdu > > &mpdus)=0
Notify the scheduler that the given list of MPDUs have been dequeued by the given Access Category.
virtual std::optional< Mask > GetQueueLinkMask(AcIndex ac, const WifiContainerQueueId &queueId, uint8_t linkId)=0
Get the mask associated with the given container queue indicating whether the given link is blocked a...
virtual void NotifyEnqueue(AcIndex ac, Ptr< WifiMpdu > mpdu)=0
Notify the scheduler that the given MPDU has been enqueued by the given Access Category.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
virtual void UnblockAllQueues(WifiQueueBlockedReason reason, const std::set< uint8_t > &linkIds={}, const std::set< WifiRcvAddr > &addrTypes={})=0
Unblock the given set of links for all the container queues of the given receiver address types for t...
virtual std::optional< WifiContainerQueueId > GetNext(AcIndex ac, std::optional< uint8_t > linkId, const WifiContainerQueueId &prevQueueId, bool skipBlockedQueues=true)=0
Get the next queue to serve after the given one.
virtual bool GetAllQueuesBlockedOnLink(uint8_t linkId, WifiRcvAddr addrType=WifiRcvAddr::COUNT, WifiQueueBlockedReason reason=WifiQueueBlockedReason::REASONS_COUNT)=0
Return whether all the container queues of the given receiver address type (if different than COUNT,...
WifiMpdu stores a (const) packet along with a MAC header.
Definition wifi-mpdu.h:51
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
WifiQueueBlockedReason
Enumeration of the reasons to block container queues.
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.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
WifiRcvAddr
enumeration of frame types based on receiver address
std::tuple< WifiContainerQueueType, WifiRcvAddr, Mac48Address, std::optional< uint8_t > > WifiContainerQueueId
Tuple (queue type, receiver address type, Address, TID) identifying a container queue.