A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
cost231-propagation-loss-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18 * <amine.ismail@udcast.com>
19 */
20
22
24
25#include "ns3/double.h"
26#include "ns3/log.h"
27#include "ns3/mobility-model.h"
28#include "ns3/pointer.h"
29
30#include <cmath>
31
32namespace ns3
33{
34
35NS_LOG_COMPONENT_DEFINE("Cost231PropagationLossModel");
36
37NS_OBJECT_ENSURE_REGISTERED(Cost231PropagationLossModel);
38
39TypeId
41{
42 static TypeId tid =
43 TypeId("ns3::Cost231PropagationLossModel")
45 .SetGroupName("Propagation")
46 .AddConstructor<Cost231PropagationLossModel>()
47 .AddAttribute("Lambda",
48 "The wavelength (default is 2.3 GHz at 300 000 km/s).",
49 DoubleValue(300000000.0 / 2.3e9),
51 MakeDoubleChecker<double>())
52 .AddAttribute("Frequency",
53 "The Frequency (default is 2.3 GHz).",
54 DoubleValue(2.3e9),
56 MakeDoubleChecker<double>())
57 .AddAttribute("BSAntennaHeight",
58 "BS Antenna Height (default is 50m).",
59 DoubleValue(50.0),
61 MakeDoubleChecker<double>())
62 .AddAttribute("SSAntennaHeight",
63 "SS Antenna Height (default is 3m).",
64 DoubleValue(3),
66 MakeDoubleChecker<double>())
67 .AddAttribute(
68 "MinDistance",
69 "The distance under which the propagation model refuses to give results (m).",
70 DoubleValue(0.5),
73 MakeDoubleChecker<double>());
74 return tid;
75}
76
78{
79 m_shadowing = 10;
80}
81
82void
83Cost231PropagationLossModel::SetLambda(double frequency, double speed)
84{
85 m_lambda = speed / frequency;
86 m_frequency = frequency;
87}
88
89double
91{
92 return m_shadowing;
93}
94
95void
97{
98 m_shadowing = shadowing;
99}
100
101void
103{
104 m_lambda = lambda;
105 m_frequency = 300000000 / lambda;
106}
107
108double
110{
111 return m_lambda;
112}
113
114void
116{
117 m_minDistance = minDistance;
118}
119
120double
122{
123 return m_minDistance;
124}
125
126void
128{
129 m_BSAntennaHeight = height;
130}
131
132double
134{
135 return m_BSAntennaHeight;
136}
137
138void
140{
141 m_SSAntennaHeight = height;
142}
143
144double
146{
147 return m_SSAntennaHeight;
148}
149
150double
152{
153 double distance = a->GetDistanceFrom(b);
154 if (distance <= m_minDistance)
155 {
156 return 0.0;
157 }
158
159 double logFrequencyMhz = std::log10(m_frequency * 1e-6);
160 double logDistanceKm = std::log10(distance * 1e-3);
161 double logBSAntennaHeight = std::log10(m_BSAntennaHeight);
162
163 double C_H =
164 0.8 + ((1.11 * logFrequencyMhz) - 0.7) * m_SSAntennaHeight - (1.56 * logFrequencyMhz);
165
166 // from the COST231 wiki entry
167 // See also http://www.lx.it.pt/cost231/final_report.htm
168 // Ch. 4, eq. 4.4.3, pg. 135
169
170 double loss_in_db = 46.3 + (33.9 * logFrequencyMhz) - (13.82 * logBSAntennaHeight) - C_H +
171 ((44.9 - 6.55 * logBSAntennaHeight) * logDistanceKm) + m_shadowing;
172
173 NS_LOG_DEBUG("dist =" << distance << ", Path Loss = " << loss_in_db);
174
175 return (0 - loss_in_db);
176}
177
178double
181 Ptr<MobilityModel> b) const
182{
183 return txPowerDbm + GetLoss(a, b);
184}
185
186int64_t
188{
189 return 0;
190}
191
192} // namespace ns3
The COST-Hata-Model is the most often cited of the COST 231 models.
double GetShadowing() const
Get the shadowing value.
void SetShadowing(double shadowing)
Set the shadowing value.
double m_SSAntennaHeight
SS Antenna Height [m].
double GetLambda() const
Get the wavelength.
void SetBSAntennaHeight(double height)
Set the BS antenna height.
static TypeId GetTypeId()
Get the type ID.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double GetBSAntennaHeight() const
Get the BS antenna height.
double GetSSAntennaHeight() const
Get the SS antenna height.
double GetMinDistance() const
Get the minimum model distance.
void SetSSAntennaHeight(double height)
Set the SS antenna height.
void SetLambda(double lambda)
Set the wavelength.
void SetMinDistance(double minDistance)
Set the minimum model distance.
double m_BSAntennaHeight
BS Antenna Height [m].
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Get the propagation loss.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
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
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_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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.