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
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
A base class which provides memory management and object aggregation.
Definition: object.h:88
void ResetPhy(HeSigAParameters params)
Reset PHY to IDLE.
static TypeId GetTypeId(void)
Get the type ID.
double m_obssPdLevelMax
Maximum OBSS PD level (dBm)
double m_txPowerRefSiso
SISO reference TX power level (dBm)
void DoDispose(void) override
Destructor implementation.
Ptr< WifiNetDevice > m_device
Pointer to the WifiNetDevice.
double m_obssPdLevel
Current OBSS PD level (dBm)
double m_obssPdLevelMin
Minimum OBSS PD level (dBm)
double m_txPowerRefMimo
MIMO reference TX power level (dBm)
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.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Ptr< WifiPhy > GetPhy(void) const
Ptr< HeConfiguration > GetHeConfiguration(void) 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:67
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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#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
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
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:43
phy
Definition: third.py:93
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition: he-phy.h:47
uint8_t bssColor
BSS color.
Definition: he-phy.h:49
double rssiW
RSSI in W.
Definition: he-phy.h:48