24 #include "ns3/simulator.h"
41 .SetGroupName (
"Wifi")
43 .AddAttribute (
"MaxSize",
49 .AddAttribute (
"MaxDelay",
"If a packet stays longer than this delay in the queue, it is dropped.",
53 .AddAttribute (
"DropPolicy",
"Upon enqueue with full queue, drop oldest (DropOldest) or newest (DropNewest) packet",
58 .AddTraceSource (
"Expired",
"MPDU dropped because its lifetime expired.",
60 "ns3::WifiMacQueueItem::TracedCallback")
83 NS_LOG_DEBUG (
"Removing packet that stayed in the queue for too long (" <<
84 now - (*it)->GetTimeStamp () <<
")");
95 NS_ASSERT (item !=
nullptr && item->IsQueued ());
96 auto it = item->m_queueIt;
118 return Insert (end (), item);
126 return Insert (begin (), item);
134 "WifiMacQueues must be in packet mode");
143 ConstIterator it = begin ();
182 for (ConstIterator it = begin (); it != end (); )
198 if (mpdu->IsQueued ())
212 for (
auto it = begin (); it != end (); it++)
216 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
229 NS_ASSERT (item ==
nullptr || item->IsQueued ());
231 ConstIterator it = (item !=
nullptr ? std::next (item->m_queueIt) : begin ());
237 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
239 if (((*it)->GetHeader ().IsData () || (*it)->GetHeader ().IsQosData ())
240 && (*it)->GetDestinationAddress () == dest)
255 NS_ASSERT (item ==
nullptr || item->IsQueued ());
257 ConstIterator it = (item !=
nullptr ? std::next (item->m_queueIt) : begin ());
263 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
265 if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid)
280 NS_ASSERT (item ==
nullptr || item->IsQueued ());
282 ConstIterator it = (item !=
nullptr ? std::next (item->m_queueIt) : begin ());
288 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
290 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
291 && (*it)->GetHeader ().GetQosTid () == tid)
307 NS_ASSERT (item ==
nullptr || item->IsQueued ());
309 ConstIterator it = (item !=
nullptr ? std::next (item->m_queueIt) : begin ());
315 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
317 if (!(*it)->GetHeader ().IsQosData () || !blockedPackets
318 || !blockedPackets->IsBlocked ((*it)->GetHeader ().GetAddr1 (), (*it)->GetHeader ().GetQosTid ()))
335 for (ConstIterator it = begin (); it != end (); )
350 NS_ASSERT (item != 0 && item->IsQueued ());
354 ConstIterator next = std::next (item->m_queueIt);
356 return (next == end () ?
nullptr : *next);
362 ConstIterator it = begin ();
367 ConstIterator next = std::next (item->m_queueIt);
369 return (next == end () ?
nullptr : *next);
386 NS_ASSERT (*currentItem->m_queueIt == currentItem);
389 auto pos = std::next (currentItem->m_queueIt);
391 bool ret =
Insert (pos, newItem);
402 uint32_t nPackets = 0;
405 for (ConstIterator it = begin (); it != end (); )
409 if ((*it)->GetHeader ().IsData () && (*it)->GetDestinationAddress () == dest)
425 uint32_t nPackets = 0;
428 for (ConstIterator it = begin (); it != end (); )
432 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
433 && (*it)->GetHeader ().GetQosTid () == tid)
451 for (ConstIterator it = begin (); it != end (); )
470 for (ConstIterator it = begin (); it != end (); )
487 for (ConstIterator it = begin (); it != end (); )
528 if (item->GetHeader ().IsQosData ())
530 WifiAddressTidPair addressTidPair (item->GetHeader ().GetAddr1 (), item->GetHeader ().GetQosTid ());
541 item->m_queueAc =
m_ac;
542 item->m_queueIt = ret;
555 if (item != 0 && item->GetHeader ().IsQosData ())
557 WifiAddressTidPair addressTidPair (item->GetHeader ().GetAddr1 (), item->GetHeader ().GetQosTid ());
580 if (item != 0 && item->GetHeader ().IsQosData ())
582 WifiAddressTidPair addressTidPair (item->GetHeader ().GetAddr1 (), item->GetHeader ().GetQosTid ());
Hold variables of type enum.
Smart pointer class similar to boost::intrusive_ptr.
Introspection did not find any typical Config paths.
uint32_t GetNPackets(void) const
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
uint32_t GetNBytes(void) const
QueueSize GetMaxSize(void) const
Template class for packet Queues.
Ptr< Item > DoDequeue(ConstIterator pos)
Pull the item to dequeue from the queue.
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
static Time Now(void)
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
bool DoEnqueue(ConstIterator pos, Ptr< WifiMacQueueItem > item)
Wrapper for the DoEnqueue method provided by the base class that additionally sets the iterator field...
Time m_maxDelay
Time to live for packets in the queue.
Ptr< const WifiMacQueueItem > PeekByTidAndAddress(uint8_t tid, Mac48Address dest, Ptr< const WifiMacQueueItem > item=nullptr) const
Search and return, if present in the queue, the first packet having the receiver address equal to des...
bool PushFront(Ptr< WifiMacQueueItem > item)
Enqueue the given Wifi MAC queue item at the front of the queue.
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.
uint32_t GetNPacketsByAddress(Mac48Address dest)
Return the number of packets having destination address specified by dest.
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedBytes
Per (MAC address, TID) pair queued bytes.
Ptr< const WifiMacQueueItem > PeekFirstAvailable(const Ptr< QosBlockedDestinations > blockedPackets=nullptr, Ptr< const WifiMacQueueItem > item=nullptr) const
Return first available packet for transmission.
bool TtlExceeded(Ptr< const WifiMacQueueItem > item, const Time &now)
Remove the given item if it has been in the queue for too long.
Ptr< WifiMacQueueItem > DoDequeue(ConstIterator pos)
Wrapper for the DoDequeue method provided by the base class that additionally resets the iterator fie...
Time GetMaxDelay(void) const
Return the maximum delay before the packet is discarded.
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedPackets
Per (MAC address, TID) pair queued packets.
void SetMaxDelay(Time delay)
Set the maximum delay before the packet is discarded.
Ptr< const WifiMacQueueItem > PeekByAddress(Mac48Address dest, Ptr< const WifiMacQueueItem > item=nullptr) const
Search and return, if present in the queue, the first packet (either Data frame or QoS Data frame) ha...
bool Insert(ConstIterator pos, Ptr< WifiMacQueueItem > item)
Enqueue the given Wifi MAC queue item before the given position.
Ptr< const WifiMacQueueItem > Peek(void) const override
Peek the packet in the front of the queue.
Ptr< WifiMacQueueItem > DoRemove(ConstIterator pos)
Wrapper for the DoRemove method provided by the base class that additionally resets the iterator fiel...
bool Enqueue(Ptr< WifiMacQueueItem > item) override
Enqueue the given Wifi MAC queue item at the end of the queue.
Ptr< const WifiMacQueueItem > PeekByTid(uint8_t tid, Ptr< const WifiMacQueueItem > item=nullptr) const
Search and return, if present in the queue, the first packet having the TID equal to tid.
uint32_t GetNPackets(void)
static TypeId GetTypeId(void)
Get the type ID.
WifiMacQueue(AcIndex ac=AC_UNDEF)
Constructor.
TracedCallback< Ptr< const WifiMacQueueItem > > m_traceExpired
Traced callback: fired when a packet is dropped due to lifetime expiration.
Ptr< WifiMacQueueItem > Dequeue(void) override
Dequeue the packet in the front of the queue.
AcIndex m_ac
the access category
void Replace(Ptr< const WifiMacQueueItem > currentItem, Ptr< WifiMacQueueItem > newItem)
Replace the given current item with the given new item.
DropPolicy m_dropPolicy
Drop behavior of queue.
void DequeueIfQueued(Ptr< const WifiMacQueueItem > mpdu)
Dequeue the given MPDU if it is stored in this queue.
Ptr< WifiMacQueueItem > Remove(void) override
Remove the packet in the front of the queue.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_TEMPLATE_CLASS_DEFINE(type, param)
Explicitly instantiate a template class and register the resulting instance with the TypeId system.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
@ PACKETS
Use number of packets for queue size.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
@ AC_UNDEF
Total number of ACs.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
std::pair< Mac48Address, uint8_t > WifiAddressTidPair
(MAC address, TID) pair