diff --git a/src/wifi/model/he/he-frame-exchange-manager.cc b/src/wifi/model/he/he-frame-exchange-manager.cc index ae00d8cb8..7dea19278 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.cc +++ b/src/wifi/model/he/he-frame-exchange-manager.cc @@ -21,6 +21,7 @@ #include "ns3/log.h" #include "ns3/abort.h" #include "he-frame-exchange-manager.h" +#include "he-configuration.h" #undef NS_LOG_APPEND_CONTEXT #define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] " @@ -52,4 +53,15 @@ HeFrameExchangeManager::~HeFrameExchangeManager () NS_LOG_FUNCTION_NOARGS (); } +uint16_t +HeFrameExchangeManager::GetSupportedBaBufferSize (void) const +{ + NS_ASSERT (m_mac->GetHeConfiguration () != 0); + if (m_mac->GetHeConfiguration ()->GetMpduBufferSize () > 64) + { + return 256; + } + return 64; +} + } //namespace ns3 diff --git a/src/wifi/model/he/he-frame-exchange-manager.h b/src/wifi/model/he/he-frame-exchange-manager.h index 2de879ee2..ec75e1523 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.h +++ b/src/wifi/model/he/he-frame-exchange-manager.h @@ -41,6 +41,9 @@ public: static TypeId GetTypeId (void); HeFrameExchangeManager (); virtual ~HeFrameExchangeManager (); + + // Overridden from VhtFrameExchangeManager + virtual uint16_t GetSupportedBaBufferSize (void) const override; }; } //namespace ns3 diff --git a/src/wifi/model/ht/ht-frame-exchange-manager.cc b/src/wifi/model/ht/ht-frame-exchange-manager.cc index c02c15057..778924dfe 100644 --- a/src/wifi/model/ht/ht-frame-exchange-manager.cc +++ b/src/wifi/model/ht/ht-frame-exchange-manager.cc @@ -187,6 +187,62 @@ HtFrameExchangeManager::SendAddBaRequest (Mac48Address dest, uint8_t tid, uint16 SendMpduWithProtection (mpdu, txParams); } +void +HtFrameExchangeManager::SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, + Mac48Address originator) +{ + NS_LOG_FUNCTION (this << originator); + WifiMacHeader hdr; + hdr.SetType (WIFI_MAC_MGT_ACTION); + hdr.SetAddr1 (originator); + hdr.SetAddr2 (m_self); + hdr.SetAddr3 (m_bssid); + hdr.SetDsNotFrom (); + hdr.SetDsNotTo (); + + MgtAddBaResponseHeader respHdr; + StatusCode code; + code.SetSuccess (); + respHdr.SetStatusCode (code); + //Here a control about queues type? + respHdr.SetAmsduSupport (reqHdr->IsAmsduSupported ()); + + if (reqHdr->IsImmediateBlockAck ()) + { + respHdr.SetImmediateBlockAck (); + } + else + { + respHdr.SetDelayedBlockAck (); + } + respHdr.SetTid (reqHdr->GetTid ()); + + respHdr.SetBufferSize (GetSupportedBaBufferSize () - 1); + respHdr.SetTimeout (reqHdr->GetTimeout ()); + + WifiActionHeader actionHdr; + WifiActionHeader::ActionValue action; + action.blockAck = WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE; + actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action); + + Ptr packet = Create (); + packet->AddHeader (respHdr); + packet->AddHeader (actionHdr); + + CreateBlockAckAgreement (&respHdr, originator, reqHdr->GetStartingSequence ()); + + //It is unclear which queue this frame should go into. For now we + //bung it into the queue corresponding to the TID for which we are + //establishing an agreement, and push it to the head. + m_mac->GetQosTxop (reqHdr->GetTid ())->PushFront (packet, hdr); +} + +uint16_t +HtFrameExchangeManager::GetSupportedBaBufferSize (void) const +{ + return 64; +} + void HtFrameExchangeManager::SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator) { diff --git a/src/wifi/model/ht/ht-frame-exchange-manager.h b/src/wifi/model/ht/ht-frame-exchange-manager.h index 0752ebc44..3b82c51b9 100644 --- a/src/wifi/model/ht/ht-frame-exchange-manager.h +++ b/src/wifi/model/ht/ht-frame-exchange-manager.h @@ -161,6 +161,22 @@ public: * \param tid the TID associated with the Block Ack agreement */ void DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid); + /** + * This method can be called to accept a received ADDBA Request. An + * ADDBA Response will be constructed and queued for transmission. + * + * \param reqHdr a pointer to the received ADDBA Request header. + * \param originator the MAC address of the originator. + */ + void SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, + Mac48Address originator); + /** + * Get the maximum supported buffer size for a Block Ack agreement. This value + * is typically included in ADDBA Response frames. + * + * \return the maximum supported buffer size for a Block Ack agreement + */ + virtual uint16_t GetSupportedBaBufferSize (void) const; /** * Return true if a Block Ack agreement has been established with the given diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index 3bc8393ae..55799366c 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -795,7 +795,12 @@ RegularWifiMac::Receive (Ptr mpdu) //We've received an ADDBA Request. Our policy here is //to automatically accept it, so we get the ADDBA //Response on it's way immediately. - SendAddBaResponse (&reqHdr, from); + NS_ASSERT (m_feManager != 0); + Ptr htFem = DynamicCast (m_feManager); + if (htFem != 0) + { + htFem->SendAddBaResponse (&reqHdr, from); + } //This frame is now completely dealt with, so we're done. return; } @@ -827,8 +832,11 @@ RegularWifiMac::Receive (Ptr mpdu) //agreement exists in HtFrameExchangeManager and we need to //destroy it. NS_ASSERT (m_feManager != 0); - Ptr htFem = StaticCast (m_feManager); - htFem->DestroyBlockAckAgreement (from, delBaHdr.GetTid ()); + Ptr htFem = DynamicCast (m_feManager); + if (htFem != 0) + { + htFem->DestroyBlockAckAgreement (from, delBaHdr.GetTid ()); + } } else { @@ -864,68 +872,6 @@ RegularWifiMac::DeaggregateAmsduAndForward (Ptr mpdu) } } -void -RegularWifiMac::SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, - Mac48Address originator) -{ - NS_LOG_FUNCTION (this); - WifiMacHeader hdr; - hdr.SetType (WIFI_MAC_MGT_ACTION); - hdr.SetAddr1 (originator); - hdr.SetAddr2 (GetAddress ()); - hdr.SetAddr3 (GetBssid ()); - hdr.SetDsNotFrom (); - hdr.SetDsNotTo (); - - MgtAddBaResponseHeader respHdr; - StatusCode code; - code.SetSuccess (); - respHdr.SetStatusCode (code); - //Here a control about queues type? - respHdr.SetAmsduSupport (reqHdr->IsAmsduSupported ()); - - if (reqHdr->IsImmediateBlockAck ()) - { - respHdr.SetImmediateBlockAck (); - } - else - { - respHdr.SetDelayedBlockAck (); - } - respHdr.SetTid (reqHdr->GetTid ()); - - Ptr heConfiguration = GetHeConfiguration (); - if (heConfiguration && heConfiguration->GetMpduBufferSize () > 64) - { - respHdr.SetBufferSize (255); - } - else - { - respHdr.SetBufferSize (63); - } - respHdr.SetTimeout (reqHdr->GetTimeout ()); - - WifiActionHeader actionHdr; - WifiActionHeader::ActionValue action; - action.blockAck = WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE; - actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action); - - Ptr packet = Create (); - packet->AddHeader (respHdr); - packet->AddHeader (actionHdr); - - //We need to notify our FrameExchangeManager object as it will have to buffer all - //correctly received packets for this Block Ack session - NS_ASSERT (m_feManager != 0); - Ptr htFem = StaticCast (m_feManager); - htFem->CreateBlockAckAgreement (&respHdr, originator, reqHdr->GetStartingSequence ()); - - //It is unclear which queue this frame should go into. For now we - //bung it into the queue corresponding to the TID for which we are - //establishing an agreement, and push it to the head. - m_edca[QosUtilsMapTidToAc (reqHdr->GetTid ())]->PushFront (packet, hdr); -} - TypeId RegularWifiMac::GetTypeId (void) { diff --git a/src/wifi/model/regular-wifi-mac.h b/src/wifi/model/regular-wifi-mac.h index 15ac23080..900855067 100644 --- a/src/wifi/model/regular-wifi-mac.h +++ b/src/wifi/model/regular-wifi-mac.h @@ -257,16 +257,6 @@ protected: */ virtual void DeaggregateAmsduAndForward (Ptr mpdu); - /** - * This method can be called to accept a received ADDBA Request. An - * ADDBA Response will be constructed and queued for transmission. - * - * \param reqHdr a pointer to the received ADDBA Request header. - * \param originator the MAC address of the originator. - */ - void SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, - Mac48Address originator); - /** * Enable or disable QoS support for the device. *