diff --git a/src/wifi/model/block-ack-manager.cc b/src/wifi/model/block-ack-manager.cc index f9b5cf875..f66a8d393 100644 --- a/src/wifi/model/block-ack-manager.cc +++ b/src/wifi/model/block-ack-manager.cc @@ -590,22 +590,27 @@ BlockAckManager::NotifyDiscardedMpdu (Ptr mpdu) ScheduleBlockAckReq (recipient, tid); } +CtrlBAckRequestHeader +BlockAckManager::GetBlockAckReqHeader (Mac48Address recipient, uint8_t tid) const +{ + NS_LOG_FUNCTION (this << recipient << +tid); + AgreementsCI it = m_agreements.find (std::make_pair (recipient, tid)); + NS_ASSERT (it != m_agreements.end ()); + + CtrlBAckRequestHeader reqHdr; + reqHdr.SetType (m_blockAckType); + reqHdr.SetTidInfo (tid); + reqHdr.SetStartingSequence ((*it).second.first.GetStartingSequence ()); + return reqHdr; +} + void BlockAckManager::ScheduleBlockAckReq (Mac48Address recipient, uint8_t tid) { NS_LOG_FUNCTION (this << recipient << +tid); - AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); - NS_ASSERT (it != m_agreements.end ()); - - OriginatorBlockAckAgreement &agreement = (*it).second.first; - - CtrlBAckRequestHeader reqHdr; - reqHdr.SetType (m_blockAckType); - reqHdr.SetTidInfo (agreement.GetTid ()); - reqHdr.SetStartingSequence (agreement.GetStartingSequence ()); Ptr bar = Create (); - bar->AddHeader (reqHdr); + bar->AddHeader (GetBlockAckReqHeader (recipient, tid)); WifiMacHeader hdr; hdr.SetAddr1 (recipient); hdr.SetType (WIFI_MAC_CTL_BACKREQ); diff --git a/src/wifi/model/block-ack-manager.h b/src/wifi/model/block-ack-manager.h index 1c41ac515..736f0ebe9 100644 --- a/src/wifi/model/block-ack-manager.h +++ b/src/wifi/model/block-ack-manager.h @@ -35,6 +35,7 @@ class WifiRemoteStationManager; class MgtAddBaResponseHeader; class MgtAddBaRequestHeader; class CtrlBAckResponseHeader; +class CtrlBAckRequestHeader; class MacTxMiddle; class WifiMacQueue; class WifiMode; @@ -388,6 +389,15 @@ public: */ void NotifyDiscardedMpdu (Ptr mpdu); + /** + * \param recipient the recipient + * \param tid the TID + * + * 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 diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc index ab3e1d3e3..43ed5fc39 100644 --- a/src/wifi/model/mac-low.cc +++ b/src/wifi/model/mac-low.cc @@ -268,6 +268,14 @@ MacLow::ResetPhy (void) m_phy = 0; } +Ptr +MacLow::GetEdca (uint8_t tid) const +{ + auto it = m_edca.find (QosUtilsMapTidToAc (tid)); + NS_ASSERT (it != m_edca.end ()); + return it->second; +} + void MacLow::SetMac (const Ptr mac) { diff --git a/src/wifi/model/mac-low.h b/src/wifi/model/mac-low.h index 2431cdec4..aa149e28e 100644 --- a/src/wifi/model/mac-low.h +++ b/src/wifi/model/mac-low.h @@ -88,6 +88,11 @@ public: * Remove WifiPhy associated with this MacLow. */ void ResetPhy (void); + /** + * \param tid the Traffic ID + * \return the QosTxop corresponding to the given TID + */ + Ptr GetEdca (uint8_t tid) const; /** * Set up WifiMac associated with this MacLow. * diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index eb9337d28..33ed12870 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -142,6 +142,27 @@ QosTxop::GetBaStartingSequence (Mac48Address address, uint8_t tid) const return m_baManager->GetOriginatorStartingSequence (address, tid); } +Ptr +QosTxop::PrepareBlockAckRequest (Mac48Address recipient, uint8_t tid) const +{ + NS_LOG_FUNCTION (this << recipient << +tid); + + CtrlBAckRequestHeader reqHdr = m_low->GetEdca (tid)->m_baManager->GetBlockAckReqHeader (recipient, tid); + Ptr bar = Create (); + bar->AddHeader (reqHdr); + + WifiMacHeader hdr; + hdr.SetType (WIFI_MAC_CTL_BACKREQ); + hdr.SetAddr1 (recipient); + hdr.SetAddr2 (m_low->GetAddress ()); + hdr.SetDsNotTo (); + hdr.SetDsNotFrom (); + hdr.SetNoRetry (); + hdr.SetNoMoreFragments (); + + return Create (bar, hdr); +} + void QosTxop::ScheduleBlockAckReq (Mac48Address address, uint8_t tid) { diff --git a/src/wifi/model/qos-txop.h b/src/wifi/model/qos-txop.h index fdfe151cf..b747ca4f2 100644 --- a/src/wifi/model/qos-txop.h +++ b/src/wifi/model/qos-txop.h @@ -185,6 +185,16 @@ public: * recipient for the given TID. */ uint16_t GetBaStartingSequence (Mac48Address address, uint8_t tid) const; + /** + * \param recipient Address of recipient. + * \param tid Traffic ID. + * + * Prepare a Block Ack Request to be sent to recipient for Traffic ID + * tid. The header for the Block Ack Request is requested to the QosTxop + * corresponding to the given TID. A block ack agreement with the given recipient + * for the given TID must have been established by such QosTxop. + */ + Ptr PrepareBlockAckRequest (Mac48Address recipient, uint8_t tid) const; /** * \param address recipient address * \param tid traffic ID