A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
oh-buildings-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 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/mobility-building-info.h>
30
#include "ns3/okumura-hata-propagation-loss-model.h"
31
#include "ns3/enum.h"
32
33
34
namespace
ns3
{
35
36
NS_LOG_COMPONENT_DEFINE
(
"OhBuildingsPropagationLossModel"
);
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
.SetGroupName (
"Buildings"
)
58
59
.AddConstructor<
OhBuildingsPropagationLossModel
> ();
60
61
return
tid;
62
}
63
64
65
double
66
OhBuildingsPropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
67
{
68
NS_LOG_FUNCTION
(
this
<< a << b);
69
70
// get the MobilityBuildingInfo pointers
71
Ptr<MobilityBuildingInfo>
a1 = a->
GetObject
<
MobilityBuildingInfo
> ();
72
Ptr<MobilityBuildingInfo>
b1 = b->
GetObject
<
MobilityBuildingInfo
> ();
73
NS_ASSERT_MSG
((a1 != 0) && (b1 != 0),
"OhBuildingsPropagationLossModel only works with MobilityBuildingInfo"
);
74
75
double
loss = 0.0;
76
77
bool
isAIndoor = a1->IsIndoor ();
78
bool
isBIndoor = b1->IsIndoor ();
79
80
if
(!isAIndoor)
// a is outdoor
81
{
82
if
(!isBIndoor)
// b is outdoor
83
{
84
loss =
m_okumuraHata
->GetLoss (a, b);
85
NS_LOG_INFO
(
this
<<
" O-O : "
<< loss);
86
}
87
else
88
{
89
// b indoor
90
loss =
m_okumuraHata
->GetLoss (a, b) +
ExternalWallLoss
(b1);
91
NS_LOG_INFO
(
this
<<
" O-I : "
<< loss);
92
}
// end b1->isIndoor ()
93
}
94
else
95
{
96
// a is indoor
97
if
(isBIndoor)
// b is indoor
98
{
99
if
(a1->GetBuilding () == b1->GetBuilding ())
100
{
101
// nodes are in same building -> indoor communication ITU-R P.1238
102
loss =
m_okumuraHata
->GetLoss (a, b) +
InternalWallsLoss
(a1, b1);
103
NS_LOG_INFO
(
this
<<
" I-I (same building)"
<< loss);
104
105
}
106
else
107
{
108
// nodes are in different buildings
109
loss =
m_okumuraHata
->GetLoss (a, b) +
ExternalWallLoss
(a1) +
ExternalWallLoss
(b1);
110
NS_LOG_INFO
(
this
<<
" I-O-I (different buildings): "
<< loss);
111
}
112
}
113
else
114
{
115
loss =
m_okumuraHata
->GetLoss (a, b) +
ExternalWallLoss
(a1);
116
NS_LOG_INFO
(
this
<<
" I-O : "
<< loss);
117
}
// end if (isBIndoor)
118
}
// end if (!isAIndoor)
119
120
loss =
std::max
(0.0, loss);
121
return
loss;
122
}
123
124
125
}
// namespace ns3
max
#define max(a, b)
Definition:
80211b.c:43
ns3::BuildingsPropagationLossModel
This model provides means for simulating the following propagation phenomena in the presence of build...
Definition:
buildings-propagation-loss-model.h:58
ns3::BuildingsPropagationLossModel::ExternalWallLoss
double ExternalWallLoss(Ptr< MobilityBuildingInfo > a) const
Definition:
buildings-propagation-loss-model.cc:104
ns3::BuildingsPropagationLossModel::InternalWallsLoss
double InternalWallsLoss(Ptr< MobilityBuildingInfo > a, Ptr< MobilityBuildingInfo > b) const
Definition:
buildings-propagation-loss-model.cc:138
ns3::MobilityBuildingInfo
mobility buildings information (to be used by mobility models)
Definition:
mobility-building-info.h:49
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition:
object.h:470
ns3::OhBuildingsPropagationLossModel
this model combines the OkumuraHata model with the BuildingsPropagationLossModel
Definition:
oh-buildings-propagation-loss-model.h:40
ns3::OhBuildingsPropagationLossModel::m_okumuraHata
Ptr< OkumuraHataPropagationLossModel > m_okumuraHata
Definition:
oh-buildings-propagation-loss-model.h:56
ns3::OhBuildingsPropagationLossModel::GetLoss
virtual double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
oh-buildings-propagation-loss-model.cc:66
ns3::OhBuildingsPropagationLossModel::~OhBuildingsPropagationLossModel
~OhBuildingsPropagationLossModel()
Definition:
oh-buildings-propagation-loss-model.cc:47
ns3::OhBuildingsPropagationLossModel::OhBuildingsPropagationLossModel
OhBuildingsPropagationLossModel()
Definition:
oh-buildings-propagation-loss-model.cc:42
ns3::OhBuildingsPropagationLossModel::GetTypeId
static TypeId GetTypeId(void)
Definition:
oh-buildings-propagation-loss-model.cc:52
ns3::Ptr< MobilityModel >
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition:
assert.h:88
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:244
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition:
log.h:281
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
oh-buildings-propagation-loss-model.h
src
buildings
model
oh-buildings-propagation-loss-model.cc
Generated on Mon Sep 27 2021 10:49:45 for ns-3 by
1.9.1