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 "he-phy.h"
23
24#include "ns3/double.h"
25#include "ns3/log.h"
26#include "ns3/wifi-net-device.h"
27#include "ns3/wifi-phy.h"
28#include "ns3/wifi-utils.h"
29
30namespace ns3
31{
32
33NS_LOG_COMPONENT_DEFINE("ObssPdAlgorithm");
34NS_OBJECT_ENSURE_REGISTERED(ObssPdAlgorithm);
35
36TypeId
38{
39 static ns3::TypeId tid =
40 ns3::TypeId("ns3::ObssPdAlgorithm")
42 .SetGroupName("Wifi")
43 .AddAttribute("ObssPdLevel",
44 "The current OBSS PD level (dBm).",
45 DoubleValue(-82.0),
48 MakeDoubleChecker<double>(-101, -62))
49 .AddAttribute("ObssPdLevelMin",
50 "Minimum value (dBm) of OBSS PD level.",
51 DoubleValue(-82.0),
53 MakeDoubleChecker<double>(-101, -62))
54 .AddAttribute("ObssPdLevelMax",
55 "Maximum value (dBm) of OBSS PD level.",
56 DoubleValue(-62.0),
58 MakeDoubleChecker<double>(-101, -62))
59 .AddAttribute("TxPowerRefSiso",
60 "The SISO reference TX power level (dBm).",
61 DoubleValue(21),
63 MakeDoubleChecker<double>())
64 .AddAttribute("TxPowerRefMimo",
65 "The MIMO reference TX power level (dBm).",
66 DoubleValue(25),
68 MakeDoubleChecker<double>())
69 .AddTraceSource("Reset",
70 "Trace CCA Reset event",
72 "ns3::ObssPdAlgorithm::ResetTracedCallback");
73 return tid;
74}
75
76void
78{
79 NS_LOG_FUNCTION(this);
80 m_device = nullptr;
81}
82
83void
85{
86 NS_LOG_FUNCTION(this << device);
87 m_device = device;
88 auto hePhy = DynamicCast<HePhy>(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE));
89 NS_ASSERT(hePhy);
90 hePhy->SetObssPdAlgorithm(this);
91}
92
93void
95{
96 double txPowerMaxSiso = 0;
97 double txPowerMaxMimo = 0;
98 bool powerRestricted = false;
99 // Fetch my BSS color
101 NS_ASSERT(heConfiguration);
102 uint8_t bssColor = heConfiguration->GetBssColor();
103 NS_LOG_DEBUG("My BSS color " << (uint16_t)bssColor << " received frame "
104 << (uint16_t)params.bssColor);
105
108 {
109 txPowerMaxSiso = m_txPowerRefSiso - (m_obssPdLevel - m_obssPdLevelMin);
110 txPowerMaxMimo = m_txPowerRefMimo - (m_obssPdLevel - m_obssPdLevelMin);
111 powerRestricted = true;
112 }
113 m_resetEvent(bssColor, WToDbm(params.rssiW), powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
114 phy->ResetCca(powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
115}
116
117void
119{
120 NS_LOG_FUNCTION(this << level);
121 m_obssPdLevel = level;
122}
123
124double
126{
127 return m_obssPdLevel;
128}
129
130} // 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:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
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:685
#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
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
#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:45
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
Declaration of ns3::HePhy class and ns3::HeSigAParameters struct.
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
phy
Definition: third.py:82
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition: he-phy.h:50
uint8_t bssColor
BSS color.
Definition: he-phy.h:52
double rssiW
RSSI in W.
Definition: he-phy.h:51