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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
10
11#include "he-configuration.h"
12
13#include "ns3/config.h"
14#include "ns3/double.h"
15#include "ns3/eht-phy.h"
16#include "ns3/log.h"
17#include "ns3/node.h"
18#include "ns3/sta-wifi-mac.h"
19#include "ns3/wifi-net-device.h"
20#include "ns3/wifi-phy.h"
21#include "ns3/wifi-utils.h"
22
23namespace ns3
24{
25
26NS_LOG_COMPONENT_DEFINE("ConstantObssPdAlgorithm");
27NS_OBJECT_ENSURE_REGISTERED(ConstantObssPdAlgorithm);
28
34
37{
38 static ns3::TypeId tid = ns3::TypeId("ns3::ConstantObssPdAlgorithm")
40 .SetGroupName("Wifi")
41 .AddConstructor<ConstantObssPdAlgorithm>();
42 return tid;
43}
44
45void
47{
48 auto phy = device->GetPhy();
49 if (phy->GetStandard() >= WIFI_STANDARD_80211be)
50 {
51 auto ehtPhy = DynamicCast<EhtPhy>(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_EHT));
52 NS_ASSERT(ehtPhy);
53 ehtPhy->SetEndOfHeSigACallback(MakeCallback(&ConstantObssPdAlgorithm::ReceiveHeSigA, this));
54 }
55 auto hePhy = DynamicCast<HePhy>(phy->GetPhyEntity(WIFI_MOD_CLASS_HE));
56 NS_ASSERT(hePhy);
57 hePhy->SetEndOfHeSigACallback(MakeCallback(&ConstantObssPdAlgorithm::ReceiveHeSigA, this));
59}
60
61void
63{
64 NS_LOG_FUNCTION(this << +params.bssColor << params.rssi);
65
66 Ptr<StaWifiMac> mac = m_device->GetMac()->GetObject<StaWifiMac>();
67 if (mac && !mac->IsAssociated())
68 {
69 NS_LOG_DEBUG("This is not an associated STA: skip OBSS PD algorithm");
70 return;
71 }
72
73 Ptr<HeConfiguration> heConfiguration = m_device->GetHeConfiguration();
74 NS_ASSERT(heConfiguration);
75 uint8_t bssColor = heConfiguration->GetBssColor();
76
77 if (bssColor == 0)
78 {
79 NS_LOG_DEBUG("BSS color is 0");
80 return;
81 }
82 if (params.bssColor == 0)
83 {
84 NS_LOG_DEBUG("Received BSS color is 0");
85 return;
86 }
87 // TODO: SRP_AND_NON-SRG_OBSS-PD_PROHIBITED=1 => OBSS_PD SR is not allowed
88
89 bool isObss = (bssColor != params.bssColor);
90 if (isObss)
91 {
92 const auto obssPdLevel = GetObssPdLevel();
93 if (params.rssi < obssPdLevel)
94 {
95 NS_LOG_DEBUG("Frame is OBSS and RSSI "
96 << params.rssi << " dBm is below OBSS-PD level of " << obssPdLevel
97 << " dBm; reset PHY to IDLE");
98 ResetPhy(params);
99 }
100 else
101 {
102 NS_LOG_DEBUG("Frame is OBSS and RSSI is above OBSS-PD level");
103 }
104 }
105}
106
107} // 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.
Smart pointer class similar to boost::intrusive_ptr.
The Wifi MAC high model for a non-AP STA in a BSS.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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:35
@ 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.
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:684
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition he-phy.h:44