A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
threshold-preamble-detection-model.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
9
#include "
threshold-preamble-detection-model.h
"
10
11
#include "
wifi-utils.h
"
12
13
#include "ns3/double.h"
14
#include "ns3/log.h"
15
16
namespace
ns3
17
{
18
19
NS_LOG_COMPONENT_DEFINE
(
"ThresholdPreambleDetectionModel"
);
20
21
NS_OBJECT_ENSURE_REGISTERED
(ThresholdPreambleDetectionModel);
22
23
TypeId
24
ThresholdPreambleDetectionModel::GetTypeId
()
25
{
26
static
TypeId
tid =
27
TypeId
(
"ns3::ThresholdPreambleDetectionModel"
)
28
.
SetParent
<
PreambleDetectionModel
>()
29
.SetGroupName(
"Wifi"
)
30
.AddConstructor<
ThresholdPreambleDetectionModel
>()
31
.AddAttribute(
"Threshold"
,
32
"Preamble is successfully detected if the SNR is at or above this value "
33
"(expressed in dB)."
,
34
DoubleValue
(4),
35
MakeDoubleAccessor
(&
ThresholdPreambleDetectionModel::m_threshold
),
36
MakeDoubleChecker<dB_u>
())
37
.AddAttribute(
"MinimumRssi"
,
38
"Preamble is dropped if the RSSI is below this value (expressed in dBm)."
,
39
DoubleValue
(-82),
40
MakeDoubleAccessor
(&
ThresholdPreambleDetectionModel::m_rssiMin
),
41
MakeDoubleChecker<dBm_u>
());
42
return
tid;
43
}
44
45
ThresholdPreambleDetectionModel::ThresholdPreambleDetectionModel
()
46
{
47
NS_LOG_FUNCTION
(
this
);
48
}
49
50
ThresholdPreambleDetectionModel::~ThresholdPreambleDetectionModel
()
51
{
52
NS_LOG_FUNCTION
(
this
);
53
}
54
55
bool
56
ThresholdPreambleDetectionModel::IsPreambleDetected
(
dBm_u
rssi,
57
double
snr,
58
MHz_u
channelWidth)
const
59
{
60
NS_LOG_FUNCTION
(
this
<< rssi <<
RatioToDb
(snr) << channelWidth);
61
if
(rssi >=
m_rssiMin
)
62
{
63
if
(
RatioToDb
(snr) >=
m_threshold
)
64
{
65
return
true
;
66
}
67
else
68
{
69
NS_LOG_DEBUG
(
"Received RSSI is above the target RSSI but SNR is too low"
);
70
return
false
;
71
}
72
}
73
else
74
{
75
NS_LOG_DEBUG
(
"Received RSSI is below the target RSSI"
);
76
return
false
;
77
}
78
}
79
80
}
// namespace ns3
double
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::PreambleDetectionModel
the interface for Wifi's preamble detection models
Definition
preamble-detection-model.h:25
ns3::ThresholdPreambleDetectionModel
A threshold-based model for detecting PHY preamble.
Definition
threshold-preamble-detection-model.h:26
ns3::ThresholdPreambleDetectionModel::ThresholdPreambleDetectionModel
ThresholdPreambleDetectionModel()
Definition
threshold-preamble-detection-model.cc:45
ns3::ThresholdPreambleDetectionModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
threshold-preamble-detection-model.cc:24
ns3::ThresholdPreambleDetectionModel::m_threshold
dB_u m_threshold
SNR threshold used to decide whether a preamble is successfully received.
Definition
threshold-preamble-detection-model.h:39
ns3::ThresholdPreambleDetectionModel::~ThresholdPreambleDetectionModel
~ThresholdPreambleDetectionModel() override
Definition
threshold-preamble-detection-model.cc:50
ns3::ThresholdPreambleDetectionModel::IsPreambleDetected
bool IsPreambleDetected(dBm_u rssi, double snr, MHz_u channelWidth) const override
A pure virtual method that must be implemented in the subclass.
Definition
threshold-preamble-detection-model.cc:56
ns3::ThresholdPreambleDetectionModel::m_rssiMin
dBm_u m_rssiMin
Minimum RSSI that shall be received to start the decision.
Definition
threshold-preamble-detection-model.h:40
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
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::RatioToDb
dB_u RatioToDb(double ratio)
Convert from ratio to dB.
Definition
wifi-utils.cc:44
ns3::MakeDoubleChecker
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition
double.h:82
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition
double.h:32
threshold-preamble-detection-model.h
wifi-utils.h
src
wifi
model
threshold-preamble-detection-model.cc
Generated on Fri Nov 8 2024 13:59:08 for ns-3 by
1.11.0