A Discrete-Event Network Simulator
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
10
11#include "wifi-utils.h"
12
13#include "ns3/double.h"
14#include "ns3/log.h"
15
16namespace ns3
17{
18
19NS_LOG_COMPONENT_DEFINE("ThresholdPreambleDetectionModel");
20
21NS_OBJECT_ENSURE_REGISTERED(ThresholdPreambleDetectionModel);
22
23TypeId
25{
26 static TypeId tid =
27 TypeId("ns3::ThresholdPreambleDetectionModel")
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),
37 .AddAttribute("MinimumRssi",
38 "Preamble is dropped if the RSSI is below this value (expressed in dBm).",
39 DoubleValue(-82),
42 return tid;
43}
44
49
54
55bool
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
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
the interface for Wifi's preamble detection models
A threshold-based model for detecting PHY preamble.
dB_u m_threshold
SNR threshold used to decide whether a preamble is successfully received.
bool IsPreambleDetected(dBm_u rssi, double snr, MHz_u channelWidth) const override
A pure virtual method that must be implemented in the subclass.
dBm_u m_rssiMin
Minimum RSSI that shall be received to start the decision.
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_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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
dB_u RatioToDb(double ratio)
Convert from ratio to dB.
Definition wifi-utils.cc:44
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32