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:
342  bool TtlExceeded (ConstIterator &it);
352  bool DoEnqueue (ConstIterator pos, Ptr<WifiMacQueueItem> item);
361  Ptr<WifiMacQueueItem> DoDequeue (ConstIterator pos);
370  Ptr<WifiMacQueueItem> DoRemove (ConstIterator pos);
371 
374  mutable bool m_expiredPacketsPresent;
375 
377  std::unordered_map<WifiAddressTidPair, uint32_t, WifiAddressTidHash> m_nQueuedPackets;
379  std::unordered_map<WifiAddressTidPair, uint32_t, WifiAddressTidHash> m_nQueuedBytes;
380 
383 
385 };
386 
387 } //namespace ns3
388 
389 #endif /* WIFI_MAC_QUEUE_H */
Time m_maxDelay
Time to live for packets in the queue.
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedBytes
Per (MAC address, TID) pair queued bytes.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
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:308
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
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedPackets
Per (MAC address, TID) pair queued packets.
a unique identifier for an interface.
Definition: type-id.h:58
std::list< Ptr< Item > >::const_iterator ConstIterator
Const iterator.
Definition: queue.h:306