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
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Manuel Requena <manuel.requena@cttc.es>
18
*/
19
20
#include "ns3/constant-spectrum-propagation-loss.h"
21
22
#include "
spectrum-signal-parameters.h
"
23
24
#include "ns3/double.h"
25
#include "ns3/log.h"
26
27
#include <cmath>
28
29
namespace
ns3
30
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"ConstantSpectrumPropagationLossModel"
);
33
34
NS_OBJECT_ENSURE_REGISTERED
(ConstantSpectrumPropagationLossModel);
35
36
ConstantSpectrumPropagationLossModel::ConstantSpectrumPropagationLossModel
()
37
{
38
NS_LOG_FUNCTION
(
this
);
39
}
40
41
ConstantSpectrumPropagationLossModel::~ConstantSpectrumPropagationLossModel
()
42
{
43
NS_LOG_FUNCTION
(
this
);
44
}
45
46
TypeId
47
ConstantSpectrumPropagationLossModel::GetTypeId
()
48
{
49
static
TypeId
tid =
50
TypeId
(
"ns3::ConstantSpectrumPropagationLossModel"
)
51
.
SetParent
<
SpectrumPropagationLossModel
>()
52
.SetGroupName(
"Spectrum"
)
53
.AddConstructor<
ConstantSpectrumPropagationLossModel
>()
54
.AddAttribute(
"Loss"
,
55
"Path loss (dB) between transmitter and receiver"
,
56
DoubleValue
(1.0),
57
MakeDoubleAccessor
(&
ConstantSpectrumPropagationLossModel::SetLossDb
,
58
&
ConstantSpectrumPropagationLossModel::GetLossDb
),
59
MakeDoubleChecker<double>());
60
return
tid;
61
}
62
63
void
64
ConstantSpectrumPropagationLossModel::SetLossDb
(
double
lossDb)
65
{
66
NS_LOG_FUNCTION
(
this
);
67
m_lossDb
= lossDb;
68
m_lossLinear
= std::pow(10,
m_lossDb
/ 10);
69
}
70
71
double
72
ConstantSpectrumPropagationLossModel::GetLossDb
()
const
73
{
74
NS_LOG_FUNCTION
(
this
);
75
return
m_lossDb
;
76
}
77
78
Ptr<SpectrumValue>
79
ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
(
80
Ptr<const SpectrumSignalParameters>
params,
81
Ptr<const MobilityModel>
a,
82
Ptr<const MobilityModel>
b)
const
83
{
84
NS_LOG_FUNCTION
(
this
);
85
86
Ptr<SpectrumValue>
rxPsd = Copy<SpectrumValue>(params->psd);
87
Values::iterator vit = rxPsd->ValuesBegin();
88
Bands::const_iterator fit = rxPsd->ConstBandsBegin();
89
90
while
(vit != rxPsd->ValuesEnd())
91
{
92
NS_ASSERT
(fit != rxPsd->ConstBandsEnd());
93
NS_LOG_LOGIC
(
"Ptx = "
<< *vit);
94
*vit /=
m_lossLinear
;
// Prx = Ptx / loss
95
NS_LOG_LOGIC
(
"Prx = "
<< *vit);
96
++vit;
97
++fit;
98
}
99
return
rxPsd;
100
}
101
102
}
// namespace ns3
ns3::ConstantSpectrumPropagationLossModel
A Constant (fixed) propagation loss.
Definition:
constant-spectrum-propagation-loss.h:34
ns3::ConstantSpectrumPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
constant-spectrum-propagation-loss.cc:47
ns3::ConstantSpectrumPropagationLossModel::SetLossDb
void SetLossDb(double lossDb)
Set the propagation loss.
Definition:
constant-spectrum-propagation-loss.cc:64
ns3::ConstantSpectrumPropagationLossModel::GetLossDb
double GetLossDb() const
Get the propagation loss.
Definition:
constant-spectrum-propagation-loss.cc:72
ns3::ConstantSpectrumPropagationLossModel::~ConstantSpectrumPropagationLossModel
~ConstantSpectrumPropagationLossModel() override
Definition:
constant-spectrum-propagation-loss.cc:41
ns3::ConstantSpectrumPropagationLossModel::m_lossDb
double m_lossDb
Propagation loss [dB].
Definition:
constant-spectrum-propagation-loss.h:60
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:79
ns3::ConstantSpectrumPropagationLossModel::ConstantSpectrumPropagationLossModel
ConstantSpectrumPropagationLossModel()
Definition:
constant-spectrum-propagation-loss.cc:36
ns3::ConstantSpectrumPropagationLossModel::m_lossLinear
double m_lossLinear
Propagation loss (linear)
Definition:
constant-spectrum-propagation-loss.h:61
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:42
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:78
ns3::SpectrumPropagationLossModel
spectrum-aware propagation loss model
Definition:
spectrum-propagation-loss-model.h:43
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:936
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:66
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition:
double.h:43
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition:
log.h:282
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:238
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
spectrum-signal-parameters.h
src
spectrum
model
constant-spectrum-propagation-loss.cc
Generated on Sun Jul 2 2023 18:22:03 for ns-3 by
1.9.6