A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
friis-spectrum-propagation-loss.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 CTTC
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Nicola Baldo <nbaldo@cttc.es>
18
*/
19
20
#include "
friis-spectrum-propagation-loss.h
"
21
22
#include "
spectrum-signal-parameters.h
"
23
24
#include <ns3/mobility-model.h>
25
26
#include <cmath>
// for M_PI
27
28
namespace
ns3
29
{
30
31
NS_OBJECT_ENSURE_REGISTERED
(FriisSpectrumPropagationLossModel);
32
33
FriisSpectrumPropagationLossModel::FriisSpectrumPropagationLossModel
()
34
{
35
}
36
37
FriisSpectrumPropagationLossModel::~FriisSpectrumPropagationLossModel
()
38
{
39
}
40
41
TypeId
42
FriisSpectrumPropagationLossModel::GetTypeId
()
43
{
44
static
TypeId
tid =
TypeId
(
"ns3::FriisSpectrumPropagationLossModel"
)
45
.
SetParent
<
SpectrumPropagationLossModel
>()
46
.SetGroupName(
"Spectrum"
)
47
.AddConstructor<
FriisSpectrumPropagationLossModel
>();
48
return
tid;
49
}
50
51
Ptr<SpectrumValue>
52
FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
(
53
Ptr<const SpectrumSignalParameters>
params
,
54
Ptr<const MobilityModel>
a,
55
Ptr<const MobilityModel>
b)
const
56
{
57
Ptr<SpectrumValue>
rxPsd = Copy<SpectrumValue>(
params
->psd);
58
auto
vit = rxPsd->
ValuesBegin
();
59
auto
fit
= rxPsd->
ConstBandsBegin
();
60
61
NS_ASSERT
(a);
62
NS_ASSERT
(b);
63
64
double
d = a->GetDistanceFrom(b);
65
66
while
(vit != rxPsd->
ValuesEnd
())
67
{
68
NS_ASSERT
(
fit
!= rxPsd->
ConstBandsEnd
());
69
*vit /=
CalculateLoss
(
fit
->fc, d);
// Prx = Ptx / loss
70
++vit;
71
++
fit
;
72
}
73
return
rxPsd;
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
int64_t
98
FriisSpectrumPropagationLossModel::DoAssignStreams
(int64_t stream)
99
{
100
return
0;
101
}
102
103
}
// namespace ns3
f
double f(double x, void *params)
Definition:
80211b.c:70
ns3::FriisSpectrumPropagationLossModel
Friis spectrum propagation loss model.
Definition:
friis-spectrum-propagation-loss.h:43
ns3::FriisSpectrumPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
friis-spectrum-propagation-loss.cc:42
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::FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > params, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Definition:
friis-spectrum-propagation-loss.cc:52
ns3::FriisSpectrumPropagationLossModel::~FriisSpectrumPropagationLossModel
~FriisSpectrumPropagationLossModel() override
Definition:
friis-spectrum-propagation-loss.cc:37
ns3::FriisSpectrumPropagationLossModel::DoAssignStreams
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Definition:
friis-spectrum-propagation-loss.cc:98
ns3::FriisSpectrumPropagationLossModel::FriisSpectrumPropagationLossModel
FriisSpectrumPropagationLossModel()
Definition:
friis-spectrum-propagation-loss.cc:33
ns3::Ptr< SpectrumValue >
ns3::SpectrumPropagationLossModel
spectrum-aware propagation loss model
Definition:
spectrum-propagation-loss-model.h:44
ns3::SpectrumValue::ConstBandsEnd
Bands::const_iterator ConstBandsEnd() const
Definition:
spectrum-value.cc:96
ns3::SpectrumValue::ValuesBegin
Values::iterator ValuesBegin()
Definition:
spectrum-value.cc:78
ns3::SpectrumValue::ConstBandsBegin
Bands::const_iterator ConstBandsBegin() const
Definition:
spectrum-value.cc:90
ns3::SpectrumValue::ValuesEnd
Values::iterator ValuesEnd()
Definition:
spectrum-value.cc:84
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
friis-spectrum-propagation-loss.h
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:66
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
two-ray-to-three-gpp-ch-calibration.fit
fit
Definition:
two-ray-to-three-gpp-ch-calibration.py:563
two-ray-to-three-gpp-ch-calibration.params
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
Definition:
two-ray-to-three-gpp-ch-calibration.py:514
spectrum-signal-parameters.h
src
spectrum
model
friis-spectrum-propagation-loss.cc
Generated on Sun Mar 3 2024 17:11:08 for ns-3 by
1.9.1