A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
constant-obss-pd-algorithm.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2018 University of Washington
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
*/
20
21
#include "ns3/log.h"
22
#include "ns3/node.h"
23
#include "ns3/config.h"
24
#include "ns3/double.h"
25
#include "
constant-obss-pd-algorithm.h
"
26
#include "ns3/sta-wifi-mac.h"
27
#include "ns3/wifi-utils.h"
28
#include "ns3/wifi-phy.h"
29
#include "
he-phy.h
"
30
#include "ns3/wifi-net-device.h"
31
#include "
he-configuration.h
"
32
33
namespace
ns3
{
34
35
NS_LOG_COMPONENT_DEFINE
(
"ConstantObssPdAlgorithm"
);
36
NS_OBJECT_ENSURE_REGISTERED
(ConstantObssPdAlgorithm);
37
38
ConstantObssPdAlgorithm::ConstantObssPdAlgorithm
()
39
:
ObssPdAlgorithm
()
40
{
41
NS_LOG_FUNCTION
(
this
);
42
}
43
44
TypeId
45
ConstantObssPdAlgorithm::GetTypeId
(
void
)
46
{
47
static
ns3::TypeId
tid =
ns3::TypeId
(
"ns3::ConstantObssPdAlgorithm"
)
48
.
SetParent
<
ObssPdAlgorithm
> ()
49
.SetGroupName (
"Wifi"
)
50
.AddConstructor<
ConstantObssPdAlgorithm
> ()
51
;
52
return
tid;
53
}
54
55
void
56
ConstantObssPdAlgorithm::ConnectWifiNetDevice
(
const
Ptr<WifiNetDevice>
device)
57
{
58
Ptr<WifiPhy>
phy
= device->
GetPhy
();
59
auto
hePhy = DynamicCast<HePhy> (
phy
->GetPhyEntity (
WIFI_MOD_CLASS_HE
));
60
NS_ASSERT
(hePhy);
61
hePhy->SetEndOfHeSigACallback (
MakeCallback
(&
ConstantObssPdAlgorithm::ReceiveHeSigA
,
this
));
62
ObssPdAlgorithm::ConnectWifiNetDevice
(device);
63
}
64
65
void
66
ConstantObssPdAlgorithm::ReceiveHeSigA
(
HeSigAParameters
params)
67
{
68
NS_LOG_FUNCTION
(
this
<< +params.
bssColor
<<
WToDbm
(params.
rssiW
));
69
70
Ptr<StaWifiMac>
mac
=
m_device
->
GetMac
()->GetObject<
StaWifiMac
>();
71
if
(
mac
&& !
mac
->IsAssociated ())
72
{
73
NS_LOG_DEBUG
(
"This is not an associated STA: skip OBSS PD algorithm"
);
74
return
;
75
}
76
77
Ptr<HeConfiguration>
heConfiguration =
m_device
->
GetHeConfiguration
();
78
NS_ASSERT
(heConfiguration);
79
uint8_t bssColor = heConfiguration->GetBssColor ();
80
81
if
(bssColor == 0)
82
{
83
NS_LOG_DEBUG
(
"BSS color is 0"
);
84
return
;
85
}
86
if
(params.
bssColor
== 0)
87
{
88
NS_LOG_DEBUG
(
"Received BSS color is 0"
);
89
return
;
90
}
91
//TODO: SRP_AND_NON-SRG_OBSS-PD_PROHIBITED=1 => OBSS_PD SR is not allowed
92
93
bool
isObss = (bssColor != params.
bssColor
);
94
if
(isObss)
95
{
96
if
(
WToDbm
(params.
rssiW
) <
m_obssPdLevel
)
97
{
98
NS_LOG_DEBUG
(
"Frame is OBSS and RSSI "
<<
WToDbm
(params.
rssiW
) <<
" is below OBSS-PD level of "
<<
m_obssPdLevel
<<
"; reset PHY to IDLE"
);
99
ResetPhy
(params);
100
}
101
else
102
{
103
NS_LOG_DEBUG
(
"Frame is OBSS and RSSI is above OBSS-PD level"
);
104
}
105
}
106
}
107
108
}
//namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:67
ns3::HeSigAParameters::bssColor
uint8_t bssColor
BSS color.
Definition:
he-phy.h:49
ns3::WifiNetDevice::GetPhy
Ptr< WifiPhy > GetPhy(void) const
Definition:
wifi-net-device.cc:207
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WIFI_MOD_CLASS_HE
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
Definition:
wifi-phy-common.h:132
ns3::WToDbm
double WToDbm(double w)
Convert from Watts to dBm.
Definition:
wifi-utils.cc:43
third.mac
mac
Definition:
third.py:99
he-phy.h
Declaration of ns3::HePhy class and ns3::HeSigAParameters struct.
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
ns3::ObssPdAlgorithm::m_obssPdLevel
double m_obssPdLevel
Current OBSS PD level (dBm)
Definition:
obss-pd-algorithm.h:90
ns3::ObssPdAlgorithm::m_device
Ptr< WifiNetDevice > m_device
Pointer to the WifiNetDevice.
Definition:
obss-pd-algorithm.h:89
ns3::WifiNetDevice::GetHeConfiguration
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition:
wifi-net-device.cc:480
ns3::Ptr< WifiNetDevice >
ns3::ConstantObssPdAlgorithm::ConnectWifiNetDevice
void ConnectWifiNetDevice(const Ptr< WifiNetDevice > device) override
Connect the WifiNetDevice and setup eventual callbacks.
Definition:
constant-obss-pd-algorithm.cc:56
ns3::ConstantObssPdAlgorithm::ReceiveHeSigA
void ReceiveHeSigA(HeSigAParameters params) override
Definition:
constant-obss-pd-algorithm.cc:66
ns3::ConstantObssPdAlgorithm::ConstantObssPdAlgorithm
ConstantObssPdAlgorithm()
Definition:
constant-obss-pd-algorithm.cc:38
ns3::MakeCallback
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition:
callback.h:1642
ns3::ObssPdAlgorithm::ConnectWifiNetDevice
virtual void ConnectWifiNetDevice(const Ptr< WifiNetDevice > device)
Connect the WifiNetDevice and setup eventual callbacks.
Definition:
obss-pd-algorithm.cc:80
ns3::ObssPdAlgorithm
OBSS PD algorithm interface.
Definition:
obss-pd-algorithm.h:46
constant-obss-pd-algorithm.h
ns3::HeSigAParameters::rssiW
double rssiW
RSSI in W.
Definition:
he-phy.h:48
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition:
log.h:273
ns3::ConstantObssPdAlgorithm::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
constant-obss-pd-algorithm.cc:45
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:244
ns3::ConstantObssPdAlgorithm
Constant OBSS PD algorithm.
Definition:
constant-obss-pd-algorithm.h:43
ns3::StaWifiMac
The Wifi MAC high model for a non-AP STA in a BSS.
Definition:
sta-wifi-mac.h:107
he-configuration.h
ns3::HeSigAParameters
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition:
he-phy.h:47
ns3::ObssPdAlgorithm::ResetPhy
void ResetPhy(HeSigAParameters params)
Reset PHY to IDLE.
Definition:
obss-pd-algorithm.cc:87
third.phy
phy
Definition:
third.py:93
ns3::WifiNetDevice::GetMac
Ptr< WifiMac > GetMac(void) const
Definition:
wifi-net-device.cc:201
src
wifi
model
he
constant-obss-pd-algorithm.cc
Generated on Fri Oct 1 2021 17:03:44 for ns-3 by
1.8.20