24 #include "ns3/simulator.h" 40 .SetGroupName (
"Wifi")
42 .AddAttribute (
"MaxSize",
48 .AddAttribute (
"MaxDelay",
"If a packet stays longer than this delay in the queue, it is dropped.",
52 .AddAttribute (
"DropPolicy",
"Upon enqueue with full queue, drop oldest (DropOldest) or newest (DropNewest) packet",
57 .AddTraceSource (
"Expired",
"MPDU dropped because its lifetime expired.",
59 "ns3::WifiMacQueueItem::TracedCallback")
65 : m_expiredPacketsPresent (false),
99 NS_LOG_DEBUG (
"Removing packet that stayed in the queue for too long (" <<
114 return Insert (end (), item);
122 return Insert (begin (), item);
130 "WifiMacQueues must be in packet mode");
135 return DoEnqueue (pos, item);
139 ConstIterator it = begin ();
144 return DoEnqueue (it, item);
148 return DoEnqueue (pos, item);
160 return DoEnqueue (pos, item);
167 for (ConstIterator it = begin (); it != end (); )
171 return DoDequeue (it);
242 return DoDequeue (pos);
246 ConstIterator it = begin ();
258 return DoDequeue (it);
269 Ptr<const WifiMacQueueItem>
273 for (
auto it = begin (); it != end (); it++)
288 WifiMacQueue::ConstIterator
292 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
299 if (((*it)->GetHeader ().IsData () || (*it)->GetHeader ().IsQosData ())
300 && (*it)->GetDestinationAddress () == dest)
316 WifiMacQueue::ConstIterator
320 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
327 if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid)
343 WifiMacQueue::ConstIterator
347 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
354 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
355 && (*it)->GetHeader ().GetQosTid () == tid)
371 WifiMacQueue::ConstIterator
375 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
382 if (!(*it)->GetHeader ().IsQosData () || !blockedPackets
383 || !blockedPackets->IsBlocked ((*it)->GetHeader ().GetAddr1 (), (*it)->GetHeader ().GetQosTid ()))
404 for (ConstIterator it = begin (); it != end (); )
408 return DoRemove (it);
419 for (ConstIterator it = begin (); it != end (); )
423 if ((*it)->GetPacket () == packet)
432 NS_LOG_DEBUG (
"Packet " << packet <<
" not found in the queue");
436 WifiMacQueue::ConstIterator
443 ConstIterator curr = pos++;
449 ConstIterator it = begin ();
457 ConstIterator curr = pos++;
475 uint32_t nPackets = 0;
477 for (ConstIterator it = begin (); it != end (); )
481 if ((*it)->GetHeader ().IsData () && (*it)->GetDestinationAddress () == dest)
497 uint32_t nPackets = 0;
498 for (ConstIterator it = begin (); it != end (); )
502 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
503 && (*it)->GetHeader ().GetQosTid () == tid)
519 for (ConstIterator it = begin (); it != end (); )
536 for (ConstIterator it = begin (); it != end (); )
551 for (ConstIterator it = begin (); it != end (); )
Time m_maxDelay
Time to live for packets in the queue.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
#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.
#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.
Introspection did not find any typical Config paths.
#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.
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...
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.
Ptr< const WifiMacQueueItem > Peek(void) const
Peek the packet in the front of the queue.
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
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.
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...
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.
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.
#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.
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
uint32_t GetNPackets(void)
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...