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
itu-r-1238-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) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Marco Miozzo <marco.miozzo@cttc.es>,
19
* Nicola Baldo <nbaldo@cttc.es>
20
*
21
*/
22
#include "ns3/log.h"
23
#include "ns3/double.h"
24
#include "ns3/enum.h"
25
#include "ns3/mobility-model.h"
26
#include <cmath>
27
28
#include "
itu-r-1238-propagation-loss-model.h
"
29
#include "
buildings-mobility-model.h
"
30
31
NS_LOG_COMPONENT_DEFINE
(
"ItuR1238PropagationLossModel"
);
32
33
namespace
ns3 {
34
35
NS_OBJECT_ENSURE_REGISTERED
(ItuR1238PropagationLossModel);
36
37
38
TypeId
39
ItuR1238PropagationLossModel::GetTypeId
(
void
)
40
{
41
static
TypeId
tid =
TypeId
(
"ns3::ItuR1238PropagationLossModel"
)
42
43
.
SetParent
<
PropagationLossModel
> ()
44
45
.AddAttribute (
"Frequency"
,
46
"The Frequency (default is 2.106 GHz)."
,
47
DoubleValue
(2160e6),
48
MakeDoubleAccessor (&
ItuR1238PropagationLossModel::m_frequency
),
49
MakeDoubleChecker<double> ());
50
51
return
tid;
52
}
53
54
double
55
ItuR1238PropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a1,
Ptr<MobilityModel>
b1)
const
56
{
57
NS_LOG_FUNCTION
(
this
<< a1 << b1);
58
Ptr<BuildingsMobilityModel>
a = DynamicCast<BuildingsMobilityModel> (a1);
59
Ptr<BuildingsMobilityModel>
b = DynamicCast<BuildingsMobilityModel> (b1);
60
NS_ASSERT_MSG
((a != 0) && (b != 0),
"ItuR1238PropagationLossModel only works with BuildingsMobilityModel"
);
61
NS_ASSERT_MSG
(a->
GetBuilding
()->
GetId
() == b->GetBuilding ()->GetId (),
"ITU-R 1238 applies only to nodes that are in the same building"
);
62
double
N = 0.0;
63
int
n = std::abs (a->
GetFloorNumber
() - b->GetFloorNumber ());
64
NS_LOG_LOGIC
(
this
<<
" A floor "
<< (uint16_t)a->
GetFloorNumber
() <<
" B floor "
<< (uint16_t)b->GetFloorNumber () <<
" n "
<< n);
65
double
Lf = 0.0;
66
Ptr<Building>
aBuilding = a->
GetBuilding
();
67
if
(aBuilding->
GetBuildingType
() ==
Building::Residential
)
68
{
69
N = 28;
70
if
(n >= 1)
71
{
72
Lf = 4 * n;
73
}
74
NS_LOG_LOGIC
(
this
<<
" Residential "
);
75
}
76
else
if
(aBuilding->
GetBuildingType
() ==
Building::Office
)
77
{
78
N = 30;
79
if
(n >= 1)
80
{
81
Lf = 15 + (4 * (n - 1));
82
}
83
NS_LOG_LOGIC
(
this
<<
" Office "
);
84
}
85
else
if
(aBuilding->
GetBuildingType
() ==
Building::Commercial
)
86
{
87
N = 22;
88
if
(n >= 1)
89
{
90
Lf = 6 + (3 * (n - 1));
91
}
92
NS_LOG_LOGIC
(
this
<<
" Commercial "
);
93
}
94
else
95
{
96
NS_LOG_ERROR
(
this
<<
" Unkwnon Wall Type"
);
97
}
98
double
loss = 20 * std::log10 (
m_frequency
/ 1e6
/*MHz*/
) + N * std::log10 (a->
GetDistanceFrom
(b)) + Lf - 28.0;
99
NS_LOG_INFO
(
this
<<
" Node "
<< a->
GetPosition
() <<
" <-> "
<< b->GetPosition () <<
" loss = "
<< loss <<
" dB"
);
100
101
return
loss;
102
}
103
104
105
double
106
ItuR1238PropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
107
Ptr<MobilityModel>
a,
108
Ptr<MobilityModel>
b)
const
109
{
110
return
(txPowerDbm -
GetLoss
(a, b));
111
}
112
113
114
int64_t
115
ItuR1238PropagationLossModel::DoAssignStreams
(int64_t stream)
116
{
117
return
0;
118
}
119
120
121
}
// namespace ns3
src
buildings
model
itu-r-1238-propagation-loss-model.cc
Generated on Tue May 14 2013 11:08:16 for ns-3 by
1.8.1.2