A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
constant-spectrum-propagation-loss.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Manuel Requena <manuel.requena@cttc.es>
19  */
20 
21 #include <cmath>
22 
23 #include "ns3/log.h"
24 
25 #include "ns3/constant-spectrum-propagation-loss.h"
26 #include "ns3/double.h"
27 
28 
29 NS_LOG_COMPONENT_DEFINE ("ConstantSpectrumPropagationLossModel");
30 
31 namespace ns3 {
32 
33 
34 NS_OBJECT_ENSURE_REGISTERED (ConstantSpectrumPropagationLossModel)
35  ;
36 
38 {
39  NS_LOG_FUNCTION (this);
40 }
41 
43 {
44  NS_LOG_FUNCTION (this);
45 }
46 
47 TypeId
49 {
50  static TypeId tid = TypeId ("ns3::ConstantSpectrumPropagationLossModel")
52  .AddConstructor<ConstantSpectrumPropagationLossModel> ()
53  .AddAttribute ("Loss",
54  "Path loss (dB) between transmitter and receiver",
55  DoubleValue (1.0),
58  MakeDoubleChecker<double> ())
59  ;
60  return tid;
61 }
62 
63 
64 void
66 {
67  NS_LOG_FUNCTION (this);
68  m_lossDb = lossDb;
69  m_lossLinear = std::pow (10, m_lossDb / 10);
70 }
71 
72 
73 double
75 {
76  NS_LOG_FUNCTION (this);
77  return m_lossDb;
78 }
79 
80 
85 {
86  NS_LOG_FUNCTION (this);
87 
88  Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
89  Values::iterator vit = rxPsd->ValuesBegin ();
90  Bands::const_iterator fit = rxPsd->ConstBandsBegin ();
91 
92  while (vit != rxPsd->ValuesEnd ())
93  {
94  NS_ASSERT (fit != rxPsd->ConstBandsEnd ());
95  NS_LOG_LOGIC ("Ptx = " << *vit);
96  *vit /= m_lossLinear; // Prx = Ptx / loss
97  NS_LOG_LOGIC ("Prx = " << *vit);
98  ++vit;
99  ++fit;
100  }
101  return rxPsd;
102 }
103 
104 
105 } // namespace ns3
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
#define NS_ASSERT(condition)
Definition: assert.h:64
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
NS_LOG_COMPONENT_DEFINE("ConstantSpectrumPropagationLossModel")
spectrum-aware propagation loss model
Hold a floating point type.
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
virtual Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumValue > txPsd, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const