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 (); )
Hold variables of type enum.
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.
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< WifiMacQueueItem > DequeueFirstAvailable(const Ptr< QosBlockedDestinations > blockedPackets=nullptr)
Return first available packet for transmission.
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.
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< 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.
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...
void SetMaxDelay(Time delay)
Set the maximum delay before the packet is discarded.
static const ConstIterator EMPTY
Invalid iterator to signal an empty queue.
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 > DequeueByAddress(Mac48Address dest)
Search and return, if present in the queue, the first packet (either Data frame or QoS Data frame) ha...
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.
uint32_t GetNPackets(void)
Ptr< WifiMacQueueItem > DequeueByTid(uint8_t tid)
Search and return, if present in the queue, the first packet having the TID equal to tid.
bool m_expiredPacketsPresent
True if expired packets are in the queue.
static TypeId GetTypeId(void)
Get the type ID.
ConstIterator PeekFirstAvailable(const Ptr< QosBlockedDestinations > blockedPackets=nullptr, ConstIterator pos=EMPTY) const
Return first available packet for transmission.
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.
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...
TracedCallback< Ptr< const WifiMacQueueItem > > m_traceExpired
Traced callback: fired when a packet is dropped due to lifetime expiration.
bool TtlExceeded(ConstIterator &it)
Remove the item pointed to by the iterator it if it has been in the queue for too long.
Ptr< WifiMacQueueItem > Dequeue(void) override
Dequeue the packet in the front of the queue.
DropPolicy m_dropPolicy
Drop behavior of queue.
Ptr< WifiMacQueueItem > Remove(void) override
Remove the packet in the front of the queue.
uint32_t GetSize(void) const
Return the size of the packet stored by this item, including header size and trailer size.
std::list< QueueIteratorPair > m_queueIts
Queue iterators pointing to this MSDU(s), if queued.
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
#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 AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
static std::list< Ptr< WifiMacQueueItem > > g_emptyWifiMacQueue
empty Wi-Fi MAC queue
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 AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
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