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-1238-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-1238-propagation-loss-model.h
"
11
12
#include "
mobility-building-info.h
"
13
14
#include "ns3/double.h"
15
#include "ns3/enum.h"
16
#include "ns3/log.h"
17
#include "ns3/mobility-model.h"
18
19
#include <cmath>
20
21
namespace
ns3
22
{
23
24
NS_LOG_COMPONENT_DEFINE
(
"ItuR1238PropagationLossModel"
);
25
26
NS_OBJECT_ENSURE_REGISTERED
(
ItuR1238PropagationLossModel
);
27
28
TypeId
29
ItuR1238PropagationLossModel::GetTypeId
()
30
{
31
static
TypeId
tid =
32
TypeId
(
"ns3::ItuR1238PropagationLossModel"
)
33
34
.
SetParent
<
PropagationLossModel
>()
35
.SetGroupName(
"Buildings"
)
36
37
.AddAttribute(
"Frequency"
,
38
"The Frequency (default is 2.106 GHz)."
,
39
DoubleValue
(2160e6),
40
MakeDoubleAccessor
(&
ItuR1238PropagationLossModel::m_frequency
),
41
MakeDoubleChecker<double>
());
42
43
return
tid;
44
}
45
46
double
47
ItuR1238PropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a1,
Ptr<MobilityModel>
b1)
const
48
{
49
NS_LOG_FUNCTION
(
this
<< a1 << b1);
50
Ptr<MobilityBuildingInfo>
a = a1->GetObject<
MobilityBuildingInfo
>();
51
Ptr<MobilityBuildingInfo>
b = b1->GetObject<
MobilityBuildingInfo
>();
52
NS_ASSERT_MSG
(a && b,
"ItuR1238PropagationLossModel only works with MobilityBuildingInfo"
);
53
NS_ASSERT_MSG
(a->GetBuilding()->GetId() == b->GetBuilding()->GetId(),
54
"ITU-R 1238 applies only to nodes that are in the same building"
);
55
double
N = 0.0;
56
int
n = std::abs(a->GetFloorNumber() - b->GetFloorNumber());
57
NS_LOG_LOGIC
(
this
<<
" A floor "
<< (uint16_t)a->GetFloorNumber() <<
" B floor "
58
<< (uint16_t)b->GetFloorNumber() <<
" n "
<< n);
59
double
Lf = 0.0;
60
Ptr<Building>
aBuilding = a->GetBuilding();
61
if
(aBuilding->GetBuildingType() ==
Building::Residential
)
62
{
63
N = 28;
64
if
(n >= 1)
65
{
66
Lf = 4 * n;
67
}
68
NS_LOG_LOGIC
(
this
<<
" Residential "
);
69
}
70
else
if
(aBuilding->GetBuildingType() ==
Building::Office
)
71
{
72
N = 30;
73
if
(n >= 1)
74
{
75
Lf = 15 + (4 * (n - 1));
76
}
77
NS_LOG_LOGIC
(
this
<<
" Office "
);
78
}
79
else
if
(aBuilding->GetBuildingType() ==
Building::Commercial
)
80
{
81
N = 22;
82
if
(n >= 1)
83
{
84
Lf = 6 + (3 * (n - 1));
85
}
86
NS_LOG_LOGIC
(
this
<<
" Commercial "
);
87
}
88
else
89
{
90
NS_LOG_ERROR
(
this
<<
" Unkwnon Wall Type"
);
91
}
92
double
loss = 20 * std::log10(
m_frequency
/ 1e6
/*MHz*/
) +
93
N * std::log10(a1->GetDistanceFrom(b1)) + Lf - 28.0;
94
NS_LOG_INFO
(
this
<<
" Node "
<< a1->GetPosition() <<
" <-> "
<< b1->GetPosition()
95
<<
" loss = "
<< loss <<
" dB"
);
96
97
return
loss;
98
}
99
100
double
101
ItuR1238PropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
102
Ptr<MobilityModel>
a,
103
Ptr<MobilityModel>
b)
const
104
{
105
return
(txPowerDbm -
GetLoss
(a, b));
106
}
107
108
int64_t
109
ItuR1238PropagationLossModel::DoAssignStreams
(int64_t stream)
110
{
111
return
0;
112
}
113
114
}
// namespace ns3
ns3::Building::Residential
@ Residential
Definition
building.h:47
ns3::Building::Commercial
@ Commercial
Definition
building.h:49
ns3::Building::Office
@ Office
Definition
building.h:48
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::ItuR1238PropagationLossModel
This class implements the ITU-R 1238 propagation loss model.
Definition
itu-r-1238-propagation-loss-model.h:28
ns3::ItuR1238PropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition
itu-r-1238-propagation-loss-model.cc:47
ns3::ItuR1238PropagationLossModel::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-1238-propagation-loss-model.cc:109
ns3::ItuR1238PropagationLossModel::DoCalcRxPower
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
Definition
itu-r-1238-propagation-loss-model.cc:101
ns3::ItuR1238PropagationLossModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
itu-r-1238-propagation-loss-model.cc:29
ns3::ItuR1238PropagationLossModel::m_frequency
double m_frequency
frequency in MHz
Definition
itu-r-1238-propagation-loss-model.h:54
ns3::MobilityBuildingInfo
mobility buildings information (to be used by mobility models)
Definition
mobility-building-info.h:37
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_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_ERROR
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition
log.h:243
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_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition
log.h:264
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-1238-propagation-loss-model.h
mobility-building-info.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
buildings
model
itu-r-1238-propagation-loss-model.cc
Generated on Wed Jun 11 2025 13:15:27 for ns-3 by
1.13.2