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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
oh-buildings-propagation-loss-model.cc
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 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
*
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 "oh-buildings-propagation-loss-model.h"
29
#include "ns3/buildings-mobility-model.h"
30
#include "ns3/okumura-hata-propagation-loss-model.h"
31
#include "ns3/enum.h"
32
33
34
NS_LOG_COMPONENT_DEFINE
(
"OhBuildingsPropagationLossModel"
);
35
36
namespace
ns3 {
37
38
NS_OBJECT_ENSURE_REGISTERED (OhBuildingsPropagationLossModel);
39
40
41
42
OhBuildingsPropagationLossModel::OhBuildingsPropagationLossModel ()
43
{
44
m_okumuraHata = CreateObject<OkumuraHataPropagationLossModel> ();
45
}
46
47
OhBuildingsPropagationLossModel::~OhBuildingsPropagationLossModel ()
48
{
49
}
50
51
TypeId
52
OhBuildingsPropagationLossModel::GetTypeId (
void
)
53
{
54
static
TypeId tid = TypeId (
"ns3::OhBuildingsPropagationLossModel"
)
55
56
.SetParent<BuildingsPropagationLossModel> ()
57
58
.AddConstructor<OhBuildingsPropagationLossModel> ();
59
60
return
tid;
61
}
62
63
64
double
65
OhBuildingsPropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
66
{
67
NS_LOG_FUNCTION
(
this
<< a << b);
68
69
// get the BuildingsMobilityModel pointers
70
Ptr<BuildingsMobilityModel>
a1 = DynamicCast<BuildingsMobilityModel> (a);
71
Ptr<BuildingsMobilityModel>
b1 = DynamicCast<BuildingsMobilityModel> (b);
72
NS_ASSERT_MSG
((a1 != 0) && (b1 != 0),
"OhBuildingsPropagationLossModel only works with BuildingsMobilityModel"
);
73
74
double
loss = 0.0;
75
76
if
(a1->IsOutdoor ())
77
{
78
if
(b1->IsOutdoor ())
79
{
80
loss = m_okumuraHata->GetLoss (a1, b1);
81
NS_LOG_INFO
(
this
<<
" O-O : "
<< loss);
82
}
83
else
84
{
85
// b indoor
86
loss = m_okumuraHata->GetLoss (a1, b1) + ExternalWallLoss (b1);
87
NS_LOG_INFO
(
this
<<
" O-I : "
<< loss);
88
}
// end b1->isIndoor ()
89
}
90
else
91
{
92
// a is indoor
93
if
(b1->IsIndoor ())
94
{
95
if
(a1->GetBuilding () == b1->GetBuilding ())
96
{
97
// nodes are in same building -> indoor communication ITU-R P.1238
98
loss = m_okumuraHata->GetLoss (a1, b1) + InternalWallsLoss (a1, b1);;
99
NS_LOG_INFO
(
this
<<
" I-I (same building)"
<< loss);
100
101
}
102
else
103
{
104
// nodes are in different buildings
105
loss = m_okumuraHata->GetLoss (a1, b1) + ExternalWallLoss (a1) + ExternalWallLoss (b1);
106
NS_LOG_INFO
(
this
<<
" I-O-I (different buildings): "
<< loss);
107
}
108
}
109
else
110
{
111
loss = m_okumuraHata->GetLoss (a1, b1) + ExternalWallLoss (a1);
112
NS_LOG_INFO
(
this
<<
" I-O : "
<< loss);
113
}
// end b1->IsIndoor ()
114
}
// end a1->IsOutdoor ()
115
116
loss = std::max (0.0, loss);
117
return
loss;
118
}
119
120
121
}
// namespace ns3
ns3::Ptr< MobilityModel >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Definition:
log.h:264
ns3::OhBuildingsPropagationLossModel::GetLoss
virtual double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
oh-buildings-propagation-loss-model.cc:65
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
Definition:
assert.h:86
src
buildings
model
oh-buildings-propagation-loss-model.cc
Generated on Sun Mar 16 2014 11:25:01 for ns-3 by
1.8.6