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")
66 : m_expiredPacketsPresent (false),
100 NS_LOG_DEBUG (
"Removing packet that stayed in the queue for too long (" <<
115 return Insert (end (), item);
123 return Insert (begin (), item);
131 "WifiMacQueues must be in packet mode");
140 ConstIterator it = begin ();
177 for (ConstIterator it = begin (); it != end (); )
256 ConstIterator it = begin ();
279 Ptr<const WifiMacQueueItem>
283 for (
auto it = begin (); it != end (); it++)
298 WifiMacQueue::ConstIterator
302 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
309 if (((*it)->GetHeader ().IsData () || (*it)->GetHeader ().IsQosData ())
310 && (*it)->GetDestinationAddress () == dest)
326 WifiMacQueue::ConstIterator
330 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
337 if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid)
353 WifiMacQueue::ConstIterator
357 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
364 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
365 && (*it)->GetHeader ().GetQosTid () == tid)
381 WifiMacQueue::ConstIterator
385 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
392 if (!(*it)->GetHeader ().IsQosData () || !blockedPackets
393 || !blockedPackets->IsBlocked ((*it)->GetHeader ().GetAddr1 (), (*it)->GetHeader ().GetQosTid ()))
414 for (ConstIterator it = begin (); it != end (); )
429 for (ConstIterator it = begin (); it != end (); )
433 if ((*it)->GetPacket () == packet)
442 NS_LOG_DEBUG (
"Packet " << packet <<
" not found in the queue");
446 WifiMacQueue::ConstIterator
453 ConstIterator curr = pos++;
459 ConstIterator it = begin ();
467 ConstIterator curr = pos++;
485 uint32_t nPackets = 0;
487 for (ConstIterator it = begin (); it != end (); )
491 if ((*it)->GetHeader ().IsData () && (*it)->GetDestinationAddress () == dest)
507 uint32_t nPackets = 0;
508 for (ConstIterator it = begin (); it != end (); )
512 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
513 && (*it)->GetHeader ().GetQosTid () == tid)
529 for (ConstIterator it = begin (); it != end (); )
546 for (ConstIterator it = begin (); it != end (); )
561 for (ConstIterator it = begin (); it != end (); )
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
Simulation virtual time values and global simulation resolution.
#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.
QueueSize GetMaxSize(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< WifiMacQueueItem > DoDequeue(ConstIterator pos)
Wrapper for the DoDequeue method provided by the base class that additionally resets the iterator fie...
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
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
Hold variables of type enum.
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.
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
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...
Use number of packets for queue size.
static TypeId GetTypeId(void)
Get the type ID.
Time GetMaxDelay(void) const
Return the maximum delay before the packet is discarded.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
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)
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.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Ptr< WifiMacQueueItem > DequeueFirstAvailable(const Ptr< QosBlockedDestinations > blockedPackets=nullptr)
Return first available packet for transmission.
static Time Now(void)
Return the current simulation virtual time.
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...
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.
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.
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.
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedPackets
Per (MAC address, TID) pair queued packets.
#define NS_OBJECT_TEMPLATE_CLASS_DEFINE(type, param)
Explicitly instantiate a template class and register the resulting instance with the TypeId system...
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.
uint32_t GetNPackets(void)
Ptr< Item > DoDequeue(ConstIterator pos)
Pull the item to dequeue from the queue.
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
a unique identifier for an interface.
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.
Ptr< WifiMacQueueItem > DequeueByTid(uint8_t tid)
Search and return, if present in the queue, the first packet having the TID equal to tid...