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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>,
7 * Nicola Baldo <nbaldo@cttc.es>
8 *
9 */
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
20namespace ns3
21{
22
23NS_LOG_COMPONENT_DEFINE("OkumuraHataPropagationLossModel");
24
25NS_OBJECT_ENSURE_REGISTERED(OkumuraHataPropagationLossModel);
26
27TypeId
29{
30 static TypeId tid =
31 TypeId("ns3::OkumuraHataPropagationLossModel")
33 .SetGroupName("Propagation")
34 .AddConstructor<OkumuraHataPropagationLossModel>()
35 .AddAttribute("Frequency",
36 "The propagation frequency in Hz",
37 DoubleValue(2160e6),
40 .AddAttribute(
41 "Environment",
42 "Environment Scenario",
46 "Urban",
48 "SubUrban",
50 "OpenAreas"))
51 .AddAttribute(
52 "CitySize",
53 "Dimension of the city",
56 MakeEnumChecker(SmallCity, "Small", MediumCity, "Medium", LargeCity, "Large"));
57 return tid;
58}
59
64
68
69double
71{
72 double loss = 0.0;
73 double fmhz = m_frequency / 1e6;
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;
118 {
119 loss += -2 * (std::pow(std::log10(fmhz / 28), 2)) - 5.4;
120 }
122 {
123 loss += -4.70 * 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
149double
152 Ptr<MobilityModel> b) const
153{
154 return (txPowerDbm - GetLoss(a, b));
155}
156
157int64_t
159{
160 return 0;
161}
162
163} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Hold variables of type enum.
Definition enum.h:52
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.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
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
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition enum.h:221