A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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>
28
#include "
cost231-propagation-loss-model.h
"
29
30
namespace
ns3 {
31
32
NS_LOG_COMPONENT_DEFINE
(
"Cost231PropagationLossModel"
)
33
;
34
NS_OBJECT_ENSURE_REGISTERED
(Cost231PropagationLossModel)
35
;
36
37
TypeId
38
Cost231PropagationLossModel::GetTypeId
(
void
)
39
{
40
static
TypeId
tid =
TypeId
(
"ns3::Cost231PropagationLossModel"
)
41
42
.
SetParent
<
PropagationLossModel
> ()
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),
61
MakeDoubleAccessor (&
Cost231PropagationLossModel::m_BSAntennaHeight
),
62
MakeDoubleChecker<double> ())
63
64
.AddAttribute (
"SSAntennaHeight"
,
65
" SS Antenna Height (default is 3m)."
,
66
DoubleValue
(3),
67
MakeDoubleAccessor (&
Cost231PropagationLossModel::m_SSAntennaHeight
),
68
MakeDoubleChecker<double> ())
69
70
.AddAttribute (
"MinDistance"
,
71
"The distance under which the propagation model refuses to give results (m) "
,
72
DoubleValue
(0.5),
73
MakeDoubleAccessor (&
Cost231PropagationLossModel::SetMinDistance
, &
Cost231PropagationLossModel::GetMinDistance
),
74
MakeDoubleChecker<double> ());
75
return
tid;
76
}
77
78
Cost231PropagationLossModel::Cost231PropagationLossModel
()
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
92
Cost231PropagationLossModel::GetShadowing
(
void
)
93
{
94
return
m_shadowing
;
95
}
96
void
97
Cost231PropagationLossModel::SetShadowing
(
double
shadowing)
98
{
99
m_shadowing
= shadowing;
100
}
101
102
void
103
Cost231PropagationLossModel::SetLambda
(
double
lambda)
104
{
105
m_lambda
= lambda;
106
m_frequency
= 300000000 / lambda;
107
}
108
109
double
110
Cost231PropagationLossModel::GetLambda
(
void
)
const
111
{
112
return
m_lambda
;
113
}
114
115
void
116
Cost231PropagationLossModel::SetMinDistance
(
double
minDistance)
117
{
118
m_minDistance
= minDistance;
119
}
120
double
121
Cost231PropagationLossModel::GetMinDistance
(
void
)
const
122
{
123
return
m_minDistance
;
124
}
125
126
void
127
Cost231PropagationLossModel::SetBSAntennaHeight
(
double
height)
128
{
129
m_BSAntennaHeight
= height;
130
}
131
132
double
133
Cost231PropagationLossModel::GetBSAntennaHeight
(
void
)
const
134
{
135
return
m_BSAntennaHeight
;
136
}
137
138
void
139
Cost231PropagationLossModel::SetSSAntennaHeight
(
double
height)
140
{
141
m_SSAntennaHeight
= height;
142
}
143
144
double
145
Cost231PropagationLossModel::GetSSAntennaHeight
(
void
)
const
146
{
147
return
m_SSAntennaHeight
;
148
}
149
150
void
151
Cost231PropagationLossModel::SetEnvironment
(
Environment
env)
152
{
153
m_environment
= env;
154
}
155
Cost231PropagationLossModel::Environment
156
Cost231PropagationLossModel::GetEnvironment
(
void
)
const
157
{
158
return
m_environment
;
159
}
160
161
double
162
Cost231PropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
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
188
Cost231PropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
189
{
190
return
txPowerDbm +
GetLoss
(a, b);
191
}
192
193
int64_t
194
Cost231PropagationLossModel::DoAssignStreams
(int64_t stream)
195
{
196
return
0;
197
}
198
199
}
ns3::Cost231PropagationLossModel::GetMinDistance
double GetMinDistance(void) const
Definition:
cost231-propagation-loss-model.cc:121
ns3::Ptr< MobilityModel >
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition:
mobility-model.cc:80
ns3::NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
ns3::Cost231PropagationLossModel::Cost231PropagationLossModel
Cost231PropagationLossModel()
Definition:
cost231-propagation-loss-model.cc:78
ns3::Cost231PropagationLossModel::SetShadowing
void SetShadowing(double shadowing)
Definition:
cost231-propagation-loss-model.cc:97
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
ns3::Cost231PropagationLossModel::GetEnvironment
Environment GetEnvironment(void) const
Definition:
cost231-propagation-loss-model.cc:156
ns3::Cost231PropagationLossModel::DoCalcRxPower
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
cost231-propagation-loss-model.cc:188
ns3::Cost231PropagationLossModel::GetTypeId
static TypeId GetTypeId(void)
Definition:
cost231-propagation-loss-model.cc:38
ns3::Cost231PropagationLossModel::m_environment
Environment m_environment
Definition:
cost231-propagation-loss-model.h:87
ns3::Cost231PropagationLossModel::SetEnvironment
void SetEnvironment(Environment env)
Definition:
cost231-propagation-loss-model.cc:151
cost231-propagation-loss-model.h
ns3::Cost231PropagationLossModel::m_SSAntennaHeight
double m_SSAntennaHeight
Definition:
cost231-propagation-loss-model.h:84
ns3::Cost231PropagationLossModel::GetBSAntennaHeight
double GetBSAntennaHeight(void) const
Definition:
cost231-propagation-loss-model.cc:133
ns3::Cost231PropagationLossModel::m_minDistance
double m_minDistance
Definition:
cost231-propagation-loss-model.h:88
ns3::Cost231PropagationLossModel::DoAssignStreams
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
Definition:
cost231-propagation-loss-model.cc:194
ns3::Cost231PropagationLossModel::GetShadowing
double GetShadowing(void)
Definition:
cost231-propagation-loss-model.cc:92
ns3::Cost231PropagationLossModel::C
double C
Definition:
cost231-propagation-loss-model.h:85
ns3::Cost231PropagationLossModel::m_shadowing
double m_shadowing
Definition:
cost231-propagation-loss-model.h:90
ns3::Cost231PropagationLossModel::m_lambda
double m_lambda
Definition:
cost231-propagation-loss-model.h:86
ns3::Cost231PropagationLossModel::SetBSAntennaHeight
void SetBSAntennaHeight(double height)
Definition:
cost231-propagation-loss-model.cc:127
ns3::Cost231PropagationLossModel::SetSSAntennaHeight
void SetSSAntennaHeight(double height)
Definition:
cost231-propagation-loss-model.cc:139
ns3::Cost231PropagationLossModel::SetMinDistance
void SetMinDistance(double minDistance)
Definition:
cost231-propagation-loss-model.cc:116
ns3::PropagationLossModel
Modelize the propagation loss through a transmission medium.
Definition:
propagation-loss-model.h:49
ns3::Cost231PropagationLossModel::GetSSAntennaHeight
double GetSSAntennaHeight(void) const
Definition:
cost231-propagation-loss-model.cc:145
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Definition:
log.h:289
ns3::Cost231PropagationLossModel::m_frequency
double m_frequency
Definition:
cost231-propagation-loss-model.h:89
ns3::Cost231PropagationLossModel::SetLambda
void SetLambda(double lambda)
Definition:
cost231-propagation-loss-model.cc:103
ns3::Cost231PropagationLossModel::m_BSAntennaHeight
double m_BSAntennaHeight
Definition:
cost231-propagation-loss-model.h:83
ns3::Cost231PropagationLossModel::Environment
Environment
Definition:
cost231-propagation-loss-model.h:56
ns3::Cost231PropagationLossModel::GetLambda
double GetLambda(void) const
Definition:
cost231-propagation-loss-model.cc:110
ns3::Cost231PropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
cost231-propagation-loss-model.cc:162
ns3::DoubleValue
Hold a floating point type.
Definition:
double.h:41
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
src
propagation
model
cost231-propagation-loss-model.cc
Generated on Sat Apr 19 2014 14:07:07 for ns-3 by
1.8.6