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
friis-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) 2009 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: Nicola Baldo <nbaldo@cttc.es>
19
*/
20
21
22
#include <ns3/mobility-model.h>
23
#include <ns3/friis-spectrum-propagation-loss.h>
24
#include <math.h>
25
26
27
28
namespace
ns3 {
29
30
NS_OBJECT_ENSURE_REGISTERED
(FriisSpectrumPropagationLossModel);
31
32
33
FriisSpectrumPropagationLossModel::FriisSpectrumPropagationLossModel
()
34
{
35
}
36
37
FriisSpectrumPropagationLossModel::~FriisSpectrumPropagationLossModel
()
38
{
39
}
40
41
42
TypeId
43
FriisSpectrumPropagationLossModel::GetTypeId
(
void
)
44
{
45
static
TypeId
tid =
TypeId
(
"ns3::FriisSpectrumPropagationLossModel"
)
46
.
SetParent
<
SpectrumPropagationLossModel
> ()
47
.AddConstructor<FriisSpectrumPropagationLossModel> ()
48
;
49
return
tid;
50
}
51
52
53
Ptr<SpectrumValue>
54
FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
(
Ptr<const SpectrumValue>
txPsd,
55
Ptr<const MobilityModel>
a,
56
Ptr<const MobilityModel>
b)
const
57
{
58
Ptr<SpectrumValue>
rxPsd = Copy<SpectrumValue> (txPsd);
59
Values::iterator vit = rxPsd->
ValuesBegin
();
60
Bands::const_iterator fit = rxPsd->
ConstBandsBegin
();
61
62
NS_ASSERT
(a);
63
NS_ASSERT
(b);
64
65
double
d = a->
GetDistanceFrom
(b);
66
67
while
(vit != rxPsd->
ValuesEnd
())
68
{
69
NS_ASSERT
(fit != rxPsd->
ConstBandsEnd
());
70
*vit /=
CalculateLoss
(fit->fc, d);
// Prx = Ptx / loss
71
++vit;
72
++fit;
73
}
74
return
rxPsd;
75
}
76
77
78
double
79
FriisSpectrumPropagationLossModel::CalculateLoss
(
double
f,
double
d)
const
80
{
81
NS_ASSERT
(d >= 0);
82
83
if
(d == 0)
84
{
85
return
1;
86
}
87
88
NS_ASSERT
(f > 0);
89
double
loss_sqrt = (4 * M_PI * f * d) / 3e8;
90
double
loss = loss_sqrt * loss_sqrt;
91
92
if
(loss < 1)
93
{
94
loss = 1;
95
}
96
return
loss;
97
}
98
99
100
101
102
103
104
105
106
107
108
109
}
// namespace ns3
src
spectrum
model
friis-spectrum-propagation-loss.cc
Generated on Tue Oct 9 2012 16:45:46 for ns-3 by
1.8.1.2