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 "wifi-mac-queue-item.h"
28 #include "ns3/queue.h"
29 #include <unordered_map>
30 #include "qos-utils.h"
31 
32 namespace ns3 {
33 
34 class QosBlockedDestinations;
35 
36 // The following explicit template instantiation declaration prevents modules
37 // including this header file from implicitly instantiating Queue<WifiMacQueueItem>.
38 // This would cause python examples using wifi to crash at runtime with the
39 // following error message: "Trying to allocate twice the same UID:
40 // ns3::Queue<WifiMacQueueItem>"
41 extern template class Queue<WifiMacQueueItem>;
42 
43 
60 {
61 public:
66  static TypeId GetTypeId (void);
67  WifiMacQueue ();
68  ~WifiMacQueue ();
69 
72  {
74  DROP_OLDEST
75  };
76 
82 
88  void SetMaxDelay (Time delay);
94  Time GetMaxDelay (void) const;
95 
102  bool Enqueue (Ptr<WifiMacQueueItem> item) override;
109  bool PushFront (Ptr<WifiMacQueueItem> item);
117  bool Insert (ConstIterator pos, Ptr<WifiMacQueueItem> item);
123  Ptr<WifiMacQueueItem> Dequeue (void) override;
134  Ptr<WifiMacQueueItem> DequeueByAddress (Mac48Address dest);
144  Ptr<WifiMacQueueItem> DequeueByTid (uint8_t tid);
157  Ptr<WifiMacQueueItem> DequeueByTidAndAddress (uint8_t tid,
158  Mac48Address dest);
170  Ptr<WifiMacQueueItem> DequeueFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets = nullptr);
179  Ptr<WifiMacQueueItem> Dequeue (WifiMacQueue::ConstIterator pos);
185  Ptr<const WifiMacQueueItem> Peek (void) const override;
198  ConstIterator PeekByAddress (Mac48Address dest, ConstIterator pos = EMPTY) const;
210  ConstIterator PeekByTid (uint8_t tid, ConstIterator pos = EMPTY) const;
225  ConstIterator PeekByTidAndAddress (uint8_t tid, Mac48Address dest, ConstIterator pos = EMPTY) const;
234  ConstIterator PeekFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets = nullptr,
235  ConstIterator pos = EMPTY) const;
241  Ptr<WifiMacQueueItem> Remove (void) override;
251  bool Remove (Ptr<const Packet> packet);
262  ConstIterator Remove (ConstIterator pos, bool removeExpired = false);
271  uint32_t GetNPacketsByAddress (Mac48Address dest);
282  uint32_t GetNPacketsByTidAndAddress (uint8_t tid, Mac48Address dest);
283 
295  uint32_t GetNPackets (uint8_t tid, Mac48Address dest) const;
307  uint32_t GetNBytes (uint8_t tid, Mac48Address dest) const;
308 
314  bool IsEmpty (void);
315 
321  uint32_t GetNPackets (void);
322 
328  uint32_t GetNBytes (void);
329 
330  static const ConstIterator EMPTY;
331 
332 
333 private:
343  inline bool TtlExceeded (ConstIterator &it, const Time& now);
353  bool DoEnqueue (ConstIterator pos, Ptr<WifiMacQueueItem> item);
362  Ptr<WifiMacQueueItem> DoDequeue (ConstIterator pos);
371  Ptr<WifiMacQueueItem> DoRemove (ConstIterator pos);
372 
375  mutable bool m_expiredPacketsPresent;
376 
378  std::unordered_map<WifiAddressTidPair, uint32_t, WifiAddressTidHash> m_nQueuedPackets;
380  std::unordered_map<WifiAddressTidPair, uint32_t, WifiAddressTidHash> m_nQueuedBytes;
381 
384 
386 };
387 
388 } //namespace ns3
389 
390 #endif /* WIFI_MAC_QUEUE_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::WifiMacQueue::Dequeue
Ptr< WifiMacQueueItem > Dequeue(WifiMacQueue::ConstIterator pos)
Dequeue the item at position pos in the queue.
ns3::WifiMacQueue
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
Definition: wifi-mac-queue.h:60
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
qos-utils.h
ns3::Queue::ConstIterator
std::list< Ptr< Item > >::const_iterator ConstIterator
Const iterator.
Definition: queue.h:306
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
wifi-mac-queue-item.h
ns3::WifiMacQueue::m_nQueuedPackets
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedPackets
Per (MAC address, TID) pair queued packets.
Definition: wifi-mac-queue.h:378
ns3::WifiMacQueue::NS_LOG_TEMPLATE_DECLARE
NS_LOG_TEMPLATE_DECLARE
redefinition of the log component
Definition: wifi-mac-queue.h:385
ns3::Ptr< WifiMacQueueItem >
ns3::WifiMacQueue::m_maxDelay
Time m_maxDelay
Time to live for packets in the queue.
Definition: wifi-mac-queue.h:373
ns3::WifiMacQueue::DropPolicy
DropPolicy
drop policy
Definition: wifi-mac-queue.h:72
ns3::WifiMacQueue::DROP_NEWEST
@ DROP_NEWEST
Definition: wifi-mac-queue.h:73
ns3::WifiMacQueue::m_expiredPacketsPresent
bool m_expiredPacketsPresent
True if expired packets are in the queue.
Definition: wifi-mac-queue.h:375
ns3::WifiMacQueue::m_nQueuedBytes
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedBytes
Per (MAC address, TID) pair queued bytes.
Definition: wifi-mac-queue.h:380
Queue< WifiMacQueueItem >
Introspection did not find any typical Config paths.
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::WifiMacQueue::m_dropPolicy
DropPolicy m_dropPolicy
Drop behavior of queue.
Definition: wifi-mac-queue.h:374
ns3::Queue::Iterator
std::list< Ptr< Item > >::iterator Iterator
Iterator.
Definition: queue.h:308
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::Queue
Template class for packet Queues.
Definition: queue.h:254
ns3::WifiMacQueue::EMPTY
static const ConstIterator EMPTY
Invalid iterator to signal an empty queue.
Definition: wifi-mac-queue.h:330
ns3::WifiMacQueue::m_traceExpired
TracedCallback< Ptr< const WifiMacQueueItem > > m_traceExpired
Traced callback: fired when a packet is dropped due to lifetime expiration.
Definition: wifi-mac-queue.h:383