24 #include "ns3/simulator.h" 40 .SetGroupName (
"Wifi")
42 .AddAttribute (
"MaxQueueSize",
47 .AddAttribute (
"MaxDelay",
"If a packet stays longer than this delay in the queue, it is dropped.",
51 .AddAttribute (
"DropPolicy",
"Upon enqueue with full queue, drop oldest (DropOldest) or newest (DropNewest) packet",
56 .AddTraceSource (
"Expired",
"MPDU dropped because its lifetime expired.",
58 "ns3::WifiMacQueueItem::TracedCallback")
64 : m_expiredPacketsPresent (false),
74 const WifiMacQueue::ConstIterator
WifiMacQueue::EMPTY = std::list<Ptr<WifiMacQueueItem>> ().end ();
109 NS_LOG_DEBUG (
"Removing packet that stayed in the queue for too long (" <<
124 return Insert (end (), item);
132 return Insert (begin (), item);
140 "WifiMacQueues must be in packet mode");
147 return DoEnqueue (pos, item);
151 ConstIterator it = begin ();
156 return DoEnqueue (it, item);
160 return DoEnqueue (pos, item);
172 return DoEnqueue (pos, item);
179 for (ConstIterator it = begin (); it != end (); )
183 return DoDequeue (it);
254 return DoDequeue (pos);
258 ConstIterator it = begin ();
270 return DoDequeue (it);
281 Ptr<const WifiMacQueueItem>
285 for (
auto it = begin (); it != end (); it++)
300 WifiMacQueue::ConstIterator
304 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
311 if (((*it)->GetHeader ().IsData () || (*it)->GetHeader ().IsQosData ())
312 && (*it)->GetDestinationAddress () == dest)
328 WifiMacQueue::ConstIterator
332 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
339 if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid)
355 WifiMacQueue::ConstIterator
359 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
366 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
367 && (*it)->GetHeader ().GetQosTid () == tid)
383 WifiMacQueue::ConstIterator
387 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
394 if (!(*it)->GetHeader ().IsQosData () || !blockedPackets
395 || !blockedPackets->IsBlocked ((*it)->GetHeader ().GetAddr1 (), (*it)->GetHeader ().GetQosTid ()))
416 for (ConstIterator it = begin (); it != end (); )
420 return DoRemove (it);
431 for (ConstIterator it = begin (); it != end (); )
435 if ((*it)->GetPacket () == packet)
444 NS_LOG_DEBUG (
"Packet " << packet <<
" not found in the queue");
448 WifiMacQueue::ConstIterator
455 ConstIterator curr = pos++;
461 ConstIterator it = begin ();
469 ConstIterator curr = pos++;
487 uint32_t nPackets = 0;
489 for (ConstIterator it = begin (); it != end (); )
493 if ((*it)->GetHeader ().IsData () && (*it)->GetDestinationAddress () == dest)
509 uint32_t nPackets = 0;
510 for (ConstIterator it = begin (); it != end (); )
514 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
515 && (*it)->GetHeader ().GetQosTid () == tid)
531 for (ConstIterator it = begin (); it != end (); )
548 for (ConstIterator it = begin (); it != end (); )
563 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.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Ptr< const AttributeAccessor > MakeEnumAccessor(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.
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
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
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...
void SetMaxQueueSize(QueueSize size)
Set the maximum size of this queue.
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...
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.
TracedCallback< Ptr< const WifiMacQueueItem > > m_traceExpired
True if expired packets are in the queue
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.
QueueSize GetMaxQueueSize(void) const
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.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< WifiMacQueueItem > Remove(void)
Remove the packet in the front of the queue.
QueueSize m_maxSize
max queue size
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< 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...
#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...