wifi: Use attribute to set the AC of the queue of a Txop object

This commit is contained in:
Stefano Avallone
2024-03-25 23:13:11 +01:00
parent b19dd21407
commit 4af7d97120
7 changed files with 54 additions and 28 deletions

View File

@@ -32,6 +32,7 @@
#include "ns3/random-variable-stream.h"
#include "ns3/simulator.h"
#include "ns3/socket.h"
#include "ns3/string.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/wifi-mac-queue-scheduler.h"
#include "ns3/wifi-mac-queue.h"
@@ -611,7 +612,7 @@ MeshWifiInterfaceMac::ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
// We use the single DCF provided by WifiMac for the purpose of
// Beacon transmission. For this we need to reconfigure the channel
// access parameters slightly, and do so here.
m_txop = CreateObject<Txop>();
m_txop = CreateObjectWithAttributes<Txop>("AcIndex", StringValue("AC_BE_NQOS"));
m_txop->SetWifiMac(this);
GetLink(0).channelAccessManager->Add(m_txop);
m_txop->SetTxMiddle(m_txMiddle);

View File

@@ -112,7 +112,7 @@ ApWifiMac::ApWifiMac()
: m_enableBeaconGeneration(false)
{
NS_LOG_FUNCTION(this);
m_beaconTxop = CreateObject<Txop>(CreateObject<WifiMacQueue>(AC_BEACON));
m_beaconTxop = CreateObjectWithAttributes<Txop>("AcIndex", StringValue("AC_BEACON"));
m_beaconTxop->SetTxMiddle(m_txMiddle);
// Let the lower layers know that we are acting as an AP.

View File

@@ -99,12 +99,18 @@ QosTxop::GetTypeId()
return tid;
}
QosTxop::QosTxop(AcIndex ac)
: Txop(CreateObject<WifiMacQueue>(ac)),
m_ac(ac)
QosTxop::QosTxop()
{
NS_LOG_FUNCTION(this);
m_baManager = CreateObject<BlockAckManager>();
}
void
QosTxop::CreateQueue(AcIndex aci)
{
NS_LOG_FUNCTION(this << aci);
Txop::CreateQueue(aci);
m_ac = aci;
m_baManager->SetQueue(m_queue);
m_baManager->SetBlockDestinationCallback(
Callback<void, Mac48Address, uint8_t>([this](Mac48Address recipient, uint8_t tid) {

View File

@@ -79,13 +79,7 @@ class QosTxop : public Txop
*/
static TypeId GetTypeId();
/**
* Constructor
*
* \param ac the Access Category
*/
QosTxop(AcIndex ac = AC_UNDEF);
QosTxop();
~QosTxop() override;
bool IsQosTxop() const override;
@@ -439,6 +433,7 @@ class QosTxop : public Txop
};
void DoDispose() override;
void CreateQueue(AcIndex aci) override;
/**
* Get a reference to the link associated with the given ID.

View File

@@ -54,6 +54,27 @@ Txop::GetTypeId()
.SetParent<ns3::Object>()
.SetGroupName("Wifi")
.AddConstructor<Txop>()
.AddAttribute("AcIndex",
"The AC index of the packets contained in the wifi MAC queue of this "
"Txop object.",
EnumValue(AcIndex::AC_UNDEF),
MakeEnumAccessor<AcIndex>(&Txop::CreateQueue),
MakeEnumChecker(AC_BE,
"AC_BE",
AC_BK,
"AC_BK",
AC_VI,
"AC_VI",
AC_VO,
"AC_VO",
AC_BE_NQOS,
"AC_BE_NQOS",
AC_VI,
"AC_VI",
AC_BEACON,
"AC_BEACON",
AC_UNDEF,
"AC_UNDEF"))
.AddAttribute("MinCw",
"The minimum value of the contention window (just for the first link, "
"in case of 11be multi-link devices).",
@@ -132,12 +153,6 @@ Txop::GetTypeId()
}
Txop::Txop()
: Txop(CreateObject<WifiMacQueue>(AC_BE_NQOS))
{
}
Txop::Txop(Ptr<WifiMacQueue> queue)
: m_queue(queue)
{
NS_LOG_FUNCTION(this);
m_rng = m_shuffleLinkIdsGen.GetRv();
@@ -159,6 +174,14 @@ Txop::DoDispose()
m_links.clear();
}
void
Txop::CreateQueue(AcIndex aci)
{
NS_LOG_FUNCTION(this << aci);
NS_ABORT_MSG_IF(m_queue, "Wifi MAC queue can only be created once");
m_queue = CreateObject<WifiMacQueue>(aci);
}
std::unique_ptr<Txop::LinkEntity>
Txop::CreateLinkEntity() const
{

View File

@@ -51,6 +51,7 @@ class WifiMpdu;
class UniformRandomVariable;
class CtrlBAckResponseHeader;
class WifiMac;
enum AcIndex : uint8_t; // opaque enum declaration
enum WifiMacDropReason : uint8_t; // opaque enum declaration
/**
@@ -81,14 +82,6 @@ class Txop : public Object
{
public:
Txop();
/**
* Constructor
*
* \param queue the wifi MAC queue
*/
Txop(Ptr<WifiMacQueue> queue);
~Txop() override;
/**
@@ -462,6 +455,13 @@ class Txop : public Object
void DoDispose() override;
void DoInitialize() override;
/**
* Create a wifi MAC queue containing packets of the given AC
*
* \param aci the index of the given AC
*/
virtual void CreateQueue(AcIndex aci);
/* Txop notifications forwarded here */
/**
* Notify that access request has been received for the given link.

View File

@@ -36,6 +36,7 @@
#include "ns3/log.h"
#include "ns3/packet.h"
#include "ns3/pointer.h"
#include "ns3/string.h"
#include "ns3/vht-configuration.h"
#include <algorithm>
@@ -644,7 +645,7 @@ WifiMac::SetupEdcaQueue(AcIndex ac)
// already configured.
NS_ASSERT(!m_edca.contains(ac));
Ptr<QosTxop> edca = CreateObject<QosTxop>(ac);
auto edca = CreateObjectWithAttributes<QosTxop>("AcIndex", EnumValue<AcIndex>(ac));
edca->SetTxMiddle(m_txMiddle);
edca->GetBaManager()->SetTxOkCallback(
MakeCallback(&MpduTracedCallback::operator(), &m_ackedMpduCallback));
@@ -1215,7 +1216,7 @@ WifiMac::SetQosSupported(bool enable)
if (!m_qosSupported)
{
// create a non-QoS TXOP
m_txop = CreateObject<Txop>();
m_txop = CreateObjectWithAttributes<Txop>("AcIndex", StringValue("AC_BE_NQOS"));
m_txop->SetTxMiddle(m_txMiddle);
m_txop->SetDroppedMpduCallback(
MakeCallback(&DroppedMpduTracedCallback::operator(), &m_droppedMpduCallback));