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 */
40
41/**
42 * @brief Stream insertion operator.
43 *
44 * @param os the stream
45 * @param reason the reason to block container queues
46 * @returns a reference to the stream
47 */
48inline std::ostream&
49operator<<(std::ostream& os, WifiQueueBlockedReason reason)
50{
51 switch (reason)
52 {
54 return (os << "WAITING_ADDBA_RESP");
56 return (os << "POWER_SAVE_MODE");
58 return (os << "USING_OTHER_EMLSR_LINK");
60 return (os << "WAITING_EMLSR_TRANSITION_DELAY");
62 return (os << "TID_NOT_MAPPED");
64 return (os << "REASONS_COUNT");
65 default:
66 NS_ABORT_MSG("Unknown queue blocked reason");
67 return (os << "unknown");
68 }
69}
70
71/**
72 * @ingroup wifi
73 *
74 * WifiMacQueueScheduler is an abstract base class defining the public interface
75 * for a wifi MAC queue scheduler.
76 */
78{
79 public:
80 /**
81 * @brief Get the type ID.
82 * @return the object TypeId
83 */
84 static TypeId GetTypeId();
85
86 /**
87 * Set the wifi MAC.
88 *
89 * @param mac the wifi MAC
90 */
91 virtual void SetWifiMac(Ptr<WifiMac> mac);
92
93 /**
94 * Get the next queue to serve, which is guaranteed to contain at least an MPDU
95 * whose lifetime has not expired. Queues containing MPDUs that cannot be sent
96 * over the given link (if any) are ignored.
97 *
98 * @param ac the Access Category that we want to serve
99 * @param linkId the ID of the link on which MPDUs contained in the returned queue must be
100 * allowed to be sent
101 * @return the ID of the selected container queue (if any)
102 */
103 virtual std::optional<WifiContainerQueueId> GetNext(AcIndex ac,
104 std::optional<uint8_t> linkId) = 0;
105 /**
106 * Get the next queue to serve after the given one. The returned queue is
107 * guaranteed to contain at least an MPDU whose lifetime has not expired.
108 * Queues containing MPDUs that cannot be sent over the given link (if any) are ignored.
109 *
110 * @param ac the Access Category that we want to serve
111 * @param linkId the ID of the link on which MPDUs contained in the returned queue must be
112 * allowed to be sent
113 * @param prevQueueId the ID of the container queue served previously
114 * @return the ID of the selected container queue (if any)
115 */
116 virtual std::optional<WifiContainerQueueId> GetNext(
117 AcIndex ac,
118 std::optional<uint8_t> linkId,
119 const WifiContainerQueueId& prevQueueId) = 0;
120
121 /**
122 * Get the list of the IDs of the links the given MPDU (belonging to the given
123 * Access Category) can be sent over.
124 *
125 * @param ac the given Access Category
126 * @param mpdu the given MPDU
127 * @param ignoredReasons list of reasons for blocking a link that are ignored
128 * @return the list of the IDs of the links the given MPDU can be sent over
129 */
130 virtual std::list<uint8_t> GetLinkIds(
131 AcIndex ac,
133 const std::list<WifiQueueBlockedReason>& ignoredReasons = {}) = 0;
134
135 /**
136 * Block the given set of links for the container queues of the given types and
137 * Access Category that hold frames having the given Receiver Address (RA),
138 * Transmitter Address (TA) and TID (if needed) for the given reason, such that
139 * frames in these queues are not transmitted on the given set of links.
140 *
141 * @param reason the reason for blocking the queues
142 * @param ac the given Access Category
143 * @param types the types of the queues to block
144 * @param rxAddress the Receiver Address (RA) of the frames
145 * @param txAddress the Transmitter Address (TA) of the frames
146 * @param tids the TIDs optionally identifying the queues to block
147 * @param linkIds set of links to block (empty to block all setup links)
148 */
150 AcIndex ac,
151 const std::list<WifiContainerQueueType>& types,
152 const Mac48Address& rxAddress,
153 const Mac48Address& txAddress,
154 const std::set<uint8_t>& tids = {},
155 const std::set<uint8_t>& linkIds = {}) = 0;
156 /**
157 * Unblock 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 can be transmitted on the given set of links.
161 *
162 * @param reason the reason for unblocking the queues
163 * @param ac the given Access Category
164 * @param types the types of the queues to unblock
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 unblock
168 * @param linkIds set of links to unblock (empty to unblock 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 /**
179 * Block the given set of links for all the container queues for the given reason.
180 *
181 * @param reason the reason for blocking the queues
182 * @param linkIds set of links to block (empty to block all setup links)
183 */
185 const std::set<uint8_t>& linkIds = {}) = 0;
186
187 /**
188 * Unblock the given set of links for all the container queues for the given reason.
189 *
190 * @param reason the reason for unblocking the queues
191 * @param linkIds set of links to unblock (empty to unblock all setup links)
192 */
194 const std::set<uint8_t>& linkIds = {}) = 0;
195
196 /**
197 * Return whether all the container queues are blocked for the given link for the given
198 * reason, if different than REASONS_COUNT, or for any reason, otherwise.
199 *
200 * @param linkId the ID of the given link
201 * @param reason the reason to check (if different than REASONS_COUNT)
202 * @return whether all the container queues are blocked for the given link
203 */
205 uint8_t linkId,
207
208 /// Bitset identifying the reasons to block individual links for a container queue
209 using Mask = std::bitset<static_cast<std::size_t>(WifiQueueBlockedReason::REASONS_COUNT)>;
210
211 /**
212 * Get the mask associated with the given container queue indicating whether the given link
213 * is blocked and for which reason, provided that the given container queue exists and has
214 * a mask for the given link.
215 *
216 * @param ac the given Access Category
217 * @param queueId the ID of the given container queue
218 * @param linkId the ID of the given link
219 * @return the mask associated with the given container queue for the given link
220 */
221 virtual std::optional<Mask> GetQueueLinkMask(AcIndex ac,
222 const WifiContainerQueueId& queueId,
223 uint8_t linkId) = 0;
224
225 /**
226 * Check whether an MPDU has to be dropped before enqueuing the given MPDU.
227 *
228 * @param ac the Access Category of the MPDU being enqueued
229 * @param mpdu the MPDU to enqueue
230 * @return a pointer to the MPDU to drop, if any, or a null pointer, otherwise
231 */
233 /**
234 * Notify the scheduler that the given MPDU has been enqueued by the given Access
235 * Category. The container queue in which the MPDU has been enqueued must be
236 * assigned a priority value.
237 *
238 * @param ac the Access Category of the enqueued MPDU
239 * @param mpdu the enqueued MPDU
240 */
241 virtual void NotifyEnqueue(AcIndex ac, Ptr<WifiMpdu> mpdu) = 0;
242 /**
243 * Notify the scheduler that the given list of MPDUs have been dequeued by the
244 * given Access Category. The container queues which became empty after dequeuing
245 * the MPDUs are removed from the sorted list of queues.
246 *
247 * @param ac the Access Category of the dequeued MPDUs
248 * @param mpdus the list of dequeued MPDUs
249 */
250 virtual void NotifyDequeue(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
251 /**
252 * Notify the scheduler that the given list of MPDUs have been removed by the
253 * given Access Category. The container queues which became empty after removing
254 * the MPDUs are removed from the sorted list of queues.
255 *
256 * @param ac the Access Category of the removed MPDUs
257 * @param mpdus the list of removed MPDUs
258 */
259 virtual void NotifyRemove(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
260
261 protected:
262 void DoDispose() override;
263
264 /**
265 * Get the wifi MAC.
266 *
267 * @return the wifi MAC
268 */
269 Ptr<WifiMac> GetMac() const;
270
271 private:
272 Ptr<WifiMac> m_mac; //!< MAC layer
273};
274
275} // namespace ns3
276
277#endif /* WIFI_MAC_QUEUE_SCHEDULER_H */
an EUI-48 address
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:49
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 bool GetAllQueuesBlockedOnLink(uint8_t linkId, WifiQueueBlockedReason reason=WifiQueueBlockedReason::REASONS_COUNT)=0
Return whether all the container queues are blocked for the given link for the given reason,...
virtual void SetWifiMac(Ptr< WifiMac > mac)
Set the wifi MAC.
Ptr< WifiMac > GetMac() const
Get the wifi MAC.
virtual void UnblockAllQueues(WifiQueueBlockedReason reason, const std::set< uint8_t > &linkIds={})=0
Unblock the given set of links for all the container queues for the given reason.
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 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 std::optional< WifiContainerQueueId > GetNext(AcIndex ac, std::optional< uint8_t > linkId, const WifiContainerQueueId &prevQueueId)=0
Get the next queue to serve after the given one.
virtual void BlockAllQueues(WifiQueueBlockedReason reason, const std::set< uint8_t > &linkIds={})=0
Block the given set of links for all the container queues for the given reason.
virtual std::optional< WifiContainerQueueId > GetNext(AcIndex ac, std::optional< uint8_t > linkId)=0
Get the next queue to serve, which is guaranteed to contain at least an MPDU whose lifetime has not e...
#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:62
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std:: tuple< WifiContainerQueueType, WifiReceiverAddressType, Mac48Address, std::optional< uint8_t > > WifiContainerQueueId
Tuple (queue type, receiver address type, Address, TID) identifying a container queue.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148