16#include "ns3/boolean.h"
17#include "ns3/eht-frame-exchange-manager.h"
18#include "ns3/emlsr-manager.h"
19#include "ns3/erp-ofdm-phy.h"
36 TypeId(
"ns3::WifiDefaultProtectionManager")
40 .AddAttribute(
"EnableMuRts",
41 "If enabled, always protect a DL/UL MU frame exchange with MU-RTS/CTS.",
45 .AddAttribute(
"SingleRtsPerTxop",
46 "If enabled, a protection mechanism (RTS or MU-RTS) is normally used no "
47 "more than once in a TXOP, regardless of the destination of the data "
48 "frame (unless required for specific purposes, such as transmitting an "
49 "Initial Control Frame to an EMLSR client).",
53 .AddAttribute(
"SkipMuRtsBeforeBsrp",
54 "If enabled, MU-RTS is not used to protect the transmission of a BSRP "
72std::unique_ptr<WifiProtection>
77 const auto& hdr = mpdu->GetHeader();
82 return std::make_unique<WifiNoProtection>();
92 if (dlMuPpdu || isEmlsrDestination ||
106 return std::make_unique<WifiNoProtection>();
126 std::unique_ptr<WifiProtection> protection;
138std::unique_ptr<WifiProtection>
163 std::unique_ptr<WifiProtection> protection;
176std::unique_ptr<WifiProtection>
185 return std::make_unique<WifiNoProtection>();
190 if (
const auto& protectedStas =
m_mac->GetFrameExchangeManager(
m_linkId)->GetProtectedStas();
193 return std::make_unique<WifiNoProtection>();
198 bool emlsrNeedRts =
false;
202 auto emlsrManager = staMac->GetEmlsrManager();
204 emlsrNeedRts = emlsrManager && staMac->IsEmlsrLink(
m_linkId) &&
205 (emlsrManager->GetElapsedMediumSyncDelayTimer(
m_linkId) ||
206 m_mac->GetLinkForPhy(emlsrManager->GetMainPhyId()) !=
m_linkId);
212 auto protection = std::make_unique<WifiRtsCtsProtection>();
213 protection->rtsTxVector =
216 protection->ctsTxVector =
218 protection->rtsTxVector.GetMode());
225 auto protection = std::make_unique<WifiCtsToSelfProtection>();
231 return std::make_unique<WifiNoProtection>();
234std::unique_ptr<WifiProtection>
240 auto receiver = mpdu->GetHeader().GetAddr1();
245 dlMuPpdu || isEmlsrDestination ||
248 const auto& protectedStas =
m_mac->GetFrameExchangeManager(
m_linkId)->GetProtectedStas();
249 const auto isProtected = protectedStas.contains(receiver);
252 const auto anyUnprotected =
253 std::any_of(psduInfoMap.cbegin(), psduInfoMap.cend(), [&protectedStas](
const auto& info) {
254 return !protectedStas.contains(info.first);
256 const auto needMuRts =
260 (isEmlsrDestination && !isProtected);
269 return std::make_unique<WifiNoProtection>();
287 if (protection !=
nullptr)
320 const auto isPunctured =
321 std::find(inactiveSubchannels.cbegin(), inactiveSubchannels.cend(),
true) !=
322 inactiveSubchannels.cend();
323 const auto muRtsVariant = ((txWidth ==
MHz_u{320}) || isPunctured)
350 if (isEmlsrDestination && !isProtected)
358 return std::unique_ptr<WifiMuRtsCtsProtection>(protection);
368std::unique_ptr<WifiProtection>
373 NS_ASSERT(mpdu->GetHeader().IsTrigger());
376 mpdu->GetPacket()->PeekHeader(trigger);
380 auto protection = std::make_unique<WifiMuRtsCtsProtection>();
387 protection->muRts.SetVariant(trigger.
GetVariant());
388 protection->muRts.SetUlBandwidth(txWidth);
393 const auto& protectedStas =
m_mac->GetFrameExchangeManager(
m_linkId)->GetProtectedStas();
394 bool allProtected =
true;
395 bool isUnprotectedEmlsrDst =
false;
397 for (
const auto& userInfo : trigger)
402 auto staIt = staList.find(userInfo.GetAid12());
405 const auto isProtected = protectedStas.contains(staIt->second);
406 allProtected = allProtected && isProtected;
408 isUnprotectedEmlsrDst =
409 isUnprotectedEmlsrDst ||
415 isUnprotectedEmlsrDst;
424 return std::make_unique<WifiNoProtection>();
428 protection->muRtsTxVector =
433 protection->muRtsTxVector.SetChannelWidth(txWidth);
435 const auto modulation = protection->muRtsTxVector.GetModulationClass();
440 if (isUnprotectedEmlsrDst)
444 ehtFem->SetIcfPaddingAndTxVector(protection->muRts, protection->muRtsTxVector);
static WifiMode GetErpOfdmRate6Mbps()
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
bool m_skipMuRtsBeforeBsrp
whether to skip MU-RTS before BSRP TF
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.
bool m_singleRtsPerTxop
true for using protection only once in a TXOP
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 > GetPsduProtection(const WifiMacHeader &hdr, const WifiTxParameters &txParams) const
Select the protection method for a single PSDU.
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...
Ptr< WifiMac > m_mac
MAC which is using this Protection Manager.
void AddUserInfoToMuRts(CtrlTriggerHeader &muRts, MHz_u 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.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
const PsduInfoMap & GetPsduInfoMap() const
Get a const reference to the map containing information about PSDUs.
std::unique_ptr< WifiProtection > m_protection
protection method
bool LastAddedIsFirstMpdu(Mac48Address receiver) const
Check if the last added MPDU is the first MPDU for the given receiver.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
void SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
WifiModulationClass GetModulationClass() const
Get the modulation class specified by this TXVECTOR.
MHz_u GetChannelWidth() const
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
const std::vector< bool > & GetInactiveSubchannels() const
Get the 20 MHz subchannels that are punctured.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#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.
Ptr< const AttributeChecker > MakeBooleanChecker()
double MHz_u
MHz weak type.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
WifiMuRtsCtsProtection specifies that MU-RTS/CTS protection method is used.
CtrlTriggerHeader muRts
MU-RTS.
WifiTxVector muRtsTxVector
MU-RTS TXVECTOR.