A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
obss-pd-algorithm.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#include "obss-pd-algorithm.h"
10
11#include "ns3/double.h"
12#include "ns3/eht-phy.h"
13#include "ns3/log.h"
14#include "ns3/wifi-net-device.h"
15#include "ns3/wifi-phy.h"
16#include "ns3/wifi-utils.h"
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("ObssPdAlgorithm");
23
26{
27 static ns3::TypeId tid =
28 ns3::TypeId("ns3::ObssPdAlgorithm")
30 .SetGroupName("Wifi")
31 .AddAttribute("ObssPdLevel",
32 "The current OBSS PD level (dBm).",
33 DoubleValue(-82.0),
36 MakeDoubleChecker<dBm_u>(-101, -62))
37 .AddAttribute("ObssPdLevelMin",
38 "Minimum value (dBm) of OBSS PD level.",
39 DoubleValue(-82.0),
41 MakeDoubleChecker<dBm_u>(-101, -62))
42 .AddAttribute("ObssPdLevelMax",
43 "Maximum value (dBm) of OBSS PD level.",
44 DoubleValue(-62.0),
46 MakeDoubleChecker<dBm_u>(-101, -62))
47 .AddAttribute("TxPowerRefSiso",
48 "The SISO reference TX power level (dBm).",
49 DoubleValue(21),
52 .AddAttribute("TxPowerRefMimo",
53 "The MIMO reference TX power level (dBm).",
54 DoubleValue(25),
57 .AddTraceSource("Reset",
58 "Trace CCA Reset event",
60 "ns3::ObssPdAlgorithm::ResetTracedCallback");
61 return tid;
62}
63
64void
66{
67 NS_LOG_FUNCTION(this);
68 m_device = nullptr;
69}
70
71void
73{
74 NS_LOG_FUNCTION(this << device);
75 m_device = device;
76 auto phy = device->GetPhy();
77 if (phy->GetStandard() >= WIFI_STANDARD_80211be)
78 {
79 auto ehtPhy =
80 std::dynamic_pointer_cast<EhtPhy>(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_EHT));
81 NS_ASSERT(ehtPhy);
82 ehtPhy->SetObssPdAlgorithm(this);
83 }
84 auto hePhy =
85 std::dynamic_pointer_cast<HePhy>(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE));
86 NS_ASSERT(hePhy);
87 hePhy->SetObssPdAlgorithm(this);
88}
89
90void
92{
93 dBm_u txPowerMaxSiso{0};
94 dBm_u txPowerMaxMimo{0};
95 bool powerRestricted = false;
96 // Fetch my BSS color
97 Ptr<HeConfiguration> heConfiguration = m_device->GetHeConfiguration();
98 NS_ASSERT(heConfiguration);
99 uint8_t bssColor = heConfiguration->m_bssColor;
100 NS_LOG_DEBUG("My BSS color " << (uint16_t)bssColor << " received frame "
101 << (uint16_t)params.bssColor);
102
103 Ptr<WifiPhy> phy = m_device->GetPhy();
105 {
106 txPowerMaxSiso = m_txPowerRefSiso - (m_obssPdLevel - m_obssPdLevelMin);
107 txPowerMaxMimo = m_txPowerRefMimo - (m_obssPdLevel - m_obssPdLevelMin);
108 powerRestricted = true;
109 }
110 m_resetEvent(bssColor, params.rssi, powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
111 phy->ResetCca(powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
112}
113
114void
116{
117 NS_LOG_FUNCTION(this << level);
118 m_obssPdLevel = level;
119}
120
121dBm_u
123{
124 return m_obssPdLevel;
125}
126
127} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Object()
Constructor.
Definition object.cc:96
OBSS PD algorithm interface.
void DoDispose() override
Destructor implementation.
void ResetPhy(HeSigAParameters params)
Reset PHY to IDLE.
void SetObssPdLevel(dBm_u level)
dBm_u m_obssPdLevel
Current OBSS PD level.
static TypeId GetTypeId()
Get the type ID.
dBm_u m_txPowerRefSiso
SISO reference TX power level.
dBm_u m_obssPdLevelMin
Minimum OBSS PD level.
Ptr< WifiNetDevice > m_device
Pointer to the WifiNetDevice.
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.
dBm_u m_obssPdLevelMax
Maximum OBSS PD level.
dBm_u m_txPowerRefMimo
MIMO reference TX power level.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
a unique identifier for an interface.
Definition type-id.h:49
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition double.h:32
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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
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 dBm_u
dBm weak type
Definition wifi-units.h:27
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition he-phy.h:44