A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
constant-spectrum-propagation-loss.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Manuel Requena <manuel.requena@cttc.es>
19
*/
20
21
#include <cmath>
22
23
#include "ns3/log.h"
24
25
#include "ns3/constant-spectrum-propagation-loss.h"
26
#include "ns3/double.h"
27
28
29
namespace
ns3
{
30
31
NS_LOG_COMPONENT_DEFINE
(
"ConstantSpectrumPropagationLossModel"
);
32
33
NS_OBJECT_ENSURE_REGISTERED
(ConstantSpectrumPropagationLossModel);
34
35
ConstantSpectrumPropagationLossModel::ConstantSpectrumPropagationLossModel
()
36
{
37
NS_LOG_FUNCTION
(
this
);
38
}
39
40
ConstantSpectrumPropagationLossModel::~ConstantSpectrumPropagationLossModel
()
41
{
42
NS_LOG_FUNCTION
(
this
);
43
}
44
45
TypeId
46
ConstantSpectrumPropagationLossModel::GetTypeId
(
void
)
47
{
48
static
TypeId
tid =
TypeId
(
"ns3::ConstantSpectrumPropagationLossModel"
)
49
.
SetParent
<
SpectrumPropagationLossModel
> ()
50
.AddConstructor<ConstantSpectrumPropagationLossModel> ()
51
.AddAttribute (
"Loss"
,
52
"Path loss (dB) between transmitter and receiver"
,
53
DoubleValue
(1.0),
54
MakeDoubleAccessor
(&
ConstantSpectrumPropagationLossModel::SetLossDb
,
55
&
ConstantSpectrumPropagationLossModel::GetLossDb
),
56
MakeDoubleChecker<double> ())
57
;
58
return
tid;
59
}
60
61
62
void
63
ConstantSpectrumPropagationLossModel::SetLossDb
(
double
lossDb)
64
{
65
NS_LOG_FUNCTION
(
this
);
66
m_lossDb
= lossDb;
67
m_lossLinear
= std::pow (10,
m_lossDb
/ 10);
68
}
69
70
71
double
72
ConstantSpectrumPropagationLossModel::GetLossDb
()
const
73
{
74
NS_LOG_FUNCTION
(
this
);
75
return
m_lossDb
;
76
}
77
78
79
Ptr<SpectrumValue>
80
ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
(
Ptr<const SpectrumValue>
txPsd,
81
Ptr<const MobilityModel>
a,
82
Ptr<const MobilityModel>
b)
const
83
{
84
NS_LOG_FUNCTION
(
this
);
85
86
Ptr<SpectrumValue>
rxPsd = Copy<SpectrumValue> (txPsd);
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
103
}
// namespace ns3
ns3::ConstantSpectrumPropagationLossModel::ConstantSpectrumPropagationLossModel
ConstantSpectrumPropagationLossModel()
Definition:
constant-spectrum-propagation-loss.cc:35
ns3::Ptr< SpectrumValue >
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:207
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:44
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:61
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
ns3::ConstantSpectrumPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Definition:
constant-spectrum-propagation-loss.cc:46
ns3::SpectrumValue::ValuesEnd
Values::iterator ValuesEnd()
Definition:
spectrum-value.cc:88
ns3::ConstantSpectrumPropagationLossModel::m_lossDb
double m_lossDb
Definition:
constant-spectrum-propagation-loss.h:45
ns3::ConstantSpectrumPropagationLossModel::GetLossDb
double GetLossDb() const
Definition:
constant-spectrum-propagation-loss.cc:72
ns3::ConstantSpectrumPropagationLossModel::m_lossLinear
double m_lossLinear
Definition:
constant-spectrum-propagation-loss.h:46
ns3::SpectrumValue::ConstBandsEnd
Bands::const_iterator ConstBandsEnd() const
Definition:
spectrum-value.cc:100
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition:
log.h:252
ns3::SpectrumValue::ConstBandsBegin
Bands::const_iterator ConstBandsBegin() const
Definition:
spectrum-value.cc:94
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ConstantSpectrumPropagationLossModel::SetLossDb
void SetLossDb(double lossDb)
Definition:
constant-spectrum-propagation-loss.cc:63
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition:
double.h:42
ns3::SpectrumValue::ValuesBegin
Values::iterator ValuesBegin()
Definition:
spectrum-value.cc:82
ns3::SpectrumPropagationLossModel
spectrum-aware propagation loss model
Definition:
spectrum-propagation-loss-model.h:44
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition:
double.h:41
ns3::ConstantSpectrumPropagationLossModel::~ConstantSpectrumPropagationLossModel
~ConstantSpectrumPropagationLossModel()
Definition:
constant-spectrum-propagation-loss.cc:40
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:51
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:631
ns3::ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
virtual Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumValue > txPsd, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
Definition:
constant-spectrum-propagation-loss.cc:80
src
spectrum
model
constant-spectrum-propagation-loss.cc
Generated on Thu Feb 5 2015 18:33:52 for ns-3 by
1.8.9.1