A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
constant-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
21
22#include "he-configuration.h"
23
24#include "ns3/config.h"
25#include "ns3/double.h"
26#include "ns3/eht-phy.h"
27#include "ns3/log.h"
28#include "ns3/node.h"
29#include "ns3/sta-wifi-mac.h"
30#include "ns3/wifi-net-device.h"
31#include "ns3/wifi-phy.h"
32#include "ns3/wifi-utils.h"
33
34namespace ns3
35{
36
37NS_LOG_COMPONENT_DEFINE("ConstantObssPdAlgorithm");
38NS_OBJECT_ENSURE_REGISTERED(ConstantObssPdAlgorithm);
39
42{
43 NS_LOG_FUNCTION(this);
44}
45
48{
49 static ns3::TypeId tid = ns3::TypeId("ns3::ConstantObssPdAlgorithm")
51 .SetGroupName("Wifi")
52 .AddConstructor<ConstantObssPdAlgorithm>();
53 return tid;
54}
55
56void
58{
59 auto phy = device->GetPhy();
60 if (phy->GetStandard() >= WIFI_STANDARD_80211be)
61 {
62 auto ehtPhy = DynamicCast<EhtPhy>(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_EHT));
63 NS_ASSERT(ehtPhy);
64 ehtPhy->SetEndOfHeSigACallback(MakeCallback(&ConstantObssPdAlgorithm::ReceiveHeSigA, this));
65 }
66 auto hePhy = DynamicCast<HePhy>(phy->GetPhyEntity(WIFI_MOD_CLASS_HE));
67 NS_ASSERT(hePhy);
68 hePhy->SetEndOfHeSigACallback(MakeCallback(&ConstantObssPdAlgorithm::ReceiveHeSigA, this));
70}
71
72void
74{
75 NS_LOG_FUNCTION(this << +params.bssColor << WToDbm(params.rssiW));
76
78 if (mac && !mac->IsAssociated())
79 {
80 NS_LOG_DEBUG("This is not an associated STA: skip OBSS PD algorithm");
81 return;
82 }
83
85 NS_ASSERT(heConfiguration);
86 uint8_t bssColor = heConfiguration->GetBssColor();
87
88 if (bssColor == 0)
89 {
90 NS_LOG_DEBUG("BSS color is 0");
91 return;
92 }
93 if (params.bssColor == 0)
94 {
95 NS_LOG_DEBUG("Received BSS color is 0");
96 return;
97 }
98 // TODO: SRP_AND_NON-SRG_OBSS-PD_PROHIBITED=1 => OBSS_PD SR is not allowed
99
100 bool isObss = (bssColor != params.bssColor);
101 if (isObss)
102 {
103 const double obssPdLevel = GetObssPdLevel();
104 if (WToDbm(params.rssiW) < obssPdLevel)
105 {
106 NS_LOG_DEBUG("Frame is OBSS and RSSI " << WToDbm(params.rssiW)
107 << " is below OBSS-PD level of " << obssPdLevel
108 << "; reset PHY to IDLE");
109 ResetPhy(params);
110 }
111 else
112 {
113 NS_LOG_DEBUG("Frame is OBSS and RSSI is above OBSS-PD level");
114 }
115 }
116}
117
118} // namespace ns3
void ConnectWifiNetDevice(const Ptr< WifiNetDevice > device) override
Connect the WifiNetDevice and setup eventual callbacks.
void ReceiveHeSigA(HeSigAParameters params) override
static TypeId GetTypeId()
Get the type ID.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:522
OBSS PD algorithm interface.
void ResetPhy(HeSigAParameters params)
Reset PHY to IDLE.
Ptr< WifiNetDevice > m_device
Pointer to the WifiNetDevice.
virtual void ConnectWifiNetDevice(const Ptr< WifiNetDevice > device)
Connect the WifiNetDevice and setup eventual callbacks.
double GetObssPdLevel() const
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:143
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Ptr< WifiMac > GetMac() const
Ptr< HeConfiguration > GetHeConfiguration() const
#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
@ 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
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:704
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition: he-phy.h:54