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 * 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
12#include "ns3/double.h"
13#include "ns3/enum.h"
14#include "ns3/log.h"
15#include "ns3/mobility-model.h"
16
17#include <cmath>
18
19namespace ns3
20{
21
22NS_LOG_COMPONENT_DEFINE("ItuR1411LosPropagationLossModel");
23
24NS_OBJECT_ENSURE_REGISTERED(ItuR1411LosPropagationLossModel);
25
26TypeId
28{
29 static TypeId tid =
30 TypeId("ns3::ItuR1411LosPropagationLossModel")
32 .SetGroupName("Propagation")
33 .AddConstructor<ItuR1411LosPropagationLossModel>()
34 .AddAttribute("Frequency",
35 "The propagation frequency in Hz",
36 DoubleValue(2160e6),
39
40 return tid;
41}
42
47
51
52double
54{
55 NS_LOG_FUNCTION(this);
56 double dist = a->GetDistanceFrom(b);
57 double lossLow = 0.0;
58 double lossUp = 0.0;
59 NS_ASSERT_MSG(a->GetPosition().z > 0 && b->GetPosition().z > 0,
60 "nodes' height must be greater than 0");
61 double Lbp = std::fabs(20 * std::log10((m_lambda * m_lambda) /
62 (8 * M_PI * a->GetPosition().z * b->GetPosition().z)));
63 double Rbp = (4 * a->GetPosition().z * b->GetPosition().z) / m_lambda;
64 NS_LOG_LOGIC(this << " Lbp " << Lbp << " Rbp " << Rbp << " lambda " << m_lambda);
65 if (dist <= Rbp)
66 {
67 lossLow = Lbp + 20 * std::log10(dist / Rbp);
68 lossUp = Lbp + 20 + 25 * std::log10(dist / Rbp);
69 }
70 else
71 {
72 lossLow = Lbp + 40 * std::log10(dist / Rbp);
73 lossUp = Lbp + 20 + 40 * std::log10(dist / Rbp);
74 }
75
76 double loss = (lossUp + lossLow) / 2;
77
78 return loss;
79}
80
81void
83{
84 NS_ASSERT(freq > 0.0);
85 m_lambda = 299792458.0 / freq;
86}
87
88double
91 Ptr<MobilityModel> b) const
92{
93 return (txPowerDbm - GetLoss(a, b));
94}
95
96int64_t
98{
99 return 0;
100}
101} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
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.
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(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#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_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_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.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32