From 45473264459b9ac76b4c6ee65a0b07dc1bb5315e Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sun, 7 Jun 2020 23:06:03 +0200 Subject: [PATCH] wifi: (fixes #211) Remove MSDUs with expired lifetime when (re)starting channel access --- src/wifi/model/qos-txop.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index 9ee3c5ae0..8222d6fee 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -985,11 +985,15 @@ void QosTxop::RestartAccessIfNeeded (void) { NS_LOG_FUNCTION (this); - if ((m_currentPacket != 0 - // check first if the BA manager retransmit queue is empty, so that expired - // frames (if any) are removed and a BlockAckRequest is scheduled to advance - // the starting sequence number of the transmit (and receiver) window - || m_baManager->HasPackets () || !m_queue->IsEmpty ()) + + // check if the BA manager retransmit queue is empty, so that expired + // frames (if any) are removed and a BlockAckRequest is scheduled to advance + // the starting sequence number of the transmit (and receiver) window + bool baManagerHasPackets = m_baManager->HasPackets (); + // remove MSDUs with expired lifetime starting from the head of the queue + bool queueIsNotEmpty = !m_queue->IsEmpty (); + + if ((m_currentPacket != 0 || baManagerHasPackets || queueIsNotEmpty) && !IsAccessRequested ()) { Ptr packet; @@ -1024,11 +1028,16 @@ void QosTxop::StartAccessIfNeeded (void) { NS_LOG_FUNCTION (this); + + // check if the BA manager retransmit queue is empty, so that expired + // frames (if any) are removed and a BlockAckRequest is scheduled to advance + // the starting sequence number of the transmit (and receiver) window + bool baManagerHasPackets = m_baManager->HasPackets (); + // remove MSDUs with expired lifetime starting from the head of the queue + bool queueIsNotEmpty = !m_queue->IsEmpty (); + if (m_currentPacket == 0 - // check first if the BA manager retransmit queue is empty, so that expired - // frames (if any) are removed and a BlockAckRequest is scheduled to advance - // the starting sequence number of the transmit (and receiver) window - && (m_baManager->HasPackets () || !m_queue->IsEmpty ()) + && (baManagerHasPackets || queueIsNotEmpty) && !IsAccessRequested ()) { Ptr packet;