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
constant-spectrum-propagation-loss.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Manuel Requena <manuel.requena@cttc.es>
7
*/
8
9
#include "
constant-spectrum-propagation-loss.h
"
10
11
#include "
spectrum-signal-parameters.h
"
12
13
#include "ns3/double.h"
14
#include "ns3/log.h"
15
16
#include <cmath>
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"ConstantSpectrumPropagationLossModel"
);
22
23
NS_OBJECT_ENSURE_REGISTERED
(ConstantSpectrumPropagationLossModel);
24
25
ConstantSpectrumPropagationLossModel::ConstantSpectrumPropagationLossModel
()
26
{
27
NS_LOG_FUNCTION
(
this
);
28
}
29
30
ConstantSpectrumPropagationLossModel::~ConstantSpectrumPropagationLossModel
()
31
{
32
NS_LOG_FUNCTION
(
this
);
33
}
34
35
TypeId
36
ConstantSpectrumPropagationLossModel::GetTypeId
()
37
{
38
static
TypeId
tid =
39
TypeId
(
"ns3::ConstantSpectrumPropagationLossModel"
)
40
.
SetParent
<
SpectrumPropagationLossModel
>()
41
.SetGroupName(
"Spectrum"
)
42
.AddConstructor<
ConstantSpectrumPropagationLossModel
>()
43
.AddAttribute(
"Loss"
,
44
"Path loss (dB) between transmitter and receiver"
,
45
DoubleValue
(1.0),
46
MakeDoubleAccessor
(&
ConstantSpectrumPropagationLossModel::SetLossDb
,
47
&
ConstantSpectrumPropagationLossModel::GetLossDb
),
48
MakeDoubleChecker<double>
());
49
return
tid;
50
}
51
52
void
53
ConstantSpectrumPropagationLossModel::SetLossDb
(
double
lossDb)
54
{
55
NS_LOG_FUNCTION
(
this
);
56
m_lossDb
= lossDb;
57
m_lossLinear
= std::pow(10,
m_lossDb
/ 10);
58
}
59
60
double
61
ConstantSpectrumPropagationLossModel::GetLossDb
()
const
62
{
63
NS_LOG_FUNCTION
(
this
);
64
return
m_lossDb
;
65
}
66
67
Ptr<SpectrumValue>
68
ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
(
69
Ptr<const SpectrumSignalParameters>
params,
70
Ptr<const MobilityModel>
a,
71
Ptr<const MobilityModel>
b)
const
72
{
73
NS_LOG_FUNCTION
(
this
);
74
75
Ptr<SpectrumValue>
rxPsd =
Copy<SpectrumValue>
(params->psd);
76
auto
vit = rxPsd->ValuesBegin();
77
auto
fit = rxPsd->ConstBandsBegin();
78
79
while
(vit != rxPsd->ValuesEnd())
80
{
81
NS_ASSERT
(fit != rxPsd->ConstBandsEnd());
82
NS_LOG_LOGIC
(
"Ptx = "
<< *vit);
83
*vit /=
m_lossLinear
;
// Prx = Ptx / loss
84
NS_LOG_LOGIC
(
"Prx = "
<< *vit);
85
++vit;
86
++fit;
87
}
88
return
rxPsd;
89
}
90
91
int64_t
92
ConstantSpectrumPropagationLossModel::DoAssignStreams
(int64_t stream)
93
{
94
return
0;
95
}
96
97
}
// namespace ns3
ns3::ConstantSpectrumPropagationLossModel
A Constant (fixed) propagation loss.
Definition
constant-spectrum-propagation-loss.h:23
ns3::ConstantSpectrumPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
constant-spectrum-propagation-loss.cc:36
ns3::ConstantSpectrumPropagationLossModel::SetLossDb
void SetLossDb(double lossDb)
Set the propagation loss.
Definition
constant-spectrum-propagation-loss.cc:53
ns3::ConstantSpectrumPropagationLossModel::GetLossDb
double GetLossDb() const
Get the propagation loss.
Definition
constant-spectrum-propagation-loss.cc:61
ns3::ConstantSpectrumPropagationLossModel::~ConstantSpectrumPropagationLossModel
~ConstantSpectrumPropagationLossModel() override
Definition
constant-spectrum-propagation-loss.cc:30
ns3::ConstantSpectrumPropagationLossModel::m_lossDb
double m_lossDb
Propagation loss [dB].
Definition
constant-spectrum-propagation-loss.h:50
ns3::ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > params, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Definition
constant-spectrum-propagation-loss.cc:68
ns3::ConstantSpectrumPropagationLossModel::DoAssignStreams
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Definition
constant-spectrum-propagation-loss.cc:92
ns3::ConstantSpectrumPropagationLossModel::ConstantSpectrumPropagationLossModel
ConstantSpectrumPropagationLossModel()
Definition
constant-spectrum-propagation-loss.cc:25
ns3::ConstantSpectrumPropagationLossModel::m_lossLinear
double m_lossLinear
Propagation loss (linear)
Definition
constant-spectrum-propagation-loss.h:51
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::SpectrumPropagationLossModel
spectrum-aware propagation loss model
Definition
spectrum-propagation-loss-model.h:33
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
constant-spectrum-propagation-loss.h
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_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition
log.h:271
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::MakeDoubleChecker
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition
double.h:82
ns3::Copy
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition
ptr.h:604
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition
double.h:32
spectrum-signal-parameters.h
src
spectrum
model
constant-spectrum-propagation-loss.cc
Generated on Fri Nov 8 2024 13:59:06 for ns-3 by
1.11.0