A Discrete-Event Network Simulator
API
wifi-mac-queue-container.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_CONTAINER_H
21 #define WIFI_MAC_QUEUE_CONTAINER_H
22 
23 #include "wifi-mac-queue-elem.h"
24 
25 #include "ns3/mac48-address.h"
26 
27 #include <list>
28 #include <optional>
29 #include <tuple>
30 #include <unordered_map>
31 
32 namespace ns3
33 {
34 
37 {
42  WIFI_DATA_QUEUE = 4
43 };
44 
70  std::tuple<WifiContainerQueueType, Mac48Address, std::optional<uint8_t>>;
71 
72 } // namespace ns3
73 
74 /****************************************************
75  * Global Functions (outside namespace ns3)
76  ***************************************************/
77 
83 template <>
84 struct std::hash<ns3::WifiContainerQueueId>
85 {
91  std::size_t operator()(ns3::WifiContainerQueueId queueId) const;
92 };
93 
94 namespace ns3
95 {
96 
105 {
106  public:
108  using ContainerQueue = std::list<WifiMacQueueElem>;
110  using iterator = ContainerQueue::iterator;
112  using const_iterator = ContainerQueue::const_iterator;
113 
117  void clear();
118 
127 
135 
142  Ptr<WifiMpdu> GetItem(const const_iterator it) const;
143 
153 
161  const ContainerQueue& GetQueue(const WifiContainerQueueId& queueId) const;
162 
170  uint32_t GetNBytes(const WifiContainerQueueId& queueId) const;
171 
180  std::pair<iterator, iterator> ExtractExpiredMpdus(const WifiContainerQueueId& queueId) const;
188  std::pair<iterator, iterator> ExtractAllExpiredMpdus() const;
196  std::pair<iterator, iterator> GetAllExpiredMpdus() const;
197 
198  private:
207  std::pair<iterator, iterator> DoExtractExpiredMpdus(ContainerQueue& queue) const;
208 
209  mutable std::unordered_map<WifiContainerQueueId, ContainerQueue>
212  mutable std::unordered_map<WifiContainerQueueId, uint32_t>
214 };
215 
216 } // namespace ns3
217 
218 #endif /* WIFI_MAC_QUEUE_CONTAINER_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Class for the container used by WifiMacQueue.
const ContainerQueue & GetQueue(const WifiContainerQueueId &queueId) const
Get a const reference to the container queue identified by the given QueueId.
void clear()
Erase all elements from the container.
static WifiContainerQueueId GetQueueId(Ptr< const WifiMpdu > mpdu)
Return the QueueId identifying the container queue in which the given MPDU is (or is to be) enqueued.
ContainerQueue::iterator iterator
iterator over elements in a container queue
std::unordered_map< WifiContainerQueueId, uint32_t > m_nBytesPerQueue
size in bytes of the container queues
uint32_t GetNBytes(const WifiContainerQueueId &queueId) const
Get the total size of the MPDUs stored in the queue identified by the given QueueId.
Ptr< WifiMpdu > GetItem(const const_iterator it) const
Return the WifiMpdu included in the element pointed to by the given iterator.
std::pair< iterator, iterator > ExtractAllExpiredMpdus() const
Transfer non-inflight MPDUs with expired lifetime in all the container queues to the container queue ...
iterator insert(const_iterator pos, Ptr< WifiMpdu > item)
Insert the given item at the specified location in the container.
std::unordered_map< WifiContainerQueueId, ContainerQueue > m_queues
the container queues
std::list< WifiMacQueueElem > ContainerQueue
Type of a queue held by the container.
iterator erase(const_iterator pos)
Erase the specified elements from the container.
std::pair< iterator, iterator > GetAllExpiredMpdus() const
Get the range [first, last) of iterators pointing to all the MPDUs queued in the container queue stor...
ContainerQueue::const_iterator const_iterator
const iterator over elements in a container queue
ContainerQueue m_expiredQueue
queue storing MPDUs with expired lifetime
std::pair< iterator, iterator > ExtractExpiredMpdus(const WifiContainerQueueId &queueId) const
Transfer non-inflight MPDUs with expired lifetime in the container queue identified by the given Queu...
std::pair< iterator, iterator > DoExtractExpiredMpdus(ContainerQueue &queue) const
Transfer non-inflight MPDUs with expired lifetime in the given container queue to the container queue...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiContainerQueueType
enumeration of container queue types
@ WIFI_QOSDATA_UNICAST_QUEUE
@ WIFI_QOSDATA_BROADCAST_QUEUE
std::tuple< WifiContainerQueueType, Mac48Address, std::optional< uint8_t > > WifiContainerQueueId
Tuple (queue type, Address, TID) identifying a container queue.