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
#include <ns3/mobility-model.h>
22
#include <ns3/friis-spectrum-propagation-loss.h>
23
#include <cmath>
// for M_PI
24
25
26
namespace
ns3 {
27
28
NS_OBJECT_ENSURE_REGISTERED
(FriisSpectrumPropagationLossModel);
29
30
31
FriisSpectrumPropagationLossModel::FriisSpectrumPropagationLossModel
()
32
{
33
}
34
35
FriisSpectrumPropagationLossModel::~FriisSpectrumPropagationLossModel
()
36
{
37
}
38
39
40
TypeId
41
FriisSpectrumPropagationLossModel::GetTypeId
(
void
)
42
{
43
static
TypeId
tid =
TypeId
(
"ns3::FriisSpectrumPropagationLossModel"
)
44
.
SetParent
<
SpectrumPropagationLossModel
> ()
45
.AddConstructor<FriisSpectrumPropagationLossModel> ()
46
;
47
return
tid;
48
}
49
50
51
Ptr<SpectrumValue>
52
FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
(
Ptr<const SpectrumValue>
txPsd,
53
Ptr<const MobilityModel>
a,
54
Ptr<const MobilityModel>
b)
const
55
{
56
Ptr<SpectrumValue>
rxPsd = Copy<SpectrumValue> (txPsd);
57
Values::iterator vit = rxPsd->
ValuesBegin
();
58
Bands::const_iterator fit = rxPsd->
ConstBandsBegin
();
59
60
NS_ASSERT
(a);
61
NS_ASSERT
(b);
62
63
double
d = a->GetDistanceFrom (b);
64
65
while
(vit != rxPsd->
ValuesEnd
())
66
{
67
NS_ASSERT
(fit != rxPsd->
ConstBandsEnd
());
68
*vit /=
CalculateLoss
(fit->fc, d);
// Prx = Ptx / loss
69
++vit;
70
++fit;
71
}
72
return
rxPsd;
73
}
74
75
76
double
77
FriisSpectrumPropagationLossModel::CalculateLoss
(
double
f,
double
d)
const
78
{
79
NS_ASSERT
(d >= 0);
80
81
if
(d == 0)
82
{
83
return
1;
84
}
85
86
NS_ASSERT
(f > 0);
87
double
loss_sqrt = (4 * M_PI * f * d) / 3e8;
88
double
loss = loss_sqrt * loss_sqrt;
89
90
if
(loss < 1)
91
{
92
loss = 1;
93
}
94
return
loss;
95
}
96
97
98
99
100
101
102
103
104
105
106
107
}
// namespace ns3
ns3::Ptr< SpectrumValue >
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition:
object-base.h:38
ns3::FriisSpectrumPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Definition:
friis-spectrum-propagation-loss.cc:41
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
ns3::FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
virtual Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumValue > txPsd, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
Definition:
friis-spectrum-propagation-loss.cc:52
ns3::SpectrumValue::ValuesEnd
Values::iterator ValuesEnd()
Definition:
spectrum-value.cc:84
ns3::FriisSpectrumPropagationLossModel::~FriisSpectrumPropagationLossModel
~FriisSpectrumPropagationLossModel()
Definition:
friis-spectrum-propagation-loss.cc:35
ns3::SpectrumValue::ConstBandsEnd
Bands::const_iterator ConstBandsEnd() const
Definition:
spectrum-value.cc:96
ns3::FriisSpectrumPropagationLossModel::FriisSpectrumPropagationLossModel
FriisSpectrumPropagationLossModel()
Definition:
friis-spectrum-propagation-loss.cc:31
ns3::SpectrumValue::ConstBandsBegin
Bands::const_iterator ConstBandsBegin() const
Definition:
spectrum-value.cc:90
ns3::SpectrumValue::ValuesBegin
Values::iterator ValuesBegin()
Definition:
spectrum-value.cc:78
ns3::FriisSpectrumPropagationLossModel::CalculateLoss
double CalculateLoss(double f, double d) const
Return the propagation loss L according to a simplified version of Friis' formula in which antenna ga...
Definition:
friis-spectrum-propagation-loss.cc:77
ns3::SpectrumPropagationLossModel
spectrum-aware propagation loss model
Definition:
spectrum-propagation-loss-model.h:44
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:610
src
spectrum
model
friis-spectrum-propagation-loss.cc
Generated on Tue Jun 17 2014 01:13:05 for ns-3 by
1.8.6