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 /// Bitset identifying the reasons to block individual links for a container queue
179 using Mask = std::bitset<static_cast<std::size_t>(WifiQueueBlockedReason::REASONS_COUNT)>;
180
181 /**
182 * Get the mask associated with the given container queue indicating whether the given link
183 * is blocked and for which reason, provided that the given container queue exists and has
184 * a mask for the given link.
185 *
186 * \param ac the given Access Category
187 * \param queueId the ID of the given container queue
188 * \param linkId the ID of the given link
189 * \return the mask associated with the given container queue for the given link
190 */
191 virtual std::optional<Mask> GetQueueLinkMask(AcIndex ac,
192 const WifiContainerQueueId& queueId,
193 uint8_t linkId) = 0;
194
195 /**
196 * Check whether an MPDU has to be dropped before enqueuing the given MPDU.
197 *
198 * \param ac the Access Category of the MPDU being enqueued
199 * \param mpdu the MPDU to enqueue
200 * \return a pointer to the MPDU to drop, if any, or a null pointer, otherwise
201 */
203 /**
204 * Notify the scheduler that the given MPDU has been enqueued by the given Access
205 * Category. The container queue in which the MPDU has been enqueued must be
206 * assigned a priority value.
207 *
208 * \param ac the Access Category of the enqueued MPDU
209 * \param mpdu the enqueued MPDU
210 */
211 virtual void NotifyEnqueue(AcIndex ac, Ptr<WifiMpdu> mpdu) = 0;
212 /**
213 * Notify the scheduler that the given list of MPDUs have been dequeued by the
214 * given Access Category. The container queues which became empty after dequeuing
215 * the MPDUs are removed from the sorted list of queues.
216 *
217 * \param ac the Access Category of the dequeued MPDUs
218 * \param mpdus the list of dequeued MPDUs
219 */
220 virtual void NotifyDequeue(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
221 /**
222 * Notify the scheduler that the given list of MPDUs have been removed by the
223 * given Access Category. The container queues which became empty after removing
224 * the MPDUs are removed from the sorted list of queues.
225 *
226 * \param ac the Access Category of the removed MPDUs
227 * \param mpdus the list of removed MPDUs
228 */
229 virtual void NotifyRemove(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
230
231 protected:
232 void DoDispose() override;
233
234 /**
235 * Get the wifi MAC.
236 *
237 * \return the wifi MAC
238 */
239 Ptr<WifiMac> GetMac() const;
240
241 private:
242 Ptr<WifiMac> m_mac; //!< MAC layer
243};
244
245} // namespace ns3
246
247#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:48
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.
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: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