A Discrete-Event Network Simulator
API
oh-buildings-propagation-loss-model.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Marco Miozzo <marco.miozzo@cttc.es>
18  *
19  */
20 
22 
23 #include "mobility-building-info.h"
24 
25 #include "ns3/double.h"
26 #include "ns3/enum.h"
27 #include "ns3/log.h"
28 #include "ns3/mobility-model.h"
29 #include "ns3/okumura-hata-propagation-loss-model.h"
30 #include "ns3/pointer.h"
31 #include "ns3/propagation-loss-model.h"
32 
33 #include <cmath>
34 
35 namespace ns3
36 {
37 
38 NS_LOG_COMPONENT_DEFINE("OhBuildingsPropagationLossModel");
39 
40 NS_OBJECT_ENSURE_REGISTERED(OhBuildingsPropagationLossModel);
41 
43 {
44  m_okumuraHata = CreateObject<OkumuraHataPropagationLossModel>();
45 }
46 
48 {
49 }
50 
51 TypeId
53 {
54  static TypeId tid = TypeId("ns3::OhBuildingsPropagationLossModel")
55 
57  .SetGroupName("Buildings")
58 
59  .AddConstructor<OhBuildingsPropagationLossModel>();
60 
61  return tid;
62 }
63 
64 double
66 {
67  NS_LOG_FUNCTION(this << a << b);
68 
69  // get the MobilityBuildingInfo pointers
72  NS_ASSERT_MSG(a1 && b1, "OhBuildingsPropagationLossModel only works with MobilityBuildingInfo");
73 
74  double loss = 0.0;
75 
76  bool isAIndoor = a1->IsIndoor();
77  bool isBIndoor = b1->IsIndoor();
78 
79  if (!isAIndoor) // a is outdoor
80  {
81  if (!isBIndoor) // b is outdoor
82  {
83  loss = m_okumuraHata->GetLoss(a, b);
84  NS_LOG_INFO(this << " O-O : " << loss);
85  }
86  else
87  {
88  // b indoor
89  loss = m_okumuraHata->GetLoss(a, b) + ExternalWallLoss(b1);
90  NS_LOG_INFO(this << " O-I : " << loss);
91  } // end b1->isIndoor ()
92  }
93  else
94  {
95  // a is indoor
96  if (isBIndoor) // b is indoor
97  {
98  if (a1->GetBuilding() == b1->GetBuilding())
99  {
100  // nodes are in same building -> indoor communication ITU-R P.1238
101  loss = m_okumuraHata->GetLoss(a, b) + InternalWallsLoss(a1, b1);
102  NS_LOG_INFO(this << " I-I (same building)" << loss);
103  }
104  else
105  {
106  // nodes are in different buildings
107  loss = m_okumuraHata->GetLoss(a, b) + ExternalWallLoss(a1) + ExternalWallLoss(b1);
108  NS_LOG_INFO(this << " I-O-I (different buildings): " << loss);
109  }
110  }
111  else
112  {
113  loss = m_okumuraHata->GetLoss(a, b) + ExternalWallLoss(a1);
114  NS_LOG_INFO(this << " I-O : " << loss);
115  } // end if (isBIndoor)
116  } // end if (!isAIndoor)
117 
118  loss = std::max(0.0, loss);
119  return loss;
120 }
121 
122 } // namespace ns3
#define max(a, b)
Definition: 80211b.c:42
This model provides means for simulating the following propagation phenomena in the presence of build...
double ExternalWallLoss(Ptr< MobilityBuildingInfo > a) const
Calculate the external wall loss.
double InternalWallsLoss(Ptr< MobilityBuildingInfo > a, Ptr< MobilityBuildingInfo > b) const
Calculate the internal wall loss.
mobility buildings information (to be used by mobility models)
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
this model combines the OkumuraHata model with the BuildingsPropagationLossModel
Ptr< OkumuraHataPropagationLossModel > m_okumuraHata
OkumuraHata Propagation Loss Model.
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
#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:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.