A Discrete-Event Network Simulator
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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Marco Miozzo <marco.miozzo@cttc.es>,
18 * Nicola Baldo <nbaldo@cttc.es>
19 *
20 */
22
23#include "ns3/double.h"
24#include "ns3/enum.h"
25#include "ns3/log.h"
26#include "ns3/mobility-model.h"
27
28#include <algorithm>
29#include <cmath>
30
31namespace ns3
32{
33
34NS_LOG_COMPONENT_DEFINE("OkumuraHataPropagationLossModel");
35
36NS_OBJECT_ENSURE_REGISTERED(OkumuraHataPropagationLossModel);
37
38TypeId
40{
41 static TypeId tid =
42 TypeId("ns3::OkumuraHataPropagationLossModel")
44 .SetGroupName("Propagation")
45 .AddConstructor<OkumuraHataPropagationLossModel>()
46 .AddAttribute("Frequency",
47 "The propagation frequency in Hz",
48 DoubleValue(2160e6),
50 MakeDoubleChecker<double>())
51 .AddAttribute(
52 "Environment",
53 "Environment Scenario",
55 MakeEnumAccessor<EnvironmentType>(&OkumuraHataPropagationLossModel::m_environment),
57 "Urban",
59 "SubUrban",
61 "OpenAreas"))
62 .AddAttribute(
63 "CitySize",
64 "Dimension of the city",
66 MakeEnumAccessor<CitySize>(&OkumuraHataPropagationLossModel::m_citySize),
67 MakeEnumChecker(SmallCity, "Small", MediumCity, "Medium", LargeCity, "Large"));
68 return tid;
69}
70
73{
74}
75
77{
78}
79
80double
82{
83 double loss = 0.0;
84 double fmhz = m_frequency / 1e6;
85 double log_fMhz = std::log10(fmhz);
86 // In the Okumura Hata literature, the distance is expressed in units of kilometers
87 // but other lengths are expressed in meters
88 double distKm = a->GetDistanceFrom(b) / 1000.0;
89
90 Vector aPosition = a->GetPosition();
91 Vector bPosition = b->GetPosition();
92
93 double hb = std::max(aPosition.z, bPosition.z);
94 double hm = std::min(aPosition.z, bPosition.z);
95
96 NS_ASSERT_MSG(hb > 0 && hm > 0, "nodes' height must be greater then 0");
97
98 double log_hb = std::log10(hb);
99 double log_aHeight = 13.82 * log_hb;
100 double log_bHeight = 0.0;
101
102 if (m_frequency <= 1.500e9)
103 {
104 // standard Okumura Hata
105 // see eq. (4.4.1) in the COST 231 final report
106
107 if (m_citySize == LargeCity)
108 {
109 if (fmhz < 200)
110 {
111 log_bHeight = 8.29 * std::pow(log10(1.54 * hm), 2) - 1.1;
112 }
113 else
114 {
115 log_bHeight = 3.2 * std::pow(log10(11.75 * hm), 2) - 4.97;
116 }
117 }
118 else
119 {
120 log_bHeight = 0.8 + (1.1 * log_fMhz - 0.7) * hm - 1.56 * log_fMhz;
121 }
122
123 NS_LOG_INFO(this << " logf " << 26.16 * log_fMhz << " loga " << log_aHeight << " X "
124 << ((44.9 - (6.55 * log_hb)) * std::log10(distKm)) << " logb "
125 << log_bHeight);
126 loss = 69.55 + (26.16 * log_fMhz) - log_aHeight +
127 ((44.9 - (6.55 * log_hb)) * std::log10(distKm)) - log_bHeight;
129 {
130 loss += -2 * (std::pow(std::log10(fmhz / 28), 2)) - 5.4;
131 }
133 {
134 loss += -4.70 * std::pow(log_fMhz, 2) + 18.33 * log_fMhz - 40.94;
135 }
136 }
137 else
138 {
139 // COST 231 Okumura model
140 // see eq. (4.4.3) in the COST 231 final report
141
142 double C = 0.0;
143
144 if (m_citySize == LargeCity)
145 {
146 log_bHeight = 3.2 * std::pow(std::log10(11.75 * hm), 2);
147 C = 3;
148 }
149 else
150 {
151 log_bHeight = (1.1 * log_fMhz - 0.7) * hm - (1.56 * log_fMhz - 0.8);
152 }
153
154 loss = 46.3 + (33.9 * log_fMhz) - log_aHeight +
155 ((44.9 - (6.55 * log_hb)) * std::log10(distKm)) - log_bHeight + C;
156 }
157 return loss;
158}
159
160double
163 Ptr<MobilityModel> b) const
164{
165 return (txPowerDbm - GetLoss(a, b));
166}
167
168int64_t
170{
171 return 0;
172}
173
174} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Hold variables of type enum.
Definition: enum.h:62
this class implements the Okumura Hata propagation loss model
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
EnvironmentType m_environment
Environment Scenario.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#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:86
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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:189