A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
friis-spectrum-propagation-loss.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 CTTC
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Nicola Baldo <nbaldo@cttc.es>
7
*/
8
9
#include "
friis-spectrum-propagation-loss.h
"
10
11
#include "
spectrum-signal-parameters.h
"
12
13
#include <ns3/mobility-model.h>
14
15
#include <cmath>
// for M_PI
16
17
namespace
ns3
18
{
19
20
NS_OBJECT_ENSURE_REGISTERED
(FriisSpectrumPropagationLossModel);
21
22
FriisSpectrumPropagationLossModel::FriisSpectrumPropagationLossModel
()
23
{
24
}
25
26
FriisSpectrumPropagationLossModel::~FriisSpectrumPropagationLossModel
()
27
{
28
}
29
30
TypeId
31
FriisSpectrumPropagationLossModel::GetTypeId
()
32
{
33
static
TypeId
tid =
TypeId
(
"ns3::FriisSpectrumPropagationLossModel"
)
34
.
SetParent
<
SpectrumPropagationLossModel
>()
35
.SetGroupName(
"Spectrum"
)
36
.AddConstructor<
FriisSpectrumPropagationLossModel
>();
37
return
tid;
38
}
39
40
Ptr<SpectrumValue>
41
FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity
(
42
Ptr<const SpectrumSignalParameters>
params,
43
Ptr<const MobilityModel>
a,
44
Ptr<const MobilityModel>
b)
const
45
{
46
Ptr<SpectrumValue>
rxPsd =
Copy<SpectrumValue>
(params->psd);
47
auto
vit = rxPsd->ValuesBegin();
48
auto
fit = rxPsd->ConstBandsBegin();
49
50
NS_ASSERT
(a);
51
NS_ASSERT
(b);
52
53
double
d = a->GetDistanceFrom(b);
54
55
while
(vit != rxPsd->ValuesEnd())
56
{
57
NS_ASSERT
(fit != rxPsd->ConstBandsEnd());
58
*vit /=
CalculateLoss
(fit->fc, d);
// Prx = Ptx / loss
59
++vit;
60
++fit;
61
}
62
return
rxPsd;
63
}
64
65
double
66
FriisSpectrumPropagationLossModel::CalculateLoss
(
double
f,
double
d)
const
67
{
68
NS_ASSERT
(d >= 0);
69
70
if
(d == 0)
71
{
72
return
1;
73
}
74
75
NS_ASSERT
(f > 0);
76
double
loss_sqrt = (4 * M_PI * f * d) / 3e8;
77
double
loss = loss_sqrt * loss_sqrt;
78
79
if
(loss < 1)
80
{
81
loss = 1;
82
}
83
return
loss;
84
}
85
86
int64_t
87
FriisSpectrumPropagationLossModel::DoAssignStreams
(int64_t stream)
88
{
89
return
0;
90
}
91
92
}
// namespace ns3
ns3::FriisSpectrumPropagationLossModel
Friis spectrum propagation loss model.
Definition
friis-spectrum-propagation-loss.h:32
ns3::FriisSpectrumPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
friis-spectrum-propagation-loss.cc:31
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:66
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:41
ns3::FriisSpectrumPropagationLossModel::~FriisSpectrumPropagationLossModel
~FriisSpectrumPropagationLossModel() override
Definition
friis-spectrum-propagation-loss.cc:26
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:87
ns3::FriisSpectrumPropagationLossModel::FriisSpectrumPropagationLossModel
FriisSpectrumPropagationLossModel()
Definition
friis-spectrum-propagation-loss.cc:22
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::SpectrumPropagationLossModel
spectrum-aware propagation loss model
Definition
spectrum-propagation-loss-model.h:33
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
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:55
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Copy
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition
ptr.h:604
spectrum-signal-parameters.h
src
spectrum
model
friis-spectrum-propagation-loss.cc
Generated on Fri Nov 8 2024 13:59:06 for ns-3 by
1.11.0