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")
40 
42 
43  .AddConstructor<Cost231PropagationLossModel> ()
44 
45  .AddAttribute ("Lambda",
46  "The wavelength (default is 2.3 GHz at 300 000 km/s).",
47  DoubleValue (300000000.0 / 2.3e9),
49  MakeDoubleChecker<double> ())
50 
51  .AddAttribute ("Frequency",
52  "The Frequency (default is 2.3 GHz).",
53  DoubleValue (2.3e9),
55  MakeDoubleChecker<double> ())
56 
57  .AddAttribute ("BSAntennaHeight",
58  "BS Antenna Height (default is 50m).",
59  DoubleValue (50.0),
61  MakeDoubleChecker<double> ())
62 
63  .AddAttribute ("SSAntennaHeight",
64  "SS Antenna Height (default is 3m).",
65  DoubleValue (3),
67  MakeDoubleChecker<double> ())
68 
69  .AddAttribute ("MinDistance",
70  "The distance under which the propagation model refuses to give results (m) ",
71  DoubleValue (0.5),
73  MakeDoubleChecker<double> ());
74  return tid;
75 }
76 
78 {
79  m_shadowing = 10;
80 }
81 
82 void
83 Cost231PropagationLossModel::SetLambda (double frequency, double speed)
84 {
85  m_lambda = speed / frequency;
86  m_frequency = frequency;
87 }
88 
89 double
91 {
92  return m_shadowing;
93 }
94 void
96 {
97  m_shadowing = shadowing;
98 }
99 
100 void
102 {
103  m_lambda = lambda;
104  m_frequency = 300000000 / lambda;
105 }
106 
107 double
109 {
110  return m_lambda;
111 }
112 
113 void
115 {
116  m_minDistance = minDistance;
117 }
118 double
120 {
121  return m_minDistance;
122 }
123 
124 void
126 {
127  m_BSAntennaHeight = height;
128 }
129 
130 double
132 {
133  return m_BSAntennaHeight;
134 }
135 
136 void
138 {
139  m_SSAntennaHeight = height;
140 }
141 
142 double
144 {
145  return m_SSAntennaHeight;
146 }
147 
148 double
150 {
151 
152  double distance = a->GetDistanceFrom (b);
153  if (distance <= m_minDistance)
154  {
155  return 0.0;
156  }
157 
158  double frequency_MHz = m_frequency * 1e-6;
159 
160  double distance_km = distance * 1e-3;
161 
162  double C_H = 0.8 + ((1.11 * std::log10(frequency_MHz)) - 0.7) * m_SSAntennaHeight - (1.56 * std::log10(frequency_MHz));
163 
164  // from the COST231 wiki entry
165  // See also http://www.lx.it.pt/cost231/final_report.htm
166  // Ch. 4, eq. 4.4.3, pg. 135
167 
168  double loss_in_db = 46.3 + (33.9 * std::log10(frequency_MHz)) - (13.82 * std::log10 (m_BSAntennaHeight)) - C_H
169  + ((44.9 - 6.55 * std::log10 (m_BSAntennaHeight)) * std::log10 (distance_km)) + m_shadowing;
170 
171  NS_LOG_DEBUG ("dist =" << distance << ", Path Loss = " << loss_in_db);
172 
173  return (0 - loss_in_db);
174 
175 }
176 
177 double
179 {
180  return txPowerDbm + GetLoss (a, b);
181 }
182 
183 int64_t
185 {
186  return 0;
187 }
188 
189 }
double GetMinDistance(void) const
Get the minimum model distance.
double GetDistanceFrom(Ptr< const MobilityModel > position) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
void SetShadowing(double shadowing)
Set the shadowing value.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagatinLossModel. ...
static TypeId GetTypeId(void)
Get the type ID.
double m_SSAntennaHeight
SS Antenna Height [m].
double GetBSAntennaHeight(void) const
Get the BS antenna height.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
double GetShadowing(void)
Get the shadowing value.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetBSAntennaHeight(double height)
Set the BS antenna height.
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
void SetSSAntennaHeight(double height)
Set the SS antenna height.
void SetMinDistance(double minDistance)
Set the minimum model distance.
Models the propagation loss through a transmission medium.
double GetSSAntennaHeight(void) const
Get the SS antenna height.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
void SetLambda(double lambda)
Set the wavelength.
double m_BSAntennaHeight
BS Antenna Height [m].
double GetLambda(void) const
Get the wavelength.
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Get the propagation loss.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:51
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631