A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>
7 *
8 */
9
11
13
14#include "ns3/double.h"
15#include "ns3/enum.h"
16#include "ns3/log.h"
17#include "ns3/mobility-model.h"
18#include "ns3/okumura-hata-propagation-loss-model.h"
19#include "ns3/pointer.h"
20#include "ns3/propagation-loss-model.h"
21
22#include <cmath>
23
24namespace ns3
25{
26
27NS_LOG_COMPONENT_DEFINE("OhBuildingsPropagationLossModel");
28
29NS_OBJECT_ENSURE_REGISTERED(OhBuildingsPropagationLossModel);
30
35
39
42{
43 static TypeId tid = TypeId("ns3::OhBuildingsPropagationLossModel")
44
46 .SetGroupName("Buildings")
47
48 .AddConstructor<OhBuildingsPropagationLossModel>();
49
50 return tid;
51}
52
53double
55{
56 NS_LOG_FUNCTION(this << a << b);
57
58 // get the MobilityBuildingInfo pointers
61 NS_ASSERT_MSG(a1 && b1, "OhBuildingsPropagationLossModel only works with MobilityBuildingInfo");
62
63 double loss = 0.0;
64
65 bool isAIndoor = a1->IsIndoor();
66 bool isBIndoor = b1->IsIndoor();
67
68 if (!isAIndoor) // a is outdoor
69 {
70 if (!isBIndoor) // b is outdoor
71 {
72 loss = m_okumuraHata->GetLoss(a, b);
73 NS_LOG_INFO(this << " O-O : " << loss);
74 }
75 else
76 {
77 // b indoor
78 loss = m_okumuraHata->GetLoss(a, b) + ExternalWallLoss(b1);
79 NS_LOG_INFO(this << " O-I : " << loss);
80 } // end b1->isIndoor ()
81 }
82 else
83 {
84 // a is indoor
85 if (isBIndoor) // b is indoor
86 {
87 if (a1->GetBuilding() == b1->GetBuilding())
88 {
89 // nodes are in same building -> indoor communication ITU-R P.1238
90 loss = m_okumuraHata->GetLoss(a, b) + InternalWallsLoss(a1, b1);
91 NS_LOG_INFO(this << " I-I (same building)" << loss);
92 }
93 else
94 {
95 // nodes are in different buildings
96 loss = m_okumuraHata->GetLoss(a, b) + ExternalWallLoss(a1) + ExternalWallLoss(b1);
97 NS_LOG_INFO(this << " I-O-I (different buildings): " << loss);
98 }
99 }
100 else
101 {
102 loss = m_okumuraHata->GetLoss(a, b) + ExternalWallLoss(a1);
103 NS_LOG_INFO(this << " I-O : " << loss);
104 } // end if (isBIndoor)
105 } // end if (!isAIndoor)
106
107 loss = std::max(0.0, loss);
108 return loss;
109}
110
111} // namespace ns3
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)
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
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#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:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.