A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
constant-spectrum-propagation-loss.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 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: Manuel Requena <manuel.requena@cttc.es>
18 */
19
20#include "ns3/constant-spectrum-propagation-loss.h"
21
23
24#include "ns3/double.h"
25#include "ns3/log.h"
26
27#include <cmath>
28
29namespace ns3
30{
31
32NS_LOG_COMPONENT_DEFINE("ConstantSpectrumPropagationLossModel");
33
34NS_OBJECT_ENSURE_REGISTERED(ConstantSpectrumPropagationLossModel);
35
37{
38 NS_LOG_FUNCTION(this);
39}
40
42{
43 NS_LOG_FUNCTION(this);
44}
45
48{
49 static TypeId tid =
50 TypeId("ns3::ConstantSpectrumPropagationLossModel")
52 .SetGroupName("Spectrum")
54 .AddAttribute("Loss",
55 "Path loss (dB) between transmitter and receiver",
56 DoubleValue(1.0),
59 MakeDoubleChecker<double>());
60 return tid;
61}
62
63void
65{
66 NS_LOG_FUNCTION(this);
67 m_lossDb = lossDb;
68 m_lossLinear = std::pow(10, m_lossDb / 10);
69}
70
71double
73{
74 NS_LOG_FUNCTION(this);
75 return m_lossDb;
76}
77
83{
84 NS_LOG_FUNCTION(this);
85
86 Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue>(params->psd);
87 Values::iterator vit = rxPsd->ValuesBegin();
88 Bands::const_iterator fit = rxPsd->ConstBandsBegin();
89
90 while (vit != rxPsd->ValuesEnd())
91 {
92 NS_ASSERT(fit != rxPsd->ConstBandsEnd());
93 NS_LOG_LOGIC("Ptx = " << *vit);
94 *vit /= m_lossLinear; // Prx = Ptx / loss
95 NS_LOG_LOGIC("Prx = " << *vit);
96 ++vit;
97 ++fit;
98 }
99 return rxPsd;
100}
101
102} // namespace ns3
void SetLossDb(double lossDb)
Set the propagation loss.
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > params, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
spectrum-aware propagation loss model
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:936
#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
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.