A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-mac-queue.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005, 2009 INRIA
3 * Copyright (c) 2009 MIRKO BANCHI
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * Mirko Banchi <mk.banchi@gmail.com>
20 * Stefano Avallone <stavallo@unina.it>
21 */
22
23#ifndef WIFI_MAC_QUEUE_H
24#define WIFI_MAC_QUEUE_H
25
26#include "qos-utils.h"
28#include "wifi-mpdu.h"
29
30#include "ns3/queue.h"
31
32#include <functional>
33#include <optional>
34#include <unordered_map>
35
36namespace ns3
37{
38
39class WifiMacQueueScheduler;
40
41// The following explicit template instantiation declaration prevents modules
42// including this header file from implicitly instantiating Queue<WifiMpdu>.
43// This would cause python examples using wifi to crash at runtime with the
44// following error message: "Trying to allocate twice the same UID:
45// ns3::Queue<WifiMpdu>"
46extern template class Queue<WifiMpdu, ns3::WifiMacQueueContainer>;
47
67{
68 public:
73 static TypeId GetTypeId();
74
81
82 ~WifiMacQueue() override;
83
85 using Queue<WifiMpdu, WifiMacQueueContainer>::ConstIterator;
86 using Queue<WifiMpdu, WifiMacQueueContainer>::Iterator;
87 using Queue<WifiMpdu, WifiMacQueueContainer>::IsEmpty;
88 using Queue<WifiMpdu, WifiMacQueueContainer>::GetNPackets;
89 using Queue<WifiMpdu, WifiMacQueueContainer>::GetNBytes;
90
96 AcIndex GetAc() const;
97
103 void SetScheduler(Ptr<WifiMacQueueScheduler> scheduler);
104
110 void SetMaxDelay(Time delay);
116 Time GetMaxDelay() const;
117
124 bool Enqueue(Ptr<WifiMpdu> item) override;
130 Ptr<WifiMpdu> Dequeue() override;
136 void DequeueIfQueued(const std::list<Ptr<const WifiMpdu>>& mpdus);
142 Ptr<const WifiMpdu> Peek() const override;
150 Ptr<WifiMpdu> Peek(std::optional<uint8_t> linkId) const;
166 Ptr<WifiMpdu> PeekByTidAndAddress(uint8_t tid,
167 Mac48Address dest,
168 Ptr<const WifiMpdu> item = nullptr) const;
183 Ptr<WifiMpdu> PeekByQueueId(const WifiContainerQueueId& queueId,
184 Ptr<const WifiMpdu> item = nullptr) const;
185
197 Ptr<WifiMpdu> PeekFirstAvailable(uint8_t linkId, Ptr<const WifiMpdu> item = nullptr) const;
203 Ptr<WifiMpdu> Remove() override;
214
218 void Flush();
219
228 void Replace(Ptr<const WifiMpdu> currentItem, Ptr<WifiMpdu> newItem);
229
237 uint32_t GetNPackets(const WifiContainerQueueId& queueId) const;
238
246 uint32_t GetNBytes(const WifiContainerQueueId& queueId) const;
247
256 bool TtlExceeded(Ptr<const WifiMpdu> item, const Time& now);
257
269 void ExtractExpiredMpdus(const WifiContainerQueueId& queueId) const;
279 void ExtractAllExpiredMpdus() const;
283 void WipeAllExpiredMpdus();
284
292 Ptr<WifiMpdu> GetOriginal(Ptr<WifiMpdu> mpdu);
293
300 Ptr<WifiMpdu> GetAlias(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
301
302 protected:
303 using Queue<WifiMpdu, WifiMacQueueContainer>::GetContainer;
304
305 void DoDispose() override;
306
307 private:
312 Iterator GetIt(Ptr<const WifiMpdu> mpdu) const;
313
321 bool Insert(ConstIterator pos, Ptr<WifiMpdu> item);
331 bool DoEnqueue(ConstIterator pos, Ptr<WifiMpdu> item);
339 void DoDequeue(const std::list<ConstIterator>& iterators);
348 Ptr<WifiMpdu> DoRemove(ConstIterator pos);
349
353
356
358};
359
360} // namespace ns3
361
362#endif /* WIFI_MAC_QUEUE_H */
an EUI-48 address
Definition: mac48-address.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Template class for packet Queues.
Definition: queue.h:268
Container::iterator Iterator
Iterator.
Definition: queue.h:321
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Class for the container used by WifiMacQueue.
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
Time m_maxDelay
Time to live for packets in the queue.
Ptr< WifiMacQueueScheduler > m_scheduler
the MAC queue scheduler
NS_LOG_TEMPLATE_DECLARE
redefinition of the log component
TracedCallback< Ptr< const WifiMpdu > > m_traceExpired
Traced callback: fired when a packet is dropped due to lifetime expiration.
AcIndex m_ac
the access category
WifiMpdu stores a (const) packet along with a MAC header.
Definition: wifi-mpdu.h:62
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:73
@ AC_UNDEF
Total number of ACs.
Definition: qos-utils.h:87
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.