A Discrete-Event Network Simulator
API
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 
31 namespace ns3
32 {
33 
34 class WifiMpdu;
35 class WifiMac;
36 
42 enum class WifiQueueBlockedReason : uint8_t
43 {
50 };
51 
59 inline std::ostream&
60 operator<<(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 
89 {
90  public:
95  static TypeId GetTypeId();
96 
102  virtual void SetWifiMac(Ptr<WifiMac> mac);
103 
114  virtual std::optional<WifiContainerQueueId> GetNext(AcIndex ac,
115  std::optional<uint8_t> linkId) = 0;
127  virtual std::optional<WifiContainerQueueId> GetNext(
128  AcIndex ac,
129  std::optional<uint8_t> linkId,
130  const WifiContainerQueueId& prevQueueId) = 0;
131 
140  virtual std::list<uint8_t> GetLinkIds(AcIndex ac, Ptr<const WifiMpdu> mpdu) = 0;
141 
156  virtual void BlockQueues(WifiQueueBlockedReason reason,
157  AcIndex ac,
158  const std::list<WifiContainerQueueType>& types,
159  const Mac48Address& rxAddress,
160  const Mac48Address& txAddress,
161  const std::set<uint8_t>& tids = {},
162  const std::set<uint8_t>& linkIds = {}) = 0;
178  AcIndex ac,
179  const std::list<WifiContainerQueueType>& types,
180  const Mac48Address& rxAddress,
181  const Mac48Address& txAddress,
182  const std::set<uint8_t>& tids = {},
183  const std::set<uint8_t>& linkIds = {}) = 0;
184 
186  using Mask = std::bitset<static_cast<std::size_t>(WifiQueueBlockedReason::REASONS_COUNT)>;
187 
198  virtual std::optional<Mask> GetQueueLinkMask(AcIndex ac,
199  const WifiContainerQueueId& queueId,
200  uint8_t linkId) = 0;
201 
218  virtual void NotifyEnqueue(AcIndex ac, Ptr<WifiMpdu> mpdu) = 0;
227  virtual void NotifyDequeue(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
236  virtual void NotifyRemove(AcIndex ac, const std::list<Ptr<WifiMpdu>>& mpdus) = 0;
237 
238  protected:
239  void DoDispose() override;
240 
246  Ptr<WifiMac> GetMac() const;
247 
248  private:
250 };
251 
252 } // namespace ns3
253 
254 #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
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 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 Ptr< WifiMpdu > HasToDropBeforeEnqueue(AcIndex ac, Ptr< WifiMpdu > mpdu)=0
Check whether an MPDU has to be dropped before enqueuing the given MPDU.
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::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::list< uint8_t > GetLinkIds(AcIndex ac, Ptr< const WifiMpdu > mpdu)=0
Get the list of the IDs of the links the given MPDU (belonging to the given Access Category) can be s...
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 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< 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...
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 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.
#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::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:159
mac
Definition: third.py:92
#define list