27#include "ns3/boolean.h"
28#include "ns3/erp-ofdm-phy.h"
44 TypeId(
"ns3::WifiDefaultProtectionManager")
48 .AddAttribute(
"EnableMuRts",
49 "If enabled, always protect a DL/UL MU frame exchange with MU-RTS/CTS.",
66std::unique_ptr<WifiProtection>
80 (psduInfoMap.size() > 1 ||
81 (psduInfoMap.size() == 1 && psduInfoMap.begin()->first != mpdu->GetHeader().GetAddr1()));
82 auto isEmlsrDestination =
85 if (dlMuPpdu || isEmlsrDestination ||
99 return std::make_unique<WifiNoProtection>();
103 if (mpdu->GetHeader().IsTrigger())
119 std::unique_ptr<WifiProtection> protection;
132std::unique_ptr<WifiProtection>
157 std::unique_ptr<WifiProtection> protection;
172std::unique_ptr<WifiProtection>
182 return std::make_unique<WifiNoProtection>();
188 return std::make_unique<WifiNoProtection>();
194 auto protection = std::make_unique<WifiRtsCtsProtection>();
196 protection->ctsTxVector =
198 protection->rtsTxVector.GetMode());
206 auto protection = std::make_unique<WifiCtsToSelfProtection>();
211 return std::make_unique<WifiNoProtection>();
214std::unique_ptr<WifiProtection>
220 auto receiver = mpdu->GetHeader().GetAddr1();
223 (psduInfoMap.size() > 1 ||
224 (psduInfoMap.size() == 1 && psduInfoMap.begin()->first != receiver));
227 dlMuPpdu || isEmlsrDestination ||
234 (dlMuPpdu &&
m_sendMuRts && !isProtected) || (isEmlsrDestination && !isProtected);
243 return std::make_unique<WifiNoProtection>();
256 auto apMac = StaticCast<ApWifiMac>(
m_mac);
262 if (protection !=
nullptr)
284 NS_ASSERT_MSG(address != receiver,
"This must be the first MPDU for " << receiver);
305 if (isEmlsrDestination && !isProtected)
315 return std::unique_ptr<WifiMuRtsCtsProtection>(protection);
325std::unique_ptr<WifiProtection>
330 NS_ASSERT(mpdu->GetHeader().IsTrigger());
333 mpdu->GetPacket()->PeekHeader(trigger);
337 auto protection = std::make_unique<WifiMuRtsCtsProtection>();
344 protection->muRts.SetUlBandwidth(txWidth);
347 const auto& staList = StaticCast<ApWifiMac>(
m_mac)->GetStaList(
m_linkId);
348 std::remove_reference_t<
decltype(staList)>::const_iterator staIt;
350 bool allProtected =
true;
351 bool isUnprotectedEmlsrDst =
false;
353 for (
const auto& userInfo : trigger)
358 staIt = staList.find(userInfo.GetAid12());
363 allProtected = allProtected && isProtected;
365 isUnprotectedEmlsrDst =
366 isUnprotectedEmlsrDst ||
370 bool needMuRts = (
m_sendMuRts && !allProtected) || isUnprotectedEmlsrDst;
375 return std::make_unique<WifiNoProtection>();
379 protection->muRtsTxVector =
386 const auto modulation = protection->muRtsTxVector.GetModulationClass();
394 if (isUnprotectedEmlsrDst)
AttributeValue implementation for Boolean.
static WifiMode GetErpOfdmRate6Mbps()
Return a WifiMode for ERP-OFDM at 6 Mbps.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
WifiDefaultProtectionManager is the default protection manager, which selects the protection method f...
std::unique_ptr< WifiProtection > TryAddMpdu(Ptr< const WifiMpdu > mpdu, const WifiTxParameters &txParams) override
Determine the protection method to use if the given MPDU is added to the current frame.
~WifiDefaultProtectionManager() override
bool m_sendMuRts
true for sending an MU-RTS to protect DL MU PPDUs
std::unique_ptr< WifiProtection > TryAggregateMsdu(Ptr< const WifiMpdu > msdu, const WifiTxParameters &txParams) override
Determine the protection method to use if the given MSDU is aggregated to the current frame.
WifiDefaultProtectionManager()
static TypeId GetTypeId()
Get the type ID.
virtual std::unique_ptr< WifiProtection > TryUlMuTransmission(Ptr< const WifiMpdu > mpdu, const WifiTxParameters &txParams)
Calculate the protection method for the UL MU transmission solicited by the given Trigger Frame.
virtual std::unique_ptr< WifiProtection > TryAddMpduToMuPpdu(Ptr< const WifiMpdu > mpdu, const WifiTxParameters &txParams)
Calculate the protection method to use if the given MPDU is added to the current DL MU PPDU (represen...
virtual std::unique_ptr< WifiProtection > GetPsduProtection(const WifiMacHeader &hdr, uint32_t size, const WifiTxVector &txVector) const
Select the protection method for a single PSDU.
Ptr< FrameExchangeManager > GetFrameExchangeManager(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get the Frame Exchange Manager associated with the given link.
TypeOfStation GetTypeOfStation() const
Return the type of station.
WifiProtectionManager is an abstract base class.
Ptr< WifiMac > m_mac
MAC which is using this Protection Manager.
void AddUserInfoToMuRts(CtrlTriggerHeader &muRts, uint16_t txWidth, const Mac48Address &receiver) const
Add a User Info field to the given MU-RTS Trigger Frame to solicit a CTS from the station with the gi...
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager() const
uint8_t m_linkId
ID of the link this Protection Manager is operating on.
bool GetEmlsrEnabled(const Mac48Address &address) const
void AdjustTxVectorForIcf(WifiTxVector &txVector) const
Adjust the TXVECTOR for an initial Control frame to ensure that the modulation class is non-HT and th...
WifiTxVector GetCtsToSelfTxVector()
Since CTS-to-self parameters are not dependent on the station, it is implemented in wifi remote stati...
WifiTxVector GetCtsTxVector(Mac48Address to, WifiMode rtsTxMode) const
Return a TXVECTOR for the CTS frame given the destination and the mode of the RTS used by the sender.
WifiTxVector GetRtsTxVector(Mac48Address address)
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
uint32_t GetSizeIfAddMpdu(Ptr< const WifiMpdu > mpdu) const
Get the size in bytes of the frame in case the given MPDU is added.
const PsduInfoMap & GetPsduInfoMap() const
Get a const reference to the map containing information about PSDUs.
std::pair< uint32_t, uint32_t > GetSizeIfAggregateMsdu(Ptr< const WifiMpdu > msdu) const
Get the size in bytes of the frame in case the given MSDU is aggregated.
std::unique_ptr< WifiProtection > m_protection
protection method
const PsduInfo * GetPsduInfo(Mac48Address receiver) const
Get a pointer to the information about the PSDU addressed to the given receiver, if present,...
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
WifiModulationClass GetModulationClass() const
Get the modulation class specified by this TXVECTOR.
uint16_t GetChannelWidth() const
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeChecker > MakeBooleanChecker()
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiMuRtsCtsProtection specifies that MU-RTS/CTS protection method is used.
CtrlTriggerHeader muRts
MU-RTS.
WifiTxVector muRtsTxVector
MU-RTS TXVECTOR.