A Discrete-Event Network Simulator
API
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/double.h"
23 #include "obss-pd-algorithm.h"
24 #include "ns3/wifi-net-device.h"
25 #include "ns3/wifi-phy.h"
26 #include "he-phy.h"
27 #include "ns3/wifi-utils.h"
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("ObssPdAlgorithm");
32 NS_OBJECT_ENSURE_REGISTERED (ObssPdAlgorithm);
33 
34 TypeId
36 {
37  static ns3::TypeId tid = ns3::TypeId ("ns3::ObssPdAlgorithm")
38  .SetParent<Object> ()
39  .SetGroupName ("Wifi")
40  .AddAttribute ("ObssPdLevel",
41  "The current OBSS PD level (dBm).",
42  DoubleValue (-82.0),
44  MakeDoubleChecker<double> (-101, -62))
45  .AddAttribute ("ObssPdLevelMin",
46  "Minimum value (dBm) of OBSS PD level.",
47  DoubleValue (-82.0),
49  MakeDoubleChecker<double> (-101, -62))
50  .AddAttribute ("ObssPdLevelMax",
51  "Maximum value (dBm) of OBSS PD level.",
52  DoubleValue (-62.0),
54  MakeDoubleChecker<double> (-101, -62))
55  .AddAttribute ("TxPowerRefSiso",
56  "The SISO reference TX power level (dBm).",
57  DoubleValue (21),
59  MakeDoubleChecker<double> ())
60  .AddAttribute ("TxPowerRefMimo",
61  "The MIMO reference TX power level (dBm).",
62  DoubleValue (25),
64  MakeDoubleChecker<double> ())
65  .AddTraceSource ("Reset", "Trace CCA Reset event",
67  "ns3::ObssPdAlgorithm::ResetTracedCallback")
68  ;
69  return tid;
70 }
71 
72 void
74 {
75  NS_LOG_FUNCTION (this);
76  m_device = 0;
77 }
78 
79 void
81 {
82  NS_LOG_FUNCTION (this << device);
83  m_device = device;
84 }
85 
86 void
88 {
89  double txPowerMaxSiso = 0;
90  double txPowerMaxMimo = 0;
91  bool powerRestricted = false;
92  // Fetch my BSS color
93  Ptr<HeConfiguration> heConfiguration = m_device->GetHeConfiguration ();
94  NS_ASSERT (heConfiguration);
95  uint8_t bssColor = heConfiguration->GetBssColor ();
96  NS_LOG_DEBUG ("My BSS color " << (uint16_t) bssColor << " received frame " << (uint16_t) params.bssColor);
97 
100  {
101  txPowerMaxSiso = m_txPowerRefSiso - (m_obssPdLevel - m_obssPdLevelMin);
102  txPowerMaxMimo = m_txPowerRefMimo - (m_obssPdLevel - m_obssPdLevelMin);
103  powerRestricted = true;
104  }
105  m_resetEvent (bssColor, WToDbm (params.rssiW), powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
106  phy->ResetCca (powerRestricted, txPowerMaxSiso, txPowerMaxMimo);
107 }
108 
109 } //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::ObssPdAlgorithm::m_txPowerRefMimo
double m_txPowerRefMimo
MIMO reference TX power level (dBm)
Definition: obss-pd-algorithm.h:97
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::WToDbm
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:47
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::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
ns3::ObssPdAlgorithm::DoDispose
void DoDispose(void) override
Destructor implementation.
Definition: obss-pd-algorithm.cc:73
ns3::ObssPdAlgorithm::m_obssPdLevel
double m_obssPdLevel
Current OBSS PD level (dBm)
Definition: obss-pd-algorithm.h:90
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Definition: trace-source-accessor.h:202
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::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::ObssPdAlgorithm::m_txPowerRefSiso
double m_txPowerRefSiso
SISO reference TX power level (dBm)
Definition: obss-pd-algorithm.h:96
ns3::ObssPdAlgorithm::ConnectWifiNetDevice
virtual void ConnectWifiNetDevice(const Ptr< WifiNetDevice > device)
Connect the WifiNetDevice and setup eventual callbacks.
Definition: obss-pd-algorithm.cc:80
ns3::MakeDoubleAccessor
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:42
ns3::ObssPdAlgorithm::m_resetEvent
TracedCallback< uint8_t, double, bool, double, double > m_resetEvent
TracedCallback signature for PHY reset events.
Definition: obss-pd-algorithm.h:102
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
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::ObssPdAlgorithm::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: obss-pd-algorithm.cc:35
ns3::ObssPdAlgorithm::m_obssPdLevelMax
double m_obssPdLevelMax
Maximum OBSS PD level (dBm)
Definition: obss-pd-algorithm.h:95
ns3::HeSigAParameters
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition: he-phy.h:47
ns3::ObssPdAlgorithm::m_obssPdLevelMin
double m_obssPdLevelMin
Minimum OBSS PD level (dBm)
Definition: obss-pd-algorithm.h:94
ns3::ObssPdAlgorithm::ResetPhy
void ResetPhy(HeSigAParameters params)
Reset PHY to IDLE.
Definition: obss-pd-algorithm.cc:87
obss-pd-algorithm.h
third.phy
phy
Definition: third.py:93