diff --git a/src/wifi/model/txop.cc b/src/wifi/model/txop.cc index 8e8c10fff..1c3783162 100644 --- a/src/wifi/model/txop.cc +++ b/src/wifi/model/txop.cc @@ -113,6 +113,27 @@ Txop::DoDispose (void) m_mac = 0; m_rng = 0; m_txMiddle = 0; + m_links.clear (); +} + +std::unique_ptr +Txop::CreateLinkEntity (void) const +{ + return std::make_unique (); +} + +Txop::LinkEntity& +Txop::GetLink (uint8_t linkId) const +{ + NS_ASSERT (linkId < m_links.size ()); + NS_ASSERT (m_links.at (linkId)); // check that the pointer owns an object + return *m_links.at (linkId); +} + +uint8_t +Txop::GetNLinks (void) const +{ + return m_links.size (); } void Txop::SetTxMiddle (const Ptr txMiddle) @@ -126,6 +147,13 @@ Txop::SetWifiMac (const Ptr mac) { NS_LOG_FUNCTION (this << mac); m_mac = mac; + m_links.resize (m_mac->GetNLinks ()); + uint8_t linkId = 0; + for (auto& link : m_links) + { + link = CreateLinkEntity (); + link->id = linkId++; + } } void diff --git a/src/wifi/model/txop.h b/src/wifi/model/txop.h index bd3e84a81..7c66f88a3 100644 --- a/src/wifi/model/txop.h +++ b/src/wifi/model/txop.h @@ -23,6 +23,7 @@ #include "ns3/traced-value.h" #include "wifi-mac-header.h" +#include namespace ns3 { @@ -312,6 +313,33 @@ protected: */ void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound); + /** + * Structure holding information specific to a single link. Here, the meaning of + * "link" is that of the 11be amendment which introduced multi-link devices. For + * previous amendments, only one link can be created. + */ + struct LinkEntity + { + /// Destructor (a virtual method is needed to make this struct polymorphic) + virtual ~LinkEntity () = default; + + uint8_t id {0}; //!< Link ID (starting at 0) + }; + + /** + * Get a reference to the link associated with the given ID. + * + * \param linkId the given link ID + * \return a reference to the link associated with the given ID + */ + LinkEntity& GetLink (uint8_t linkId) const; + /** + * Get the number of links. + * + * \return the number of links + */ + uint8_t GetNLinks (void) const; + DroppedMpdu m_droppedMpduCallback; //!< the dropped MPDU callback Ptr m_queue; //!< the wifi MAC queue Ptr m_txMiddle; //!< the MacTxMiddle @@ -335,6 +363,16 @@ protected: TracedCallback m_backoffTrace; //!< backoff trace value TracedValue m_cwTrace; //!< CW trace value + +private: + /** + * Create a LinkEntity object. + * + * \return a unique pointer to the created LinkEntity object + */ + virtual std::unique_ptr CreateLinkEntity (void) const; + + std::vector> m_links; //!< vector of LinkEntity objects }; } //namespace ns3