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;
25class WifiMacQueue;
26
27/**
28 * @ingroup wifi
29 *
30 * Enumeration of the reasons to block container queues.
31 */
43
44/**
45 * @brief Stream insertion operator.
46 *
47 * @param os the stream
48 * @param reason the reason to block container queues
49 * @returns a reference to the stream
50 */
51inline std::ostream&
52operator<<(std::ostream& os, WifiQueueBlockedReason reason)
53{
54 switch (reason)
55 {
57 return (os << "WAITING_ADDBA_RESP");
59 return (os << "POWER_SAVE_MODE");
61 return (os << "USING_OTHER_EMLSR_LINK");
63 return (os << "WAITING_EMLSR_TRANSITION_DELAY");
65 return (os << "TID_NOT_MAPPED");
67 return (os << "WAIT_UNTIL_DTIM");
69 return (os << "TX_GROUP_AFTER_DTIM");
71 return (os << "REASONS_COUNT");
72 default:
73 NS_ABORT_MSG("Unknown queue blocked reason");
74 return (os << "unknown");
75 }
76}
77
78/**
79 * @ingroup wifi
80 *
81 * WifiMacQueueScheduler is an abstract base class defining the public interface
82 * for a wifi MAC queue scheduler.
83 */
85{
86 public:
87 /**
88 * @brief Get the type ID.
89 * @return the object TypeId
90 */
91 static TypeId GetTypeId();
92
93 /**
94 * Set the wifi MAC.
95 *
96 * @param mac the wifi MAC
97 */
98 virtual void SetWifiMac(Ptr<WifiMac> mac);
99
100 /**
101 * Set the Wifi MAC queue associated with the given Access Category.
102 *
103 * @param ac the Access Category
104 * @param queue the Wifi MAC queue
105 */
106 virtual void SetWifiMacQueue(AcIndex ac, Ptr<WifiMacQueue> queue);
107
108 /**
109 * Get the next queue to serve, which is guaranteed to contain at least an MPDU whose lifetime
110 * has not expired. Queues containing MPDUs that cannot be sent over the given link, if any, or
111 * on any link, otherwise, are ignored if and only if <i>skipBlockedQueues</i> is true.
112 *
113 * @param ac the Access Category that we want to serve
114 * @param linkId the ID of the link on which MPDUs contained in the returned queue must be
115 * allowed to be sent
116 * @param skipBlockedQueues whether queues containing MPDUs that cannot be sent over the given
117 * link, if any, or on any link, otherwise, must be ignored
118 * @return the ID of the selected container queue (if any)
119 */
120 virtual std::optional<WifiContainerQueueId> GetNext(AcIndex ac,
121 std::optional<uint8_t> linkId,
122 bool skipBlockedQueues = true) = 0;
123 /**
124 * Get the next queue to serve after the given one. The returned queue is guaranteed to contain
125 * at least an MPDU whose lifetime has not expired. Queues containing MPDUs that cannot be sent
126 * over the given link, if any, or on any link, otherwise, are ignored if and only if
127 * <i>skipBlockedQueues</i> is true.
128 *
129 * @param ac the Access Category that we want to serve
130 * @param linkId the ID of the link on which MPDUs contained in the returned queue must be
131 * allowed to be sent
132 * @param prevQueueId the ID of the container queue served previously
133 * @param skipBlockedQueues whether queues containing MPDUs that cannot be sent over the given
134 * link, if any, or on any link, otherwise, must be ignored
135 * @return the ID of the selected container queue (if any)
136 */
137 virtual std::optional<WifiContainerQueueId> GetNext(AcIndex ac,
138 std::optional<uint8_t> linkId,
139 const WifiContainerQueueId& prevQueueId,
140 bool skipBlockedQueues = true) = 0;
141
142 /**
143 * Get the list of the IDs of the links the given MPDU (belonging to the given
144 * Access Category) can be sent over.
145 *
146 * @param ac the given Access Category
147 * @param mpdu the given MPDU
148 * @param ignoredReasons list of reasons for blocking a link that are ignored
149 * @return the list of the IDs of the links the given MPDU can be sent over
150 */
151 virtual std::list<uint8_t> GetLinkIds(
152 AcIndex ac,
154 const std::list<WifiQueueBlockedReason>& ignoredReasons = {}) = 0;
155
156 /**
157 * Block the given set of links for the container queues of the given types and
158 * Access Category that hold frames having the given Receiver Address (RA),
159 * Transmitter Address (TA) and TID (if needed) for the given reason, such that
160 * frames in these queues are not transmitted on the given set of links.
161 *
162 * @param reason the reason for blocking the queues
163 * @param ac the given Access Category
164 * @param types the types of the queues to block
165 * @param rxAddress the Receiver Address (RA) of the frames
166 * @param txAddress the Transmitter Address (TA) of the frames
167 * @param tids the TIDs optionally identifying the queues to block
168 * @param linkIds set of links to block (empty to block all setup links)
169 */
171 AcIndex ac,
172 const std::list<WifiContainerQueueType>& types,
173 const Mac48Address& rxAddress,
174 const Mac48Address& txAddress,
175 const std::set<uint8_t>& tids = {},
176 const std::set<uint8_t>& linkIds = {}) = 0;
177 /**
178 * Unblock the given set of links for the container queues of the given types and
179 * Access Category that hold frames having the given Receiver Address (RA),
180 * Transmitter Address (TA) and TID (if needed) for the given reason, such that
181 * frames in these queues can be transmitted on the given set of links.
182 *
183 * @param reason the reason for unblocking the queues
184 * @param ac the given Access Category
185 * @param types the types of the queues to unblock
186 * @param rxAddress the Receiver Address (RA) of the frames
187 * @param txAddress the Transmitter Address (TA) of the frames
188 * @param tids the TIDs optionally identifying the queues to unblock
189 * @param linkIds set of links to unblock (empty to unblock all setup links)
190 */
192 AcIndex ac,
193 const std::list<WifiContainerQueueType>& types,
194 const Mac48Address& rxAddress,
195 const Mac48Address& txAddress,
196 const std::set<uint8_t>& tids = {},
197 const std::set<uint8_t>& linkIds = {}) = 0;
198
199 /**
200 * Block the given set of links for all the container queues of the given receiver
201 * address types for the given reason.
202 *
203 * @param reason the reason for blocking the queues
204 * @param linkIds set of links to block (empty to block all setup links)
205 * @param addrTypes set of receiver address types (empty to block all types)
206 */
208 const std::set<uint8_t>& linkIds = {},
209 const std::set<WifiRcvAddr>& addrTypes = {}) = 0;
210
211 /**
212 * Unblock the given set of links for all the container queues of the given receiver
213 * address types for the given reason.
214 *
215 * @param reason the reason for unblocking the queues
216 * @param linkIds set of links to unblock (empty to unblock all setup links)
217 * @param addrTypes set of receiver address types (empty to unblock all types)
218 */
220 const std::set<uint8_t>& linkIds = {},
221 const std::set<WifiRcvAddr>& addrTypes = {}) = 0;
222
223 /**
224 * Return whether all the container queues of the given receiver address type (if different
225 * than COUNT, or of any receiver address type, otherwise) are blocked for the given link for
226 * the given reason (if different than REASONS_COUNT, or for any reason, otherwise).
227 *
228 * @param linkId the ID of the given link
229 * @param addrType receiver address types (empty to block all types)
230 * @param reason the reason to check (if different than REASONS_COUNT)
231 * @return whether all the container queues are blocked for the given link
232 */
234 uint8_t linkId,
237
238 /// Bitset identifying the reasons to block individual links for a container queue
239 using Mask = std::bitset<static_cast<std::size_t>(WifiQueueBlockedReason::REASONS_COUNT)>;
240
241 /**
242 * Get the mask associated with the given container queue indicating whether the given link
243 * is blocked and for which reason, provided that the given container queue exists and has
244 * a mask for the given link.
245 *
246 * @param ac the given Access Category
247 * @param queueId the ID of the given container queue
248 * @param linkId the ID of the given link
249 * @return the mask associated with the given container queue for the given link
250 */
251 virtual std::optional<Mask> GetQueueLinkMask(AcIndex ac,
252 const WifiContainerQueueId& queueId,
253 uint8_t linkId) = 0;
254
255 /**
256 * Check whether an MPDU has to be dropped before enqueuing the given MPDU.
257 *
258 * @param ac the Access Category of the MPDU being enqueued
259 * @param mpdu the MPDU to enqueue
260 * @return a pointer to the MPDU to drop, if any, or a null pointer, otherwise
261 */
263 /**
264 * Notify the scheduler that the given MPDU has been enqueued by the given Access
265 * Category. The container queue in which the MPDU has been enqueued must be
266 * assigned a priority value.
267 *
268 * @param ac the Access Category of the enqueued MPDU
269 * @param mpdu the enqueued MPDU
270 */
271 virtual void NotifyEnqueue(AcIndex ac, Ptr<WifiMpdu> mpdu) = 0;
272 /**
273 * Notify the scheduler that the given list of MPDUs have been dequeued by the
274 * given Access Category. The container queues which became empty after dequeuing
275 * the MPDUs are removed from the sorted list of queues.
276 *
277 * @param ac the Access Category of the dequeued MPDUs
278 * @param mpdus the list of dequeued MPDUs
279 */
280 virtual void NotifyDequeue(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
281 /**
282 * Notify the scheduler that the given list of MPDUs have been removed by the
283 * given Access Category. The container queues which became empty after removing
284 * the MPDUs are removed from the sorted list of queues.
285 *
286 * @param ac the Access Category of the removed MPDUs
287 * @param mpdus the list of removed MPDUs
288 */
289 virtual void NotifyRemove(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
290
291 protected:
292 void DoDispose() override;
293
294 /**
295 * Get the wifi MAC.
296 *
297 * @return the wifi MAC
298 */
299 Ptr<WifiMac> GetMac() const;
300
301 private:
302 Ptr<WifiMac> m_mac; //!< MAC layer
303};
304
305} // namespace ns3
306
307#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
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
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 SetWifiMacQueue(AcIndex ac, Ptr< WifiMacQueue > queue)
Set the Wifi MAC queue associated with the given Access Category.
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
Structure identifying a container queue.