This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" paragraph 6; IEEE 802.11-2012). More...
#include "wifi-mac-queue.h"
Public Types | |
enum | DropPolicy { DROP_NEWEST, DROP_OLDEST } |
drop policy More... | |
Public Member Functions | |
WifiMacQueue (AcIndex ac=AC_UNDEF) | |
Constructor. More... | |
~WifiMacQueue () | |
Ptr< WifiMacQueueItem > | Dequeue (void) override |
Dequeue the packet in the front of the queue. More... | |
void | DequeueIfQueued (Ptr< const WifiMacQueueItem > mpdu) |
Dequeue the given MPDU if it is stored in this queue. More... | |
bool | Enqueue (Ptr< WifiMacQueueItem > item) override |
Enqueue the given Wifi MAC queue item at the end of the queue. More... | |
Time | GetMaxDelay (void) const |
Return the maximum delay before the packet is discarded. More... | |
uint32_t | GetNBytes (uint8_t tid, Mac48Address dest) const |
Return the number of bytes in the queue having tid equal to tid and destination address equal to dest. More... | |
uint32_t | GetNBytes (void) |
uint32_t | GetNPackets (uint8_t tid, Mac48Address dest) const |
Return the number of QoS packets in the queue having tid equal to tid and destination address equal to dest. More... | |
uint32_t | GetNPackets (void) |
uint32_t | GetNPacketsByAddress (Mac48Address dest) |
Return the number of packets having destination address specified by dest. More... | |
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. More... | |
bool | Insert (ConstIterator pos, Ptr< WifiMacQueueItem > item) |
Enqueue the given Wifi MAC queue item before the given position. More... | |
bool | IsEmpty (void) |
Ptr< const WifiMacQueueItem > | Peek (void) const override |
Peek the packet in the front of the queue. More... | |
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) having the receiver address equal to addr. More... | |
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. More... | |
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 dest, and TID equal to tid. More... | |
ConstIterator | PeekFirstAvailable (const Ptr< QosBlockedDestinations > blockedPackets=nullptr, ConstIterator pos=EMPTY) const |
Return first available packet for transmission. More... | |
bool | PushFront (Ptr< WifiMacQueueItem > item) |
Enqueue the given Wifi MAC queue item at the front of the queue. More... | |
ConstIterator | Remove (ConstIterator pos, bool removeExpired=false) |
Remove the item at position pos in the queue and return an iterator pointing to the item following the removed one. More... | |
bool | Remove (Ptr< const Packet > packet) |
If exists, removes packet from queue and returns true. More... | |
Ptr< WifiMacQueueItem > | Remove (void) override |
Remove the packet in the front of the queue. More... | |
void | SetMaxDelay (Time delay) |
Set the maximum delay before the packet is discarded. More... | |
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. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Static Public Attributes | |
static const ConstIterator | EMPTY = g_emptyWifiMacQueue.end () |
Invalid iterator to signal an empty queue. More... | |
Private Member Functions | |
Ptr< WifiMacQueueItem > | DoDequeue (ConstIterator pos) |
Wrapper for the DoDequeue method provided by the base class that additionally resets the iterator field of the item and updates internal statistics, if an item was dequeued. More... | |
bool | DoEnqueue (ConstIterator pos, Ptr< WifiMacQueueItem > item) |
Wrapper for the DoEnqueue method provided by the base class that additionally sets the iterator field of the item and updates internal statistics, if insertion succeeded. More... | |
Ptr< WifiMacQueueItem > | DoRemove (ConstIterator pos) |
Wrapper for the DoRemove method provided by the base class that additionally resets the iterator field of the item and updates internal statistics, if an item was dropped. More... | |
Private Attributes | |
AcIndex | m_ac |
the access category More... | |
DropPolicy | m_dropPolicy |
Drop behavior of queue. More... | |
Time | m_maxDelay |
Time to live for packets in the queue. More... | |
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > | m_nQueuedBytes |
Per (MAC address, TID) pair queued bytes. More... | |
std::unordered_map< WifiAddressTidPair, uint32_t, WifiAddressTidHash > | m_nQueuedPackets |
Per (MAC address, TID) pair queued packets. More... | |
TracedCallback< Ptr< const WifiMacQueueItem > > | m_traceExpired |
Traced callback: fired when a packet is dropped due to lifetime expiration. More... | |
NS_LOG_TEMPLATE_DECLARE | |
redefinition of the log component More... | |
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" paragraph 6; IEEE 802.11-2012).
When a packet is received by the MAC, to be sent to the PHY, it is queued in the internal queue after being tagged by the current time.
When a packet is dequeued, the queue checks its timestamp to verify whether or not it should be dropped. If dot11EDCATableMSDULifetime has elapsed, it is dropped. Otherwise, it is returned to the caller.
ns3::WifiMacQueue is accessible through the following paths with Config::Set and Config::Connect:
Size of this type is 384 bytes (on a 64-bit architecture).
Definition at line 59 of file wifi-mac-queue.h.
Constructor.
ac | the Access Category of the packets stored in this queue |
Definition at line 65 of file wifi-mac-queue.cc.
ns3::WifiMacQueue::~WifiMacQueue | ( | ) |
Definition at line 71 of file wifi-mac-queue.cc.
References m_nQueuedBytes, m_nQueuedPackets, and NS_LOG_FUNCTION_NOARGS.
|
override |
Dequeue the packet in the front of the queue.
Definition at line 160 of file wifi-mac-queue.cc.
References DoDequeue(), ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
void ns3::WifiMacQueue::DequeueIfQueued | ( | Ptr< const WifiMacQueueItem > | mpdu | ) |
Dequeue the given MPDU if it is stored in this queue.
mpdu | the given MPDU |
Definition at line 176 of file wifi-mac-queue.cc.
References DoDequeue(), m_ac, NS_ASSERT, and NS_LOG_FUNCTION.
|
private |
Wrapper for the DoDequeue method provided by the base class that additionally resets the iterator field of the item and updates internal statistics, if an item was dequeued.
pos | the position of the item to dequeue |
Definition at line 527 of file wifi-mac-queue.cc.
References ns3::AC_UNDEF, ns3::Queue< Item >::DoDequeue(), ns3::WifiMacHeader::GetAddr1(), ns3::WifiMacQueueItem::GetHeader(), ns3::WifiMacHeader::GetQosTid(), ns3::WifiMacQueueItem::GetSize(), ns3::WifiMacHeader::IsQosData(), ns3::WifiMacQueueItem::IsQueued(), m_nQueuedBytes, m_nQueuedPackets, ns3::WifiMacQueueItem::m_queueAc, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
Referenced by Dequeue(), and DequeueIfQueued().
|
private |
Wrapper for the DoEnqueue method provided by the base class that additionally sets the iterator field of the item and updates internal statistics, if insertion succeeded.
pos | the position before where the item will be inserted |
item | the item to enqueue |
Definition at line 500 of file wifi-mac-queue.cc.
References ns3::WifiMacHeader::GetAddr1(), ns3::WifiMacQueueItem::GetHeader(), ns3::WifiMacHeader::GetQosTid(), ns3::WifiMacQueueItem::GetSize(), ns3::WifiMacHeader::IsQosData(), m_ac, m_nQueuedBytes, m_nQueuedPackets, ns3::WifiMacQueueItem::m_queueAc, and ns3::WifiMacQueueItem::m_queueIt.
Referenced by Insert().
|
private |
Wrapper for the DoRemove method provided by the base class that additionally resets the iterator field of the item and updates internal statistics, if an item was dropped.
pos | the position of the item to drop |
Definition at line 560 of file wifi-mac-queue.cc.
References ns3::AC_UNDEF, ns3::Queue< Item >::DoRemove(), ns3::WifiMacHeader::GetAddr1(), ns3::WifiMacQueueItem::GetHeader(), ns3::WifiMacHeader::GetQosTid(), ns3::WifiMacQueueItem::GetSize(), ns3::WifiMacHeader::IsQosData(), ns3::WifiMacQueueItem::IsQueued(), m_nQueuedBytes, m_nQueuedPackets, ns3::WifiMacQueueItem::m_queueAc, and NS_ASSERT.
Referenced by Insert(), Remove(), and TtlExceeded().
|
override |
Enqueue the given Wifi MAC queue item at the end of the queue.
item | the Wifi MAC queue item to be enqueued at the end |
Definition at line 96 of file wifi-mac-queue.cc.
References Insert(), and NS_LOG_FUNCTION.
Time ns3::WifiMacQueue::GetMaxDelay | ( | void | ) | const |
Return the maximum delay before the packet is discarded.
Definition at line 90 of file wifi-mac-queue.cc.
References m_maxDelay.
uint32_t ns3::WifiMacQueue::GetNBytes | ( | uint8_t | tid, |
Mac48Address | dest | ||
) | const |
Return the number of bytes in the queue having tid equal to tid and destination address equal to dest.
The complexity in the average case is constant. However, packets expired since the last non-const operation on the queue are included in the returned count.
tid | the given TID |
dest | the given destination |
Definition at line 488 of file wifi-mac-queue.cc.
References m_nQueuedBytes.
uint32_t ns3::WifiMacQueue::GetNBytes | ( | void | ) |
Overrides the GetNBytes method provided by QueueBase
Definition at line 459 of file wifi-mac-queue.cc.
References ns3::QueueBase::GetNBytes(), ns3::Simulator::Now(), NS_LOG_FUNCTION, and TtlExceeded().
uint32_t ns3::WifiMacQueue::GetNPackets | ( | uint8_t | tid, |
Mac48Address | dest | ||
) | const |
Return the number of QoS packets in the queue having tid equal to tid and destination address equal to dest.
The complexity in the average case is constant. However, packets expired since the last non-const operation on the queue are included in the returned count.
tid | the given TID |
dest | the given destination |
Definition at line 476 of file wifi-mac-queue.cc.
References m_nQueuedPackets.
uint32_t ns3::WifiMacQueue::GetNPackets | ( | void | ) |
Overrides the GetNPackets method provided by QueueBase
Definition at line 442 of file wifi-mac-queue.cc.
References ns3::QueueBase::GetNPackets(), ns3::Simulator::Now(), NS_LOG_FUNCTION, and TtlExceeded().
uint32_t ns3::WifiMacQueue::GetNPacketsByAddress | ( | Mac48Address | dest | ) |
Return the number of packets having destination address specified by dest.
The complexity is linear in the size of the queue.
dest | the given destination |
Definition at line 376 of file wifi-mac-queue.cc.
References ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
uint32_t ns3::WifiMacQueue::GetNPacketsByTidAndAddress | ( | uint8_t | tid, |
Mac48Address | dest | ||
) |
Return the number of QoS packets having TID equal to tid and destination address equal to dest.
The complexity is linear in the size of the queue.
tid | the given TID |
dest | the given destination |
Definition at line 400 of file wifi-mac-queue.cc.
References ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
|
static |
Get the type ID.
Definition at line 37 of file wifi-mac-queue.cc.
References DROP_NEWEST, DROP_OLDEST, ns3::QueueBase::GetMaxSize(), m_dropPolicy, m_traceExpired, ns3::MakeEnumAccessor(), ns3::MakeEnumChecker(), ns3::MakeQueueSizeAccessor(), ns3::MakeQueueSizeChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MilliSeconds(), SetMaxDelay(), ns3::QueueBase::SetMaxSize(), and ns3::TypeId::SetParent().
bool ns3::WifiMacQueue::Insert | ( | ConstIterator | pos, |
Ptr< WifiMacQueueItem > | item | ||
) |
Enqueue the given Wifi MAC queue item before the given position.
pos | the position before which the item is to be inserted |
item | the Wifi MAC queue item to be enqueued |
Definition at line 112 of file wifi-mac-queue.cc.
References DoEnqueue(), DoRemove(), DROP_OLDEST, ns3::QueueBase::GetNPackets(), m_dropPolicy, ns3::Simulator::Now(), NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::PACKETS, and TtlExceeded().
Referenced by Enqueue(), and PushFront().
bool ns3::WifiMacQueue::IsEmpty | ( | void | ) |
Overrides the IsEmpty method provided by QueueBase
Definition at line 424 of file wifi-mac-queue.cc.
References ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
|
override |
Peek the packet in the front of the queue.
The packet is not removed.
Definition at line 190 of file wifi-mac-queue.cc.
References m_maxDelay, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
WifiMacQueue::ConstIterator ns3::WifiMacQueue::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) having the receiver address equal to addr.
If pos is a valid iterator, the search starts from the packet pointed to by the given iterator. This method does not remove the packet from the queue.
dest | the given destination |
pos | the iterator pointing to the packet the search starts from |
Definition at line 208 of file wifi-mac-queue.cc.
References EMPTY, m_maxDelay, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
WifiMacQueue::ConstIterator ns3::WifiMacQueue::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.
If pos is a valid iterator, the search starts from the packet pointed to by the given iterator. This method does not remove the packet from the queue.
tid | the given TID |
pos | the iterator pointing to the packet the search starts from |
Definition at line 232 of file wifi-mac-queue.cc.
References EMPTY, m_maxDelay, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
WifiMacQueue::ConstIterator ns3::WifiMacQueue::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 dest, and TID equal to tid.
If pos is a valid iterator, the search starts from the packet pointed to by the given iterator. This method does not remove the packet from the queue. It is typically used by ns3::QosTxop in order to perform correct MSDU aggregation (A-MSDU).
tid | the given TID |
dest | the given destination |
pos | the iterator pointing to the packet the search starts from |
Definition at line 255 of file wifi-mac-queue.cc.
References EMPTY, m_maxDelay, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
WifiMacQueue::ConstIterator ns3::WifiMacQueue::PeekFirstAvailable | ( | const Ptr< QosBlockedDestinations > | blockedPackets = nullptr , |
ConstIterator | pos = EMPTY |
||
) | const |
Return first available packet for transmission.
The packet is not removed from queue.
blockedPackets | the destination address & TID pairs that are waiting for a BlockAck response |
pos | the iterator pointing to the packet the search starts from |
Definition at line 279 of file wifi-mac-queue.cc.
References EMPTY, m_maxDelay, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
bool ns3::WifiMacQueue::PushFront | ( | Ptr< WifiMacQueueItem > | item | ) |
Enqueue the given Wifi MAC queue item at the front of the queue.
item | the Wifi MAC queue item to be enqueued at the front |
Definition at line 104 of file wifi-mac-queue.cc.
References Insert(), and NS_LOG_FUNCTION.
WifiMacQueue::ConstIterator ns3::WifiMacQueue::Remove | ( | ConstIterator | pos, |
bool | removeExpired = false |
||
) |
Remove the item at position pos in the queue and return an iterator pointing to the item following the removed one.
If removeExpired is true, all the items in the queue from the head to the given position are removed if their lifetime expired.
pos | the position of the item to be removed |
removeExpired | true to remove expired items |
Definition at line 343 of file wifi-mac-queue.cc.
References DoRemove(), ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
If exists, removes packet from queue and returns true.
Otherwise it takes no effects and return false. Deletion of the packet is performed in linear time (O(n)).
packet | the packet to be removed |
Definition at line 320 of file wifi-mac-queue.cc.
References DoRemove(), ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
|
override |
Remove the packet in the front of the queue.
Definition at line 303 of file wifi-mac-queue.cc.
References DoRemove(), ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
Referenced by OfdmaAckSequenceTest::Transmit().
void ns3::WifiMacQueue::SetMaxDelay | ( | Time | delay | ) |
Set the maximum delay before the packet is discarded.
delay | the maximum delay |
Definition at line 83 of file wifi-mac-queue.cc.
References m_maxDelay, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
inline |
Remove the item pointed to by the iterator it if it has been in the queue for too long.
Implementation of inline functions.
If the item is removed, the iterator is updated to point to the item that followed the erased one.
it | an iterator pointing to the item |
now | a copy of Simulator::Now() |
Definition at line 352 of file wifi-mac-queue.h.
References DoRemove(), m_maxDelay, m_traceExpired, and NS_LOG_DEBUG.
Referenced by Dequeue(), DoDequeue(), GetNBytes(), GetNPackets(), GetNPacketsByAddress(), GetNPacketsByTidAndAddress(), Insert(), IsEmpty(), and Remove().
|
static |
Invalid iterator to signal an empty queue.
Definition at line 298 of file wifi-mac-queue.h.
Referenced by PeekByAddress(), PeekByTid(), PeekByTidAndAddress(), PeekFirstAvailable(), and ns3::QosTxop::PeekNextMpdu().
|
private |
the access category
Definition at line 333 of file wifi-mac-queue.h.
Referenced by DequeueIfQueued(), and DoEnqueue().
|
private |
Drop behavior of queue.
Definition at line 332 of file wifi-mac-queue.h.
Referenced by GetTypeId(), and Insert().
|
private |
Time to live for packets in the queue.
Definition at line 331 of file wifi-mac-queue.h.
Referenced by GetMaxDelay(), Peek(), PeekByAddress(), PeekByTid(), PeekByTidAndAddress(), PeekFirstAvailable(), SetMaxDelay(), and TtlExceeded().
|
private |
Per (MAC address, TID) pair queued bytes.
Definition at line 338 of file wifi-mac-queue.h.
Referenced by ~WifiMacQueue(), DoDequeue(), DoEnqueue(), DoRemove(), and GetNBytes().
|
private |
Per (MAC address, TID) pair queued packets.
Definition at line 336 of file wifi-mac-queue.h.
Referenced by ~WifiMacQueue(), DoDequeue(), DoEnqueue(), DoRemove(), and GetNPackets().
|
private |
Traced callback: fired when a packet is dropped due to lifetime expiration.
Definition at line 341 of file wifi-mac-queue.h.
Referenced by GetTypeId(), and TtlExceeded().
|
private |
redefinition of the log component
Definition at line 343 of file wifi-mac-queue.h.