A Discrete-Event Network Simulator
API
cost231-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) 2007,2008, 2009 INRIA, UDcast
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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  * <amine.ismail@udcast.com>
20  */
21 
22 #include "ns3/propagation-loss-model.h"
23 #include "ns3/log.h"
24 #include "ns3/mobility-model.h"
25 #include "ns3/double.h"
26 #include "ns3/pointer.h"
27 #include <cmath>
29 
30 namespace ns3 {
31 
32 NS_LOG_COMPONENT_DEFINE ("Cost231PropagationLossModel");
33 
34 NS_OBJECT_ENSURE_REGISTERED (Cost231PropagationLossModel);
35 
36 TypeId
38 {
39  static TypeId tid = TypeId ("ns3::Cost231PropagationLossModel")
41  .SetGroupName ("Propagation")
42  .AddConstructor<Cost231PropagationLossModel> ()
43  .AddAttribute ("Lambda",
44  "The wavelength (default is 2.3 GHz at 300 000 km/s).",
45  DoubleValue (300000000.0 / 2.3e9),
47  MakeDoubleChecker<double> ())
48  .AddAttribute ("Frequency",
49  "The Frequency (default is 2.3 GHz).",
50  DoubleValue (2.3e9),
52  MakeDoubleChecker<double> ())
53  .AddAttribute ("BSAntennaHeight",
54  "BS Antenna Height (default is 50m).",
55  DoubleValue (50.0),
57  MakeDoubleChecker<double> ())
58  .AddAttribute ("SSAntennaHeight",
59  "SS Antenna Height (default is 3m).",
60  DoubleValue (3),
62  MakeDoubleChecker<double> ())
63  .AddAttribute ("MinDistance",
64  "The distance under which the propagation model refuses to give results (m) ",
65  DoubleValue (0.5),
67  MakeDoubleChecker<double> ());
68  return tid;
69 }
70 
72 {
73  m_shadowing = 10;
74 }
75 
76 void
77 Cost231PropagationLossModel::SetLambda (double frequency, double speed)
78 {
79  m_lambda = speed / frequency;
80  m_frequency = frequency;
81 }
82 
83 double
85 {
86  return m_shadowing;
87 }
88 void
90 {
91  m_shadowing = shadowing;
92 }
93 
94 void
96 {
97  m_lambda = lambda;
98  m_frequency = 300000000 / lambda;
99 }
100 
101 double
103 {
104  return m_lambda;
105 }
106 
107 void
109 {
110  m_minDistance = minDistance;
111 }
112 double
114 {
115  return m_minDistance;
116 }
117 
118 void
120 {
121  m_BSAntennaHeight = height;
122 }
123 
124 double
126 {
127  return m_BSAntennaHeight;
128 }
129 
130 void
132 {
133  m_SSAntennaHeight = height;
134 }
135 
136 double
138 {
139  return m_SSAntennaHeight;
140 }
141 
142 double
144 {
145 
146  double distance = a->GetDistanceFrom (b);
147  if (distance <= m_minDistance)
148  {
149  return 0.0;
150  }
151 
152  double frequency_MHz = m_frequency * 1e-6;
153 
154  double distance_km = distance * 1e-3;
155 
156  double C_H = 0.8 + ((1.11 * std::log10(frequency_MHz)) - 0.7) * m_SSAntennaHeight - (1.56 * std::log10(frequency_MHz));
157 
158  // from the COST231 wiki entry
159  // See also http://www.lx.it.pt/cost231/final_report.htm
160  // Ch. 4, eq. 4.4.3, pg. 135
161 
162  double loss_in_db = 46.3 + (33.9 * std::log10(frequency_MHz)) - (13.82 * std::log10 (m_BSAntennaHeight)) - C_H
163  + ((44.9 - 6.55 * std::log10 (m_BSAntennaHeight)) * std::log10 (distance_km)) + m_shadowing;
164 
165  NS_LOG_DEBUG ("dist =" << distance << ", Path Loss = " << loss_in_db);
166 
167  return (0 - loss_in_db);
168 
169 }
170 
171 double
173 {
174  return txPowerDbm + GetLoss (a, b);
175 }
176 
177 int64_t
179 {
180  return 0;
181 }
182 
183 }
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
ns3::Cost231PropagationLossModel::m_minDistance
double m_minDistance
minimum distance [m]
Definition: cost231-propagation-loss-model.h:147
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ns3::Cost231PropagationLossModel::GetMinDistance
double GetMinDistance(void) const
Get the minimum model distance.
Definition: cost231-propagation-loss-model.cc:113
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Cost231PropagationLossModel::m_lambda
double m_lambda
The wavelength.
Definition: cost231-propagation-loss-model.h:146
ns3::Cost231PropagationLossModel::DoAssignStreams
int64_t DoAssignStreams(int64_t stream) override
Subclasses must implement this; those not using random variables can return zero.
Definition: cost231-propagation-loss-model.cc:178
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition: mobility-model.cc:94
ns3::Cost231PropagationLossModel::SetSSAntennaHeight
void SetSSAntennaHeight(double height)
Set the SS antenna height.
Definition: cost231-propagation-loss-model.cc:131
cost231-propagation-loss-model.h
ns3::PropagationLossModel
Models the propagation loss through a transmission medium.
Definition: propagation-loss-model.h:50
ns3::Cost231PropagationLossModel::m_frequency
double m_frequency
frequency [Hz]
Definition: cost231-propagation-loss-model.h:148
ns3::Cost231PropagationLossModel::GetShadowing
double GetShadowing(void)
Get the shadowing value.
Definition: cost231-propagation-loss-model.cc:84
ns3::Cost231PropagationLossModel::SetBSAntennaHeight
void SetBSAntennaHeight(double height)
Set the BS antenna height.
Definition: cost231-propagation-loss-model.cc:119
ns3::Cost231PropagationLossModel::SetMinDistance
void SetMinDistance(double minDistance)
Set the minimum model distance.
Definition: cost231-propagation-loss-model.cc:108
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::Ptr< MobilityModel >
ns3::Cost231PropagationLossModel::SetShadowing
void SetShadowing(double shadowing)
Set the shadowing value.
Definition: cost231-propagation-loss-model.cc:89
ns3::Cost231PropagationLossModel::m_SSAntennaHeight
double m_SSAntennaHeight
SS Antenna Height [m].
Definition: cost231-propagation-loss-model.h:145
ns3::Cost231PropagationLossModel::Cost231PropagationLossModel
Cost231PropagationLossModel()
Definition: cost231-propagation-loss-model.cc:71
ns3::Cost231PropagationLossModel::m_BSAntennaHeight
double m_BSAntennaHeight
BS Antenna Height [m].
Definition: cost231-propagation-loss-model.h:144
ns3::Cost231PropagationLossModel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: cost231-propagation-loss-model.cc:37
ns3::Cost231PropagationLossModel::GetBSAntennaHeight
double GetBSAntennaHeight(void) const
Get the BS antenna height.
Definition: cost231-propagation-loss-model.cc:125
ns3::Cost231PropagationLossModel::GetLambda
double GetLambda(void) const
Get the wavelength.
Definition: cost231-propagation-loss-model.cc:102
ns3::Cost231PropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Get the propagation loss.
Definition: cost231-propagation-loss-model.cc:143
ns3::Cost231PropagationLossModel::GetSSAntennaHeight
double GetSSAntennaHeight(void) const
Get the SS antenna height.
Definition: cost231-propagation-loss-model.cc:137
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::Cost231PropagationLossModel::DoCalcRxPower
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Returns the Rx Power taking into account only the particular PropagationLossModel.
Definition: cost231-propagation-loss-model.cc:172
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ns3::Cost231PropagationLossModel::SetLambda
void SetLambda(double lambda)
Set the wavelength.
Definition: cost231-propagation-loss-model.cc:95
ns3::Cost231PropagationLossModel::m_shadowing
double m_shadowing
Shadowing loss [dB].
Definition: cost231-propagation-loss-model.h:149
ns3::Cost231PropagationLossModel
The COST-Hata-Model is the most often cited of the COST 231 models.
Definition: cost231-propagation-loss-model.h:51