|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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")
100 return Insert (end (), item);
108 return Insert (begin (), item);
116 "WifiMacQueues must be in packet mode");
125 ConstIterator it = begin ();
164 for (ConstIterator it = begin (); it != end (); )
180 if (mpdu->IsQueued ())
194 for (
auto it = begin (); it != end (); it++)
198 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
207 WifiMacQueue::ConstIterator
211 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
217 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
219 if (((*it)->GetHeader ().IsData () || (*it)->GetHeader ().IsQosData ())
220 && (*it)->GetDestinationAddress () == dest)
231 WifiMacQueue::ConstIterator
235 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
241 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
243 if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid)
254 WifiMacQueue::ConstIterator
258 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
264 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
266 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
267 && (*it)->GetHeader ().GetQosTid () == tid)
278 WifiMacQueue::ConstIterator
282 ConstIterator it = (pos !=
EMPTY ? pos : begin ());
288 if (now <= (*it)->GetTimeStamp () +
m_maxDelay)
290 if (!(*it)->GetHeader ().IsQosData () || !blockedPackets
291 || !blockedPackets->IsBlocked ((*it)->GetHeader ().GetAddr1 (), (*it)->GetHeader ().GetQosTid ()))
308 for (ConstIterator it = begin (); it != end (); )
325 for (ConstIterator it = begin (); it != end (); )
329 if ((*it)->GetPacket () == packet)
338 NS_LOG_DEBUG (
"Packet " << packet <<
" not found in the queue");
342 WifiMacQueue::ConstIterator
349 ConstIterator curr = pos++;
357 ConstIterator it = begin ();
362 ConstIterator curr = pos++;
380 uint32_t nPackets = 0;
383 for (ConstIterator it = begin (); it != end (); )
387 if ((*it)->GetHeader ().IsData () && (*it)->GetDestinationAddress () == dest)
403 uint32_t nPackets = 0;
406 for (ConstIterator it = begin (); it != end (); )
410 if ((*it)->GetHeader ().IsQosData () && (*it)->GetDestinationAddress () == dest
411 && (*it)->GetHeader ().GetQosTid () == tid)
429 for (ConstIterator it = begin (); it != end (); )
448 for (ConstIterator it = begin (); it != end (); )
465 for (ConstIterator it = begin (); it != end (); )
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< Item > DoDequeue(ConstIterator pos)
Pull the item to dequeue from the queue.
uint32_t GetNBytes(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint32_t GetNPackets(void) const
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetNPackets(void)
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
uint32_t GetNPacketsByAddress(Mac48Address dest)
Return the number of packets having destination address specified by dest.
ConstIterator PeekFirstAvailable(const Ptr< QosBlockedDestinations > blockedPackets=nullptr, ConstIterator pos=EMPTY) const
Return first available packet for transmission.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Time GetMaxDelay(void) const
Return the maximum delay before the packet is discarded.
@ PACKETS
Use number of packets for queue size.
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedPackets
Per (MAC address, TID) pair queued packets.
Ptr< WifiMacQueueItem > DoRemove(ConstIterator pos)
Wrapper for the DoRemove method provided by the base class that additionally resets the iterator fiel...
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
bool Insert(ConstIterator pos, Ptr< WifiMacQueueItem > item)
Enqueue the given Wifi MAC queue item before the given position.
Hold variables of type enum.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
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) override
Dequeue the packet in the front of the queue.
Time m_maxDelay
Time to live for packets in the queue.
bool Enqueue(Ptr< WifiMacQueueItem > item) override
Enqueue the given Wifi MAC queue item at the end of the queue.
AcIndex m_ac
the access category
bool DoEnqueue(ConstIterator pos, Ptr< WifiMacQueueItem > item)
Wrapper for the DoEnqueue method provided by the base class that additionally sets the iterator field...
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > m_nQueuedBytes
Per (MAC address, TID) pair queued bytes.
Introspection did not find any typical Config paths.
void DequeueIfQueued(Ptr< const WifiMacQueueItem > mpdu)
Dequeue the given MPDU if it is stored in this queue.
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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
@ AC_UNDEF
Total number of ACs.
Simulation virtual time values and global simulation resolution.
#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 > DoDequeue(ConstIterator pos)
Wrapper for the DoDequeue method provided by the base class that additionally resets the iterator fie...
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...
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...
static std::list< Ptr< WifiMacQueueItem > > g_emptyWifiMacQueue
empty Wi-Fi MAC queue
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
std::pair< Mac48Address, uint8_t > WifiAddressTidPair
(MAC address, TID) pair
bool IsQueued(void) const
Return true if this item is stored in some queue, false otherwise.
Ptr< WifiMacQueueItem > Remove(void) override
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.
DropPolicy m_dropPolicy
Drop behavior of queue.
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void SetMaxDelay(Time delay)
Set the maximum delay before the packet is discarded.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
WifiMacQueue(AcIndex ac=AC_UNDEF)
Constructor.
Ptr< const WifiMacQueueItem > Peek(void) const override
Peek the packet in the front of the queue.
QueueSize GetMaxSize(void) const
#define NS_OBJECT_TEMPLATE_CLASS_DEFINE(type, param)
Explicitly instantiate a template class and register the resulting instance with the TypeId system.
uint32_t GetSize(void) const
Return the size of the packet stored by this item, including header size and trailer size.
static TypeId GetTypeId(void)
Get the type ID.
Class for representing queue sizes.
Template class for packet Queues.
ConstIterator m_queueIt
Queue iterator pointing to this MPDU, if queued.
static const ConstIterator EMPTY
Invalid iterator to signal an empty queue.
bool TtlExceeded(ConstIterator &it, const Time &now)
Remove the item pointed to by the iterator it if it has been in the queue for too long.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
TracedCallback< Ptr< const WifiMacQueueItem > > m_traceExpired
Traced callback: fired when a packet is dropped due to lifetime expiration.
AcIndex m_queueAc
AC associated with the queue this MPDU is stored into.