A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
29 
30 NS_LOG_COMPONENT_DEFINE ("OkumuraHataPropagationLossModel");
31 
32 namespace ns3 {
33 
34 NS_OBJECT_ENSURE_REGISTERED (OkumuraHataPropagationLossModel)
35  ;
36 
37 
38 TypeId
40 {
41  static TypeId tid = TypeId ("ns3::OkumuraHataPropagationLossModel")
42 
44 
45  .AddAttribute ("Frequency",
46  "The propagation frequency in Hz",
47  DoubleValue (2160e6),
49  MakeDoubleChecker<double> ())
50 
51  .AddAttribute ("Environment",
52  "Environment Scenario",
56  SubUrbanEnvironment, "SubUrban",
57  OpenAreasEnvironment, "OpenAreas"))
58 
59  .AddAttribute ("CitySize",
60  "Dimension of the city",
63  MakeEnumChecker (SmallCity, "Small",
64  MediumCity, "Medium",
65  LargeCity, "Large"));
66 
67  return tid;
68 }
69 
70 double
72 {
73  double loss = 0.0;
74  double fmhz = m_frequency / 1e6;
75  double dist = a->GetDistanceFrom (b) / 1000.0;
76  if (m_frequency <= 1.500e9)
77  {
78  // standard Okumura Hata
79  // see eq. (4.4.1) in the COST 231 final report
80  double log_f = std::log10 (fmhz);
81  double hb = (a->GetPosition ().z > b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
82  double hm = (a->GetPosition ().z < b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
83  NS_ASSERT_MSG (hb > 0 && hm > 0, "nodes' height must be greater then 0");
84  double log_aHeight = 13.82 * std::log10 (hb);
85  double log_bHeight = 0.0;
86  if (m_citySize == LargeCity)
87  {
88  if (fmhz < 200)
89  {
90  log_bHeight = 8.29 * std::pow (log10 (1.54 * hm), 2) - 1.1;
91  }
92  else
93  {
94  log_bHeight = 3.2 * std::pow (log10 (11.75 * hm), 2) - 4.97;
95  }
96  }
97  else
98  {
99  log_bHeight = 0.8 + (1.1 * log_f - 0.7) * hm - 1.56 * log_f;
100  }
101 
102  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);
103  loss = 69.55 + (26.16 * log_f) - log_aHeight + (((44.9 - (6.55 * std::log10 (hb)) )) * std::log10 (dist)) - log_bHeight;
105  {
106  loss += -2 * (std::pow (std::log10 (fmhz / 28), 2)) - 5.4;
107  }
109  {
110  loss += -4.70 * std::pow (std::log10 (fmhz),2) + 18.33 * std::log10 (fmhz) - 40.94;
111  }
112 
113  }
114  else
115  {
116  // COST 231 Okumura model
117  // see eq. (4.4.3) in the COST 231 final report
118 
119  double log_f = std::log10 (fmhz);
120  double hb = (a->GetPosition ().z > b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
121  double hm = (a->GetPosition ().z < b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
122  NS_ASSERT_MSG (hb > 0 && hm > 0, "nodes' height must be greater then 0");
123  double log_aHeight = 13.82 * std::log10 (hb);
124  double log_bHeight = 0.0;
125  double C = 0.0;
126 
127  if (m_citySize == LargeCity)
128  {
129  log_bHeight = 3.2 * std::pow ((std::log10 (11.75 * hm)), 2);
130  C = 3;
131  }
132  else
133  {
134  log_bHeight = 1.1 * log_f - 0.7 * hm - (1.56 * log_f - 0.8);
135  }
136 
137  loss = 46.3 + (33.9 * log_f) - log_aHeight + (((44.9 - (6.55 * std::log10 (hb)) )) * std::log10 (dist)) - log_bHeight + C;
138  }
139  return loss;
140 }
141 
142 double
145  Ptr<MobilityModel> b) const
146 {
147  return (txPowerDbm - GetLoss (a, b));
148 }
149 
150 int64_t
152 {
153  return 0;
154 }
155 
156 
157 } // namespace ns3
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Definition: enum.cc:178
double GetDistanceFrom(Ptr< const MobilityModel > position) const
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Vector GetPosition(void) const
#define NS_LOG_INFO(msg)
Definition: log.h:298
NS_LOG_COMPONENT_DEFINE("OkumuraHataPropagationLossModel")
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
hold variables of type 'enum'
Definition: enum.h:37
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:118
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
Modelize the propagation loss through a transmission medium.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
Hold a floating point type.
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
double z
z coordinate of vector
Definition: vector.h:57