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
39
TypeId
40
ItuR1238PropagationLossModel::GetTypeId
(
void
)
41
{
42
static
TypeId
tid =
TypeId
(
"ns3::ItuR1238PropagationLossModel"
)
43
44
.
SetParent
<
PropagationLossModel
> ()
45
46
.AddAttribute (
"Frequency"
,
47
"The Frequency (default is 2.106 GHz)."
,
48
DoubleValue
(2160e6),
49
MakeDoubleAccessor (&
ItuR1238PropagationLossModel::m_frequency
),
50
MakeDoubleChecker<double> ());
51
52
return
tid;
53
}
54
55
double
56
ItuR1238PropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a1,
Ptr<MobilityModel>
b1)
const
57
{
58
NS_LOG_FUNCTION
(
this
<< a1 << b1);
59
Ptr<MobilityBuildingInfo>
a = a1->
GetObject
<
MobilityBuildingInfo
> ();
60
Ptr<MobilityBuildingInfo>
b = b1->
GetObject
<
MobilityBuildingInfo
> ();
61
NS_ASSERT_MSG
((a != 0) && (b != 0),
"ItuR1238PropagationLossModel only works with MobilityBuildingInfo"
);
62
NS_ASSERT_MSG
(a->GetBuilding ()->GetId () == b->GetBuilding ()->GetId (),
"ITU-R 1238 applies only to nodes that are in the same building"
);
63
double
N = 0.0;
64
int
n = std::abs (a->GetFloorNumber () - b->GetFloorNumber ());
65
NS_LOG_LOGIC
(
this
<<
" A floor "
<< (uint16_t)a->GetFloorNumber () <<
" B floor "
<< (uint16_t)b->GetFloorNumber () <<
" n "
<< n);
66
double
Lf = 0.0;
67
Ptr<Building>
aBuilding = a->GetBuilding ();
68
if
(aBuilding->GetBuildingType () ==
Building::Residential
)
69
{
70
N = 28;
71
if
(n >= 1)
72
{
73
Lf = 4 * n;
74
}
75
NS_LOG_LOGIC
(
this
<<
" Residential "
);
76
}
77
else
if
(aBuilding->GetBuildingType () ==
Building::Office
)
78
{
79
N = 30;
80
if
(n >= 1)
81
{
82
Lf = 15 + (4 * (n - 1));
83
}
84
NS_LOG_LOGIC
(
this
<<
" Office "
);
85
}
86
else
if
(aBuilding->GetBuildingType () ==
Building::Commercial
)
87
{
88
N = 22;
89
if
(n >= 1)
90
{
91
Lf = 6 + (3 * (n - 1));
92
}
93
NS_LOG_LOGIC
(
this
<<
" Commercial "
);
94
}
95
else
96
{
97
NS_LOG_ERROR
(
this
<<
" Unkwnon Wall Type"
);
98
}
99
double
loss = 20 * std::log10 (
m_frequency
/ 1e6
/*MHz*/
) + N * std::log10 (a1->
GetDistanceFrom
(b1)) + Lf - 28.0;
100
NS_LOG_INFO
(
this
<<
" Node "
<< a1->
GetPosition
() <<
" <-> "
<< b1->
GetPosition
() <<
" loss = "
<< loss <<
" dB"
);
101
102
return
loss;
103
}
104
105
106
double
107
ItuR1238PropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
108
Ptr<MobilityModel>
a,
109
Ptr<MobilityModel>
b)
const
110
{
111
return
(txPowerDbm -
GetLoss
(a, b));
112
}
113
114
115
int64_t
116
ItuR1238PropagationLossModel::DoAssignStreams
(int64_t stream)
117
{
118
return
0;
119
}
120
121
122
}
// namespace ns3
ns3::ItuR1238PropagationLossModel::DoAssignStreams
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
Definition:
itu-r-1238-propagation-loss-model.cc:116
ns3::Ptr< MobilityModel >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::ItuR1238PropagationLossModel::DoCalcRxPower
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
itu-r-1238-propagation-loss-model.cc:107
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition:
mobility-model.cc:80
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
ns3::MobilityModel::GetPosition
Vector GetPosition(void) const
Definition:
mobility-model.cc:63
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Definition:
log.h:298
ns3::ItuR1238PropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
itu-r-1238-propagation-loss-model.cc:56
ns3::Building::Office
Definition:
building.h:48
itu-r-1238-propagation-loss-model.h
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Definition:
log.h:368
ns3::Building::Residential
Definition:
building.h:48
ns3::ItuR1238PropagationLossModel::GetTypeId
static TypeId GetTypeId(void)
Definition:
itu-r-1238-propagation-loss-model.cc:40
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:271
ns3::DoubleValue
Hold a floating point type.
Definition:
double.h:41
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Definition:
object.h:361
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
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 Sat Apr 19 2014 14:06:50 for ns-3 by
1.8.6