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
NS_OBJECT_ENSURE_REGISTERED
(Cost231PropagationLossModel);
34
35
TypeId
36
Cost231PropagationLossModel::GetTypeId
(
void
)
37
{
38
static
TypeId
tid =
TypeId
(
"ns3::Cost231PropagationLossModel"
)
39
40
.
SetParent
<
PropagationLossModel
> ()
41
42
.AddConstructor<Cost231PropagationLossModel> ()
43
44
.AddAttribute (
"Lambda"
,
45
"The wavelength (default is 2.3 GHz at 300 000 km/s)."
,
46
DoubleValue
(300000000.0 / 2.3e9),
47
MakeDoubleAccessor (&
Cost231PropagationLossModel::m_lambda
),
48
MakeDoubleChecker<double> ())
49
50
.AddAttribute (
"Frequency"
,
51
"The Frequency (default is 2.3 GHz)."
,
52
DoubleValue
(2.3e9),
53
MakeDoubleAccessor (&
Cost231PropagationLossModel::m_frequency
),
54
MakeDoubleChecker<double> ())
55
56
.AddAttribute (
"BSAntennaHeight"
,
57
" BS Antenna Height (default is 50m)."
,
58
DoubleValue
(50.0),
59
MakeDoubleAccessor (&
Cost231PropagationLossModel::m_BSAntennaHeight
),
60
MakeDoubleChecker<double> ())
61
62
.AddAttribute (
"SSAntennaHeight"
,
63
" SS Antenna Height (default is 3m)."
,
64
DoubleValue
(3),
65
MakeDoubleAccessor (&
Cost231PropagationLossModel::m_SSAntennaHeight
),
66
MakeDoubleChecker<double> ())
67
68
.AddAttribute (
"MinDistance"
,
69
"The distance under which the propagation model refuses to give results (m) "
,
70
DoubleValue
(0.5),
71
MakeDoubleAccessor (&
Cost231PropagationLossModel::SetMinDistance
, &
Cost231PropagationLossModel::GetMinDistance
),
72
MakeDoubleChecker<double> ());
73
return
tid;
74
}
75
76
Cost231PropagationLossModel::Cost231PropagationLossModel
()
77
{
78
C
= 0;
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
90
Cost231PropagationLossModel::GetShadowing
(
void
)
91
{
92
return
m_shadowing
;
93
}
94
void
95
Cost231PropagationLossModel::SetShadowing
(
double
shadowing)
96
{
97
m_shadowing
= shadowing;
98
}
99
100
void
101
Cost231PropagationLossModel::SetLambda
(
double
lambda)
102
{
103
m_lambda
= lambda;
104
m_frequency
= 300000000 / lambda;
105
}
106
107
double
108
Cost231PropagationLossModel::GetLambda
(
void
)
const
109
{
110
return
m_lambda
;
111
}
112
113
void
114
Cost231PropagationLossModel::SetMinDistance
(
double
minDistance)
115
{
116
m_minDistance
= minDistance;
117
}
118
double
119
Cost231PropagationLossModel::GetMinDistance
(
void
)
const
120
{
121
return
m_minDistance
;
122
}
123
124
void
125
Cost231PropagationLossModel::SetBSAntennaHeight
(
double
height)
126
{
127
m_BSAntennaHeight
= height;
128
}
129
130
double
131
Cost231PropagationLossModel::GetBSAntennaHeight
(
void
)
const
132
{
133
return
m_BSAntennaHeight
;
134
}
135
136
void
137
Cost231PropagationLossModel::SetSSAntennaHeight
(
double
height)
138
{
139
m_SSAntennaHeight
= height;
140
}
141
142
double
143
Cost231PropagationLossModel::GetSSAntennaHeight
(
void
)
const
144
{
145
return
m_SSAntennaHeight
;
146
}
147
148
void
149
Cost231PropagationLossModel::SetEnvironment
(
Environment
env)
150
{
151
m_environment
= env;
152
}
153
Cost231PropagationLossModel::Environment
154
Cost231PropagationLossModel::GetEnvironment
(
void
)
const
155
{
156
return
m_environment
;
157
}
158
159
double
160
Cost231PropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
161
{
162
163
double
distance = a->
GetDistanceFrom
(b);
164
if
(distance <=
m_minDistance
)
165
{
166
return
0.0;
167
}
168
169
double
log_f = std::log (
m_frequency
/ 1000000000) / 2.302;
170
double
C_H = 0.8 + ((1.11 * log_f) - 0.7) *
m_SSAntennaHeight
- (1.56 * log_f);
171
double
log_BSH = std::log (
m_BSAntennaHeight
) / 2.303;
172
173
// from the COST231 wiki entry
174
// 2.303 is for the logarithm base change
175
176
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)
177
/ 2.303) +
C
+
m_shadowing
;
178
179
NS_LOG_DEBUG
(
"dist ="
<< distance <<
", Path Loss = "
<< loss_in_db);
180
181
return
(0 - loss_in_db);
182
183
}
184
185
double
186
Cost231PropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
187
{
188
return
txPowerDbm +
GetLoss
(a, b);
189
}
190
191
int64_t
192
Cost231PropagationLossModel::DoAssignStreams
(int64_t stream)
193
{
194
return
0;
195
}
196
197
}
src
propagation
model
cost231-propagation-loss-model.cc
Generated on Tue May 14 2013 11:08:32 for ns-3 by
1.8.1.2