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 * 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: Stefano Avallone <stavallo@unina.it>
18 */
19
20#ifndef WIFI_MAC_QUEUE_SCHEDULER_H
21#define WIFI_MAC_QUEUE_SCHEDULER_H
22
23#include "qos-utils.h"
25
26#include "ns3/object.h"
27
28#include <bitset>
29#include <optional>
30
31namespace ns3
32{
33
34class WifiMpdu;
35class WifiMac;
36
37/**
38 * \ingroup wifi
39 *
40 * Enumeration of the reasons to block container queues.
41 */
42enum class WifiQueueBlockedReason : uint8_t
43{
50};
51
52/**
53 * \brief Stream insertion operator.
54 *
55 * \param os the stream
56 * \param reason the reason to block container queues
57 * \returns a reference to the stream
58 */
59inline std::ostream&
60operator<<(std::ostream& os, WifiQueueBlockedReason reason)
61{
62 switch (reason)
63 {
65 return (os << "WAITING_ADDBA_RESP");
67 return (os << "POWER_SAVE_MODE");
69 return (os << "USING_OTHER_EMLSR_LINK");
71 return (os << "WAITING_EMLSR_TRANSITION_DELAY");
73 return (os << "TID_NOT_MAPPED");
75 return (os << "REASONS_COUNT");
76 default:
77 NS_ABORT_MSG("Unknown queue blocked reason");
78 return (os << "unknown");
79 }
80}
81
82/**
83 * \ingroup wifi
84 *
85 * WifiMacQueueScheduler is an abstract base class defining the public interface
86 * for a wifi MAC queue scheduler.
87 */
89{
90 public:
91 /**
92 * \brief Get the type ID.
93 * \return the object TypeId
94 */
95 static TypeId GetTypeId();
96
97 /**
98 * Set the wifi MAC.
99 *
100 * \param mac the wifi MAC
101 */
102 virtual void SetWifiMac(Ptr<WifiMac> mac);
103
104 /**
105 * Get the next queue to serve, which is guaranteed to contain at least an MPDU
106 * whose lifetime has not expired. Queues containing MPDUs that cannot be sent
107 * over the given link (if any) are ignored.
108 *
109 * \param ac the Access Category that we want to serve
110 * \param linkId the ID of the link on which MPDUs contained in the returned queue must be
111 * allowed to be sent
112 * \return the ID of the selected container queue (if any)
113 */
114 virtual std::optional<WifiContainerQueueId> GetNext(AcIndex ac,
115 std::optional<uint8_t> linkId) = 0;
116 /**
117 * Get the next queue to serve after the given one. The returned queue is
118 * guaranteed to contain at least an MPDU whose lifetime has not expired.
119 * Queues containing MPDUs that cannot be sent over the given link (if any) are ignored.
120 *
121 * \param ac the Access Category that we want to serve
122 * \param linkId the ID of the link on which MPDUs contained in the returned queue must be
123 * allowed to be sent
124 * \param prevQueueId the ID of the container queue served previously
125 * \return the ID of the selected container queue (if any)
126 */
127 virtual std::optional<WifiContainerQueueId> GetNext(
128 AcIndex ac,
129 std::optional<uint8_t> linkId,
130 const WifiContainerQueueId& prevQueueId) = 0;
131
132 /**
133 * Get the list of the IDs of the links the given MPDU (belonging to the given
134 * Access Category) can be sent over.
135 *
136 * \param ac the given Access Category
137 * \param mpdu the given MPDU
138 * \param ignoredReasons list of reasons for blocking a link that are ignored
139 * \return the list of the IDs of the links the given MPDU can be sent over
140 */
141 virtual std::list<uint8_t> GetLinkIds(
142 AcIndex ac,
144 const std::list<WifiQueueBlockedReason>& ignoredReasons = {}) = 0;
145
146 /**
147 * Block the given set of links for the container queues of the given types and
148 * Access Category that hold frames having the given Receiver Address (RA),
149 * Transmitter Address (TA) and TID (if needed) for the given reason, such that
150 * frames in these queues are not transmitted on the given set of links.
151 *
152 * \param reason the reason for blocking the queues
153 * \param ac the given Access Category
154 * \param types the types of the queues to block
155 * \param rxAddress the Receiver Address (RA) of the frames
156 * \param txAddress the Transmitter Address (TA) of the frames
157 * \param tids the TIDs optionally identifying the queues to block
158 * \param linkIds set of links to block (empty to block all setup links)
159 */
161 AcIndex ac,
162 const std::list<WifiContainerQueueType>& types,
163 const Mac48Address& rxAddress,
164 const Mac48Address& txAddress,
165 const std::set<uint8_t>& tids = {},
166 const std::set<uint8_t>& linkIds = {}) = 0;
167 /**
168 * Unblock the given set of links for the container queues of the given types and
169 * Access Category that hold frames having the given Receiver Address (RA),
170 * Transmitter Address (TA) and TID (if needed) for the given reason, such that
171 * frames in these queues can be transmitted on the given set of links.
172 *
173 * \param reason the reason for unblocking the queues
174 * \param ac the given Access Category
175 * \param types the types of the queues to unblock
176 * \param rxAddress the Receiver Address (RA) of the frames
177 * \param txAddress the Transmitter Address (TA) of the frames
178 * \param tids the TIDs optionally identifying the queues to unblock
179 * \param linkIds set of links to unblock (empty to unblock all setup links)
180 */
182 AcIndex ac,
183 const std::list<WifiContainerQueueType>& types,
184 const Mac48Address& rxAddress,
185 const Mac48Address& txAddress,
186 const std::set<uint8_t>& tids = {},
187 const std::set<uint8_t>& linkIds = {}) = 0;
188
189 /// Bitset identifying the reasons to block individual links for a container queue
190 using Mask = std::bitset<static_cast<std::size_t>(WifiQueueBlockedReason::REASONS_COUNT)>;
191
192 /**
193 * Get the mask associated with the given container queue indicating whether the given link
194 * is blocked and for which reason, provided that the given container queue exists and has
195 * a mask for the given link.
196 *
197 * \param ac the given Access Category
198 * \param queueId the ID of the given container queue
199 * \param linkId the ID of the given link
200 * \return the mask associated with the given container queue for the given link
201 */
202 virtual std::optional<Mask> GetQueueLinkMask(AcIndex ac,
203 const WifiContainerQueueId& queueId,
204 uint8_t linkId) = 0;
205
206 /**
207 * Check whether an MPDU has to be dropped before enqueuing the given MPDU.
208 *
209 * \param ac the Access Category of the MPDU being enqueued
210 * \param mpdu the MPDU to enqueue
211 * \return a pointer to the MPDU to drop, if any, or a null pointer, otherwise
212 */
214 /**
215 * Notify the scheduler that the given MPDU has been enqueued by the given Access
216 * Category. The container queue in which the MPDU has been enqueued must be
217 * assigned a priority value.
218 *
219 * \param ac the Access Category of the enqueued MPDU
220 * \param mpdu the enqueued MPDU
221 */
222 virtual void NotifyEnqueue(AcIndex ac, Ptr<WifiMpdu> mpdu) = 0;
223 /**
224 * Notify the scheduler that the given list of MPDUs have been dequeued by the
225 * given Access Category. The container queues which became empty after dequeuing
226 * the MPDUs are removed from the sorted list of queues.
227 *
228 * \param ac the Access Category of the dequeued MPDUs
229 * \param mpdus the list of dequeued MPDUs
230 */
231 virtual void NotifyDequeue(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
232 /**
233 * Notify the scheduler that the given list of MPDUs have been removed by the
234 * given Access Category. The container queues which became empty after removing
235 * the MPDUs are removed from the sorted list of queues.
236 *
237 * \param ac the Access Category of the removed MPDUs
238 * \param mpdus the list of removed MPDUs
239 */
240 virtual void NotifyRemove(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
241
242 protected:
243 void DoDispose() override;
244
245 /**
246 * Get the wifi MAC.
247 *
248 * \return the wifi MAC
249 */
250 Ptr<WifiMac> GetMac() const;
251
252 private:
253 Ptr<WifiMac> m_mac; //!< MAC layer
254};
255
256} // namespace ns3
257
258#endif /* WIFI_MAC_QUEUE_SCHEDULER_H */
an EUI-48 address
Definition: mac48-address.h:46
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
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 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.
Ptr< WifiMac > m_mac
MAC layer.
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 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:49
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:73
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:159
std::tuple< WifiContainerQueueType, WifiReceiverAddressType, Mac48Address, std::optional< uint8_t > > WifiContainerQueueId
Tuple (queue type, receiver address type, Address, TID) identifying a container queue.