A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
itu-r-1411-los-propagation-loss-model.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011, 2012 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: Marco Miozzo <marco.miozzo@cttc.es>,
19  * Nicola Baldo <nbaldo@cttc.es>
20  *
21  */
22 #include "ns3/log.h"
23 #include "ns3/double.h"
24 #include "ns3/enum.h"
25 #include "ns3/mobility-model.h"
26 #include <cmath>
27 
29 
30 NS_LOG_COMPONENT_DEFINE ("ItuR1411LosPropagationLossModel");
31 
32 namespace ns3 {
33 
34 NS_OBJECT_ENSURE_REGISTERED (ItuR1411LosPropagationLossModel);
35 
36 TypeId
38 {
39  static TypeId tid = TypeId ("ns3::ItuR1411LosPropagationLossModel")
40 
42  .AddConstructor<ItuR1411LosPropagationLossModel> ()
43 
44  .AddAttribute ("Frequency",
45  "The propagation frequency in Hz",
46  DoubleValue (2160e6),
48  MakeDoubleChecker<double> ());
49 
50  return tid;
51 }
52 
55 {
56 }
57 
59 {
60 }
61 
62 double
64 {
65  NS_LOG_FUNCTION (this);
66  double dist = a->GetDistanceFrom (b);
67  double lossLow = 0.0;
68  double lossUp = 0.0;
69  NS_ASSERT_MSG (a->GetPosition ().z > 0 && b->GetPosition ().z > 0, "nodes' height must be greater than 0");
70  double Lbp = std::fabs (20 * std::log10 ((m_lambda * m_lambda) / (8 * M_PI * a->GetPosition ().z * b->GetPosition ().z)));
71  double Rbp = (4 * a->GetPosition ().z * b->GetPosition ().z) / m_lambda;
72  NS_LOG_LOGIC (this << " Lbp " << Lbp << " Rbp " << Rbp << " lambda " << m_lambda);
73  if (dist <= Rbp)
74  {
75  lossLow = Lbp + 20 * std::log10 (dist / Rbp);
76  lossUp = Lbp + 20 + 25 * std::log10 (dist / Rbp);
77  }
78  else
79  {
80  lossLow = Lbp + 40 * std::log10 (dist / Rbp);
81  lossUp = Lbp + 20 + 40 * std::log10 (dist / Rbp);
82  }
83 
84  double loss = (lossUp + lossLow) / 2;
85 
86  return loss;
87 }
88 
89 
90 void
92 {
93  NS_ASSERT (freq > 0.0);
94  m_lambda = 299792458.0 / freq;
95 }
96 
97 
98 double
101  Ptr<MobilityModel> b) const
102 {
103  return (txPowerDbm - GetLoss (a, b));
104 }
105 
106 int64_t
108 {
109  return 0;
110 }
111 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
double GetDistanceFrom(Ptr< const MobilityModel > position) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
Vector GetPosition(void) const
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
void SetFrequency(double freq)
Set the operating frequency.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:84
Modelize the propagation loss through a transmission medium.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
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:610
double z
z coordinate of vector
Definition: vector.h:57