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
okumura-hata-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 "
okumura-hata-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 <algorithm>
18
#include <cmath>
19
20
namespace
ns3
21
{
22
23
NS_LOG_COMPONENT_DEFINE
(
"OkumuraHataPropagationLossModel"
);
24
25
NS_OBJECT_ENSURE_REGISTERED
(OkumuraHataPropagationLossModel);
26
27
TypeId
28
OkumuraHataPropagationLossModel::GetTypeId
()
29
{
30
static
TypeId
tid =
31
TypeId
(
"ns3::OkumuraHataPropagationLossModel"
)
32
.
SetParent
<
PropagationLossModel
>()
33
.SetGroupName(
"Propagation"
)
34
.AddConstructor<
OkumuraHataPropagationLossModel
>()
35
.AddAttribute(
"Frequency"
,
36
"The propagation frequency in Hz"
,
37
DoubleValue
(2160
e6
),
38
MakeDoubleAccessor
(&
OkumuraHataPropagationLossModel::m_frequency
),
39
MakeDoubleChecker<double>
())
40
.AddAttribute(
41
"Environment"
,
42
"Environment Scenario"
,
43
EnumValue
(
UrbanEnvironment
),
44
MakeEnumAccessor<EnvironmentType>
(&
OkumuraHataPropagationLossModel::m_environment
),
45
MakeEnumChecker
(
UrbanEnvironment
,
46
"Urban"
,
47
SubUrbanEnvironment
,
48
"SubUrban"
,
49
OpenAreasEnvironment
,
50
"OpenAreas"
))
51
.AddAttribute(
52
"CitySize"
,
53
"Dimension of the city"
,
54
EnumValue
(
LargeCity
),
55
MakeEnumAccessor<CitySize>
(&
OkumuraHataPropagationLossModel::m_citySize
),
56
MakeEnumChecker
(
SmallCity
,
"Small"
,
MediumCity
,
"Medium"
,
LargeCity
,
"Large"
));
57
return
tid;
58
}
59
60
OkumuraHataPropagationLossModel::OkumuraHataPropagationLossModel
()
61
:
PropagationLossModel
()
62
{
63
}
64
65
OkumuraHataPropagationLossModel::~OkumuraHataPropagationLossModel
()
66
{
67
}
68
69
double
70
OkumuraHataPropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a
,
Ptr<MobilityModel>
b)
const
71
{
72
double
loss
= 0.0;
73
double
fmhz
=
m_frequency
/ 1
e6
;
74
double
log_fMhz
= std::log10(
fmhz
);
75
// In the Okumura Hata literature, the distance is expressed in units of kilometers
76
// but other lengths are expressed in meters
77
double
distKm
=
a
->GetDistanceFrom(b) / 1000.0;
78
79
Vector
aPosition
=
a
->GetPosition();
80
Vector
bPosition
= b->GetPosition();
81
82
double
hb
= std::max(
aPosition
.z,
bPosition
.z);
83
double
hm
= std::min(
aPosition
.z,
bPosition
.z);
84
85
NS_ASSERT_MSG
(
hb
> 0 &&
hm
> 0,
"nodes' height must be greater then 0"
);
86
87
double
log_hb
= std::log10(
hb
);
88
double
log_aHeight
= 13.82 *
log_hb
;
89
double
log_bHeight
= 0.0;
90
91
if
(
m_frequency
<= 1.500e9)
92
{
93
// standard Okumura Hata
94
// see eq. (4.4.1) in the COST 231 final report
95
96
if
(
m_citySize
==
LargeCity
)
97
{
98
if
(
fmhz
< 200)
99
{
100
log_bHeight
= 8.29 * std::pow(
log10
(1.54 *
hm
), 2) - 1.1;
101
}
102
else
103
{
104
log_bHeight
= 3.2 * std::pow(
log10
(11.75 *
hm
), 2) - 4.97;
105
}
106
}
107
else
108
{
109
log_bHeight
= 0.8 + (1.1 *
log_fMhz
- 0.7) *
hm
- 1.56 *
log_fMhz
;
110
}
111
112
NS_LOG_INFO
(
this
<<
" logf "
<< 26.16 *
log_fMhz
<<
" loga "
<<
log_aHeight
<<
" X "
113
<< ((44.9 - (6.55 *
log_hb
)) * std::log10(
distKm
)) <<
" logb "
114
<<
log_bHeight
);
115
loss
= 69.55 + (26.16 *
log_fMhz
) -
log_aHeight
+
116
((44.9 - (6.55 *
log_hb
)) * std::log10(
distKm
)) -
log_bHeight
;
117
if
(
m_environment
==
SubUrbanEnvironment
)
118
{
119
loss
+= -2 * (std::pow(std::log10(
fmhz
/ 28), 2)) - 5.4;
120
}
121
else
if
(
m_environment
==
OpenAreasEnvironment
)
122
{
123
loss
+= -4.78 * std::pow(
log_fMhz
, 2) + 18.33 *
log_fMhz
- 40.94;
124
}
125
}
126
else
127
{
128
// COST 231 Okumura model
129
// see eq. (4.4.3) in the COST 231 final report
130
131
double
C = 0.0;
132
133
if
(
m_citySize
==
LargeCity
)
134
{
135
log_bHeight
= 3.2 * std::pow(std::log10(11.75 *
hm
), 2);
136
C = 3;
137
}
138
else
139
{
140
log_bHeight
= (1.1 *
log_fMhz
- 0.7) *
hm
- (1.56 *
log_fMhz
- 0.8);
141
}
142
143
loss
= 46.3 + (33.9 *
log_fMhz
) -
log_aHeight
+
144
((44.9 - (6.55 *
log_hb
)) * std::log10(
distKm
)) -
log_bHeight
+ C;
145
}
146
return
loss
;
147
}
148
149
double
150
OkumuraHataPropagationLossModel::DoCalcRxPower
(
double
txPowerDbm
,
151
Ptr<MobilityModel>
a
,
152
Ptr<MobilityModel>
b)
const
153
{
154
return
(
txPowerDbm
-
GetLoss
(
a
, b));
155
}
156
157
int64_t
158
OkumuraHataPropagationLossModel::DoAssignStreams
(int64_t stream)
159
{
160
return
0;
161
}
162
163
}
// 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::EnumValue
Hold variables of type enum.
Definition
enum.h:52
ns3::OkumuraHataPropagationLossModel
this class implements the Okumura Hata propagation loss model
Definition
okumura-hata-propagation-loss-model.h:32
ns3::OkumuraHataPropagationLossModel::DoAssignStreams
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Definition
okumura-hata-propagation-loss-model.cc:158
ns3::OkumuraHataPropagationLossModel::m_environment
EnvironmentType m_environment
Environment Scenario.
Definition
okumura-hata-propagation-loss-model.h:62
ns3::OkumuraHataPropagationLossModel::m_frequency
double m_frequency
frequency in Hz
Definition
okumura-hata-propagation-loss-model.h:64
ns3::OkumuraHataPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
okumura-hata-propagation-loss-model.cc:28
ns3::OkumuraHataPropagationLossModel::DoCalcRxPower
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
Definition
okumura-hata-propagation-loss-model.cc:150
ns3::OkumuraHataPropagationLossModel::OkumuraHataPropagationLossModel
OkumuraHataPropagationLossModel()
Definition
okumura-hata-propagation-loss-model.cc:60
ns3::OkumuraHataPropagationLossModel::m_citySize
CitySize m_citySize
Size of the city.
Definition
okumura-hata-propagation-loss-model.h:63
ns3::OkumuraHataPropagationLossModel::~OkumuraHataPropagationLossModel
~OkumuraHataPropagationLossModel() override
Definition
okumura-hata-propagation-loss-model.cc:65
ns3::OkumuraHataPropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition
okumura-hata-propagation-loss-model.cc:70
ns3::PropagationLossModel
Models the propagation loss through a transmission medium.
Definition
propagation-loss-model.h:45
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_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
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
ns3::SubUrbanEnvironment
@ SubUrbanEnvironment
Definition
propagation-environment.h:26
ns3::OpenAreasEnvironment
@ OpenAreasEnvironment
Definition
propagation-environment.h:27
ns3::UrbanEnvironment
@ UrbanEnvironment
Definition
propagation-environment.h:25
ns3::LargeCity
@ LargeCity
Definition
propagation-environment.h:40
ns3::SmallCity
@ SmallCity
Definition
propagation-environment.h:38
ns3::MediumCity
@ MediumCity
Definition
propagation-environment.h:39
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeEnumChecker
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition
enum.h:179
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition
double.h:32
okumura-hata-propagation-loss-model.h
src
propagation
model
okumura-hata-propagation-loss-model.cc
Generated on Mon Dec 15 2025 15:22:02 for ns-3 by
1.9.8