wifi: Pass the MAC to MSDU and MPDU aggregator
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
#include "ht-capabilities.h"
|
||||
#include "vht-capabilities.h"
|
||||
#include "he-capabilities.h"
|
||||
#include "wifi-mac.h"
|
||||
#include "regular-wifi-mac.h"
|
||||
#include "ctrl-headers.h"
|
||||
#include "wifi-mac-trailer.h"
|
||||
|
||||
@@ -64,9 +64,17 @@ MpduAggregator::~MpduAggregator ()
|
||||
}
|
||||
|
||||
void
|
||||
MpduAggregator::SetEdcaQueues (EdcaQueues edcaQueues)
|
||||
MpduAggregator::DoDispose ()
|
||||
{
|
||||
m_edca = edcaQueues;
|
||||
m_mac = 0;
|
||||
Object::DoDispose ();
|
||||
}
|
||||
|
||||
void
|
||||
MpduAggregator::SetWifiMac (const Ptr<RegularWifiMac> mac)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << mac);
|
||||
m_mac = mac;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -116,11 +124,6 @@ MpduAggregator::GetMaxAmpduSize (Mac48Address recipient, uint8_t tid,
|
||||
NS_LOG_FUNCTION (this << recipient << +tid << modulation);
|
||||
|
||||
AcIndex ac = QosUtilsMapTidToAc (tid);
|
||||
Ptr<QosTxop> qosTxop = m_edca.find (ac)->second;
|
||||
Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (qosTxop->GetLow ()->GetPhy ()->GetDevice ());
|
||||
NS_ASSERT (device);
|
||||
Ptr<WifiRemoteStationManager> stationManager = device->GetRemoteStationManager ();
|
||||
NS_ASSERT (stationManager);
|
||||
|
||||
// Find the A-MPDU max size configured on this device
|
||||
UintegerValue size;
|
||||
@@ -128,16 +131,16 @@ MpduAggregator::GetMaxAmpduSize (Mac48Address recipient, uint8_t tid,
|
||||
switch (ac)
|
||||
{
|
||||
case AC_BE:
|
||||
device->GetMac ()->GetAttribute ("BE_MaxAmpduSize", size);
|
||||
m_mac->GetAttribute ("BE_MaxAmpduSize", size);
|
||||
break;
|
||||
case AC_BK:
|
||||
device->GetMac ()->GetAttribute ("BK_MaxAmpduSize", size);
|
||||
m_mac->GetAttribute ("BK_MaxAmpduSize", size);
|
||||
break;
|
||||
case AC_VI:
|
||||
device->GetMac ()->GetAttribute ("VI_MaxAmpduSize", size);
|
||||
m_mac->GetAttribute ("VI_MaxAmpduSize", size);
|
||||
break;
|
||||
case AC_VO:
|
||||
device->GetMac ()->GetAttribute ("VO_MaxAmpduSize", size);
|
||||
m_mac->GetAttribute ("VO_MaxAmpduSize", size);
|
||||
break;
|
||||
default:
|
||||
NS_ABORT_MSG ("Unknown AC " << ac);
|
||||
@@ -152,6 +155,9 @@ MpduAggregator::GetMaxAmpduSize (Mac48Address recipient, uint8_t tid,
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ptr<WifiRemoteStationManager> stationManager = m_mac->GetWifiRemoteStationManager ();
|
||||
NS_ASSERT (stationManager);
|
||||
|
||||
// Retrieve the Capabilities elements advertised by the recipient
|
||||
Ptr<const HeCapabilities> heCapabilities = stationManager->GetStationHeCapabilities (recipient);
|
||||
Ptr<const VhtCapabilities> vhtCapabilities = stationManager->GetStationVhtCapabilities (recipient);
|
||||
@@ -216,10 +222,10 @@ MpduAggregator::GetNextAmpdu (Ptr<const WifiMacQueueItem> mpdu, WifiTxVector txV
|
||||
NS_ASSERT (mpdu->GetHeader ().IsQosData () && !recipient.IsGroup ());
|
||||
|
||||
uint8_t tid = GetTid (mpdu->GetPacket (), mpdu->GetHeader ());
|
||||
auto edcaIt = m_edca.find (QosUtilsMapTidToAc (tid));
|
||||
NS_ASSERT (edcaIt != m_edca.end ());
|
||||
Ptr<QosTxop> qosTxop = m_mac->GetQosTxop (tid);
|
||||
NS_ASSERT (qosTxop != 0);
|
||||
|
||||
WifiModulationClass modulation = txVector.GetMode ().GetModulationClass ();
|
||||
WifiModulationClass modulation = txVector.GetModulationClass ();
|
||||
uint32_t maxAmpduSize = GetMaxAmpduSize (recipient, tid, modulation);
|
||||
|
||||
if (maxAmpduSize == 0)
|
||||
@@ -229,16 +235,16 @@ MpduAggregator::GetNextAmpdu (Ptr<const WifiMacQueueItem> mpdu, WifiTxVector txV
|
||||
}
|
||||
|
||||
//Have to make sure that the block ack agreement is established before sending an A-MPDU
|
||||
if (edcaIt->second->GetBaAgreementEstablished (recipient, tid))
|
||||
if (qosTxop->GetBaAgreementEstablished (recipient, tid))
|
||||
{
|
||||
/* here is performed MPDU aggregation */
|
||||
uint16_t startingSequenceNumber = edcaIt->second->GetBaStartingSequence (recipient, tid);
|
||||
uint16_t startingSequenceNumber = qosTxop->GetBaStartingSequence (recipient, tid);
|
||||
Ptr<WifiMacQueueItem> nextMpdu;
|
||||
uint16_t maxMpdus = edcaIt->second->GetBaBufferSize (recipient, tid);
|
||||
uint16_t maxMpdus = qosTxop->GetBaBufferSize (recipient, tid);
|
||||
uint32_t currentAmpduSize = 0;
|
||||
|
||||
// check if the received MPDU meets the size and duration constraints
|
||||
if (edcaIt->second->GetLow ()->IsWithinSizeAndTimeLimits (mpdu, txVector, 0, ppduDurationLimit))
|
||||
if (qosTxop->GetLow ()->IsWithinSizeAndTimeLimits (mpdu, txVector, 0, ppduDurationLimit))
|
||||
{
|
||||
// MPDU can be aggregated
|
||||
nextMpdu = Copy (mpdu);
|
||||
@@ -271,7 +277,7 @@ MpduAggregator::GetNextAmpdu (Ptr<const WifiMacQueueItem> mpdu, WifiTxVector txV
|
||||
nextMpdu = 0;
|
||||
|
||||
Ptr<const WifiMacQueueItem> peekedMpdu;
|
||||
peekedMpdu = edcaIt->second->PeekNextFrame (tid, recipient);
|
||||
peekedMpdu = qosTxop->PeekNextFrame (tid, recipient);
|
||||
if (peekedMpdu != 0)
|
||||
{
|
||||
uint16_t currentSequenceNumber = peekedMpdu->GetHeader ().GetSequenceNumber ();
|
||||
@@ -282,7 +288,7 @@ MpduAggregator::GetNextAmpdu (Ptr<const WifiMacQueueItem> mpdu, WifiTxVector txV
|
||||
// Note that the dequeued MPDU differs from the peeked MPDU if A-MSDU
|
||||
// aggregation is performed during the dequeue
|
||||
NS_LOG_DEBUG ("Trying to aggregate another MPDU");
|
||||
nextMpdu = edcaIt->second->DequeuePeekedFrame (peekedMpdu, txVector, true,
|
||||
nextMpdu = qosTxop->DequeuePeekedFrame (peekedMpdu, txVector, true,
|
||||
currentAmpduSize, ppduDurationLimit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ class AmpduSubframeHeader;
|
||||
class WifiTxVector;
|
||||
class Packet;
|
||||
class WifiMacQueueItem;
|
||||
class RegularWifiMac;
|
||||
|
||||
/**
|
||||
* \brief Aggregator used to construct A-MPDUs
|
||||
@@ -120,11 +121,11 @@ public:
|
||||
Time ppduDurationLimit = Time::Min ()) const;
|
||||
|
||||
/**
|
||||
* Set the map of EDCA queues.
|
||||
* Set the MAC layer to use.
|
||||
*
|
||||
* \param edcaQueues the map of EDCA queues.
|
||||
* \param mac the MAC layer to use
|
||||
*/
|
||||
void SetEdcaQueues (EdcaQueues edcaQueues);
|
||||
void SetWifiMac (const Ptr<RegularWifiMac> mac);
|
||||
|
||||
/**
|
||||
* \param ampduSize the size of the A-MPDU that needs to be padded in bytes
|
||||
@@ -145,8 +146,11 @@ public:
|
||||
*/
|
||||
static AmpduSubframeHeader GetAmpduSubframeHeader (uint16_t mpduSize, bool isSingle);
|
||||
|
||||
protected:
|
||||
virtual void DoDispose ();
|
||||
|
||||
private:
|
||||
EdcaQueues m_edca; //!< the map of EDCA queues
|
||||
Ptr<RegularWifiMac> m_mac; //!< the MAC of this station
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "wifi-phy.h"
|
||||
#include "wifi-net-device.h"
|
||||
#include "ht-capabilities.h"
|
||||
#include "wifi-mac.h"
|
||||
#include "regular-wifi-mac.h"
|
||||
#include "wifi-mac-queue.h"
|
||||
#include "wifi-mac-trailer.h"
|
||||
#include <algorithm>
|
||||
@@ -60,9 +60,17 @@ MsduAggregator::~MsduAggregator ()
|
||||
}
|
||||
|
||||
void
|
||||
MsduAggregator::SetEdcaQueues (EdcaQueues map)
|
||||
MsduAggregator::DoDispose ()
|
||||
{
|
||||
m_edca = map;
|
||||
m_mac = 0;
|
||||
Object::DoDispose ();
|
||||
}
|
||||
|
||||
void
|
||||
MsduAggregator::SetWifiMac (const Ptr<RegularWifiMac> mac)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << mac);
|
||||
m_mac = mac;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
@@ -87,7 +95,7 @@ MsduAggregator::GetNextAmsdu (Mac48Address recipient, uint8_t tid,
|
||||
*/
|
||||
NS_ABORT_MSG_IF (recipient.IsGroup (), "Recipient address is group addressed");
|
||||
|
||||
Ptr<QosTxop> qosTxop = m_edca.find (QosUtilsMapTidToAc (tid))->second;
|
||||
Ptr<QosTxop> qosTxop = m_mac->GetQosTxop (tid);
|
||||
Ptr<WifiMacQueue> queue = qosTxop->GetWifiMacQueue ();
|
||||
WifiMacQueue::ConstIterator peekedIt = queue->PeekByTidAndAddress (tid, recipient);
|
||||
|
||||
@@ -104,7 +112,7 @@ MsduAggregator::GetNextAmsdu (Mac48Address recipient, uint8_t tid,
|
||||
*/
|
||||
// No check required for now, as we always set the A-MSDU Supported field to 1
|
||||
|
||||
WifiModulationClass modulation = txVector.GetMode ().GetModulationClass ();
|
||||
WifiModulationClass modulation = txVector.GetModulationClass ();
|
||||
|
||||
// Get the maximum size of the A-MSDU we can send to the recipient
|
||||
uint16_t maxAmsduSize = GetMaxAmsduSize (recipient, tid, modulation);
|
||||
@@ -189,11 +197,6 @@ MsduAggregator::GetMaxAmsduSize (Mac48Address recipient, uint8_t tid,
|
||||
NS_LOG_FUNCTION (this << recipient << +tid << modulation);
|
||||
|
||||
AcIndex ac = QosUtilsMapTidToAc (tid);
|
||||
Ptr<QosTxop> qosTxop = m_edca.find (ac)->second;
|
||||
Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (qosTxop->GetLow ()->GetPhy ()->GetDevice ());
|
||||
NS_ASSERT (device);
|
||||
Ptr<WifiRemoteStationManager> stationManager = device->GetRemoteStationManager ();
|
||||
NS_ASSERT (stationManager);
|
||||
|
||||
// Find the A-MSDU max size configured on this device
|
||||
UintegerValue size;
|
||||
@@ -201,16 +204,16 @@ MsduAggregator::GetMaxAmsduSize (Mac48Address recipient, uint8_t tid,
|
||||
switch (ac)
|
||||
{
|
||||
case AC_BE:
|
||||
device->GetMac ()->GetAttribute ("BE_MaxAmsduSize", size);
|
||||
m_mac->GetAttribute ("BE_MaxAmsduSize", size);
|
||||
break;
|
||||
case AC_BK:
|
||||
device->GetMac ()->GetAttribute ("BK_MaxAmsduSize", size);
|
||||
m_mac->GetAttribute ("BK_MaxAmsduSize", size);
|
||||
break;
|
||||
case AC_VI:
|
||||
device->GetMac ()->GetAttribute ("VI_MaxAmsduSize", size);
|
||||
m_mac->GetAttribute ("VI_MaxAmsduSize", size);
|
||||
break;
|
||||
case AC_VO:
|
||||
device->GetMac ()->GetAttribute ("VO_MaxAmsduSize", size);
|
||||
m_mac->GetAttribute ("VO_MaxAmsduSize", size);
|
||||
break;
|
||||
default:
|
||||
NS_ABORT_MSG ("Unknown AC " << ac);
|
||||
@@ -225,6 +228,9 @@ MsduAggregator::GetMaxAmsduSize (Mac48Address recipient, uint8_t tid,
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ptr<WifiRemoteStationManager> stationManager = m_mac->GetWifiRemoteStationManager ();
|
||||
NS_ASSERT (stationManager);
|
||||
|
||||
// Retrieve the Capabilities elements advertised by the recipient
|
||||
Ptr<const VhtCapabilities> vhtCapabilities = stationManager->GetStationVhtCapabilities (recipient);
|
||||
Ptr<const HtCapabilities> htCapabilities = stationManager->GetStationHtCapabilities (recipient);
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace ns3 {
|
||||
class Packet;
|
||||
class QosTxop;
|
||||
class WifiTxVector;
|
||||
class RegularWifiMac;
|
||||
|
||||
/**
|
||||
* \brief Aggregator used to construct A-MSDUs
|
||||
@@ -117,11 +118,11 @@ public:
|
||||
static WifiMacQueueItem::DeaggregatedMsdus Deaggregate (Ptr<Packet> aggregatedPacket);
|
||||
|
||||
/**
|
||||
* Set the map of EDCA queues.
|
||||
* Set the MAC layer to use.
|
||||
*
|
||||
* \param map the map of EDCA queues.
|
||||
* \param mac the MAC layer to use
|
||||
*/
|
||||
void SetEdcaQueues (EdcaQueues map);
|
||||
void SetWifiMac (const Ptr<RegularWifiMac> mac);
|
||||
|
||||
/**
|
||||
* Calculate how much padding must be added to the end of an A-MSDU of the
|
||||
@@ -134,8 +135,11 @@ public:
|
||||
*/
|
||||
static uint8_t CalculatePadding (uint16_t amsduSize);
|
||||
|
||||
protected:
|
||||
virtual void DoDispose ();
|
||||
|
||||
private:
|
||||
EdcaQueues m_edca; //!< the map of EDCA queues
|
||||
Ptr<RegularWifiMac> m_mac; //!< the MAC of this station
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
@@ -1199,13 +1199,13 @@ RegularWifiMac::EnableAggregation (void)
|
||||
if (m_low->GetMsduAggregator () == 0)
|
||||
{
|
||||
Ptr<MsduAggregator> msduAggregator = CreateObject<MsduAggregator> ();
|
||||
msduAggregator->SetEdcaQueues (m_edca);
|
||||
msduAggregator->SetWifiMac (this);
|
||||
m_low->SetMsduAggregator (msduAggregator);
|
||||
}
|
||||
if (m_low->GetMpduAggregator () == 0)
|
||||
{
|
||||
Ptr<MpduAggregator> mpduAggregator = CreateObject<MpduAggregator> ();
|
||||
mpduAggregator->SetEdcaQueues (m_edca);
|
||||
mpduAggregator->SetWifiMac (this);
|
||||
m_low->SetMpduAggregator (mpduAggregator);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user