A Discrete-Event Network Simulator
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>
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 
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 
65 double
67 {
68  NS_LOG_FUNCTION (this << a << b);
69 
70  // get the MobilityBuildingInfo pointers
73  NS_ASSERT_MSG ((a1 != 0) && (b1 != 0), "OhBuildingsPropagationLossModel only works with MobilityBuildingInfo");
74 
75  double loss = 0.0;
76 
77  if (a1->IsOutdoor ())
78  {
79  if (b1->IsOutdoor ())
80  {
81  loss = m_okumuraHata->GetLoss (a, b);
82  NS_LOG_INFO (this << " O-O : " << loss);
83  }
84  else
85  {
86  // b indoor
87  loss = m_okumuraHata->GetLoss (a, b) + ExternalWallLoss (b1);
88  NS_LOG_INFO (this << " O-I : " << loss);
89  } // end b1->isIndoor ()
90  }
91  else
92  {
93  // a is indoor
94  if (b1->IsIndoor ())
95  {
96  if (a1->GetBuilding () == b1->GetBuilding ())
97  {
98  // nodes are in same building -> indoor communication ITU-R P.1238
99  loss = m_okumuraHata->GetLoss (a, b) + InternalWallsLoss (a1, b1);;
100  NS_LOG_INFO (this << " I-I (same building)" << loss);
101 
102  }
103  else
104  {
105  // nodes are in different buildings
106  loss = m_okumuraHata->GetLoss (a, b) + ExternalWallLoss (a1) + ExternalWallLoss (b1);
107  NS_LOG_INFO (this << " I-O-I (different buildings): " << loss);
108  }
109  }
110  else
111  {
112  loss = m_okumuraHata->GetLoss (a, b) + ExternalWallLoss (a1);
113  NS_LOG_INFO (this << " I-O : " << loss);
114  } // end b1->IsIndoor ()
115  } // end a1->IsOutdoor ()
116 
117  loss = std::max (0.0, loss);
118  return loss;
119 }
120 
121 
122 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
this model combines the OkumuraHata model with the BuildingsPropagationLossModel
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
This model provides means for simulating the following propagation phenomena in the presence of build...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Ptr< OkumuraHataPropagationLossModel > m_okumuraHata
#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:90
mobility buildings information (to be used by mobility models)
double ExternalWallLoss(Ptr< MobilityBuildingInfo > a) const
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:455
a unique identifier for an interface.
Definition: type-id.h:57
TypeId SetParent(TypeId tid)
Definition: type-id.cc:638
double InternalWallsLoss(Ptr< MobilityBuildingInfo > a, Ptr< MobilityBuildingInfo > b) const