A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
itu-r-1238-propagation-loss-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011, 2012 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 * Nicola Baldo <nbaldo@cttc.es>
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
19#include <cmath>
20
21namespace ns3
22{
23
24NS_LOG_COMPONENT_DEFINE("ItuR1238PropagationLossModel");
25
26NS_OBJECT_ENSURE_REGISTERED(ItuR1238PropagationLossModel);
27
28TypeId
30{
31 static TypeId tid =
32 TypeId("ns3::ItuR1238PropagationLossModel")
33
35 .SetGroupName("Buildings")
36
37 .AddAttribute("Frequency",
38 "The Frequency (default is 2.106 GHz).",
39 DoubleValue(2160e6),
42
43 return tid;
44}
45
46double
48{
49 NS_LOG_FUNCTION(this << a1 << b1);
52 NS_ASSERT_MSG(a && b, "ItuR1238PropagationLossModel only works with MobilityBuildingInfo");
53 NS_ASSERT_MSG(a->GetBuilding()->GetId() == b->GetBuilding()->GetId(),
54 "ITU-R 1238 applies only to nodes that are in the same building");
55 double N = 0.0;
56 int n = std::abs(a->GetFloorNumber() - b->GetFloorNumber());
57 NS_LOG_LOGIC(this << " A floor " << (uint16_t)a->GetFloorNumber() << " B floor "
58 << (uint16_t)b->GetFloorNumber() << " n " << n);
59 double Lf = 0.0;
60 Ptr<Building> aBuilding = a->GetBuilding();
61 if (aBuilding->GetBuildingType() == Building::Residential)
62 {
63 N = 28;
64 if (n >= 1)
65 {
66 Lf = 4 * n;
67 }
68 NS_LOG_LOGIC(this << " Residential ");
69 }
70 else if (aBuilding->GetBuildingType() == Building::Office)
71 {
72 N = 30;
73 if (n >= 1)
74 {
75 Lf = 15 + (4 * (n - 1));
76 }
77 NS_LOG_LOGIC(this << " Office ");
78 }
79 else if (aBuilding->GetBuildingType() == Building::Commercial)
80 {
81 N = 22;
82 if (n >= 1)
83 {
84 Lf = 6 + (3 * (n - 1));
85 }
86 NS_LOG_LOGIC(this << " Commercial ");
87 }
88 else
89 {
90 NS_LOG_ERROR(this << " Unkwnon Wall Type");
91 }
92 double loss = 20 * std::log10(m_frequency / 1e6 /*MHz*/) +
93 N * std::log10(a1->GetDistanceFrom(b1)) + Lf - 28.0;
94 NS_LOG_INFO(this << " Node " << a1->GetPosition() << " <-> " << b1->GetPosition()
95 << " loss = " << loss << " dB");
96
97 return loss;
98}
99
100double
103 Ptr<MobilityModel> b) const
104{
105 return (txPowerDbm - GetLoss(a, b));
106}
107
108int64_t
110{
111 return 0;
112}
113
114} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
mobility buildings information (to be used by mobility models)
Models the propagation loss through a transmission medium.
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
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition double.h:32
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition log.h:243
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#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
#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.