A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
itu-r-1411-los-propagation-loss-model.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011, 2012 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: Marco Miozzo <marco.miozzo@cttc.es>,
19
* Nicola Baldo <nbaldo@cttc.es>
20
*
21
*/
22
#include "ns3/log.h"
23
#include "ns3/double.h"
24
#include "ns3/enum.h"
25
#include "ns3/mobility-model.h"
26
#include <cmath>
27
28
#include "
itu-r-1411-los-propagation-loss-model.h
"
29
30
namespace
ns3
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"ItuR1411LosPropagationLossModel"
);
33
34
NS_OBJECT_ENSURE_REGISTERED
(ItuR1411LosPropagationLossModel);
35
36
TypeId
37
ItuR1411LosPropagationLossModel::GetTypeId
(
void
)
38
{
39
static
TypeId
tid =
TypeId
(
"ns3::ItuR1411LosPropagationLossModel"
)
40
.
SetParent
<
PropagationLossModel
> ()
41
.SetGroupName (
"Propagation"
)
42
.AddConstructor<
ItuR1411LosPropagationLossModel
> ()
43
.AddAttribute (
"Frequency"
,
44
"The propagation frequency in Hz"
,
45
DoubleValue
(2160e6),
46
MakeDoubleAccessor
(&
ItuR1411LosPropagationLossModel::SetFrequency
),
47
MakeDoubleChecker<double> ());
48
49
return
tid;
50
}
51
52
ItuR1411LosPropagationLossModel::ItuR1411LosPropagationLossModel
()
53
:
PropagationLossModel
()
54
{
55
}
56
57
ItuR1411LosPropagationLossModel::~ItuR1411LosPropagationLossModel
()
58
{
59
}
60
61
double
62
ItuR1411LosPropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
63
{
64
NS_LOG_FUNCTION
(
this
);
65
double
dist = a->
GetDistanceFrom
(b);
66
double
lossLow = 0.0;
67
double
lossUp = 0.0;
68
NS_ASSERT_MSG
(a->
GetPosition
().z > 0 && b->
GetPosition
().z > 0,
"nodes' height must be greater than 0"
);
69
double
Lbp = std::fabs (20 * std::log10 ((
m_lambda
*
m_lambda
) / (8 * M_PI * a->
GetPosition
().z * b->
GetPosition
().z)));
70
double
Rbp = (4 * a->
GetPosition
().z * b->
GetPosition
().z) /
m_lambda
;
71
NS_LOG_LOGIC
(
this
<<
" Lbp "
<< Lbp <<
" Rbp "
<< Rbp <<
" lambda "
<<
m_lambda
);
72
if
(dist <= Rbp)
73
{
74
lossLow = Lbp + 20 * std::log10 (dist / Rbp);
75
lossUp = Lbp + 20 + 25 * std::log10 (dist / Rbp);
76
}
77
else
78
{
79
lossLow = Lbp + 40 * std::log10 (dist / Rbp);
80
lossUp = Lbp + 20 + 40 * std::log10 (dist / Rbp);
81
}
82
83
double
loss = (lossUp + lossLow) / 2;
84
85
return
loss;
86
}
87
88
89
void
90
ItuR1411LosPropagationLossModel::SetFrequency
(
double
freq)
91
{
92
NS_ASSERT
(freq > 0.0);
93
m_lambda
= 299792458.0 / freq;
94
}
95
96
97
double
98
ItuR1411LosPropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
99
Ptr<MobilityModel>
a,
100
Ptr<MobilityModel>
b)
const
101
{
102
return
(txPowerDbm -
GetLoss
(a, b));
103
}
104
105
int64_t
106
ItuR1411LosPropagationLossModel::DoAssignStreams
(int64_t stream)
107
{
108
return
0;
109
}
110
}
// namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
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:67
ns3::ItuR1411LosPropagationLossModel::ItuR1411LosPropagationLossModel
ItuR1411LosPropagationLossModel()
Definition:
itu-r-1411-los-propagation-loss-model.cc:52
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition:
mobility-model.cc:94
ns3::ItuR1411LosPropagationLossModel::SetFrequency
void SetFrequency(double freq)
Set the operating frequency.
Definition:
itu-r-1411-los-propagation-loss-model.cc:90
ns3::PropagationLossModel
Models the propagation loss through a transmission medium.
Definition:
propagation-loss-model.h:50
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:41
ns3::ItuR1411LosPropagationLossModel::DoCalcRxPower
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
Definition:
itu-r-1411-los-propagation-loss-model.cc:98
ns3::Ptr< MobilityModel >
ns3::ItuR1411LosPropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
itu-r-1411-los-propagation-loss-model.cc:62
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition:
assert.h:88
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition:
log.h:289
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition:
double.h:42
ns3::ItuR1411LosPropagationLossModel::~ItuR1411LosPropagationLossModel
virtual ~ItuR1411LosPropagationLossModel()
Definition:
itu-r-1411-los-propagation-loss-model.cc:57
itu-r-1411-los-propagation-loss-model.h
ns3::ItuR1411LosPropagationLossModel::m_lambda
double m_lambda
wavelength
Definition:
itu-r-1411-los-propagation-loss-model.h:94
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:244
ns3::ItuR1411LosPropagationLossModel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
itu-r-1411-los-propagation-loss-model.cc:37
ns3::ItuR1411LosPropagationLossModel
the ITU-R 1411 LOS propagation model
Definition:
itu-r-1411-los-propagation-loss-model.h:43
ns3::ItuR1411LosPropagationLossModel::DoAssignStreams
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
Definition:
itu-r-1411-los-propagation-loss-model.cc:106
ns3::MobilityModel::GetPosition
Vector GetPosition(void) const
Definition:
mobility-model.cc:64
src
propagation
model
itu-r-1411-los-propagation-loss-model.cc
Generated on Fri Oct 1 2021 17:03:33 for ns-3 by
1.8.20