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("Environment",
52 "Environment Scenario",
56 "Urban",
58 "SubUrban",
60 "OpenAreas"))
61 .AddAttribute(
62 "CitySize",
63 "Dimension of the city",
66 MakeEnumChecker(SmallCity, "Small", MediumCity, "Medium", LargeCity, "Large"));
67 return tid;
68}
69
72{
73}
74
76{
77}
78
79double
81{
82 double loss = 0.0;
83 double fmhz = m_frequency / 1e6;
84 double log_fMhz = std::log10(fmhz);
85 // In the Okumura Hata literature, the distance is expressed in units of kilometers
86 // but other lengths are expressed in meters
87 double distKm = a->GetDistanceFrom(b) / 1000.0;
88
89 Vector aPosition = a->GetPosition();
90 Vector bPosition = b->GetPosition();
91
92 double hb = std::max(aPosition.z, bPosition.z);
93 double hm = std::min(aPosition.z, bPosition.z);
94
95 NS_ASSERT_MSG(hb > 0 && hm > 0, "nodes' height must be greater then 0");
96
97 double log_hb = std::log10(hb);
98 double log_aHeight = 13.82 * log_hb;
99 double log_bHeight = 0.0;
100
101 if (m_frequency <= 1.500e9)
102 {
103 // standard Okumura Hata
104 // see eq. (4.4.1) in the COST 231 final report
105
106 if (m_citySize == LargeCity)
107 {
108 if (fmhz < 200)
109 {
110 log_bHeight = 8.29 * std::pow(log10(1.54 * hm), 2) - 1.1;
111 }
112 else
113 {
114 log_bHeight = 3.2 * std::pow(log10(11.75 * hm), 2) - 4.97;
115 }
116 }
117 else
118 {
119 log_bHeight = 0.8 + (1.1 * log_fMhz - 0.7) * hm - 1.56 * log_fMhz;
120 }
121
122 NS_LOG_INFO(this << " logf " << 26.16 * log_fMhz << " loga " << log_aHeight << " X "
123 << ((44.9 - (6.55 * log_hb)) * std::log10(distKm)) << " logb "
124 << log_bHeight);
125 loss = 69.55 + (26.16 * log_fMhz) - log_aHeight +
126 ((44.9 - (6.55 * log_hb)) * std::log10(distKm)) - log_bHeight;
128 {
129 loss += -2 * (std::pow(std::log10(fmhz / 28), 2)) - 5.4;
130 }
132 {
133 loss += -4.70 * std::pow(log_fMhz, 2) + 18.33 * log_fMhz - 40.94;
134 }
135 }
136 else
137 {
138 // COST 231 Okumura model
139 // see eq. (4.4.3) in the COST 231 final report
140
141 double C = 0.0;
142
143 if (m_citySize == LargeCity)
144 {
145 log_bHeight = 3.2 * std::pow(std::log10(11.75 * hm), 2);
146 C = 3;
147 }
148 else
149 {
150 log_bHeight = (1.1 * log_fMhz - 0.7) * hm - (1.56 * log_fMhz - 0.8);
151 }
152
153 loss = 46.3 + (33.9 * log_fMhz) - log_aHeight +
154 ((44.9 - (6.55 * log_hb)) * std::log10(distKm)) - log_bHeight + C;
155 }
156 return loss;
157}
158
159double
162 Ptr<MobilityModel> b) const
163{
164 return (txPowerDbm - GetLoss(a, b));
165}
166
167int64_t
169{
170 return 0;
171}
172
173} // 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:56
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:78
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:930
#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
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:205
#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(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:163