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");
22NS_OBJECT_ENSURE_REGISTERED(ObssPdAlgorithm);
23
24TypeId
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 = DynamicCast<EhtPhy>(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_EHT));
80 NS_ASSERT(ehtPhy);
81 ehtPhy->SetObssPdAlgorithm(this);
82 }
83 auto hePhy = DynamicCast<HePhy>(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE));
84 NS_ASSERT(hePhy);
85 hePhy->SetObssPdAlgorithm(this);
86}
87
88void
90{
91 dBm_u txPowerMaxSiso = 0;
92 dBm_u txPowerMaxMimo = 0;
93 bool powerRestricted = false;
94 // Fetch my BSS color
95 Ptr<HeConfiguration> heConfiguration = m_device->GetHeConfiguration();
96 NS_ASSERT(heConfiguration);
97 uint8_t bssColor = heConfiguration->GetBssColor();
98 NS_LOG_DEBUG("My BSS color " << (uint16_t)bssColor << " received frame "
99 << (uint16_t)params.bssColor);
100
101 Ptr<WifiPhy> phy = m_device->GetPhy();
103 {
104 txPowerMaxSiso = m_txPowerRefSiso - (m_obssPdLevel - m_obssPdLevelMin);
105 txPowerMaxMimo = m_txPowerRefMimo - (m_obssPdLevel - m_obssPdLevelMin);
106 powerRestricted = true;
107 }
108 m_resetEvent(bssColor, params.rssi, powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
109 phy->ResetCca(powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
110}
111
112void
114{
115 NS_LOG_FUNCTION(this << level);
116 m_obssPdLevel = level;
117}
118
119dBm_u
121{
122 return m_obssPdLevel;
123}
124
125} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
A base class which provides memory management and object aggregation.
Definition object.h:78
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.
a unique identifier for an interface.
Definition type-id.h:48
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
#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.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
double dBm_u
dBm weak type
Definition wifi-units.h:27
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition he-phy.h:44