A Discrete-Event Network Simulator
API
wifi-mac-queue.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2005, 2009 INRIA
4 * Copyright (c) 2009 MIRKO BANCHI
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20 * Mirko Banchi <mk.banchi@gmail.com>
21 * Stefano Avallone <stavallo@unina.it>
22 */
23
24#ifndef WIFI_MAC_QUEUE_H
25#define WIFI_MAC_QUEUE_H
26
27#include "qos-utils.h"
29#include "wifi-mpdu.h"
30#include "ns3/queue.h"
31#include <functional>
32#include <unordered_map>
33
34namespace ns3 {
35
36class QosBlockedDestinations;
37class WifiMacQueueScheduler;
38
39// The following explicit template instantiation declaration prevents modules
40// including this header file from implicitly instantiating Queue<WifiMpdu>.
41// This would cause python examples using wifi to crash at runtime with the
42// following error message: "Trying to allocate twice the same UID:
43// ns3::Queue<WifiMpdu>"
44extern template class Queue<WifiMpdu, ns3::WifiMacQueueContainer>;
45
46
66{
67public:
72 static TypeId GetTypeId (void);
73
80
82
89
95 AcIndex GetAc (void) const;
96
102 void SetScheduler (Ptr<WifiMacQueueScheduler> scheduler);
103
109 void SetMaxDelay (Time delay);
115 Time GetMaxDelay (void) const;
116
123 bool Enqueue (Ptr<WifiMpdu> item) override;
129 Ptr<WifiMpdu> Dequeue (void) override;
135 void DequeueIfQueued (const std::list<Ptr<const WifiMpdu>>& mpdus);
141 Ptr<const WifiMpdu> Peek (void) const override;
149 Ptr<WifiMpdu> Peek (uint8_t linkId) const;
165 Ptr<WifiMpdu> PeekByTidAndAddress (uint8_t tid, Mac48Address dest,
166 Ptr<const WifiMpdu> item = nullptr) const;
181 Ptr<WifiMpdu> PeekByQueueId (const WifiContainerQueueId& queueId,
182 Ptr<const WifiMpdu> item = nullptr) const;
183
196 Ptr<WifiMpdu> PeekFirstAvailable (uint8_t linkId,
197 const Ptr<QosBlockedDestinations> blockedPackets = nullptr,
198 Ptr<const WifiMpdu> item = nullptr) const;
204 Ptr<WifiMpdu> Remove (void) override;
215
224 void Replace (Ptr<const WifiMpdu> currentItem, Ptr<WifiMpdu> newItem);
225
233 uint32_t GetNPackets (const WifiContainerQueueId& queueId) const;
234
242 uint32_t GetNBytes (const WifiContainerQueueId& queueId) const;
243
252 bool TtlExceeded (Ptr<const WifiMpdu> item, const Time& now);
253
265 void ExtractExpiredMpdus (const WifiContainerQueueId& queueId) const;
275 void ExtractAllExpiredMpdus (void) const;
279 void WipeAllExpiredMpdus (void);
280
281protected:
283
284 void DoDispose (void) override;
285
286private:
291 Iterator GetIt (Ptr<const WifiMpdu> mpdu) const;
292
300 bool Insert (ConstIterator pos, Ptr<WifiMpdu> item);
310 bool DoEnqueue (ConstIterator pos, Ptr<WifiMpdu> item);
318 void DoDequeue (const std::list<ConstIterator>& iterators);
327 Ptr<WifiMpdu> DoRemove (ConstIterator pos);
328
332
335
337};
338
339} // namespace ns3
340
341#endif /* WIFI_MAC_QUEUE_H */
an EUI-48 address
Definition: mac48-address.h:44
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Container::iterator Iterator
Iterator.
Definition: queue.h:320
Container::const_iterator ConstIterator
Const iterator.
Definition: queue.h:318
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
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
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, Mac48Address, uint8_t > WifiContainerQueueId
Tuple (queue type, Address, TID) identifying a container queue.
#define list