A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7
* <amine.ismail@udcast.com>
8
*/
9
10
#include "
cost231-propagation-loss-model.h
"
11
12
#include "
propagation-loss-model.h
"
13
14
#include "ns3/double.h"
15
#include "ns3/log.h"
16
#include "ns3/mobility-model.h"
17
#include "ns3/pointer.h"
18
19
#include <cmath>
20
21
namespace
ns3
22
{
23
24
NS_LOG_COMPONENT_DEFINE
(
"Cost231PropagationLossModel"
);
25
26
NS_OBJECT_ENSURE_REGISTERED
(Cost231PropagationLossModel);
27
28
TypeId
29
Cost231PropagationLossModel::GetTypeId
()
30
{
31
static
TypeId
tid =
32
TypeId
(
"ns3::Cost231PropagationLossModel"
)
33
.
SetParent
<
PropagationLossModel
>()
34
.SetGroupName(
"Propagation"
)
35
.AddConstructor<
Cost231PropagationLossModel
>()
36
.AddAttribute(
"Lambda"
,
37
"The wavelength (default is 2.3 GHz at 300 000 km/s)."
,
38
DoubleValue
(300000000.0 / 2.3e9),
39
MakeDoubleAccessor
(&
Cost231PropagationLossModel::m_lambda
),
40
MakeDoubleChecker<double>
())
41
.AddAttribute(
"Frequency"
,
42
"The Frequency (default is 2.3 GHz)."
,
43
DoubleValue
(2.3e9),
44
MakeDoubleAccessor
(&
Cost231PropagationLossModel::m_frequency
),
45
MakeDoubleChecker<double>
())
46
.AddAttribute(
"BSAntennaHeight"
,
47
"BS Antenna Height (default is 50m)."
,
48
DoubleValue
(50.0),
49
MakeDoubleAccessor
(&
Cost231PropagationLossModel::m_BSAntennaHeight
),
50
MakeDoubleChecker<double>
())
51
.AddAttribute(
"SSAntennaHeight"
,
52
"SS Antenna Height (default is 3m)."
,
53
DoubleValue
(3),
54
MakeDoubleAccessor
(&
Cost231PropagationLossModel::m_SSAntennaHeight
),
55
MakeDoubleChecker<double>
())
56
.AddAttribute(
57
"MinDistance"
,
58
"The distance under which the propagation model refuses to give results (m)."
,
59
DoubleValue
(0.5),
60
MakeDoubleAccessor
(&
Cost231PropagationLossModel::SetMinDistance
,
61
&
Cost231PropagationLossModel::GetMinDistance
),
62
MakeDoubleChecker<double>
());
63
return
tid;
64
}
65
66
Cost231PropagationLossModel::Cost231PropagationLossModel
()
67
{
68
m_shadowing
= 10;
69
}
70
71
void
72
Cost231PropagationLossModel::SetLambda
(
double
frequency,
double
speed)
73
{
74
m_lambda
= speed / frequency;
75
m_frequency
= frequency;
76
}
77
78
double
79
Cost231PropagationLossModel::GetShadowing
()
const
80
{
81
return
m_shadowing
;
82
}
83
84
void
85
Cost231PropagationLossModel::SetShadowing
(
double
shadowing)
86
{
87
m_shadowing
= shadowing;
88
}
89
90
void
91
Cost231PropagationLossModel::SetLambda
(
double
lambda)
92
{
93
m_lambda
= lambda;
94
m_frequency
= 300000000 / lambda;
95
}
96
97
double
98
Cost231PropagationLossModel::GetLambda
()
const
99
{
100
return
m_lambda
;
101
}
102
103
void
104
Cost231PropagationLossModel::SetMinDistance
(
double
minDistance)
105
{
106
m_minDistance
= minDistance;
107
}
108
109
double
110
Cost231PropagationLossModel::GetMinDistance
()
const
111
{
112
return
m_minDistance
;
113
}
114
115
void
116
Cost231PropagationLossModel::SetBSAntennaHeight
(
double
height)
117
{
118
m_BSAntennaHeight
= height;
119
}
120
121
double
122
Cost231PropagationLossModel::GetBSAntennaHeight
()
const
123
{
124
return
m_BSAntennaHeight
;
125
}
126
127
void
128
Cost231PropagationLossModel::SetSSAntennaHeight
(
double
height)
129
{
130
m_SSAntennaHeight
= height;
131
}
132
133
double
134
Cost231PropagationLossModel::GetSSAntennaHeight
()
const
135
{
136
return
m_SSAntennaHeight
;
137
}
138
139
double
140
Cost231PropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
141
{
142
double
distance = a->GetDistanceFrom(b);
143
if
(distance <=
m_minDistance
)
144
{
145
return
0.0;
146
}
147
148
double
logFrequencyMhz = std::log10(
m_frequency
* 1e-6);
149
double
logDistanceKm = std::log10(distance * 1e-3);
150
double
logBSAntennaHeight = std::log10(
m_BSAntennaHeight
);
151
152
double
C_H =
153
0.8 + ((1.11 * logFrequencyMhz) - 0.7) *
m_SSAntennaHeight
- (1.56 * logFrequencyMhz);
154
155
// from the COST231 wiki entry
156
// See also http://www.lx.it.pt/cost231/final_report.htm
157
// Ch. 4, eq. 4.4.3, pg. 135
158
159
double
loss_in_db = 46.3 + (33.9 * logFrequencyMhz) - (13.82 * logBSAntennaHeight) - C_H +
160
((44.9 - 6.55 * logBSAntennaHeight) * logDistanceKm) +
m_shadowing
;
161
162
NS_LOG_DEBUG
(
"dist ="
<< distance <<
", Path Loss = "
<< loss_in_db);
163
164
return
(0 - loss_in_db);
165
}
166
167
double
168
Cost231PropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
169
Ptr<MobilityModel>
a,
170
Ptr<MobilityModel>
b)
const
171
{
172
return
txPowerDbm +
GetLoss
(a, b);
173
}
174
175
int64_t
176
Cost231PropagationLossModel::DoAssignStreams
(int64_t stream)
177
{
178
return
0;
179
}
180
181
}
// namespace ns3
ns3::Cost231PropagationLossModel
The COST-Hata-Model is the most often cited of the COST 231 models.
Definition
cost231-propagation-loss-model.h:41
ns3::Cost231PropagationLossModel::GetShadowing
double GetShadowing() const
Get the shadowing value.
Definition
cost231-propagation-loss-model.cc:79
ns3::Cost231PropagationLossModel::SetShadowing
void SetShadowing(double shadowing)
Set the shadowing value.
Definition
cost231-propagation-loss-model.cc:85
ns3::Cost231PropagationLossModel::m_SSAntennaHeight
double m_SSAntennaHeight
SS Antenna Height [m].
Definition
cost231-propagation-loss-model.h:127
ns3::Cost231PropagationLossModel::GetLambda
double GetLambda() const
Get the wavelength.
Definition
cost231-propagation-loss-model.cc:98
ns3::Cost231PropagationLossModel::m_lambda
double m_lambda
The wavelength.
Definition
cost231-propagation-loss-model.h:128
ns3::Cost231PropagationLossModel::SetBSAntennaHeight
void SetBSAntennaHeight(double height)
Set the BS antenna height.
Definition
cost231-propagation-loss-model.cc:116
ns3::Cost231PropagationLossModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
cost231-propagation-loss-model.cc:29
ns3::Cost231PropagationLossModel::DoAssignStreams
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Definition
cost231-propagation-loss-model.cc:176
ns3::Cost231PropagationLossModel::m_frequency
double m_frequency
frequency [Hz]
Definition
cost231-propagation-loss-model.h:130
ns3::Cost231PropagationLossModel::GetBSAntennaHeight
double GetBSAntennaHeight() const
Get the BS antenna height.
Definition
cost231-propagation-loss-model.cc:122
ns3::Cost231PropagationLossModel::Cost231PropagationLossModel
Cost231PropagationLossModel()
Definition
cost231-propagation-loss-model.cc:66
ns3::Cost231PropagationLossModel::GetSSAntennaHeight
double GetSSAntennaHeight() const
Get the SS antenna height.
Definition
cost231-propagation-loss-model.cc:134
ns3::Cost231PropagationLossModel::GetMinDistance
double GetMinDistance() const
Get the minimum model distance.
Definition
cost231-propagation-loss-model.cc:110
ns3::Cost231PropagationLossModel::SetSSAntennaHeight
void SetSSAntennaHeight(double height)
Set the SS antenna height.
Definition
cost231-propagation-loss-model.cc:128
ns3::Cost231PropagationLossModel::SetLambda
void SetLambda(double lambda)
Set the wavelength.
Definition
cost231-propagation-loss-model.cc:91
ns3::Cost231PropagationLossModel::m_minDistance
double m_minDistance
minimum distance [m]
Definition
cost231-propagation-loss-model.h:129
ns3::Cost231PropagationLossModel::SetMinDistance
void SetMinDistance(double minDistance)
Set the minimum model distance.
Definition
cost231-propagation-loss-model.cc:104
ns3::Cost231PropagationLossModel::m_BSAntennaHeight
double m_BSAntennaHeight
BS Antenna Height [m].
Definition
cost231-propagation-loss-model.h:126
ns3::Cost231PropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Get the propagation loss.
Definition
cost231-propagation-loss-model.cc:140
ns3::Cost231PropagationLossModel::DoCalcRxPower
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
Definition
cost231-propagation-loss-model.cc:168
ns3::Cost231PropagationLossModel::m_shadowing
double m_shadowing
Shadowing loss [dB].
Definition
cost231-propagation-loss-model.h:131
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::PropagationLossModel
Models the propagation loss through a transmission medium.
Definition
propagation-loss-model.h:45
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
cost231-propagation-loss-model.h
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeDoubleChecker
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition
double.h:82
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition
double.h:32
propagation-loss-model.h
src
propagation
model
cost231-propagation-loss-model.cc
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0