A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
itu-r-1411-los-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 * 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 * Nicola Baldo <nbaldo@cttc.es>
19 *
20 */
22
23#include "ns3/double.h"
24#include "ns3/enum.h"
25#include "ns3/log.h"
26#include "ns3/mobility-model.h"
27
28#include <cmath>
29
30namespace ns3
31{
32
33NS_LOG_COMPONENT_DEFINE("ItuR1411LosPropagationLossModel");
34
35NS_OBJECT_ENSURE_REGISTERED(ItuR1411LosPropagationLossModel);
36
37TypeId
39{
40 static TypeId tid =
41 TypeId("ns3::ItuR1411LosPropagationLossModel")
43 .SetGroupName("Propagation")
44 .AddConstructor<ItuR1411LosPropagationLossModel>()
45 .AddAttribute("Frequency",
46 "The propagation frequency in Hz",
47 DoubleValue(2160e6),
49 MakeDoubleChecker<double>());
50
51 return tid;
52}
53
56{
57}
58
60{
61}
62
63double
65{
66 NS_LOG_FUNCTION(this);
67 double dist = a->GetDistanceFrom(b);
68 double lossLow = 0.0;
69 double lossUp = 0.0;
70 NS_ASSERT_MSG(a->GetPosition().z > 0 && b->GetPosition().z > 0,
71 "nodes' height must be greater than 0");
72 double Lbp = std::fabs(20 * std::log10((m_lambda * m_lambda) /
73 (8 * M_PI * a->GetPosition().z * b->GetPosition().z)));
74 double Rbp = (4 * a->GetPosition().z * b->GetPosition().z) / m_lambda;
75 NS_LOG_LOGIC(this << " Lbp " << Lbp << " Rbp " << Rbp << " lambda " << m_lambda);
76 if (dist <= Rbp)
77 {
78 lossLow = Lbp + 20 * std::log10(dist / Rbp);
79 lossUp = Lbp + 20 + 25 * std::log10(dist / Rbp);
80 }
81 else
82 {
83 lossLow = Lbp + 40 * std::log10(dist / Rbp);
84 lossUp = Lbp + 20 + 40 * std::log10(dist / Rbp);
85 }
86
87 double loss = (lossUp + lossLow) / 2;
88
89 return loss;
90}
91
92void
94{
95 NS_ASSERT(freq > 0.0);
96 m_lambda = 299792458.0 / freq;
97}
98
99double
102 Ptr<MobilityModel> b) const
103{
104 return (txPowerDbm - GetLoss(a, b));
105}
106
107int64_t
109{
110 return 0;
111}
112} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
void SetFrequency(double freq)
Set the operating frequency.
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#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
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#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.