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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 */
8
10
12
13#include "ns3/double.h"
14#include "ns3/log.h"
15
16#include <cmath>
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("ConstantSpectrumPropagationLossModel");
22
23NS_OBJECT_ENSURE_REGISTERED(ConstantSpectrumPropagationLossModel);
24
29
34
37{
38 static TypeId tid =
39 TypeId("ns3::ConstantSpectrumPropagationLossModel")
41 .SetGroupName("Spectrum")
43 .AddAttribute("Loss",
44 "Path loss (dB) between transmitter and receiver",
45 DoubleValue(1.0),
49 return tid;
50}
51
52void
54{
55 NS_LOG_FUNCTION(this);
56 m_lossDb = lossDb;
57 m_lossLinear = std::pow(10, m_lossDb / 10);
58}
59
60double
66
72{
73 NS_LOG_FUNCTION(this);
74
75 Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue>(params->psd);
76 auto vit = rxPsd->ValuesBegin();
77 auto fit = rxPsd->ConstBandsBegin();
78
79 while (vit != rxPsd->ValuesEnd())
80 {
81 NS_ASSERT(fit != rxPsd->ConstBandsEnd());
82 NS_LOG_LOGIC("Ptx = " << *vit);
83 *vit /= m_lossLinear; // Prx = Ptx / loss
84 NS_LOG_LOGIC("Prx = " << *vit);
85 ++vit;
86 ++fit;
87 }
88 return rxPsd;
89}
90
91int64_t
93{
94 return 0;
95}
96
97} // 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:31
Smart pointer class similar to boost::intrusive_ptr.
spectrum-aware propagation loss model
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_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< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition ptr.h:604
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32