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 <tuple>
29#include <unordered_map>
30
31namespace ns3
32{
33
36{
41};
42
62using WifiContainerQueueId = std::tuple<WifiContainerQueueType, Mac48Address, uint8_t>;
63
64} // namespace ns3
65
66/****************************************************
67 * Global Functions (outside namespace ns3)
68 ***************************************************/
69
75template <>
76struct std::hash<ns3::WifiContainerQueueId>
77{
83 std::size_t operator()(ns3::WifiContainerQueueId queueId) const;
84};
85
86namespace ns3
87{
88
97{
98 public:
100 using ContainerQueue = std::list<WifiMacQueueElem>;
102 using iterator = ContainerQueue::iterator;
104 using const_iterator = ContainerQueue::const_iterator;
105
109 void clear();
110
119
127
134 Ptr<WifiMpdu> GetItem(const const_iterator it) const;
135
145
153 const ContainerQueue& GetQueue(const WifiContainerQueueId& queueId) const;
154
162 uint32_t GetNBytes(const WifiContainerQueueId& queueId) const;
163
172 std::pair<iterator, iterator> ExtractExpiredMpdus(const WifiContainerQueueId& queueId) const;
180 std::pair<iterator, iterator> ExtractAllExpiredMpdus() const;
188 std::pair<iterator, iterator> GetAllExpiredMpdus() const;
189
190 private:
199 std::pair<iterator, iterator> DoExtractExpiredMpdus(ContainerQueue& queue) const;
200
201 mutable std::unordered_map<WifiContainerQueueId, ContainerQueue>
204 mutable std::unordered_map<WifiContainerQueueId, uint32_t>
206};
207
208} // namespace ns3
209
210#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 MPDUs with expired lifetime in all the container queues to the container queue storing MPDUs...
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 MPDUs with expired lifetime in the container queue identified by the given QueueId to the co...
std::pair< iterator, iterator > DoExtractExpiredMpdus(ContainerQueue &queue) const
Transfer MPDUs with expired lifetime in the given container queue to the container queue storing MPDU...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::tuple< WifiContainerQueueType, Mac48Address, uint8_t > WifiContainerQueueId
Tuple (queue type, Address, TID) identifying a container queue.
WifiContainerQueueType
enumeration of container queue types
@ WIFI_QOSDATA_UNICAST_QUEUE
@ WIFI_QOSDATA_BROADCAST_QUEUE