diff --git a/src/mesh/model/mesh-wifi-interface-mac.cc b/src/mesh/model/mesh-wifi-interface-mac.cc index 2b6640dce..6a5f25535 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.cc +++ b/src/mesh/model/mesh-wifi-interface-mac.cc @@ -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(); + m_txop = CreateObjectWithAttributes("AcIndex", StringValue("AC_BE_NQOS")); m_txop->SetWifiMac(this); GetLink(0).channelAccessManager->Add(m_txop); m_txop->SetTxMiddle(m_txMiddle); diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 223cd83e3..1d427f1cb 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -112,7 +112,7 @@ ApWifiMac::ApWifiMac() : m_enableBeaconGeneration(false) { NS_LOG_FUNCTION(this); - m_beaconTxop = CreateObject(CreateObject(AC_BEACON)); + m_beaconTxop = CreateObjectWithAttributes("AcIndex", StringValue("AC_BEACON")); m_beaconTxop->SetTxMiddle(m_txMiddle); // Let the lower layers know that we are acting as an AP. diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index 9c8fdaf2a..76ed44a4a 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -99,12 +99,18 @@ QosTxop::GetTypeId() return tid; } -QosTxop::QosTxop(AcIndex ac) - : Txop(CreateObject(ac)), - m_ac(ac) +QosTxop::QosTxop() { NS_LOG_FUNCTION(this); m_baManager = CreateObject(); +} + +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([this](Mac48Address recipient, uint8_t tid) { diff --git a/src/wifi/model/qos-txop.h b/src/wifi/model/qos-txop.h index f6d04f9f6..a9a3f811b 100644 --- a/src/wifi/model/qos-txop.h +++ b/src/wifi/model/qos-txop.h @@ -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. diff --git a/src/wifi/model/txop.cc b/src/wifi/model/txop.cc index cfbfa426a..3b9dee570 100644 --- a/src/wifi/model/txop.cc +++ b/src/wifi/model/txop.cc @@ -54,6 +54,27 @@ Txop::GetTypeId() .SetParent() .SetGroupName("Wifi") .AddConstructor() + .AddAttribute("AcIndex", + "The AC index of the packets contained in the wifi MAC queue of this " + "Txop object.", + EnumValue(AcIndex::AC_UNDEF), + MakeEnumAccessor(&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(AC_BE_NQOS)) -{ -} - -Txop::Txop(Ptr 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(aci); +} + std::unique_ptr Txop::CreateLinkEntity() const { diff --git a/src/wifi/model/txop.h b/src/wifi/model/txop.h index ba80a9ee8..b837809c2 100644 --- a/src/wifi/model/txop.h +++ b/src/wifi/model/txop.h @@ -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 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. diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index 42d4b1aeb..3d2aa4899 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -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 @@ -644,7 +645,7 @@ WifiMac::SetupEdcaQueue(AcIndex ac) // already configured. NS_ASSERT(!m_edca.contains(ac)); - Ptr edca = CreateObject(ac); + auto edca = CreateObjectWithAttributes("AcIndex", EnumValue(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(); + m_txop = CreateObjectWithAttributes("AcIndex", StringValue("AC_BE_NQOS")); m_txop->SetTxMiddle(m_txMiddle); m_txop->SetDroppedMpduCallback( MakeCallback(&DroppedMpduTracedCallback::operator(), &m_droppedMpduCallback));