A Discrete-Event Network Simulator
API
wifi-mac-queue.cc
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 #include "ns3/simulator.h"
25 #include "wifi-mac-queue.h"
27 #include <functional>
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("WifiMacQueue");
32 
33 NS_OBJECT_ENSURE_REGISTERED (WifiMacQueue);
34 NS_OBJECT_TEMPLATE_CLASS_DEFINE (Queue, WifiMacQueueItem);
35 
36 TypeId
38 {
39  static TypeId tid = TypeId ("ns3::WifiMacQueue")
41  .SetGroupName ("Wifi")
42  .AddConstructor<WifiMacQueue> ()
43  .AddAttribute ("MaxSize",
44  "The max queue size",
45  QueueSizeValue (QueueSize ("500p")),
49  .AddAttribute ("MaxDelay", "If a packet stays longer than this delay in the queue, it is dropped.",
50  TimeValue (MilliSeconds (500)),
52  MakeTimeChecker ())
53  .AddAttribute ("DropPolicy", "Upon enqueue with full queue, drop oldest (DropOldest) or newest (DropNewest) packet",
57  WifiMacQueue::DROP_NEWEST, "DropNewest"))
58  .AddTraceSource ("Expired", "MPDU dropped because its lifetime expired.",
60  "ns3::WifiMacQueueItem::TracedCallback")
61  ;
62  return tid;
63 }
64 
66  : m_expiredPacketsPresent (false),
67  NS_LOG_TEMPLATE_DEFINE ("WifiMacQueue")
68 {
69 }
70 
72 {
74  m_nQueuedPackets.clear ();
75  m_nQueuedBytes.clear ();
76 }
77 
78 static std::list<Ptr<WifiMacQueueItem>> g_emptyWifiMacQueue;
79 
80 const WifiMacQueue::ConstIterator WifiMacQueue::EMPTY = g_emptyWifiMacQueue.end ();
81 
82 void
84 {
85  NS_LOG_FUNCTION (this << delay);
86  m_maxDelay = delay;
87 }
88 
89 Time
91 {
92  return m_maxDelay;
93 }
94 
95 bool
96 WifiMacQueue::TtlExceeded (ConstIterator &it)
97 {
98  if (Simulator::Now () > (*it)->GetTimeStamp () + m_maxDelay)
99  {
100  NS_LOG_DEBUG ("Removing packet that stayed in the queue for too long (" <<
101  Simulator::Now () - (*it)->GetTimeStamp () << ")");
102  m_traceExpired (*it);
103  auto curr = it++;
104  DoRemove (curr);
105  return true;
106  }
107  return false;
108 }
109 
110 bool
112 {
113  NS_LOG_FUNCTION (this << *item);
114 
115  return Insert (end (), item);
116 }
117 
118 bool
120 {
121  NS_LOG_FUNCTION (this << *item);
122 
123  return Insert (begin (), item);
124 }
125 
126 bool
128 {
129  NS_LOG_FUNCTION (this << *item);
130  NS_ASSERT_MSG (GetMaxSize ().GetUnit () == QueueSizeUnit::PACKETS,
131  "WifiMacQueues must be in packet mode");
132 
133  // insert the item if the queue is not full
134  if (QueueBase::GetNPackets () < GetMaxSize ().GetValue ())
135  {
136  return DoEnqueue (pos, item);
137  }
138 
139  // the queue is full; scan the list in the attempt to remove stale packets
140  ConstIterator it = begin ();
141  while (it != end ())
142  {
143  if (it == pos && TtlExceeded (it))
144  {
145  return DoEnqueue (it, item);
146  }
147  if (TtlExceeded (it))
148  {
149  return DoEnqueue (pos, item);
150  }
151  it++;
152  }
153 
154  // the queue is still full, remove the oldest item if the policy is drop oldest
155  if (m_dropPolicy == DROP_OLDEST)
156  {
157  NS_LOG_DEBUG ("Remove the oldest item in the queue");
158  if (pos == begin ())
159  {
160  // Avoid invalidating pos
161  DoRemove (begin ());
162  pos = begin ();
163  }
164  else
165  {
166  DoRemove (begin ());
167  }
168  }
169 
170  return DoEnqueue (pos, item);
171 }
172 
175 {
176  NS_LOG_FUNCTION (this);
177  for (ConstIterator it = begin (); it != end (); )
178  {
179  if (!TtlExceeded (it))
180  {
181  return DoDequeue (it);
182  }
183  }
184  NS_LOG_DEBUG ("The queue is empty");
185  return 0;
186 }
187 
190 {
191  NS_LOG_FUNCTION (this << dest);
192  ConstIterator it = PeekByAddress (dest);
193 
194  if (it == end ())
195  {
196  return 0;
197  }
198  return Dequeue (it);
199 }
200 
203 {
204  NS_LOG_FUNCTION (this << +tid);
205  ConstIterator it = PeekByTid (tid);
206 
207  if (it == end ())
208  {
209  return 0;
210  }
211  return Dequeue (it);
212 }
213 
216 {
217  NS_LOG_FUNCTION (this << +tid << dest);
218  ConstIterator it = PeekByTidAndAddress (tid, dest);
219 
220  if (it == end ())
221  {
222  return 0;
223  }
224  return Dequeue (it);
225 }
226 
229 {
230  NS_LOG_FUNCTION (this);
231  ConstIterator it = PeekFirstAvailable (blockedPackets);
232 
233  if (it == end ())
234  {
235  return 0;
236  }
237  return Dequeue (it);
238 }
239 
241 WifiMacQueue::Dequeue (ConstIterator pos)
242 {
243  NS_LOG_FUNCTION (this);
244 
246  {
247  if (TtlExceeded (pos))
248  {
249  NS_LOG_DEBUG ("Packet lifetime expired");
250  return 0;
251  }
252  return DoDequeue (pos);
253  }
254 
255  // remove stale items queued before the given position
256  ConstIterator it = begin ();
257  while (it != end ())
258  {
259  if (it == pos)
260  {
261  // reset the flag signaling the presence of expired packets before returning
262  m_expiredPacketsPresent = false;
263 
264  if (TtlExceeded (it))
265  {
266  return 0;
267  }
268  return DoDequeue (it);
269  }
270  else if (!TtlExceeded (it))
271  {
272  it++;
273  }
274  }
275  NS_LOG_DEBUG ("Invalid iterator");
276  return 0;
277 }
278 
279 Ptr<const WifiMacQueueItem>
280 WifiMacQueue::Peek (void) const
281 {
282  NS_LOG_FUNCTION (this);
283  for (auto it = begin (); it != end (); it++)
284  {
285  // skip packets that stayed in the queue for too long. They will be
286  // actually removed from the queue by the next call to a non-const method
287  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
288  {
289  return DoPeek (it);
290  }
291  // signal the presence of expired packets
293  }
294  NS_LOG_DEBUG ("The queue is empty");
295  return 0;
296 }
297 
298 WifiMacQueue::ConstIterator
299 WifiMacQueue::PeekByAddress (Mac48Address dest, ConstIterator pos) const
300 {
301  NS_LOG_FUNCTION (this << dest);
302  ConstIterator it = (pos != EMPTY ? pos : begin ());
303  while (it != end ())
304  {
305  // skip packets that stayed in the queue for too long. They will be
306  // actually removed from the queue by the next call to a non-const method
307  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
308  {
309  if (((*it)->GetHeader ().IsData () || (*it)->GetHeader ().IsQosData ())
310  && (*it)->GetDestinationAddress () == dest)
311  {
312  return it;
313  }
314  }
315  else
316  {
317  // signal the presence of expired packets
319  }
320  it++;
321  }
322  NS_LOG_DEBUG ("The queue is empty");
323  return end ();
324 }
325 
326 WifiMacQueue::ConstIterator
327 WifiMacQueue::PeekByTid (uint8_t tid, ConstIterator pos) const
328 {
329  NS_LOG_FUNCTION (this << +tid);
330  ConstIterator it = (pos != EMPTY ? pos : begin ());
331  while (it != end ())
332  {
333  // skip packets that stayed in the queue for too long. They will be
334  // actually removed from the queue by the next call to a non-const method
335  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
336  {
337  if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid)
338  {
339  return it;
340  }
341  }
342  else
343  {
344  // signal the presence of expired packets
346  }
347  it++;
348  }
349  NS_LOG_DEBUG ("The queue is empty");
350  return end ();
351 }
352 
353 WifiMacQueue::ConstIterator
354 WifiMacQueue::PeekByTidAndAddress (uint8_t tid, Mac48Address dest, ConstIterator pos) const
355 {
356  NS_LOG_FUNCTION (this << +tid << dest);
357  ConstIterator it = (pos != EMPTY ? pos : begin ());
358  while (it != end ())
359  {
360  // skip packets that stayed in the queue for too long. They will be
361  // actually removed from the queue by the next call to a non-const method
362  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
363  {
364  if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
365  && (*it)->GetHeader ().GetQosTid () == tid)
366  {
367  return it;
368  }
369  }
370  else
371  {
372  // signal the presence of expired packets
374  }
375  it++;
376  }
377  NS_LOG_DEBUG ("The queue is empty");
378  return end ();
379 }
380 
381 WifiMacQueue::ConstIterator
382 WifiMacQueue::PeekFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets, ConstIterator pos) const
383 {
384  NS_LOG_FUNCTION (this);
385  ConstIterator it = (pos != EMPTY ? pos : begin ());
386  while (it != end ())
387  {
388  // skip packets that stayed in the queue for too long. They will be
389  // actually removed from the queue by the next call to a non-const method
390  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
391  {
392  if (!(*it)->GetHeader ().IsQosData () || !blockedPackets
393  || !blockedPackets->IsBlocked ((*it)->GetHeader ().GetAddr1 (), (*it)->GetHeader ().GetQosTid ()))
394  {
395  return it;
396  }
397  }
398  else
399  {
400  // signal the presence of expired packets
402  }
403  it++;
404  }
405  NS_LOG_DEBUG ("The queue is empty");
406  return end ();
407 }
408 
411 {
412  NS_LOG_FUNCTION (this);
413 
414  for (ConstIterator it = begin (); it != end (); )
415  {
416  if (!TtlExceeded (it))
417  {
418  return DoRemove (it);
419  }
420  }
421  NS_LOG_DEBUG ("The queue is empty");
422  return 0;
423 }
424 
425 bool
427 {
428  NS_LOG_FUNCTION (this << packet);
429  for (ConstIterator it = begin (); it != end (); )
430  {
431  if (!TtlExceeded (it))
432  {
433  if ((*it)->GetPacket () == packet)
434  {
435  DoRemove (it);
436  return true;
437  }
438 
439  it++;
440  }
441  }
442  NS_LOG_DEBUG ("Packet " << packet << " not found in the queue");
443  return false;
444 }
445 
446 WifiMacQueue::ConstIterator
447 WifiMacQueue::Remove (ConstIterator pos, bool removeExpired)
448 {
449  NS_LOG_FUNCTION (this);
450 
451  if (!removeExpired)
452  {
453  ConstIterator curr = pos++;
454  DoRemove (curr);
455  return pos;
456  }
457 
458  // remove stale items queued before the given position
459  ConstIterator it = begin ();
460  while (it != end ())
461  {
462  if (it == pos)
463  {
464  // reset the flag signaling the presence of expired packets before returning
465  m_expiredPacketsPresent = false;
466 
467  ConstIterator curr = pos++;
468  DoRemove (curr);
469  return pos;
470  }
471  else if (!TtlExceeded (it))
472  {
473  it++;
474  }
475  }
476  NS_LOG_DEBUG ("Invalid iterator");
477  return end ();
478 }
479 
480 uint32_t
482 {
483  NS_LOG_FUNCTION (this << dest);
484 
485  uint32_t nPackets = 0;
486 
487  for (ConstIterator it = begin (); it != end (); )
488  {
489  if (!TtlExceeded (it))
490  {
491  if ((*it)->GetHeader ().IsData () && (*it)->GetDestinationAddress () == dest)
492  {
493  nPackets++;
494  }
495 
496  it++;
497  }
498  }
499  NS_LOG_DEBUG ("returns " << nPackets);
500  return nPackets;
501 }
502 
503 uint32_t
505 {
506  NS_LOG_FUNCTION (this << dest);
507  uint32_t nPackets = 0;
508  for (ConstIterator it = begin (); it != end (); )
509  {
510  if (!TtlExceeded (it))
511  {
512  if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
513  && (*it)->GetHeader ().GetQosTid () == tid)
514  {
515  nPackets++;
516  }
517 
518  it++;
519  }
520  }
521  NS_LOG_DEBUG ("returns " << nPackets);
522  return nPackets;
523 }
524 
525 bool
527 {
528  NS_LOG_FUNCTION (this);
529  for (ConstIterator it = begin (); it != end (); )
530  {
531  if (!TtlExceeded (it))
532  {
533  NS_LOG_DEBUG ("returns false");
534  return false;
535  }
536  }
537  NS_LOG_DEBUG ("returns true");
538  return true;
539 }
540 
541 uint32_t
543 {
544  NS_LOG_FUNCTION (this);
545  // remove packets that stayed in the queue for too long
546  for (ConstIterator it = begin (); it != end (); )
547  {
548  if (!TtlExceeded (it))
549  {
550  it++;
551  }
552  }
553  return QueueBase::GetNPackets ();
554 }
555 
556 uint32_t
558 {
559  NS_LOG_FUNCTION (this);
560  // remove packets that stayed in the queue for too long
561  for (ConstIterator it = begin (); it != end (); )
562  {
563  if (!TtlExceeded (it))
564  {
565  it++;
566  }
567  }
568  return QueueBase::GetNBytes ();
569 }
570 
571 uint32_t
572 WifiMacQueue::GetNPackets (uint8_t tid, Mac48Address dest) const
573 {
574  WifiAddressTidPair addressTidPair (dest, tid);
575  auto it = m_nQueuedPackets.find (addressTidPair);
576  if (it == m_nQueuedPackets.end ())
577  {
578  return 0;
579  }
580  return m_nQueuedPackets.at (addressTidPair);
581 }
582 
583 uint32_t
584 WifiMacQueue::GetNBytes (uint8_t tid, Mac48Address dest) const
585 {
586  WifiAddressTidPair addressTidPair (dest, tid);
587  auto it = m_nQueuedBytes.find (addressTidPair);
588  if (it == m_nQueuedBytes.end ())
589  {
590  return 0;
591  }
592  return m_nQueuedBytes.at (addressTidPair);
593 }
594 
595 bool
597 {
598  Iterator ret;
599  if (Queue<WifiMacQueueItem>::DoEnqueue (pos, item, ret))
600  {
601  // update statistics about queued packets
602  if (item->GetHeader ().IsQosData ())
603  {
604  WifiAddressTidPair addressTidPair (item->GetHeader ().GetAddr1 (), item->GetHeader ().GetQosTid ());
605  auto it = m_nQueuedPackets.find (addressTidPair);
606  if (it == m_nQueuedPackets.end ())
607  {
608  m_nQueuedPackets[addressTidPair] = 0;
609  m_nQueuedBytes[addressTidPair] = 0;
610  }
611  m_nQueuedPackets[addressTidPair]++;
612  m_nQueuedBytes[addressTidPair] += item->GetSize ();
613  }
614  // set item's information about its position in the queue
615  item->m_queueIts = {{this, ret}};
616  return true;
617  }
618  return false;
619 }
620 
622 WifiMacQueue::DoDequeue (ConstIterator pos)
623 {
625 
626  if (item != 0 && item->GetHeader ().IsQosData ())
627  {
628  WifiAddressTidPair addressTidPair (item->GetHeader ().GetAddr1 (), item->GetHeader ().GetQosTid ());
629  NS_ASSERT (m_nQueuedPackets.find (addressTidPair) != m_nQueuedPackets.end ());
630  NS_ASSERT (m_nQueuedPackets[addressTidPair] >= 1);
631  NS_ASSERT (m_nQueuedBytes[addressTidPair] >= item->GetSize ());
632 
633  m_nQueuedPackets[addressTidPair]--;
634  m_nQueuedBytes[addressTidPair] -= item->GetSize ();
635  }
636 
637  if (item != 0)
638  {
639  NS_ASSERT (item->m_queueIts.size () == 1);
640  item->m_queueIts.clear ();
641  }
642 
643  return item;
644 }
645 
647 WifiMacQueue::DoRemove (ConstIterator pos)
648 {
650 
651  if (item != 0 && item->GetHeader ().IsQosData ())
652  {
653  WifiAddressTidPair addressTidPair (item->GetHeader ().GetAddr1 (), item->GetHeader ().GetQosTid ());
654  NS_ASSERT (m_nQueuedPackets.find (addressTidPair) != m_nQueuedPackets.end ());
655  NS_ASSERT (m_nQueuedPackets[addressTidPair] >= 1);
656  NS_ASSERT (m_nQueuedBytes[addressTidPair] >= item->GetSize ());
657 
658  m_nQueuedPackets[addressTidPair]--;
659  m_nQueuedBytes[addressTidPair] -= item->GetSize ();
660  }
661 
662  if (item != 0)
663  {
664  NS_ASSERT (item->m_queueIts.size () == 1);
665  item->m_queueIts.clear ();
666  }
667 
668  return item;
669 }
670 
671 } //namespace ns3
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.
std::pair< Mac48Address, uint8_t > WifiAddressTidPair
(MAC address, TID) pair
Definition: qos-utils.h:32
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetMaxDelay(Time delay)
Set the maximum delay before the packet is discarded.
Class for representing queue sizes.
Definition: queue-size.h:94
QueueSize GetMaxSize(void) const
Definition: queue.cc:217
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
std::list< QueueIteratorPair > m_queueIts
Queue iterators pointing to this MSDU(s), if queued.
uint32_t GetSize(void) const
Return the size of the packet stored by this item, including header size and trailer size...
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
Ptr< WifiMacQueueItem > DoDequeue(ConstIterator pos)
Wrapper for the DoDequeue method provided by the base class that additionally resets the iterator fie...
uint32_t GetNBytes(void)
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
Definition: queue.h:560
Introspection did not find any typical Config paths.
bool DoEnqueue(ConstIterator pos, Ptr< WifiMacQueueItem > item)
Wrapper for the DoEnqueue method provided by the base class that additionally sets the iterator field...
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
uint32_t GetNPacketsByTidAndAddress(uint8_t tid, Mac48Address dest)
Return the number of QoS packets having TID equal to tid and destination address equal to dest...
bool Enqueue(Ptr< WifiMacQueueItem > item) override
Enqueue the given Wifi MAC queue item at the end of the queue.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Template class for packet Queues.
ConstIterator PeekByTidAndAddress(uint8_t tid, Mac48Address dest, ConstIterator pos=EMPTY) const
Search and return, if present in the queue, the first packet having the receiver address equal to des...
Ptr< const WifiMacQueueItem > Peek(void) const override
Peek the packet in the front of the queue.
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
bool m_expiredPacketsPresent
True if expired packets are in the queue.
uint32_t GetNBytes(void) const
Definition: queue.cc:98
Hold variables of type enum.
Definition: enum.h:54
ConstIterator PeekByAddress(Mac48Address dest, ConstIterator pos=EMPTY) const
Search and return, if present in the queue, the first packet (either Data frame or QoS Data frame) ha...
AttributeValue implementation for Time.
Definition: nstime.h:1353
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
Definition: log.h:239
Ptr< WifiMacQueueItem > DequeueByAddress(Mac48Address dest)
Search and return, if present in the queue, the first packet (either Data frame or QoS Data frame) ha...
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: enum.h:203
Use number of packets for queue size.
Definition: queue-size.h:44
static TypeId GetTypeId(void)
Get the type ID.
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
Time GetMaxDelay(void) const
Return the maximum delay before the packet is discarded.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
Definition: queue-size.h:221
static const ConstIterator EMPTY
Invalid iterator to signal an empty queue.
DropPolicy m_dropPolicy
Drop behavior of queue.
uint32_t GetNPacketsByAddress(Mac48Address dest)
Return the number of packets having destination address specified by dest.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Definition: queue-size.cc:29
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static std::list< Ptr< WifiMacQueueItem > > g_emptyWifiMacQueue
empty Wi-Fi MAC queue
Ptr< WifiMacQueueItem > Dequeue(void) override
Dequeue the packet in the front of the queue.
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
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1354
Ptr< WifiMacQueueItem > DequeueFirstAvailable(const Ptr< QosBlockedDestinations > blockedPackets=nullptr)
Return first available packet for transmission.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
bool Insert(ConstIterator pos, Ptr< WifiMacQueueItem > item)
Enqueue the given Wifi MAC queue item before the given position.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
bool PushFront(Ptr< WifiMacQueueItem > item)
Enqueue the given Wifi MAC queue item at the front of the queue.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
bool TtlExceeded(ConstIterator &it)
Remove the item pointed to by the iterator it if it has been in the queue for too long...
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:161
Ptr< WifiMacQueueItem > DequeueByTidAndAddress(uint8_t tid, Mac48Address dest)
Search and return, if present in the queue, the first packet having the address indicated by type equ...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedPackets
Per (MAC address, TID) pair queued packets.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data...
#define NS_OBJECT_TEMPLATE_CLASS_DEFINE(type, param)
Explicitly instantiate a template class and register the resulting instance with the TypeId system...
Definition: object-base.h:67
ConstIterator PeekFirstAvailable(const Ptr< QosBlockedDestinations > blockedPackets=nullptr, ConstIterator pos=EMPTY) const
Return first available packet for transmission.
Ptr< WifiMacQueueItem > Remove(void) override
Remove the packet in the front of the queue.
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
Definition: queue.cc:200
uint32_t GetNPackets(void)
Ptr< Item > DoDequeue(ConstIterator pos)
Pull the item to dequeue from the queue.
Definition: queue.h:531
Ptr< WifiMacQueueItem > DoRemove(ConstIterator pos)
Wrapper for the DoRemove method provided by the base class that additionally resets the iterator fiel...
uint32_t GetNPackets(void) const
Definition: queue.cc:90
a unique identifier for an interface.
Definition: type-id.h:58
ConstIterator PeekByTid(uint8_t tid, ConstIterator pos=EMPTY) const
Search and return, if present in the queue, the first packet having the TID equal to tid...
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
Ptr< WifiMacQueueItem > DequeueByTid(uint8_t tid)
Search and return, if present in the queue, the first packet having the TID equal to tid...