A Discrete-Event Network Simulator
API
obss-pd-algorithm.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 University of Washington
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
18  */
19 
20 #include "obss-pd-algorithm.h"
21 
22 #include "ns3/double.h"
23 #include "ns3/eht-phy.h"
24 #include "ns3/log.h"
25 #include "ns3/wifi-net-device.h"
26 #include "ns3/wifi-phy.h"
27 #include "ns3/wifi-utils.h"
28 
29 namespace ns3
30 {
31 
32 NS_LOG_COMPONENT_DEFINE("ObssPdAlgorithm");
33 NS_OBJECT_ENSURE_REGISTERED(ObssPdAlgorithm);
34 
35 TypeId
37 {
38  static ns3::TypeId tid =
39  ns3::TypeId("ns3::ObssPdAlgorithm")
40  .SetParent<Object>()
41  .SetGroupName("Wifi")
42  .AddAttribute("ObssPdLevel",
43  "The current OBSS PD level (dBm).",
44  DoubleValue(-82.0),
47  MakeDoubleChecker<double>(-101, -62))
48  .AddAttribute("ObssPdLevelMin",
49  "Minimum value (dBm) of OBSS PD level.",
50  DoubleValue(-82.0),
52  MakeDoubleChecker<double>(-101, -62))
53  .AddAttribute("ObssPdLevelMax",
54  "Maximum value (dBm) of OBSS PD level.",
55  DoubleValue(-62.0),
57  MakeDoubleChecker<double>(-101, -62))
58  .AddAttribute("TxPowerRefSiso",
59  "The SISO reference TX power level (dBm).",
60  DoubleValue(21),
62  MakeDoubleChecker<double>())
63  .AddAttribute("TxPowerRefMimo",
64  "The MIMO reference TX power level (dBm).",
65  DoubleValue(25),
67  MakeDoubleChecker<double>())
68  .AddTraceSource("Reset",
69  "Trace CCA Reset event",
71  "ns3::ObssPdAlgorithm::ResetTracedCallback");
72  return tid;
73 }
74 
75 void
77 {
78  NS_LOG_FUNCTION(this);
79  m_device = nullptr;
80 }
81 
82 void
84 {
85  NS_LOG_FUNCTION(this << device);
86  m_device = device;
87  auto phy = device->GetPhy();
88  if (phy->GetStandard() >= WIFI_STANDARD_80211be)
89  {
90  auto ehtPhy = DynamicCast<EhtPhy>(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_EHT));
91  NS_ASSERT(ehtPhy);
92  ehtPhy->SetObssPdAlgorithm(this);
93  }
94  auto hePhy = DynamicCast<HePhy>(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE));
95  NS_ASSERT(hePhy);
96  hePhy->SetObssPdAlgorithm(this);
97 }
98 
99 void
101 {
102  double txPowerMaxSiso = 0;
103  double txPowerMaxMimo = 0;
104  bool powerRestricted = false;
105  // Fetch my BSS color
106  Ptr<HeConfiguration> heConfiguration = m_device->GetHeConfiguration();
107  NS_ASSERT(heConfiguration);
108  uint8_t bssColor = heConfiguration->GetBssColor();
109  NS_LOG_DEBUG("My BSS color " << (uint16_t)bssColor << " received frame "
110  << (uint16_t)params.bssColor);
111 
114  {
115  txPowerMaxSiso = m_txPowerRefSiso - (m_obssPdLevel - m_obssPdLevelMin);
116  txPowerMaxMimo = m_txPowerRefMimo - (m_obssPdLevel - m_obssPdLevelMin);
117  powerRestricted = true;
118  }
119  m_resetEvent(bssColor, WToDbm(params.rssiW), powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
120  phy->ResetCca(powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
121 }
122 
123 void
125 {
126  NS_LOG_FUNCTION(this << level);
127  m_obssPdLevel = level;
128 }
129 
130 double
132 {
133  return m_obssPdLevel;
134 }
135 
136 } // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
A base class which provides memory management and object aggregation.
Definition: object.h:89
void DoDispose() override
Destructor implementation.
void ResetPhy(HeSigAParameters params)
Reset PHY to IDLE.
void SetObssPdLevel(double level)
double m_obssPdLevelMax
Maximum OBSS PD level (dBm)
static TypeId GetTypeId()
Get the type ID.
double m_txPowerRefSiso
SISO reference TX power level (dBm)
Ptr< WifiNetDevice > m_device
Pointer to the WifiNetDevice.
double m_obssPdLevel
Current OBSS PD level (dBm)
double m_obssPdLevelMin
Minimum OBSS PD level (dBm)
double m_txPowerRefMimo
MIMO reference TX power level (dBm)
virtual void ConnectWifiNetDevice(const Ptr< WifiNetDevice > device)
Connect the WifiNetDevice and setup eventual callbacks.
TracedCallback< uint8_t, double, bool, double, double > m_resetEvent
TracedCallback signature for PHY reset events.
double GetObssPdLevel() const
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
Ptr< HeConfiguration > GetHeConfiguration() const
Ptr< WifiPhy > GetPhy() const
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
Definition: wifi-phy.cc:711
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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:46
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
@ WIFI_STANDARD_80211be
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:46
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
phy
Definition: third.py:89
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition: he-phy.h:54