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  NS_LOG_FUNCTION (this);
99 
100  if (Simulator::Now () > (*it)->GetTimeStamp () + m_maxDelay)
101  {
102  NS_LOG_DEBUG ("Removing packet that stayed in the queue for too long (" <<
103  Simulator::Now () - (*it)->GetTimeStamp () << ")");
104  m_traceExpired (*it);
105  auto curr = it++;
106  DoRemove (curr);
107  return true;
108  }
109  return false;
110 }
111 
112 bool
114 {
115  NS_LOG_FUNCTION (this << *item);
116 
117  return Insert (end (), item);
118 }
119 
120 bool
122 {
123  NS_LOG_FUNCTION (this << *item);
124 
125  return Insert (begin (), item);
126 }
127 
128 bool
130 {
131  NS_LOG_FUNCTION (this << *item);
132  NS_ASSERT_MSG (GetMaxSize ().GetUnit () == QueueSizeUnit::PACKETS,
133  "WifiMacQueues must be in packet mode");
134 
135  // insert the item if the queue is not full
136  if (QueueBase::GetNPackets () < GetMaxSize ().GetValue ())
137  {
138  return DoEnqueue (pos, item);
139  }
140 
141  // the queue is full; scan the list in the attempt to remove stale packets
142  ConstIterator it = begin ();
143  while (it != end ())
144  {
145  if (it == pos && TtlExceeded (it))
146  {
147  return DoEnqueue (it, item);
148  }
149  if (TtlExceeded (it))
150  {
151  return DoEnqueue (pos, item);
152  }
153  it++;
154  }
155 
156  // the queue is still full, remove the oldest item if the policy is drop oldest
157  if (m_dropPolicy == DROP_OLDEST)
158  {
159  NS_LOG_DEBUG ("Remove the oldest item in the queue");
160  if (pos == begin ())
161  {
162  // Avoid invalidating pos
163  DoRemove (begin ());
164  pos = begin ();
165  }
166  else
167  {
168  DoRemove (begin ());
169  }
170  }
171 
172  return DoEnqueue (pos, item);
173 }
174 
177 {
178  NS_LOG_FUNCTION (this);
179  for (ConstIterator it = begin (); it != end (); )
180  {
181  if (!TtlExceeded (it))
182  {
183  return DoDequeue (it);
184  }
185  }
186  NS_LOG_DEBUG ("The queue is empty");
187  return 0;
188 }
189 
192 {
193  NS_LOG_FUNCTION (this << dest);
194  ConstIterator it = PeekByAddress (dest);
195 
196  if (it == end ())
197  {
198  return 0;
199  }
200  return Dequeue (it);
201 }
202 
205 {
206  NS_LOG_FUNCTION (this << +tid);
207  ConstIterator it = PeekByTid (tid);
208 
209  if (it == end ())
210  {
211  return 0;
212  }
213  return Dequeue (it);
214 }
215 
218 {
219  NS_LOG_FUNCTION (this << +tid << dest);
220  ConstIterator it = PeekByTidAndAddress (tid, dest);
221 
222  if (it == end ())
223  {
224  return 0;
225  }
226  return Dequeue (it);
227 }
228 
231 {
232  NS_LOG_FUNCTION (this);
233  ConstIterator it = PeekFirstAvailable (blockedPackets);
234 
235  if (it == end ())
236  {
237  return 0;
238  }
239  return Dequeue (it);
240 }
241 
243 WifiMacQueue::Dequeue (ConstIterator pos)
244 {
245  NS_LOG_FUNCTION (this);
246 
248  {
249  if (TtlExceeded (pos))
250  {
251  NS_LOG_DEBUG ("Packet lifetime expired");
252  return 0;
253  }
254  return DoDequeue (pos);
255  }
256 
257  // remove stale items queued before the given position
258  ConstIterator it = begin ();
259  while (it != end ())
260  {
261  if (it == pos)
262  {
263  // reset the flag signaling the presence of expired packets before returning
264  m_expiredPacketsPresent = false;
265 
266  if (TtlExceeded (it))
267  {
268  return 0;
269  }
270  return DoDequeue (it);
271  }
272  else if (!TtlExceeded (it))
273  {
274  it++;
275  }
276  }
277  NS_LOG_DEBUG ("Invalid iterator");
278  return 0;
279 }
280 
281 Ptr<const WifiMacQueueItem>
282 WifiMacQueue::Peek (void) const
283 {
284  NS_LOG_FUNCTION (this);
285  for (auto it = begin (); it != end (); it++)
286  {
287  // skip packets that stayed in the queue for too long. They will be
288  // actually removed from the queue by the next call to a non-const method
289  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
290  {
291  return DoPeek (it);
292  }
293  // signal the presence of expired packets
295  }
296  NS_LOG_DEBUG ("The queue is empty");
297  return 0;
298 }
299 
300 WifiMacQueue::ConstIterator
301 WifiMacQueue::PeekByAddress (Mac48Address dest, ConstIterator pos) const
302 {
303  NS_LOG_FUNCTION (this << dest);
304  ConstIterator it = (pos != EMPTY ? pos : begin ());
305  while (it != end ())
306  {
307  // skip packets that stayed in the queue for too long. They will be
308  // actually removed from the queue by the next call to a non-const method
309  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
310  {
311  if (((*it)->GetHeader ().IsData () || (*it)->GetHeader ().IsQosData ())
312  && (*it)->GetDestinationAddress () == dest)
313  {
314  return it;
315  }
316  }
317  else
318  {
319  // signal the presence of expired packets
321  }
322  it++;
323  }
324  NS_LOG_DEBUG ("The queue is empty");
325  return end ();
326 }
327 
328 WifiMacQueue::ConstIterator
329 WifiMacQueue::PeekByTid (uint8_t tid, ConstIterator pos) const
330 {
331  NS_LOG_FUNCTION (this << +tid);
332  ConstIterator it = (pos != EMPTY ? pos : begin ());
333  while (it != end ())
334  {
335  // skip packets that stayed in the queue for too long. They will be
336  // actually removed from the queue by the next call to a non-const method
337  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
338  {
339  if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid)
340  {
341  return it;
342  }
343  }
344  else
345  {
346  // signal the presence of expired packets
348  }
349  it++;
350  }
351  NS_LOG_DEBUG ("The queue is empty");
352  return end ();
353 }
354 
355 WifiMacQueue::ConstIterator
356 WifiMacQueue::PeekByTidAndAddress (uint8_t tid, Mac48Address dest, ConstIterator pos) const
357 {
358  NS_LOG_FUNCTION (this << +tid << dest);
359  ConstIterator it = (pos != EMPTY ? pos : begin ());
360  while (it != end ())
361  {
362  // skip packets that stayed in the queue for too long. They will be
363  // actually removed from the queue by the next call to a non-const method
364  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
365  {
366  if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
367  && (*it)->GetHeader ().GetQosTid () == tid)
368  {
369  return it;
370  }
371  }
372  else
373  {
374  // signal the presence of expired packets
376  }
377  it++;
378  }
379  NS_LOG_DEBUG ("The queue is empty");
380  return end ();
381 }
382 
383 WifiMacQueue::ConstIterator
384 WifiMacQueue::PeekFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets, ConstIterator pos) const
385 {
386  NS_LOG_FUNCTION (this);
387  ConstIterator it = (pos != EMPTY ? pos : begin ());
388  while (it != end ())
389  {
390  // skip packets that stayed in the queue for too long. They will be
391  // actually removed from the queue by the next call to a non-const method
392  if (Simulator::Now () <= (*it)->GetTimeStamp () + m_maxDelay)
393  {
394  if (!(*it)->GetHeader ().IsQosData () || !blockedPackets
395  || !blockedPackets->IsBlocked ((*it)->GetHeader ().GetAddr1 (), (*it)->GetHeader ().GetQosTid ()))
396  {
397  return it;
398  }
399  }
400  else
401  {
402  // signal the presence of expired packets
404  }
405  it++;
406  }
407  NS_LOG_DEBUG ("The queue is empty");
408  return end ();
409 }
410 
413 {
414  NS_LOG_FUNCTION (this);
415 
416  for (ConstIterator it = begin (); it != end (); )
417  {
418  if (!TtlExceeded (it))
419  {
420  return DoRemove (it);
421  }
422  }
423  NS_LOG_DEBUG ("The queue is empty");
424  return 0;
425 }
426 
427 bool
429 {
430  NS_LOG_FUNCTION (this << packet);
431  for (ConstIterator it = begin (); it != end (); )
432  {
433  if (!TtlExceeded (it))
434  {
435  if ((*it)->GetPacket () == packet)
436  {
437  DoRemove (it);
438  return true;
439  }
440 
441  it++;
442  }
443  }
444  NS_LOG_DEBUG ("Packet " << packet << " not found in the queue");
445  return false;
446 }
447 
448 WifiMacQueue::ConstIterator
449 WifiMacQueue::Remove (ConstIterator pos, bool removeExpired)
450 {
451  NS_LOG_FUNCTION (this);
452 
453  if (!removeExpired)
454  {
455  ConstIterator curr = pos++;
456  DoRemove (curr);
457  return pos;
458  }
459 
460  // remove stale items queued before the given position
461  ConstIterator it = begin ();
462  while (it != end ())
463  {
464  if (it == pos)
465  {
466  // reset the flag signaling the presence of expired packets before returning
467  m_expiredPacketsPresent = false;
468 
469  ConstIterator curr = pos++;
470  DoRemove (curr);
471  return pos;
472  }
473  else if (!TtlExceeded (it))
474  {
475  it++;
476  }
477  }
478  NS_LOG_DEBUG ("Invalid iterator");
479  return end ();
480 }
481 
482 uint32_t
484 {
485  NS_LOG_FUNCTION (this << dest);
486 
487  uint32_t nPackets = 0;
488 
489  for (ConstIterator it = begin (); it != end (); )
490  {
491  if (!TtlExceeded (it))
492  {
493  if ((*it)->GetHeader ().IsData () && (*it)->GetDestinationAddress () == dest)
494  {
495  nPackets++;
496  }
497 
498  it++;
499  }
500  }
501  NS_LOG_DEBUG ("returns " << nPackets);
502  return nPackets;
503 }
504 
505 uint32_t
507 {
508  NS_LOG_FUNCTION (this << dest);
509  uint32_t nPackets = 0;
510  for (ConstIterator it = begin (); it != end (); )
511  {
512  if (!TtlExceeded (it))
513  {
514  if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
515  && (*it)->GetHeader ().GetQosTid () == tid)
516  {
517  nPackets++;
518  }
519 
520  it++;
521  }
522  }
523  NS_LOG_DEBUG ("returns " << nPackets);
524  return nPackets;
525 }
526 
527 bool
529 {
530  NS_LOG_FUNCTION (this);
531  for (ConstIterator it = begin (); it != end (); )
532  {
533  if (!TtlExceeded (it))
534  {
535  NS_LOG_DEBUG ("returns false");
536  return false;
537  }
538  }
539  NS_LOG_DEBUG ("returns true");
540  return true;
541 }
542 
543 uint32_t
545 {
546  NS_LOG_FUNCTION (this);
547  // remove packets that stayed in the queue for too long
548  for (ConstIterator it = begin (); it != end (); )
549  {
550  if (!TtlExceeded (it))
551  {
552  it++;
553  }
554  }
555  return QueueBase::GetNPackets ();
556 }
557 
558 uint32_t
560 {
561  NS_LOG_FUNCTION (this);
562  // remove packets that stayed in the queue for too long
563  for (ConstIterator it = begin (); it != end (); )
564  {
565  if (!TtlExceeded (it))
566  {
567  it++;
568  }
569  }
570  return QueueBase::GetNBytes ();
571 }
572 
573 uint32_t
574 WifiMacQueue::GetNPackets (uint8_t tid, Mac48Address dest) const
575 {
576  WifiAddressTidPair addressTidPair (dest, tid);
577  auto it = m_nQueuedPackets.find (addressTidPair);
578  if (it == m_nQueuedPackets.end ())
579  {
580  return 0;
581  }
582  return m_nQueuedPackets.at (addressTidPair);
583 }
584 
585 uint32_t
586 WifiMacQueue::GetNBytes (uint8_t tid, Mac48Address dest) const
587 {
588  WifiAddressTidPair addressTidPair (dest, tid);
589  auto it = m_nQueuedBytes.find (addressTidPair);
590  if (it == m_nQueuedBytes.end ())
591  {
592  return 0;
593  }
594  return m_nQueuedBytes.at (addressTidPair);
595 }
596 
597 bool
599 {
600  Iterator ret;
601  if (Queue<WifiMacQueueItem>::DoEnqueue (pos, item, ret))
602  {
603  // update statistics about queued packets
604  if (item->GetHeader ().IsQosData ())
605  {
606  WifiAddressTidPair addressTidPair (item->GetHeader ().GetAddr1 (), item->GetHeader ().GetQosTid ());
607  auto it = m_nQueuedPackets.find (addressTidPair);
608  if (it == m_nQueuedPackets.end ())
609  {
610  m_nQueuedPackets[addressTidPair] = 0;
611  m_nQueuedBytes[addressTidPair] = 0;
612  }
613  m_nQueuedPackets[addressTidPair]++;
614  m_nQueuedBytes[addressTidPair] += item->GetSize ();
615  }
616  // set item's information about its position in the queue
617  item->m_queueIts = {{this, ret}};
618  return true;
619  }
620  return false;
621 }
622 
624 WifiMacQueue::DoDequeue (ConstIterator pos)
625 {
627 
628  if (item != 0 && item->GetHeader ().IsQosData ())
629  {
630  WifiAddressTidPair addressTidPair (item->GetHeader ().GetAddr1 (), item->GetHeader ().GetQosTid ());
631  NS_ASSERT (m_nQueuedPackets.find (addressTidPair) != m_nQueuedPackets.end ());
632  NS_ASSERT (m_nQueuedPackets[addressTidPair] >= 1);
633  NS_ASSERT (m_nQueuedBytes[addressTidPair] >= item->GetSize ());
634 
635  m_nQueuedPackets[addressTidPair]--;
636  m_nQueuedBytes[addressTidPair] -= item->GetSize ();
637  }
638 
639  if (item != 0)
640  {
641  NS_ASSERT (item->m_queueIts.size () == 1);
642  item->m_queueIts.clear ();
643  }
644 
645  return item;
646 }
647 
649 WifiMacQueue::DoRemove (ConstIterator pos)
650 {
652 
653  if (item != 0 && item->GetHeader ().IsQosData ())
654  {
655  WifiAddressTidPair addressTidPair (item->GetHeader ().GetAddr1 (), item->GetHeader ().GetQosTid ());
656  NS_ASSERT (m_nQueuedPackets.find (addressTidPair) != m_nQueuedPackets.end ());
657  NS_ASSERT (m_nQueuedPackets[addressTidPair] >= 1);
658  NS_ASSERT (m_nQueuedBytes[addressTidPair] >= item->GetSize ());
659 
660  m_nQueuedPackets[addressTidPair]--;
661  m_nQueuedBytes[addressTidPair] -= item->GetSize ();
662  }
663 
664  if (item != 0)
665  {
666  NS_ASSERT (item->m_queueIts.size () == 1);
667  item->m_queueIts.clear ();
668  }
669 
670  return item;
671 }
672 
673 } //namespace ns3
Time m_maxDelay
Time to live for packets in the queue.
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedBytes
std::pair< Mac48Address, uint8_t > WifiAddressTidPair
(MAC address, TID) pair
Definition: qos-utils.h:31
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:556
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...
Ptr< WifiMacQueueItem > Dequeue(void)
Dequeue the packet in the front 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...
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
Ptr< const WifiMacQueueItem > Peek(void) const
Peek the packet in the front of the queue.
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
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
bool Enqueue(Ptr< WifiMacQueueItem > item)
Enqueue the given Wifi MAC queue item at the end of the queue.
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
Ptr< WifiMacQueueItem > Remove(void)
Remove the packet in the front of the queue.
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 bytes.
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.
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:527
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...