diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt index 15c95db93..0c4fa85fa 100644 --- a/src/wifi/CMakeLists.txt +++ b/src/wifi/CMakeLists.txt @@ -32,6 +32,7 @@ set(source_files model/eht/tid-to-link-mapping-element.cc model/eht/eht-phy.cc model/eht/eht-ppdu.cc + model/eht/emlsr-manager.cc model/eht/multi-link-element.cc model/error-rate-model.cc model/extended-capabilities.cc @@ -180,6 +181,7 @@ set(header_files model/eht/tid-to-link-mapping-element.h model/eht/eht-phy.h model/eht/eht-ppdu.h + model/eht/emlsr-manager.h model/eht/multi-link-element.h model/error-rate-model.h model/extended-capabilities.h diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index f3ae1812d..583ae1cf1 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -900,6 +900,7 @@ WifiHelper::EnableLogComponents() LogComponentEnable("DsssErrorRateModel", LOG_LEVEL_ALL); LogComponentEnable("DsssPhy", LOG_LEVEL_ALL); LogComponentEnable("DsssPpdu", LOG_LEVEL_ALL); + LogComponentEnable("EmlsrManager", LOG_LEVEL_ALL); LogComponentEnable("EhtFrameExchangeManager", LOG_LEVEL_ALL); LogComponentEnable("ErpOfdmPhy", LOG_LEVEL_ALL); LogComponentEnable("ErpOfdmPpdu", LOG_LEVEL_ALL); diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc new file mode 100644 index 000000000..b7aaefc0fb --- /dev/null +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2023 Universita' degli Studi di Napoli Federico II + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Stefano Avallone + */ + +#include "emlsr-manager.h" + +#include "eht-configuration.h" +#include "eht-frame-exchange-manager.h" + +#include "ns3/abort.h" +#include "ns3/log.h" + +namespace ns3 +{ + +NS_LOG_COMPONENT_DEFINE("EmlsrManager"); + +NS_OBJECT_ENSURE_REGISTERED(EmlsrManager); + +TypeId +EmlsrManager::GetTypeId() +{ + static TypeId tid = + TypeId("ns3::EmlsrManager") + .SetParent() + .SetGroupName("Wifi") + .AddAttribute("EmlsrPaddingDelay", + "The EMLSR Paddind Delay (not used by AP MLDs). " + "Possible values are 0 us, 32 us, 64 us, 128 us or 256 us.", + TimeValue(MicroSeconds(0)), + MakeTimeAccessor(&EmlsrManager::m_emlsrPaddingDelay), + MakeTimeChecker(MicroSeconds(0), MicroSeconds(256))) + .AddAttribute("EmlsrTransitionDelay", + "The EMLSR Transition Delay (not used by AP MLDs). " + "Possible values are 0 us, 16 us, 32 us, 64 us, 128 us or 256 us.", + TimeValue(MicroSeconds(0)), + MakeTimeAccessor(&EmlsrManager::m_emlsrTransitionDelay), + MakeTimeChecker(MicroSeconds(0), MicroSeconds(256))); + return tid; +} + +EmlsrManager::EmlsrManager() +{ + NS_LOG_FUNCTION(this); +} + +EmlsrManager::~EmlsrManager() +{ + NS_LOG_FUNCTION_NOARGS(); +} + +void +EmlsrManager::DoDispose() +{ + NS_LOG_FUNCTION(this); + m_staMac = nullptr; + Object::DoDispose(); +} + +void +EmlsrManager::SetWifiMac(Ptr mac) +{ + NS_LOG_FUNCTION(this << mac); + NS_ASSERT(mac); + m_staMac = mac; + + NS_ABORT_MSG_IF(!m_staMac->GetEhtConfiguration(), "EmlsrManager requires EHT support"); + NS_ABORT_MSG_IF(m_staMac->GetNLinks() <= 1, "EmlsrManager can only be installed on MLDs"); + NS_ABORT_MSG_IF(m_staMac->GetTypeOfStation() != STA, + "EmlsrManager can only be installed on non-AP MLDs"); +} + +Ptr +EmlsrManager::GetStaMac() const +{ + return m_staMac; +} + +Ptr +EmlsrManager::GetEhtFem(uint8_t linkId) const +{ + return StaticCast(m_staMac->GetFrameExchangeManager(linkId)); +} + +} // namespace ns3 diff --git a/src/wifi/model/eht/emlsr-manager.h b/src/wifi/model/eht/emlsr-manager.h new file mode 100644 index 000000000..569c4b7e9 --- /dev/null +++ b/src/wifi/model/eht/emlsr-manager.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2023 Universita' degli Studi di Napoli Federico II + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Stefano Avallone + */ + +#ifndef EMLSR_MANAGER_H +#define EMLSR_MANAGER_H + +#include "ns3/object.h" +#include "ns3/sta-wifi-mac.h" + +namespace ns3 +{ + +class EhtFrameExchangeManager; + +/** + * \ingroup wifi + * + * EmlsrManager is an abstract base class defining the API that EHT non-AP MLDs + * with EMLSR activated can use to handle the operations on the EMLSR links + */ +class EmlsrManager : public Object +{ + public: + /** + * \brief Get the type ID. + * \return the object TypeId + */ + static TypeId GetTypeId(); + EmlsrManager(); + ~EmlsrManager() override; + + /** + * Set the wifi MAC. Note that it must be the MAC of an EHT non-AP MLD. + * + * \param mac the wifi MAC + */ + void SetWifiMac(Ptr mac); + + protected: + void DoDispose() override; + + /** + * \return the MAC of the non-AP MLD managed by this EMLSR Manager. + */ + Ptr GetStaMac() const; + + /** + * \param linkId the ID of the given link + * \return the EHT FrameExchangeManager attached to the non-AP STA operating on the given link + */ + Ptr GetEhtFem(uint8_t linkId) const; + + Time m_emlsrPaddingDelay; //!< EMLSR Padding delay + Time m_emlsrTransitionDelay; //!< EMLSR Transition delay + + private: + Ptr m_staMac; //!< the MAC of the managed non-AP MLD +}; + +} // namespace ns3 + +#endif /* EMLSR_MANAGER_H */