diff --git a/src/wifi/model/wifi-protection-manager.cc b/src/wifi/model/wifi-protection-manager.cc new file mode 100644 index 000000000..d1a5aa819 --- /dev/null +++ b/src/wifi/model/wifi-protection-manager.cc @@ -0,0 +1,62 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2020 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 "ns3/log.h" +#include "wifi-protection-manager.h" +#include "regular-wifi-mac.h" + + +namespace ns3 { + +NS_LOG_COMPONENT_DEFINE ("WifiProtectionManager"); + +NS_OBJECT_ENSURE_REGISTERED (WifiProtectionManager); + +TypeId +WifiProtectionManager::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::WifiProtectionManager") + .SetParent () + .SetGroupName ("Wifi") + ; + return tid; +} + +WifiProtectionManager::~WifiProtectionManager () +{ + NS_LOG_FUNCTION_NOARGS (); +} + +void +WifiProtectionManager::DoDispose (void) +{ + NS_LOG_FUNCTION (this); + m_mac = 0; + Object::DoDispose (); +} + +void +WifiProtectionManager::SetWifiMac (Ptr mac) +{ + NS_LOG_FUNCTION (this << mac); + m_mac = mac; +} + +} //namespace ns3 diff --git a/src/wifi/model/wifi-protection-manager.h b/src/wifi/model/wifi-protection-manager.h new file mode 100644 index 000000000..b10ae3ddd --- /dev/null +++ b/src/wifi/model/wifi-protection-manager.h @@ -0,0 +1,94 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2020 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 WIFI_PROTECTION_MANAGER_H +#define WIFI_PROTECTION_MANAGER_H + +#include "wifi-protection.h" +#include +#include "ns3/object.h" + + +namespace ns3 { + +class WifiTxParameters; +class WifiMacQueueItem; +class RegularWifiMac; + +/** + * \ingroup wifi + * + * WifiProtectionManager is an abstract base class. Each subclass defines a logic + * to select the protection method for a given frame. + */ +class WifiProtectionManager : public Object +{ +public: + /** + * \brief Get the type ID. + * \return the object TypeId + */ + static TypeId GetTypeId (void); + virtual ~WifiProtectionManager (); + + /** + * Set the MAC which is using this Protection Manager + * + * \param mac a pointer to the MAC + */ + void SetWifiMac (Ptr mac); + + /** + * Determine the protection method to use if the given MPDU is added to the current + * frame. Return a null pointer if the protection method is unchanged or the new + * protection method otherwise. + * + * \param mpdu the MPDU to be added to the current frame + * \param txParams the current TX parameters for the current frame + * \return a null pointer if the protection method is unchanged or the new + * protection method otherwise + */ + virtual std::unique_ptr TryAddMpdu (Ptr mpdu, + const WifiTxParameters& txParams) = 0; + + /** + * Determine the protection method to use if the given MSDU is aggregated to the + * current frame. Return a null pointer if the protection method is unchanged or + * the new protection method otherwise. + * + * \param msdu the MSDU to be aggregated to the current frame + * \param txParams the current TX parameters for the current frame + * \return a null pointer if the protection method is unchanged or the new + * protection method otherwise + */ + virtual std::unique_ptr TryAggregateMsdu (Ptr msdu, + const WifiTxParameters& txParams) = 0; + +protected: + virtual void DoDispose (void); + + Ptr m_mac; //!< MAC which is using this Protection Manager +}; + + + +} //namespace ns3 + +#endif /* WIFI_PROTECTION_MANAGER_H */ diff --git a/src/wifi/wscript b/src/wifi/wscript index ffdaae261..cdac10be7 100644 --- a/src/wifi/wscript +++ b/src/wifi/wscript @@ -28,6 +28,7 @@ def build(bld): 'model/wifi-protection.cc', 'model/wifi-acknowledgment.cc', 'model/wifi-tx-parameters.cc', + 'model/wifi-protection-manager.cc', 'model/mac-low.cc', 'model/mac-low-transmission-parameters.cc', 'model/wifi-mac-queue.cc', @@ -202,6 +203,7 @@ def build(bld): 'model/wifi-protection.h', 'model/wifi-acknowledgment.h', 'model/wifi-tx-parameters.h', + 'model/wifi-protection-manager.h', 'model/mac-low.h', 'model/mac-low-transmission-parameters.h', 'model/originator-block-ack-agreement.h',