A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::Cost231PropagationLossModel")
41 
43 
44  .AddConstructor<Cost231PropagationLossModel> ()
45 
46  .AddAttribute ("Lambda",
47  "The wavelength (default is 2.3 GHz at 300 000 km/s).",
48  DoubleValue (300000000.0 / 2.3e9),
49  MakeDoubleAccessor (&Cost231PropagationLossModel::m_lambda),
50  MakeDoubleChecker<double> ())
51 
52  .AddAttribute ("Frequency",
53  "The Frequency (default is 2.3 GHz).",
54  DoubleValue (2.3e9),
55  MakeDoubleAccessor (&Cost231PropagationLossModel::m_frequency),
56  MakeDoubleChecker<double> ())
57 
58  .AddAttribute ("BSAntennaHeight",
59  " BS Antenna Height (default is 50m).",
60  DoubleValue (50.0),
62  MakeDoubleChecker<double> ())
63 
64  .AddAttribute ("SSAntennaHeight",
65  " SS Antenna Height (default is 3m).",
66  DoubleValue (3),
68  MakeDoubleChecker<double> ())
69 
70  .AddAttribute ("MinDistance",
71  "The distance under which the propagation model refuses to give results (m) ",
72  DoubleValue (0.5),
74  MakeDoubleChecker<double> ());
75  return tid;
76 }
77 
79 {
80  C = 0;
81  m_shadowing = 10;
82 }
83 
84 void
85 Cost231PropagationLossModel::SetLambda (double frequency, double speed)
86 {
87  m_lambda = speed / frequency;
88  m_frequency = frequency;
89 }
90 
91 double
93 {
94  return m_shadowing;
95 }
96 void
98 {
99  m_shadowing = shadowing;
100 }
101 
102 void
104 {
105  m_lambda = lambda;
106  m_frequency = 300000000 / lambda;
107 }
108 
109 double
111 {
112  return m_lambda;
113 }
114 
115 void
117 {
118  m_minDistance = minDistance;
119 }
120 double
122 {
123  return m_minDistance;
124 }
125 
126 void
128 {
129  m_BSAntennaHeight = height;
130 }
131 
132 double
134 {
135  return m_BSAntennaHeight;
136 }
137 
138 void
140 {
141  m_SSAntennaHeight = height;
142 }
143 
144 double
146 {
147  return m_SSAntennaHeight;
148 }
149 
150 void
152 {
153  m_environment = env;
154 }
157 {
158  return m_environment;
159 }
160 
161 double
163 {
164 
165  double distance = a->GetDistanceFrom (b);
166  if (distance <= m_minDistance)
167  {
168  return 0.0;
169  }
170 
171  double log_f = std::log (m_frequency / 1000000000) / 2.302;
172  double C_H = 0.8 + ((1.11 * log_f) - 0.7) * m_SSAntennaHeight - (1.56 * log_f);
173  double log_BSH = std::log (m_BSAntennaHeight) / 2.303;
174 
175  // from the COST231 wiki entry
176  // 2.303 is for the logarithm base change
177 
178  double loss_in_db = 46.3 + (33.9 * log_f) - (13.82 * log_BSH) - C_H + ((44.9 - 6.55 * log_BSH) * std::log (distance)
179  / 2.303) + C + m_shadowing;
180 
181  NS_LOG_DEBUG ("dist =" << distance << ", Path Loss = " << loss_in_db);
182 
183  return (0 - loss_in_db);
184 
185 }
186 
187 double
189 {
190  return txPowerDbm + GetLoss (a, b);
191 }
192 
193 int64_t
195 {
196  return 0;
197 }
198 
199 }
double GetDistanceFrom(Ptr< const MobilityModel > position) const
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
Modelize the propagation loss through a transmission medium.
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
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