diff --git a/src/wifi/model/block-ack-manager.cc b/src/wifi/model/block-ack-manager.cc index f66a8d393..6080080ee 100644 --- a/src/wifi/model/block-ack-manager.cc +++ b/src/wifi/model/block-ack-manager.cc @@ -587,7 +587,20 @@ BlockAckManager::NotifyDiscardedMpdu (Ptr mpdu) // schedule a block ack request NS_LOG_DEBUG ("Schedule a Block Ack Request for agreement (" << recipient << ", " << +tid << ")"); - ScheduleBlockAckReq (recipient, tid); + Ptr bar = Create (); + bar->AddHeader (GetBlockAckReqHeader (recipient, tid)); + + WifiMacHeader hdr; + hdr.SetType (WIFI_MAC_CTL_BACKREQ); + hdr.SetAddr1 (recipient); + hdr.SetAddr2 (mpdu->GetHeader ().GetAddr2 ()); + hdr.SetAddr3 (mpdu->GetHeader ().GetAddr3 ()); + hdr.SetDsNotTo (); + hdr.SetDsNotFrom (); + hdr.SetNoRetry (); + hdr.SetNoMoreFragments (); + + ScheduleBar (Create (bar, hdr)); } CtrlBAckRequestHeader @@ -605,28 +618,35 @@ BlockAckManager::GetBlockAckReqHeader (Mac48Address recipient, uint8_t tid) cons } void -BlockAckManager::ScheduleBlockAckReq (Mac48Address recipient, uint8_t tid) +BlockAckManager::ScheduleBar (Ptr bar) { - NS_LOG_FUNCTION (this << recipient << +tid); + NS_LOG_FUNCTION (this << *bar); + NS_ASSERT (bar->GetHeader ().IsBlockAckReq ()); - Ptr bar = Create (); - bar->AddHeader (GetBlockAckReqHeader (recipient, tid)); - WifiMacHeader hdr; - hdr.SetAddr1 (recipient); - hdr.SetType (WIFI_MAC_CTL_BACKREQ); - Bar request (Create (bar, hdr), tid); + CtrlBAckRequestHeader reqHdr; + bar->GetPacket ()->PeekHeader (reqHdr); + uint8_t tid = reqHdr.GetTidInfo (); + Bar request (bar, tid); // if a BAR for the given agreement is present, replace it with the new one for (std::list::const_iterator i = m_bars.begin (); i != m_bars.end (); i++) { - if (i->bar->GetHeader ().GetAddr1 () == recipient && i->tid == tid) + if (i->bar->GetHeader ().GetAddr1 () == bar->GetHeader ().GetAddr1 () && i->tid == tid) { i = m_bars.erase (i); m_bars.insert (i, request); return; } } - m_bars.push_back (request); + + if (bar->GetHeader ().IsRetry ()) + { + m_bars.push_front (request); + } + else + { + m_bars.push_back (request); + } } void diff --git a/src/wifi/model/block-ack-manager.h b/src/wifi/model/block-ack-manager.h index 736f0ebe9..7b3a1ea42 100644 --- a/src/wifi/model/block-ack-manager.h +++ b/src/wifi/model/block-ack-manager.h @@ -393,22 +393,20 @@ public: * \param recipient the recipient * \param tid the TID * - * Get the block ack request header for the established BA agreement + * Get the Block Ack Request header for the established BA agreement * (recipient,tid). */ CtrlBAckRequestHeader GetBlockAckReqHeader (Mac48Address recipient, uint8_t tid) const; /** - * \param recipient the recipient - * \param tid the TID + * \param bar the Block Ack Request to enqueue * - * Enqueue a block ack request for the established BA agreement - * (recipient,tid) into the queue storing the next - * BAR frames to transmit. If a BAR for the given agreement is - * already present in the queue, it is replaced by the new one. + * Enqueue the given Block Ack Request into the queue storing the next BAR + * frames to transmit. If a BAR for the same recipient and TID is already present + * in the queue, it is replaced by the new one. If the given BAR is retransmitted, + * it is placed at the head of the queue, otherwise at the tail. */ - void ScheduleBlockAckReq (Mac48Address recipient, uint8_t tid); - + void ScheduleBar (Ptr bar); private: /** diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc index 43ed5fc39..65f1390fc 100644 --- a/src/wifi/model/mac-low.cc +++ b/src/wifi/model/mac-low.cc @@ -1973,7 +1973,8 @@ MacLow::SendDataPacket (void) { Ptr qosTxop = DynamicCast (m_currentTxop); NS_ASSERT (qosTxop != 0); - qosTxop->ScheduleBlockAckReq (m_currentPacket->GetAddr1 (), *m_currentPacket->GetTids ().begin ()); + auto bar = qosTxop->PrepareBlockAckRequest (m_currentPacket->GetAddr1 (), *m_currentPacket->GetTids ().begin ()); + qosTxop->ScheduleBar (bar); } ForwardDown (m_currentPacket, m_currentTxVector); } @@ -2089,7 +2090,8 @@ MacLow::SendDataAfterCts (Time duration) { Ptr qosTxop = DynamicCast (m_currentTxop); NS_ASSERT (qosTxop != 0); - qosTxop->ScheduleBlockAckReq (m_currentPacket->GetAddr1 (), *m_currentPacket->GetTids ().begin ()); + auto bar = qosTxop->PrepareBlockAckRequest (m_currentPacket->GetAddr1 (), *m_currentPacket->GetTids ().begin ()); + qosTxop->ScheduleBar (bar); } ForwardDown (m_currentPacket, m_currentTxVector); } diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index 33ed12870..c56c58dd9 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -164,9 +164,9 @@ QosTxop::PrepareBlockAckRequest (Mac48Address recipient, uint8_t tid) const } void -QosTxop::ScheduleBlockAckReq (Mac48Address address, uint8_t tid) +QosTxop::ScheduleBar (Ptr bar) { - m_baManager->ScheduleBlockAckReq (address, tid); + m_baManager->ScheduleBar (bar); } void @@ -900,7 +900,8 @@ QosTxop::MissedBlockAck (uint8_t nMpdus) } else // missed block ack after data frame with Implicit BAR Ack policy { - m_baManager->ScheduleBlockAckReq (m_currentHdr.GetAddr1 (), tid); + Ptr bar = PrepareBlockAckRequest (m_currentHdr.GetAddr1 (), tid); + ScheduleBar (bar); m_currentPacket = 0; } } diff --git a/src/wifi/model/qos-txop.h b/src/wifi/model/qos-txop.h index b747ca4f2..32b635b69 100644 --- a/src/wifi/model/qos-txop.h +++ b/src/wifi/model/qos-txop.h @@ -196,13 +196,12 @@ public: */ Ptr PrepareBlockAckRequest (Mac48Address recipient, uint8_t tid) const; /** - * \param address recipient address - * \param tid traffic ID + * \param bar the Block Ack Request to schedule * - * Request the Block Ack manager to schedule the transmission of a - * block ack request for the established BA agreement (address,tid). + * Request the Block Ack manager to schedule the transmission of the given + * Block Ack Request. */ - void ScheduleBlockAckReq (Mac48Address address, uint8_t tid); + void ScheduleBar (Ptr bar); /* dcf notifications forwarded here */ /**