A Discrete-Event Network Simulator
lorawan @ (+)
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
j
l
m
n
o
p
q
r
s
t
w
Enumerator
a
b
c
d
e
f
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Related Symbols
:
a
b
c
d
e
g
h
i
j
l
m
n
o
p
q
r
s
t
u
w
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
e
l
v
Macros
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
wifi-bandwidth-filter.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022 Universita' degli Studi di Napoli "Federico II"
3
* Copyright (c) 2022 University of Washington (port logic to WifiBandwidthFilter)
4
*
5
* SPDX-License-Identifier: GPL-2.0-only
6
*/
7
8
#include "
wifi-bandwidth-filter.h
"
9
10
#include "
spectrum-wifi-phy.h
"
11
#include "
wifi-psdu.h
"
12
#include "
wifi-spectrum-phy-interface.h
"
13
#include "
wifi-spectrum-signal-parameters.h
"
14
15
#include "ns3/boolean.h"
16
#include "ns3/spectrum-transmit-filter.h"
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"WifiBandwidthFilter"
);
22
23
NS_OBJECT_ENSURE_REGISTERED
(WifiBandwidthFilter);
24
25
WifiBandwidthFilter::WifiBandwidthFilter
()
26
{
27
NS_LOG_FUNCTION
(
this
);
28
}
25
WifiBandwidthFilter::WifiBandwidthFilter
() {
…
}
29
30
TypeId
31
WifiBandwidthFilter::GetTypeId
()
32
{
33
static
TypeId
tid =
TypeId
(
"ns3::WifiBandwidthFilter"
)
34
.
SetParent
<
SpectrumTransmitFilter
>()
35
.SetGroupName(
"Wifi"
)
36
.AddConstructor<
WifiBandwidthFilter
>();
37
return
tid;
38
}
31
WifiBandwidthFilter::GetTypeId
() {
…
}
39
40
bool
41
WifiBandwidthFilter::DoFilter
(
Ptr<const SpectrumSignalParameters>
params,
42
Ptr<const SpectrumPhy>
receiverPhy)
43
{
44
NS_LOG_FUNCTION
(
this
<< params);
45
46
auto
wifiRxParams =
DynamicCast<const WifiSpectrumSignalParameters>
(params);
47
if
(!wifiRxParams)
48
{
49
NS_LOG_DEBUG
(
"Received a non Wi-Fi signal: do not filter"
);
50
return
false
;
51
}
52
53
auto
interface
=
DynamicCast
<const
WifiSpectrumPhyInterface
>(receiverPhy);
54
if
(!interface)
55
{
56
NS_LOG_DEBUG
(
"Sending a Wi-Fi signal to a non Wi-Fi device; do not filter"
);
57
return
false
;
58
}
59
60
auto
wifiPhy = interface->GetSpectrumWifiPhy();
61
NS_ASSERT_MSG
(wifiPhy,
62
"WifiPhy should be valid if WifiSpectrumSignalParameters was found and sending "
63
"to a WifiSpectrumPhyInterface"
);
64
65
BooleanValue
trackSignalsInactiveInterfaces;
66
wifiPhy->GetAttribute(
"TrackSignalsFromInactiveInterfaces"
, trackSignalsInactiveInterfaces);
67
68
NS_ASSERT_MSG
(trackSignalsInactiveInterfaces.
Get
() ||
69
(interface == wifiPhy->GetCurrentInterface()),
70
"DoFilter should not be called for an inactive interface if "
71
"SpectrumWifiPhy::TrackSignalsFromInactiveInterfaces attribute is not enabled"
);
72
73
NS_ASSERT
((interface != wifiPhy->GetCurrentInterface()) ||
74
(wifiPhy->GetOperatingChannel().GetTotalWidth() == interface->GetChannelWidth()));
75
NS_ASSERT
(
76
(interface != wifiPhy->GetCurrentInterface()) ||
77
(wifiPhy->GetOperatingChannel().GetFrequencies() == interface->GetCenterFrequencies()));
78
79
// The signal power is spread over a frequency interval that includes a guard
80
// band on the left and a guard band on the right of the nominal TX band
81
const
auto
rxCenterFreqs = wifiRxParams->ppdu->GetTxCenterFreqs();
82
// all segments have the same width
83
const
auto
rxWidth =
84
(wifiRxParams->ppdu->GetTxVector().GetChannelWidth() / rxCenterFreqs.size());
85
const
auto
guardBandwidth = wifiPhy->GetGuardBandwidth(rxWidth);
86
bool
filter =
true
;
87
for
(
auto
rxCenterFreq : rxCenterFreqs)
88
{
89
const
auto
rxMinFreq = rxCenterFreq - rxWidth / 2 - guardBandwidth;
90
const
auto
rxMaxFreq = rxCenterFreq + rxWidth / 2 + guardBandwidth;
91
const
auto
operatingFrequencies = interface->GetCenterFrequencies();
92
const
auto
operatingChannelWidth =
93
interface->GetChannelWidth() / operatingFrequencies.size();
94
for
(
auto
operatingFrequency : operatingFrequencies)
95
{
96
const
auto
channelMinFreq = operatingFrequency - operatingChannelWidth / 2;
97
const
auto
channelMaxFreq = operatingFrequency + operatingChannelWidth / 2;
98
/**
99
* The PPDU can be ignored if the two bands do not overlap.
100
*
101
* First non-overlapping case:
102
*
103
* ┌─────────┬─────────┬─────────┐
104
* PPDU │ Guard │ Nominal │ Guard │
105
* │ Band │ Band │ Band │
106
* └─────────┴─────────┴─────────┘
107
* rxMinFreq rxMaxFreq
108
*
109
* channelMinFreq channelMaxFreq
110
* ┌──────────────────────────────┐
111
* │ Operating │
112
* │ Channel │
113
* └──────────────────────────────┘
114
*
115
* Second non-overlapping case:
116
*
117
* ┌─────────┬─────────┬─────────┐
118
* PPDU │ Guard │ Nominal │ Guard │
119
* │ Band │ Band │ Band │
120
* └─────────┴─────────┴─────────┘
121
* rxMinFreq rxMaxFreq
122
*
123
* channelMinFreq channelMaxFreq
124
* ┌──────────────────────────────┐
125
* │ Operating │
126
* │ Channel │
127
* └──────────────────────────────┘
128
*/
129
filter &= ((rxMinFreq >= channelMaxFreq) || (rxMaxFreq <= channelMinFreq));
130
}
131
}
132
NS_LOG_DEBUG
(
"Returning "
<< filter);
133
return
filter;
134
}
41
WifiBandwidthFilter::DoFilter
(
Ptr<const SpectrumSignalParameters>
params, {
…
}
135
136
int64_t
137
WifiBandwidthFilter::DoAssignStreams
(int64_t stream)
138
{
139
return
0;
140
}
137
WifiBandwidthFilter::DoAssignStreams
(int64_t stream) {
…
}
141
142
}
// namespace ns3
ns3::BooleanValue
Definition
boolean.h:26
ns3::BooleanValue::Get
bool Get() const
Definition
boolean.cc:44
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::SpectrumTransmitFilter
spectrum-aware transmit filter object
Definition
spectrum-transmit-filter.h:29
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::WifiBandwidthFilter
Definition
wifi-bandwidth-filter.h:16
ns3::WifiBandwidthFilter::WifiBandwidthFilter
WifiBandwidthFilter()
Definition
wifi-bandwidth-filter.cc:25
ns3::WifiBandwidthFilter::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
wifi-bandwidth-filter.cc:31
ns3::WifiBandwidthFilter::DoAssignStreams
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Definition
wifi-bandwidth-filter.cc:137
ns3::WifiBandwidthFilter::DoFilter
bool DoFilter(Ptr< const SpectrumSignalParameters > params, Ptr< const SpectrumPhy > receiverPhy) override
Ignore the signal being received if it is a Wi-Fi PPDU whose TX band (including guard bands) does not...
Definition
wifi-bandwidth-filter.cc:41
ns3::WifiSpectrumPhyInterface
This class is an adaptor between class SpectrumWifiPhy (which inherits from WifiPhy) and class Spectr...
Definition
wifi-spectrum-phy-interface.h:36
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:55
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition
assert.h:75
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
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:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::DynamicCast
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition
ptr.h:580
spectrum-wifi-phy.h
wifi-bandwidth-filter.h
wifi-psdu.h
wifi-spectrum-phy-interface.h
wifi-spectrum-signal-parameters.h
src
wifi
model
wifi-bandwidth-filter.cc
Generated on Tue Apr 29 2025 20:45:54 for ns-3 by
1.11.0