A Discrete-Event Network Simulator
QKDNetSim v2.0 (NS-3 v3.41) @ (+)
API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
21 
23 
24 #include "ns3/double.h"
25 #include "ns3/log.h"
26 
27 #include <cmath>
28 
29 namespace ns3
30 {
31 
32 NS_LOG_COMPONENT_DEFINE("ConstantSpectrumPropagationLossModel");
33 
34 NS_OBJECT_ENSURE_REGISTERED(ConstantSpectrumPropagationLossModel);
35 
37 {
38  NS_LOG_FUNCTION(this);
39 }
40 
42 {
43  NS_LOG_FUNCTION(this);
44 }
45 
46 TypeId
48 {
49  static TypeId tid =
50  TypeId("ns3::ConstantSpectrumPropagationLossModel")
52  .SetGroupName("Spectrum")
53  .AddConstructor<ConstantSpectrumPropagationLossModel>()
54  .AddAttribute("Loss",
55  "Path loss (dB) between transmitter and receiver",
56  DoubleValue(1.0),
59  MakeDoubleChecker<double>());
60  return tid;
61 }
62 
63 void
65 {
66  NS_LOG_FUNCTION(this);
67  m_lossDb = lossDb;
68  m_lossLinear = std::pow(10, m_lossDb / 10);
69 }
70 
71 double
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  auto vit = rxPsd->ValuesBegin();
88  auto 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 int64_t
104 {
105  return 0;
106 }
107 
108 } // 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
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
spectrum-aware propagation loss model
Bands::const_iterator ConstBandsEnd() const
Values::iterator ValuesBegin()
Bands::const_iterator ConstBandsBegin() const
Values::iterator ValuesEnd()
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
#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_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.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.