wifi: Move SendAddBaResponse to the HT FEM

All the related methods are already there.
This commit is contained in:
Stefano Avallone
2021-03-12 18:27:38 +01:00
committed by Stefano Avallone
parent 12cd5774b2
commit 88b4bc94ba
6 changed files with 98 additions and 75 deletions

View File

@@ -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

View File

@@ -41,6 +41,9 @@ public:
static TypeId GetTypeId (void);
HeFrameExchangeManager ();
virtual ~HeFrameExchangeManager ();
// Overridden from VhtFrameExchangeManager
virtual uint16_t GetSupportedBaBufferSize (void) const override;
};
} //namespace ns3

View File

@@ -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> packet = Create<Packet> ();
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)
{

View File

@@ -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

View File

@@ -795,7 +795,12 @@ RegularWifiMac::Receive (Ptr<WifiMacQueueItem> 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<HtFrameExchangeManager> htFem = DynamicCast<HtFrameExchangeManager> (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<WifiMacQueueItem> mpdu)
//agreement exists in HtFrameExchangeManager and we need to
//destroy it.
NS_ASSERT (m_feManager != 0);
Ptr<HtFrameExchangeManager> htFem = StaticCast<HtFrameExchangeManager> (m_feManager);
htFem->DestroyBlockAckAgreement (from, delBaHdr.GetTid ());
Ptr<HtFrameExchangeManager> htFem = DynamicCast<HtFrameExchangeManager> (m_feManager);
if (htFem != 0)
{
htFem->DestroyBlockAckAgreement (from, delBaHdr.GetTid ());
}
}
else
{
@@ -864,68 +872,6 @@ RegularWifiMac::DeaggregateAmsduAndForward (Ptr<WifiMacQueueItem> 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> 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> packet = Create<Packet> ();
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<HtFrameExchangeManager> htFem = StaticCast<HtFrameExchangeManager> (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)
{

View File

@@ -257,16 +257,6 @@ protected:
*/
virtual void DeaggregateAmsduAndForward (Ptr<WifiMacQueueItem> 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.
*