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
itu-r-1411-los-propagation-loss-model.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Marco Miozzo <marco.miozzo@cttc.es>,
7
* Nicola Baldo <nbaldo@cttc.es>
8
*
9
*/
10
#include "
itu-r-1411-los-propagation-loss-model.h
"
11
12
#include "ns3/double.h"
13
#include "ns3/enum.h"
14
#include "ns3/log.h"
15
#include "ns3/mobility-model.h"
16
17
#include <cmath>
18
19
namespace
ns3
20
{
21
22
NS_LOG_COMPONENT_DEFINE
(
"ItuR1411LosPropagationLossModel"
);
23
24
NS_OBJECT_ENSURE_REGISTERED
(
ItuR1411LosPropagationLossModel
);
25
26
TypeId
27
ItuR1411LosPropagationLossModel::GetTypeId
()
28
{
29
static
TypeId
tid =
30
TypeId
(
"ns3::ItuR1411LosPropagationLossModel"
)
31
.
SetParent
<
PropagationLossModel
>()
32
.SetGroupName(
"Propagation"
)
33
.AddConstructor<
ItuR1411LosPropagationLossModel
>()
34
.AddAttribute(
"Frequency"
,
35
"The propagation frequency in Hz"
,
36
DoubleValue
(2160e6),
37
MakeDoubleAccessor
(&
ItuR1411LosPropagationLossModel::SetFrequency
),
38
MakeDoubleChecker<double>
());
39
40
return
tid;
41
}
42
43
ItuR1411LosPropagationLossModel::ItuR1411LosPropagationLossModel
()
44
:
PropagationLossModel
()
45
{
46
}
47
48
ItuR1411LosPropagationLossModel::~ItuR1411LosPropagationLossModel
()
49
{
50
}
51
52
double
53
ItuR1411LosPropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
54
{
55
NS_LOG_FUNCTION
(
this
);
56
double
dist = a->GetDistanceFrom(b);
57
double
lossLow = 0.0;
58
double
lossUp = 0.0;
59
NS_ASSERT_MSG
(a->GetPosition().z > 0 && b->GetPosition().z > 0,
60
"nodes' height must be greater than 0"
);
61
double
Lbp = std::fabs(20 * std::log10((
m_lambda
*
m_lambda
) /
62
(8 * M_PI * a->GetPosition().z * b->GetPosition().z)));
63
double
Rbp = (4 * a->GetPosition().z * b->GetPosition().z) /
m_lambda
;
64
NS_LOG_LOGIC
(
this
<<
" Lbp "
<< Lbp <<
" Rbp "
<< Rbp <<
" lambda "
<<
m_lambda
);
65
if
(dist <= Rbp)
66
{
67
lossLow = Lbp + 20 * std::log10(dist / Rbp);
68
lossUp = Lbp + 20 + 25 * std::log10(dist / Rbp);
69
}
70
else
71
{
72
lossLow = Lbp + 40 * std::log10(dist / Rbp);
73
lossUp = Lbp + 20 + 40 * std::log10(dist / Rbp);
74
}
75
76
double
loss = (lossUp + lossLow) / 2;
77
78
return
loss;
79
}
80
81
void
82
ItuR1411LosPropagationLossModel::SetFrequency
(
double
freq)
83
{
84
NS_ASSERT
(freq > 0.0);
85
m_lambda
= 299792458.0 / freq;
86
}
87
88
double
89
ItuR1411LosPropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
90
Ptr<MobilityModel>
a,
91
Ptr<MobilityModel>
b)
const
92
{
93
return
(txPowerDbm -
GetLoss
(a, b));
94
}
95
96
int64_t
97
ItuR1411LosPropagationLossModel::DoAssignStreams
(int64_t stream)
98
{
99
return
0;
100
}
101
}
// namespace ns3
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::ItuR1411LosPropagationLossModel
the ITU-R 1411 LOS propagation model
Definition
itu-r-1411-los-propagation-loss-model.h:31
ns3::ItuR1411LosPropagationLossModel::ItuR1411LosPropagationLossModel
ItuR1411LosPropagationLossModel()
Definition
itu-r-1411-los-propagation-loss-model.cc:43
ns3::ItuR1411LosPropagationLossModel::DoAssignStreams
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Definition
itu-r-1411-los-propagation-loss-model.cc:97
ns3::ItuR1411LosPropagationLossModel::SetFrequency
void SetFrequency(double freq)
Set the operating frequency.
Definition
itu-r-1411-los-propagation-loss-model.cc:82
ns3::ItuR1411LosPropagationLossModel::~ItuR1411LosPropagationLossModel
~ItuR1411LosPropagationLossModel() override
Definition
itu-r-1411-los-propagation-loss-model.cc:48
ns3::ItuR1411LosPropagationLossModel::m_lambda
double m_lambda
wavelength
Definition
itu-r-1411-los-propagation-loss-model.h:71
ns3::ItuR1411LosPropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition
itu-r-1411-los-propagation-loss-model.cc:53
ns3::ItuR1411LosPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
itu-r-1411-los-propagation-loss-model.cc:27
ns3::ItuR1411LosPropagationLossModel::DoCalcRxPower
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
Definition
itu-r-1411-los-propagation-loss-model.cc:89
ns3::PropagationLossModel::PropagationLossModel
PropagationLossModel()
Definition
propagation-loss-model.cc:40
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:66
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
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_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:75
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition
log.h:271
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:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
itu-r-1411-los-propagation-loss-model.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeDoubleChecker
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition
double.h:82
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition
double.h:32
src
propagation
model
itu-r-1411-los-propagation-loss-model.cc
Generated on Wed Jun 11 2025 13:15:37 for ns-3 by
1.13.2