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 
30 namespace ns3 {
31 
32 class QosBlockedDestinations;
33 
34 // The following explicit template instantiation declaration prevents modules
35 // including this header file from implicitly instantiating Queue<WifiMacQueueItem>.
36 // This would cause python examples using wifi to crash at runtime with the
37 // following error message: "Trying to allocate twice the same UID:
38 // ns3::Queue<WifiMacQueueItem>"
39 extern template class Queue<WifiMacQueueItem>;
40 
41 
58 {
59 public:
64  static TypeId GetTypeId (void);
65  WifiMacQueue ();
66  ~WifiMacQueue ();
67 
70  {
72  DROP_OLDEST
73  };
74 
80 
86  void SetMaxDelay (Time delay);
92  Time GetMaxDelay (void) const;
93 
100  bool Enqueue (Ptr<WifiMacQueueItem> item);
107  bool PushFront (Ptr<WifiMacQueueItem> item);
115  bool Insert (ConstIterator pos, Ptr<WifiMacQueueItem> item);
121  Ptr<WifiMacQueueItem> Dequeue (void);
132  Ptr<WifiMacQueueItem> DequeueByAddress (Mac48Address dest);
142  Ptr<WifiMacQueueItem> DequeueByTid (uint8_t tid);
155  Ptr<WifiMacQueueItem> DequeueByTidAndAddress (uint8_t tid,
156  Mac48Address dest);
168  Ptr<WifiMacQueueItem> DequeueFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets = nullptr);
177  Ptr<WifiMacQueueItem> Dequeue (WifiMacQueue::ConstIterator pos);
183  Ptr<const WifiMacQueueItem> Peek (void) const;
196  ConstIterator PeekByAddress (Mac48Address dest, ConstIterator pos = EMPTY) const;
208  ConstIterator PeekByTid (uint8_t tid, ConstIterator pos = EMPTY) const;
223  ConstIterator PeekByTidAndAddress (uint8_t tid, Mac48Address dest, ConstIterator pos = EMPTY) const;
232  ConstIterator PeekFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets = nullptr,
233  ConstIterator pos = EMPTY) const;
239  Ptr<WifiMacQueueItem> Remove (void);
249  bool Remove (Ptr<const Packet> packet);
260  ConstIterator Remove (ConstIterator pos, bool removeExpired = false);
269  uint32_t GetNPacketsByAddress (Mac48Address dest);
279  uint32_t GetNPacketsByTidAndAddress (uint8_t tid, Mac48Address dest);
280 
286  bool IsEmpty (void);
287 
293  uint32_t GetNPackets (void);
294 
300  uint32_t GetNBytes (void);
301 
302  static const ConstIterator EMPTY;
303 
304 
305 private:
314  bool TtlExceeded (ConstIterator &it);
315 
318  mutable bool m_expiredPacketsPresent;
319 
322 
324 };
325 
326 } //namespace ns3
327 
328 #endif /* WIFI_MAC_QUEUE_H */
Time m_maxDelay
Time to live for packets in the queue.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Forward calls to a chain of Callback.
Introspection did not find any typical Config paths.
Template class for packet Queues.
bool m_expiredPacketsPresent
True if expired packets are in the queue.
static const ConstIterator EMPTY
Invalid iterator to signal an empty queue.
DropPolicy m_dropPolicy
Drop behavior of queue.
std::list< Ptr< Item > >::iterator Iterator
Iterator.
Definition: queue.h:306
DropPolicy
drop policy
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedCallback< Ptr< const WifiMacQueueItem > > m_traceExpired
Traced callback: fired when a packet is dropped due to lifetime expiration.
an EUI-48 address
Definition: mac48-address.h:43
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
NS_LOG_TEMPLATE_DECLARE
redefinition of the log component
a unique identifier for an interface.
Definition: type-id.h:58
std::list< Ptr< Item > >::const_iterator ConstIterator
Const iterator.
Definition: queue.h:304