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 <math.h>
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
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
(
void
)
48
{
49
static
TypeId
tid =
TypeId
(
"ns3::ConstantSpectrumPropagationLossModel"
)
50
.
SetParent
<
SpectrumPropagationLossModel
> ()
51
.AddConstructor<ConstantSpectrumPropagationLossModel> ()
52
.AddAttribute (
"Loss"
,
53
"Path loss (dB) between transmitter and receiver"
,
54
DoubleValue
(1.0),
55
MakeDoubleAccessor (&
ConstantSpectrumPropagationLossModel::SetLossDb
,
56
&
ConstantSpectrumPropagationLossModel::GetLossDb
),
57
MakeDoubleChecker<double> ())
58
;
59
return
tid;
60
}
61
62
63
void
64
ConstantSpectrumPropagationLossModel::SetLossDb
(
double
lossDb)
65
{
66
NS_LOG_FUNCTION
(
this
);
67
m_lossDb
= lossDb;
68
m_lossLinear
= pow (10,
m_lossDb
/ 10);
69
}
70
71
72
double
73
ConstantSpectrumPropagationLossModel::GetLossDb
()
const
74
{
75
NS_LOG_FUNCTION
(
this
);
76
return
m_lossDb
;
77
}
78
79
80
Ptr<SpectrumValue>
81
ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
(
Ptr<const SpectrumValue>
txPsd,
82
Ptr<const MobilityModel>
a,
83
Ptr<const MobilityModel>
b)
const
84
{
85
NS_LOG_FUNCTION
(
this
);
86
87
Ptr<SpectrumValue>
rxPsd = Copy<SpectrumValue> (txPsd);
88
Values::iterator vit = rxPsd->
ValuesBegin
();
89
Bands::const_iterator fit = rxPsd->
ConstBandsBegin
();
90
91
while
(vit != rxPsd->
ValuesEnd
())
92
{
93
NS_ASSERT
(fit != rxPsd->
ConstBandsEnd
());
94
NS_LOG_LOGIC
(
"Ptx = "
<< *vit);
95
*vit /=
m_lossLinear
;
// Prx = Ptx / loss
96
NS_LOG_LOGIC
(
"Prx = "
<< *vit);
97
++vit;
98
++fit;
99
}
100
return
rxPsd;
101
}
102
103
104
}
// namespace ns3
src
spectrum
model
constant-spectrum-propagation-loss.cc
Generated on Tue Oct 9 2012 16:45:46 for ns-3 by
1.8.1.2