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 () | |
~WifiMacQueue () | |
Ptr< WifiMacQueueItem > | Dequeue (void) |
Dequeue the packet in the front of the queue. More... | |
Ptr< WifiMacQueueItem > | Dequeue (WifiMacQueue::ConstIterator pos) |
Dequeue the item at position pos in the queue. More... | |
Ptr< WifiMacQueueItem > | DequeueByAddress (Mac48Address dest) |
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... | |
Ptr< WifiMacQueueItem > | DequeueByTid (uint8_t tid) |
Search and return, if present in the queue, the first packet having the tid equal to tid. More... | |
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 equal to addr, and tid equal to tid. More... | |
Ptr< WifiMacQueueItem > | DequeueFirstAvailable (const Ptr< QosBlockedDestinations > blockedPackets=nullptr) |
Return first available packet for transmission. More... | |
bool | Enqueue (Ptr< WifiMacQueueItem > item) |
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... | |
QueueSize | GetMaxQueueSize (void) const |
uint32_t | GetNBytes (void) |
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 |
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... | |
Ptr< WifiMacQueueItem > | Remove (void) |
Remove the packet in the front of the queue. More... | |
bool | Remove (Ptr< const Packet > packet) |
If exists, removes packet from queue and returns true. 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... | |
void | SetMaxDelay (Time delay) |
Set the maximum delay before the packet is discarded. More... | |
void | SetMaxQueueSize (QueueSize size) |
Set the maximum size of this queue. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Static Public Attributes | |
static const ConstIterator | EMPTY = std::list<Ptr<WifiMacQueueItem>> ().end () |
Invalid iterator to signal an empty queue. More... | |
Private Member Functions | |
bool | TtlExceeded (ConstIterator &it) |
Remove the item pointed to by the iterator it if it has been in the queue for too long. More... | |
Private Attributes | |
DropPolicy | m_dropPolicy |
Drop behavior of queue. More... | |
bool | m_expiredPacketsPresent |
Time | m_maxDelay |
Time to live for packets in the queue. More... | |
QueueSize | m_maxSize |
max queue size More... | |
TracedCallback< Ptr< const WifiMacQueueItem > > | m_traceExpired |
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 280 bytes (on a 64-bit architecture).
Definition at line 57 of file wifi-mac-queue.h.
ns3::WifiMacQueue::WifiMacQueue | ( | ) |
Definition at line 63 of file wifi-mac-queue.cc.
ns3::WifiMacQueue::~WifiMacQueue | ( | ) |
Definition at line 69 of file wifi-mac-queue.cc.
References NS_LOG_FUNCTION_NOARGS.
Ptr< WifiMacQueueItem > ns3::WifiMacQueue::Dequeue | ( | void | ) |
Dequeue the packet in the front of the queue.
Definition at line 176 of file wifi-mac-queue.cc.
References NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
Referenced by DequeueByAddress(), DequeueByTid(), DequeueByTidAndAddress(), and DequeueFirstAvailable().
Ptr<WifiMacQueueItem> ns3::WifiMacQueue::Dequeue | ( | WifiMacQueue::ConstIterator | pos | ) |
Dequeue the item at position pos in the queue.
Return a null pointer if the given iterator is invalid, the queue is empty or the lifetime of the item pointed to by the given iterator is expired.
pos | the position of the item to be dequeued |
Ptr< WifiMacQueueItem > ns3::WifiMacQueue::DequeueByAddress | ( | Mac48Address | dest | ) |
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.
This method removes the packet from the queue. It is typically used by ns3::Txop during the CF period.
dest | the given destination |
Definition at line 191 of file wifi-mac-queue.cc.
References Dequeue(), NS_LOG_FUNCTION, and PeekByAddress().
Ptr< WifiMacQueueItem > ns3::WifiMacQueue::DequeueByTid | ( | uint8_t | tid | ) |
Search and return, if present in the queue, the first packet having the tid equal to tid.
This method removes the packet from the queue.
tid | the given tid |
Definition at line 204 of file wifi-mac-queue.cc.
References Dequeue(), NS_LOG_FUNCTION, and PeekByTid().
Ptr< WifiMacQueueItem > ns3::WifiMacQueue::DequeueByTidAndAddress | ( | uint8_t | tid, |
Mac48Address | dest | ||
) |
Search and return, if present in the queue, the first packet having the address indicated by type equal to addr, and tid equal to tid.
This method removes 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 |
Definition at line 217 of file wifi-mac-queue.cc.
References Dequeue(), NS_LOG_FUNCTION, and PeekByTidAndAddress().
Ptr< WifiMacQueueItem > ns3::WifiMacQueue::DequeueFirstAvailable | ( | const Ptr< QosBlockedDestinations > | blockedPackets = nullptr | ) |
Return first available packet for transmission.
A packet could be no available if it is a QoS packet with a tid and an address1 fields equal to tid and addr respectively that index a pending agreement in the BlockAckManager object. So that packet must not be transmitted until reception of an ADDBA response frame from station addressed by addr. This method removes the packet from queue.
blockedPackets |
Definition at line 230 of file wifi-mac-queue.cc.
References Dequeue(), NS_LOG_FUNCTION, and PeekFirstAvailable().
bool ns3::WifiMacQueue::Enqueue | ( | Ptr< WifiMacQueueItem > | item | ) |
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 120 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 97 of file wifi-mac-queue.cc.
References m_maxDelay.
QueueSize ns3::WifiMacQueue::GetMaxQueueSize | ( | void | ) | const |
Definition at line 84 of file wifi-mac-queue.cc.
References m_maxSize.
Referenced by Insert().
uint32_t ns3::WifiMacQueue::GetNBytes | ( | void | ) |
Overrides the GetNBytes method provided by QueueBase
Definition at line 559 of file wifi-mac-queue.cc.
References ns3::QueueBase::GetNBytes(), NS_LOG_FUNCTION, and TtlExceeded().
uint32_t ns3::WifiMacQueue::GetNPackets | ( | void | ) |
Overrides the GetNPackets method provided by QueueBase
Definition at line 544 of file wifi-mac-queue.cc.
References ns3::QueueBase::GetNPackets(), NS_LOG_FUNCTION, and TtlExceeded().
uint32_t ns3::WifiMacQueue::GetNPacketsByAddress | ( | Mac48Address | dest | ) |
Return the number of packets having destination address specified by dest.
dest | the given destination |
Definition at line 483 of file wifi-mac-queue.cc.
References 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.
tid | the given TID |
dest | the given destination |
Definition at line 506 of file wifi-mac-queue.cc.
References NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
|
static |
Get the type ID.
Definition at line 36 of file wifi-mac-queue.cc.
References DROP_NEWEST, DROP_OLDEST, m_dropPolicy, m_traceExpired, ns3::MakeEnumAccessor(), ns3::MakeEnumChecker(), ns3::MakeQueueSizeAccessor(), ns3::MakeQueueSizeChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MilliSeconds(), SetMaxDelay(), SetMaxQueueSize(), 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 136 of file wifi-mac-queue.cc.
References DROP_OLDEST, GetMaxQueueSize(), ns3::QueueBase::GetNPackets(), m_dropPolicy, NS_ASSERT_MSG(), NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::PACKETS, ns3::QueueBase::SetMaxSize(), and TtlExceeded().
Referenced by Enqueue(), and PushFront().
bool ns3::WifiMacQueue::IsEmpty | ( | void | ) |
Overrides the IsEmpty method provided by QueueBase
Definition at line 528 of file wifi-mac-queue.cc.
References NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
Ptr< const WifiMacQueueItem > ns3::WifiMacQueue::Peek | ( | void | ) | const |
Peek the packet in the front of the queue.
The packet is not removed.
Definition at line 282 of file wifi-mac-queue.cc.
References m_expiredPacketsPresent, 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 301 of file wifi-mac-queue.cc.
References EMPTY, m_expiredPacketsPresent, m_maxDelay, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by DequeueByAddress().
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 329 of file wifi-mac-queue.cc.
References EMPTY, m_expiredPacketsPresent, m_maxDelay, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by DequeueByTid().
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 356 of file wifi-mac-queue.cc.
References EMPTY, m_expiredPacketsPresent, m_maxDelay, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by DequeueByTidAndAddress().
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 | |
pos | the iterator pointing to the packet the search starts from |
Definition at line 384 of file wifi-mac-queue.cc.
References EMPTY, m_expiredPacketsPresent, m_maxDelay, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by DequeueFirstAvailable().
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 128 of file wifi-mac-queue.cc.
References Insert(), and NS_LOG_FUNCTION.
Ptr< WifiMacQueueItem > ns3::WifiMacQueue::Remove | ( | void | ) |
Remove the packet in the front of the queue.
Definition at line 412 of file wifi-mac-queue.cc.
References 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 428 of file wifi-mac-queue.cc.
References NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
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 449 of file wifi-mac-queue.cc.
References m_expiredPacketsPresent, NS_LOG_DEBUG, NS_LOG_FUNCTION, and TtlExceeded().
void ns3::WifiMacQueue::SetMaxDelay | ( | Time | delay | ) |
Set the maximum delay before the packet is discarded.
delay | the maximum delay |
Definition at line 90 of file wifi-mac-queue.cc.
References m_maxDelay, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::WifiMacQueue::SetMaxQueueSize | ( | QueueSize | size | ) |
Set the maximum size of this queue.
Trying to set a null size has no effect.
size | the maximum size |
Definition at line 77 of file wifi-mac-queue.cc.
References m_maxSize, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
private |
Remove the item pointed to by the iterator it if it has been in the queue for too long.
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 |
Definition at line 103 of file wifi-mac-queue.cc.
References m_maxDelay, m_traceExpired, ns3::Simulator::Now(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by Dequeue(), GetNBytes(), GetNPackets(), GetNPacketsByAddress(), GetNPacketsByTidAndAddress(), Insert(), IsEmpty(), and Remove().
|
static |
Invalid iterator to signal an empty queue.
Definition at line 314 of file wifi-mac-queue.h.
Referenced by PeekByAddress(), PeekByTid(), PeekByTidAndAddress(), PeekFirstAvailable(), and ns3::QosTxop::PeekNextFrame().
|
private |
Drop behavior of queue.
Definition at line 329 of file wifi-mac-queue.h.
Referenced by GetTypeId(), and Insert().
|
mutableprivate |
Definition at line 330 of file wifi-mac-queue.h.
Referenced by Peek(), PeekByAddress(), PeekByTid(), PeekByTidAndAddress(), PeekFirstAvailable(), and Remove().
|
private |
Time to live for packets in the queue.
Definition at line 328 of file wifi-mac-queue.h.
Referenced by GetMaxDelay(), Peek(), PeekByAddress(), PeekByTid(), PeekByTidAndAddress(), PeekFirstAvailable(), SetMaxDelay(), and TtlExceeded().
|
private |
max queue size
Definition at line 327 of file wifi-mac-queue.h.
Referenced by GetMaxQueueSize(), and SetMaxQueueSize().
|
private |
True if expired packets are in the queue
Traced callback: fired when a packet is dropped due to lifetime expiration
Definition at line 333 of file wifi-mac-queue.h.
Referenced by GetTypeId(), and TtlExceeded().
|
private |
redefinition of the log component
Definition at line 335 of file wifi-mac-queue.h.