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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
NS_LOG_COMPONENT_DEFINE
(
"ConstantSpectrumPropagationLossModel"
);
30
31
namespace
ns3 {
32
33
34
NS_OBJECT_ENSURE_REGISTERED
(ConstantSpectrumPropagationLossModel)
35
;
36
37
ConstantSpectrumPropagationLossModel::ConstantSpectrumPropagationLossModel
()
38
{
39
NS_LOG_FUNCTION
(
this
);
40
}
41
42
ConstantSpectrumPropagationLossModel::~ConstantSpectrumPropagationLossModel
()
43
{
44
NS_LOG_FUNCTION
(
this
);
45
}
46
47
TypeId
48
ConstantSpectrumPropagationLossModel::GetTypeId
(
void
)
49
{
50
static
TypeId
tid =
TypeId
(
"ns3::ConstantSpectrumPropagationLossModel"
)
51
.
SetParent
<
SpectrumPropagationLossModel
> ()
52
.AddConstructor<ConstantSpectrumPropagationLossModel> ()
53
.AddAttribute (
"Loss"
,
54
"Path loss (dB) between transmitter and receiver"
,
55
DoubleValue
(1.0),
56
MakeDoubleAccessor (&
ConstantSpectrumPropagationLossModel::SetLossDb
,
57
&
ConstantSpectrumPropagationLossModel::GetLossDb
),
58
MakeDoubleChecker<double> ())
59
;
60
return
tid;
61
}
62
63
64
void
65
ConstantSpectrumPropagationLossModel::SetLossDb
(
double
lossDb)
66
{
67
NS_LOG_FUNCTION
(
this
);
68
m_lossDb
= lossDb;
69
m_lossLinear
= std::pow (10,
m_lossDb
/ 10);
70
}
71
72
73
double
74
ConstantSpectrumPropagationLossModel::GetLossDb
()
const
75
{
76
NS_LOG_FUNCTION
(
this
);
77
return
m_lossDb
;
78
}
79
80
81
Ptr<SpectrumValue>
82
ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
(
Ptr<const SpectrumValue>
txPsd,
83
Ptr<const MobilityModel>
a,
84
Ptr<const MobilityModel>
b)
const
85
{
86
NS_LOG_FUNCTION
(
this
);
87
88
Ptr<SpectrumValue>
rxPsd = Copy<SpectrumValue> (txPsd);
89
Values::iterator vit = rxPsd->ValuesBegin ();
90
Bands::const_iterator fit = rxPsd->ConstBandsBegin ();
91
92
while
(vit != rxPsd->ValuesEnd ())
93
{
94
NS_ASSERT
(fit != rxPsd->ConstBandsEnd ());
95
NS_LOG_LOGIC
(
"Ptx = "
<< *vit);
96
*vit /=
m_lossLinear
;
// Prx = Ptx / loss
97
NS_LOG_LOGIC
(
"Prx = "
<< *vit);
98
++vit;
99
++fit;
100
}
101
return
rxPsd;
102
}
103
104
105
}
// namespace ns3
ns3::ConstantSpectrumPropagationLossModel::ConstantSpectrumPropagationLossModel
ConstantSpectrumPropagationLossModel()
Definition:
constant-spectrum-propagation-loss.cc:37
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
ns3::ConstantSpectrumPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Definition:
constant-spectrum-propagation-loss.cc:48
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:74
ns3::ConstantSpectrumPropagationLossModel::m_lossLinear
double m_lossLinear
Definition:
constant-spectrum-propagation-loss.h:46
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Definition:
log.h:368
ns3::ConstantSpectrumPropagationLossModel::SetLossDb
void SetLossDb(double lossDb)
Definition:
constant-spectrum-propagation-loss.cc:65
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("ConstantSpectrumPropagationLossModel")
ns3::SpectrumPropagationLossModel
spectrum-aware propagation loss model
Definition:
spectrum-propagation-loss-model.h:44
ns3::DoubleValue
Hold a floating point type.
Definition:
double.h:41
ns3::ConstantSpectrumPropagationLossModel::~ConstantSpectrumPropagationLossModel
~ConstantSpectrumPropagationLossModel()
Definition:
constant-spectrum-propagation-loss.cc:42
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
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:82
src
spectrum
model
constant-spectrum-propagation-loss.cc
Generated on Sat Apr 19 2014 14:07:08 for ns-3 by
1.8.6