A Discrete-Event Network Simulator
API
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#include "he-phy.h"
24
25#include "ns3/config.h"
26#include "ns3/double.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 Ptr<WifiPhy> phy = device->GetPhy();
60 auto hePhy = DynamicCast<HePhy>(phy->GetPhyEntity(WIFI_MOD_CLASS_HE));
61 NS_ASSERT(hePhy);
62 hePhy->SetEndOfHeSigACallback(MakeCallback(&ConstantObssPdAlgorithm::ReceiveHeSigA, this));
64}
65
66void
68{
69 NS_LOG_FUNCTION(this << +params.bssColor << WToDbm(params.rssiW));
70
71 Ptr<StaWifiMac> mac = m_device->GetMac()->GetObject<StaWifiMac>();
72 if (mac && !mac->IsAssociated())
73 {
74 NS_LOG_DEBUG("This is not an associated STA: skip OBSS PD algorithm");
75 return;
76 }
77
79 NS_ASSERT(heConfiguration);
80 uint8_t bssColor = heConfiguration->GetBssColor();
81
82 if (bssColor == 0)
83 {
84 NS_LOG_DEBUG("BSS color is 0");
85 return;
86 }
87 if (params.bssColor == 0)
88 {
89 NS_LOG_DEBUG("Received BSS color is 0");
90 return;
91 }
92 // TODO: SRP_AND_NON-SRG_OBSS-PD_PROHIBITED=1 => OBSS_PD SR is not allowed
93
94 bool isObss = (bssColor != params.bssColor);
95 if (isObss)
96 {
97 const double obssPdLevel = GetObssPdLevel();
98 if (WToDbm(params.rssiW) < obssPdLevel)
99 {
100 NS_LOG_DEBUG("Frame is OBSS and RSSI " << WToDbm(params.rssiW)
101 << " is below OBSS-PD level of " << obssPdLevel
102 << "; reset PHY to IDLE");
103 ResetPhy(params);
104 }
105 else
106 {
107 NS_LOG_DEBUG("Frame is OBSS and RSSI is above OBSS-PD level");
108 }
109 }
110}
111
112} // 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.
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
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:122
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< WifiMac > GetMac() const
Ptr< HeConfiguration > GetHeConfiguration() const
Ptr< WifiPhy > GetPhy() 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:45
@ 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
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:691
mac
Definition: third.py:85
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