28#include "ns3/simulator.h"
44 TypeId(
"ns3::WifiMacQueue")
48 .AddAttribute(
"MaxSize",
52 MakeQueueSizeChecker())
53 .AddAttribute(
"MaxDelay",
54 "If a packet stays longer than this delay in the queue, it is dropped.",
58 .AddTraceSource(
"Expired",
59 "MPDU dropped because its lifetime expired.",
61 "ns3::WifiMpdu::TracedCallback");
102 std::list<Ptr<WifiMpdu>> mpdus;
105 for (
auto it =
first; it != last; it++)
107 mpdus.push_back(it->mpdu);
120 std::list<Ptr<WifiMpdu>> mpdus;
123 for (
auto it =
first; it != last; it++)
125 mpdus.push_back(it->mpdu);
142 for (
auto it =
first; it != last;)
156 auto it =
GetIt(item);
157 if (now > it->expiryTime)
159 NS_LOG_DEBUG(
"Removing packet that stayed in the queue for too long (queuing time="
201 "WifiMacQueues must be in packet mode");
215 "pos must point to an element in the same container queue as item");
243 std::list<ConstIterator> iterators;
245 for (
const auto& mpdu : mpdus)
247 if (mpdu->IsQueued())
249 auto it =
GetIt(mpdu);
252 iterators.emplace_back(it);
274 if (!queueId.has_value())
325 NS_ASSERT(!item->GetHeader().IsQosData() || !blockedPackets ||
326 !blockedPackets->IsBlocked(item->GetHeader().GetAddr1(),
327 item->GetHeader().GetQosTid()));
337 std::optional<WifiContainerQueueId> queueId;
348 while (queueId.has_value() && blockedPackets &&
350 blockedPackets->IsBlocked(std::get<1>(queueId.value()), std::get<2>(queueId.value())))
355 if (!queueId.has_value())
375 auto it =
GetIt(mpdu);
387 auto currentIt =
GetIt(currentItem);
389 NS_ASSERT(currentIt->mpdu == currentItem);
392 Time expiryTime = currentIt->expiryTime;
393 auto pos = std::next(currentIt);
395 bool ret =
Insert(pos, newItem);
396 GetIt(newItem)->expiryTime = expiryTime;
428 if (pos !=
GetContainer().GetQueue(queueId).cend() && pos->mpdu == mpdu)
431 pos = std::next(pos);
442 item->SetQueueIt(ret, {});
446 ret->deleter = [tag](
auto mpdu) { mpdu->SetQueueIt(std::nullopt, tag); };
459 std::list<Ptr<WifiMpdu>> items;
462 for (
auto& it : iterators)
466 items.push_back(item);
Smart pointer class similar to boost::intrusive_ptr.
Introspection did not find any typical Config paths.
QueueSize GetMaxSize() const
uint32_t GetNBytes() const
uint32_t GetNPackets() const
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
Template class for packet Queues.
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
void DoDispose() override
Destructor implementation.
const ns3::WifiMacQueueContainer & GetContainer() const
Get a const reference to the container of queue items.
Container::iterator Iterator
Iterator.
Container::const_iterator ConstIterator
Const iterator.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
static Time Now()
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.
const ContainerQueue & GetQueue(const WifiContainerQueueId &queueId) const
Get a const reference to the container queue identified by the given QueueId.
static WifiContainerQueueId GetQueueId(Ptr< const WifiMpdu > mpdu)
Return the QueueId identifying the container queue in which the given MPDU is (or is to be) enqueued.
uint32_t GetNBytes(const WifiContainerQueueId &queueId) const
Get the total size of the MPDUs stored in the queue identified by the given QueueId.
std::pair< iterator, iterator > ExtractAllExpiredMpdus() const
Transfer MPDUs with expired lifetime in all the container queues to the container queue storing MPDUs...
std::pair< iterator, iterator > GetAllExpiredMpdus() const
Get the range [first, last) of iterators pointing to all the MPDUs queued in the container queue stor...
std::pair< iterator, iterator > ExtractExpiredMpdus(const WifiContainerQueueId &queueId) const
Transfer MPDUs with expired lifetime in the container queue identified by the given QueueId to the co...
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
Time m_maxDelay
Time to live for packets in the queue.
void Replace(Ptr< const WifiMpdu > currentItem, Ptr< WifiMpdu > newItem)
Replace the given current item with the given new item.
Ptr< WifiMpdu > PeekByQueueId(const WifiContainerQueueId &queueId, Ptr< const WifiMpdu > item=nullptr) const
Search and return the first packet present in the container queue identified by the given queue ID.
Ptr< WifiMpdu > Remove() override
Remove the packet in the front of the queue.
Ptr< WifiMacQueueScheduler > m_scheduler
the MAC queue scheduler
AcIndex GetAc() const
Get the Access Category of the packets stored in this queue.
bool Insert(ConstIterator pos, Ptr< WifiMpdu > item)
Enqueue the given Wifi MAC queue item before the given position.
void ExtractExpiredMpdus(const WifiContainerQueueId &queueId) const
Move MPDUs with expired lifetime from the container queue identified by the given queue ID to the con...
bool Enqueue(Ptr< WifiMpdu > item) override
Enqueue the given Wifi MAC queue item at the end of the queue.
Ptr< const WifiMpdu > Peek() const override
Peek the packet in the front of the queue.
Iterator GetIt(Ptr< const WifiMpdu > mpdu) const
bool TtlExceeded(Ptr< const WifiMpdu > item, const Time &now)
Remove the given item if it has been in the queue for too long.
void WipeAllExpiredMpdus()
Remove all MPDUs with expired lifetime from this WifiMacQueue object.
Ptr< WifiMpdu > Dequeue() override
Dequeue the packet in the front of the queue.
void SetScheduler(Ptr< WifiMacQueueScheduler > scheduler)
Set the wifi MAC queue scheduler.
void SetMaxDelay(Time delay)
Set the maximum delay before the packet is discarded.
void DoDispose() override
Destructor implementation.
Ptr< WifiMpdu > DoRemove(ConstIterator pos)
Wrapper for the DoRemove method provided by the base class that additionally resets the iterator fiel...
WifiMacQueue(AcIndex ac=AC_UNDEF)
Constructor.
void DequeueIfQueued(const std::list< Ptr< const WifiMpdu > > &mpdus)
Dequeue the given MPDUs if they are stored in this queue.
Ptr< WifiMpdu > PeekFirstAvailable(uint8_t linkId, const Ptr< QosBlockedDestinations > blockedPackets=nullptr, Ptr< const WifiMpdu > item=nullptr) const
Return first available packet for transmission on the given link.
TracedCallback< Ptr< const WifiMpdu > > m_traceExpired
Traced callback: fired when a packet is dropped due to lifetime expiration.
bool DoEnqueue(ConstIterator pos, Ptr< WifiMpdu > item)
Wrapper for the DoEnqueue method provided by the base class that additionally sets the iterator field...
AcIndex m_ac
the access category
Ptr< WifiMpdu > PeekByTidAndAddress(uint8_t tid, Mac48Address dest, Ptr< const WifiMpdu > item=nullptr) const
Search and return, if present in the queue, the first packet having the receiver address equal to des...
void DoDequeue(const std::list< ConstIterator > &iterators)
Wrapper for the DoDequeue method provided by the base class that additionally resets the iterator fie...
void ExtractAllExpiredMpdus() const
Move MPDUs with expired lifetime from all the container queues to the container queue storing MPDUs w...
static TypeId GetTypeId()
Get the type ID.
Time GetMaxDelay() const
Return the maximum delay before the packet is discarded.
Tag used to allow (only) WifiMacQueue to access the queue iterator stored by a WifiMpdu.
#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 > MakeTimeAccessor(T1 a1)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#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_TWO_DEFINE(type, param1, param2)
Explicitly instantiate a template class with two template parameters and register the resulting insta...
#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.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::tuple< WifiContainerQueueType, Mac48Address, uint8_t > WifiContainerQueueId
Tuple (queue type, Address, TID) identifying a container queue.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
@ WIFI_QOSDATA_UNICAST_QUEUE