A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
friis-spectrum-propagation-loss.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
10
12
13#include <ns3/mobility-model.h>
14
15#include <cmath> // for M_PI
16
17namespace ns3
18{
19
20NS_OBJECT_ENSURE_REGISTERED(FriisSpectrumPropagationLossModel);
21
25
29
32{
33 static TypeId tid = TypeId("ns3::FriisSpectrumPropagationLossModel")
35 .SetGroupName("Spectrum")
36 .AddConstructor<FriisSpectrumPropagationLossModel>();
37 return tid;
38}
39
45{
46 Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue>(params->psd);
47 auto vit = rxPsd->ValuesBegin();
48 auto fit = rxPsd->ConstBandsBegin();
49
50 NS_ASSERT(a);
51 NS_ASSERT(b);
52
53 double d = a->GetDistanceFrom(b);
54
55 while (vit != rxPsd->ValuesEnd())
56 {
57 NS_ASSERT(fit != rxPsd->ConstBandsEnd());
58 *vit /= CalculateLoss(fit->fc, d); // Prx = Ptx / loss
59 ++vit;
60 ++fit;
61 }
62 return rxPsd;
63}
64
65double
67{
68 NS_ASSERT(d >= 0);
69
70 if (d == 0)
71 {
72 return 1;
73 }
74
75 NS_ASSERT(f > 0);
76 double loss_sqrt = (4 * M_PI * f * d) / 3e8;
77 double loss = loss_sqrt * loss_sqrt;
78
79 if (loss < 1)
80 {
81 loss = 1;
82 }
83 return loss;
84}
85
86int64_t
88{
89 return 0;
90}
91
92} // namespace ns3
double CalculateLoss(double f, double d) const
Return the propagation loss L according to a simplified version of Friis' formula in which antenna ga...
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.
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_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< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition ptr.h:604