A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-protection-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
10
11#include "ap-wifi-mac.h"
12#include "wifi-phy.h"
13
14#include "ns3/log.h"
15
16namespace ns3
17{
18
19NS_LOG_COMPONENT_DEFINE("WifiProtectionManager");
20
21NS_OBJECT_ENSURE_REGISTERED(WifiProtectionManager);
22
23TypeId
25{
26 static TypeId tid =
27 TypeId("ns3::WifiProtectionManager").SetParent<Object>().SetGroupName("Wifi");
28 return tid;
29}
30
36
41
42void
49
50void
56
59{
60 return m_mac->GetWifiRemoteStationManager(m_linkId);
61}
62
63void
65{
66 NS_LOG_FUNCTION(this << +linkId);
67 m_linkId = linkId;
68}
69
70void
72 MHz_u txWidth,
73 const Mac48Address& receiver) const
74{
75 NS_LOG_FUNCTION(this << muRts << txWidth << receiver);
76
78
79 NS_ABORT_MSG_IF(m_mac->GetTypeOfStation() != AP, "HE APs only can send MU-RTS");
80 auto apMac = StaticCast<ApWifiMac>(m_mac);
81 ui.SetAid12(apMac->GetAssociationId(receiver, m_linkId));
82
83 const auto ctsTxWidth =
84 std::min(txWidth, GetWifiRemoteStationManager()->GetChannelWidthSupported(receiver));
85 auto phy = m_mac->GetWifiPhy(m_linkId);
86 std::size_t primaryIdx = phy->GetOperatingChannel().GetPrimaryChannelIndex(ctsTxWidth);
87 std::size_t idx80MHz = 80 / ctsTxWidth;
88 if ((phy->GetChannelWidth() == 160) && (ctsTxWidth <= 40) && (primaryIdx >= idx80MHz))
89 {
90 // the primary80 is in the higher part of the 160 MHz channel
91 primaryIdx -= 80 / ctsTxWidth;
92 }
93 switch (static_cast<uint16_t>(ctsTxWidth))
94 {
95 case 20:
96 ui.SetMuRtsRuAllocation(61 + primaryIdx);
97 break;
98 case 40:
99 ui.SetMuRtsRuAllocation(65 + primaryIdx);
100 break;
101 case 80:
103 break;
104 case 160:
106 break;
107 default:
108 NS_ABORT_MSG("Unhandled TX width: " << ctsTxWidth << " MHz");
109 }
110}
111
112} // namespace ns3
Headers for Trigger frames.
CtrlTriggerUserInfoField & AddUserInfoField()
Append a new User Info field to this Trigger frame and return a non-const reference to it.
User Info field of Trigger frames.
void SetMuRtsRuAllocation(uint8_t value)
Set the RU Allocation subfield based on the given value for the B7-B1 bits.
void SetAid12(uint16_t aid)
Set the AID12 subfield, which carries the 12 LSBs of the AID of the station for which this User Info ...
an EUI-48 address
A base class which provides memory management and object aggregation.
Definition object.h:78
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
void DoDispose() override
Destructor implementation.
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.
void SetLinkId(uint8_t linkId)
Set the ID of the link this Protection Manager is associated with.
void SetWifiMac(Ptr< WifiMac > mac)
Set the MAC which is using this Protection Manager.
static TypeId GetTypeId()
Get the type ID.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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.
Definition object-base.h:35
@ AP
Definition wifi-mac.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:587