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 <ns3/mobility-building-info.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<MobilityBuildingInfo>
a = a1->
GetObject
<
MobilityBuildingInfo
> ();
59
Ptr<MobilityBuildingInfo>
b = b1->
GetObject
<
MobilityBuildingInfo
> ();
60
NS_ASSERT_MSG
((a != 0) && (b != 0),
"ItuR1238PropagationLossModel only works with MobilityBuildingInfo"
);
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 (a1->
GetDistanceFrom
(b1)) + Lf - 28.0;
99
NS_LOG_INFO
(
this
<<
" Node "
<< a1->
GetPosition
() <<
" <-> "
<< b1->
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
ns3::ItuR1238PropagationLossModel::DoAssignStreams
virtual int64_t DoAssignStreams(int64_t stream)
Definition:
itu-r-1238-propagation-loss-model.cc:115
ns3::Ptr< MobilityModel >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
ns3::ItuR1238PropagationLossModel::DoCalcRxPower
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
itu-r-1238-propagation-loss-model.cc:106
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition:
mobility-model.cc:79
ns3::MobilityModel::GetPosition
Vector GetPosition(void) const
Definition:
mobility-model.cc:62
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Definition:
log.h:264
ns3::ItuR1238PropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
itu-r-1238-propagation-loss-model.cc:55
ns3::Building::Office
Definition:
building.h:48
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
itu-r-1238-propagation-loss-model.h
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Definition:
log.h:334
ns3::Building::Residential
Definition:
building.h:48
ns3::ItuR1238PropagationLossModel::GetTypeId
static TypeId GetTypeId(void)
Definition:
itu-r-1238-propagation-loss-model.cc:39
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
Definition:
assert.h:86
ns3::PropagationLossModel
Modelize the propagation loss through a transmission medium.
Definition:
propagation-loss-model.h:49
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("ItuR1238PropagationLossModel")
ns3::MobilityBuildingInfo
mobility buildings information (to be used by mobility models)
Definition:
mobility-building-info.h:47
NS_LOG_ERROR
#define NS_LOG_ERROR(msg)
Definition:
log.h:237
ns3::DoubleValue
Hold an floating point type.
Definition:
double.h:41
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Definition:
object.h:360
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:610
ns3::Building::Commercial
Definition:
building.h:48
ns3::ItuR1238PropagationLossModel::m_frequency
double m_frequency
frequency in MHz
Definition:
itu-r-1238-propagation-loss-model.h:62
src
buildings
model
itu-r-1238-propagation-loss-model.cc
Generated on Sun Apr 20 2014 11:14:45 for ns-3 by
1.8.6