A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
okumura-hata-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 "
okumura-hata-propagation-loss-model.h
"
29
30
namespace
ns3
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"OkumuraHataPropagationLossModel"
);
33
34
NS_OBJECT_ENSURE_REGISTERED
(OkumuraHataPropagationLossModel);
35
36
37
TypeId
38
OkumuraHataPropagationLossModel::GetTypeId
(
void
)
39
{
40
static
TypeId
tid =
TypeId
(
"ns3::OkumuraHataPropagationLossModel"
)
41
.
SetParent
<
PropagationLossModel
> ()
42
.SetGroupName (
"Propagation"
)
43
.AddConstructor<
OkumuraHataPropagationLossModel
> ()
44
.AddAttribute (
"Frequency"
,
45
"The propagation frequency in Hz"
,
46
DoubleValue
(2160e6),
47
MakeDoubleAccessor
(&
OkumuraHataPropagationLossModel::m_frequency
),
48
MakeDoubleChecker<double> ())
49
.AddAttribute (
"Environment"
,
50
"Environment Scenario"
,
51
EnumValue
(
UrbanEnvironment
),
52
MakeEnumAccessor
(&
OkumuraHataPropagationLossModel::m_environment
),
53
MakeEnumChecker
(
UrbanEnvironment
,
"Urban"
,
54
SubUrbanEnvironment
,
"SubUrban"
,
55
OpenAreasEnvironment
,
"OpenAreas"
))
56
.AddAttribute (
"CitySize"
,
57
"Dimension of the city"
,
58
EnumValue
(
LargeCity
),
59
MakeEnumAccessor
(&
OkumuraHataPropagationLossModel::m_citySize
),
60
MakeEnumChecker
(
SmallCity
,
"Small"
,
61
MediumCity
,
"Medium"
,
62
LargeCity
,
"Large"
));
63
return
tid;
64
}
65
66
OkumuraHataPropagationLossModel::OkumuraHataPropagationLossModel
()
67
:
PropagationLossModel
()
68
{
69
}
70
71
OkumuraHataPropagationLossModel::~OkumuraHataPropagationLossModel
()
72
{
73
}
74
75
double
76
OkumuraHataPropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
77
{
78
double
loss = 0.0;
79
double
fmhz =
m_frequency
/ 1e6;
80
double
dist = a->
GetDistanceFrom
(b) / 1000.0;
81
if
(
m_frequency
<= 1.500e9)
82
{
83
// standard Okumura Hata
84
// see eq. (4.4.1) in the COST 231 final report
85
double
log_f = std::log10 (fmhz);
86
double
hb = (a->
GetPosition
().z > b->
GetPosition
().z ? a->
GetPosition
().z : b->
GetPosition
().z);
87
double
hm = (a->
GetPosition
().z < b->
GetPosition
().z ? a->
GetPosition
().z : b->
GetPosition
().z);
88
NS_ASSERT_MSG
(hb > 0 && hm > 0,
"nodes' height must be greater then 0"
);
89
double
log_aHeight = 13.82 * std::log10 (hb);
90
double
log_bHeight = 0.0;
91
if
(
m_citySize
==
LargeCity
)
92
{
93
if
(fmhz < 200)
94
{
95
log_bHeight = 8.29 * std::pow (log10 (1.54 * hm), 2) - 1.1;
96
}
97
else
98
{
99
log_bHeight = 3.2 * std::pow (log10 (11.75 * hm), 2) - 4.97;
100
}
101
}
102
else
103
{
104
log_bHeight = 0.8 + (1.1 * log_f - 0.7) * hm - 1.56 * log_f;
105
}
106
107
NS_LOG_INFO
(
this
<<
" logf "
<< 26.16 * log_f <<
" loga "
<< log_aHeight <<
" X "
<< (((44.9 - (6.55 * std::log10 (hb)) )) * std::log10 (a->
GetDistanceFrom
(b))) <<
" logb "
<< log_bHeight);
108
loss = 69.55 + (26.16 * log_f) - log_aHeight + (((44.9 - (6.55 * std::log10 (hb)) )) * std::log10 (dist)) - log_bHeight;
109
if
(
m_environment
==
SubUrbanEnvironment
)
110
{
111
loss += -2 * (std::pow (std::log10 (fmhz / 28), 2)) - 5.4;
112
}
113
else
if
(
m_environment
==
OpenAreasEnvironment
)
114
{
115
loss += -4.70 * std::pow (std::log10 (fmhz),2) + 18.33 * std::log10 (fmhz) - 40.94;
116
}
117
118
}
119
else
120
{
121
// COST 231 Okumura model
122
// see eq. (4.4.3) in the COST 231 final report
123
124
double
log_f = std::log10 (fmhz);
125
double
hb = (a->
GetPosition
().z > b->
GetPosition
().z ? a->
GetPosition
().z : b->
GetPosition
().z);
126
double
hm = (a->
GetPosition
().z < b->
GetPosition
().z ? a->
GetPosition
().z : b->
GetPosition
().z);
127
NS_ASSERT_MSG
(hb > 0 && hm > 0,
"nodes' height must be greater then 0"
);
128
double
log_aHeight = 13.82 * std::log10 (hb);
129
double
log_bHeight = 0.0;
130
double
C = 0.0;
131
132
if
(
m_citySize
==
LargeCity
)
133
{
134
log_bHeight = 3.2 * std::pow ((std::log10 (11.75 * hm)), 2);
135
C = 3;
136
}
137
else
138
{
139
log_bHeight = (1.1 * log_f - 0.7) * hm - (1.56 * log_f - 0.8);
140
}
141
142
loss = 46.3 + (33.9 * log_f) - log_aHeight + (((44.9 - (6.55 * std::log10 (hb)) )) * std::log10 (dist)) - log_bHeight + C;
143
}
144
return
loss;
145
}
146
147
double
148
OkumuraHataPropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
149
Ptr<MobilityModel>
a,
150
Ptr<MobilityModel>
b)
const
151
{
152
return
(txPowerDbm -
GetLoss
(a, b));
153
}
154
155
int64_t
156
OkumuraHataPropagationLossModel::DoAssignStreams
(int64_t stream)
157
{
158
return
0;
159
}
160
161
162
}
// namespace ns3
ns3::SubUrbanEnvironment
@ SubUrbanEnvironment
Definition:
propagation-environment.h:38
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
ns3::OkumuraHataPropagationLossModel::DoAssignStreams
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
Definition:
okumura-hata-propagation-loss-model.cc:156
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeEnumChecker
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition:
enum.h:161
ns3::SmallCity
@ SmallCity
Definition:
propagation-environment.h:50
ns3::OkumuraHataPropagationLossModel::m_frequency
double m_frequency
frequency in Hz
Definition:
okumura-hata-propagation-loss-model.h:88
ns3::OkumuraHataPropagationLossModel::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:
okumura-hata-propagation-loss-model.cc:148
ns3::LargeCity
@ LargeCity
Definition:
propagation-environment.h:50
ns3::UrbanEnvironment
@ UrbanEnvironment
Definition:
propagation-environment.h:38
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition:
mobility-model.cc:94
ns3::PropagationLossModel
Models the propagation loss through a transmission medium.
Definition:
propagation-loss-model.h:50
ns3::MediumCity
@ MediumCity
Definition:
propagation-environment.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::EnumValue
Hold variables of type enum.
Definition:
enum.h:55
ns3::Ptr< MobilityModel >
ns3::OpenAreasEnvironment
@ OpenAreasEnvironment
Definition:
propagation-environment.h:38
ns3::OkumuraHataPropagationLossModel::~OkumuraHataPropagationLossModel
virtual ~OkumuraHataPropagationLossModel()
Definition:
okumura-hata-propagation-loss-model.cc:71
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition:
log.h:281
ns3::OkumuraHataPropagationLossModel::m_citySize
CitySize m_citySize
Size of the city.
Definition:
okumura-hata-propagation-loss-model.h:87
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
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::OkumuraHataPropagationLossModel
this class implements the Okumura Hata propagation loss model
Definition:
okumura-hata-propagation-loss-model.h:44
ns3::OkumuraHataPropagationLossModel::m_environment
EnvironmentType m_environment
Environment Scenario.
Definition:
okumura-hata-propagation-loss-model.h:86
ns3::OkumuraHataPropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
okumura-hata-propagation-loss-model.cc:76
ns3::MakeEnumAccessor
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition:
enum.h:203
ns3::OkumuraHataPropagationLossModel::OkumuraHataPropagationLossModel
OkumuraHataPropagationLossModel()
Definition:
okumura-hata-propagation-loss-model.cc:66
ns3::OkumuraHataPropagationLossModel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
okumura-hata-propagation-loss-model.cc:38
okumura-hata-propagation-loss-model.h
ns3::MobilityModel::GetPosition
Vector GetPosition(void) const
Definition:
mobility-model.cc:64
src
propagation
model
okumura-hata-propagation-loss-model.cc
Generated on Fri Oct 1 2021 17:03:33 for ns-3 by
1.8.20