A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
28
#include "
itu-r-1411-los-propagation-loss-model.h
"
29
30
NS_LOG_COMPONENT_DEFINE
(
"ItuR1411LosPropagationLossModel"
);
31
32
namespace
ns3 {
33
34
NS_OBJECT_ENSURE_REGISTERED
(ItuR1411LosPropagationLossModel)
35
;
36
37
TypeId
38
ItuR1411LosPropagationLossModel::GetTypeId
(
void
)
39
{
40
static
TypeId
tid =
TypeId
(
"ns3::ItuR1411LosPropagationLossModel"
)
41
42
.
SetParent
<
PropagationLossModel
> ()
43
44
.AddAttribute (
"Frequency"
,
45
"The propagation frequency in Hz"
,
46
DoubleValue
(2160e6),
47
MakeDoubleAccessor (&
ItuR1411LosPropagationLossModel::SetFrequency
),
48
MakeDoubleChecker<double> ());
49
50
return
tid;
51
}
52
53
double
54
ItuR1411LosPropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
55
{
56
NS_LOG_FUNCTION
(
this
);
57
double
dist = a->
GetDistanceFrom
(b);
58
double
lossLow = 0.0;
59
double
lossUp = 0.0;
60
NS_ASSERT_MSG
(a->
GetPosition
().
z
> 0 && b->
GetPosition
().
z
> 0,
"nodes' height must be greater than 0"
);
61
double
Lbp = std::fabs (20 * std::log10 ((
m_lambda
*
m_lambda
) / (8 * M_PI * a->
GetPosition
().
z
* b->
GetPosition
().
z
)));
62
double
Rbp = (4 * a->
GetPosition
().
z
* b->
GetPosition
().
z
) / m_lambda;
63
NS_LOG_LOGIC
(
this
<<
" Lbp "
<< Lbp <<
" Rbp "
<< Rbp <<
" lambda "
<< m_lambda);
64
if
(dist <= Rbp)
65
{
66
lossLow = Lbp + 20 * std::log10 (dist / Rbp);
67
lossUp = Lbp + 20 + 25 * std::log10 (dist / Rbp);
68
}
69
else
70
{
71
lossLow = Lbp + 40 * std::log10 (dist / Rbp);
72
lossUp = Lbp + 20 + 40 * std::log10 (dist / Rbp);
73
}
74
75
double
loss = (lossUp + lossLow) / 2;
76
77
return
loss;
78
}
79
80
81
void
82
ItuR1411LosPropagationLossModel::SetFrequency
(
double
freq)
83
{
84
NS_ASSERT
(freq > 0.0);
85
m_lambda
= 299792458.0 / freq;
86
}
87
88
89
double
90
ItuR1411LosPropagationLossModel::DoCalcRxPower
(
double
txPowerDbm,
91
Ptr<MobilityModel>
a,
92
Ptr<MobilityModel>
b)
const
93
{
94
return
(txPowerDbm -
GetLoss
(a, b));
95
}
96
97
int64_t
98
ItuR1411LosPropagationLossModel::DoAssignStreams
(int64_t stream)
99
{
100
return
0;
101
}
102
}
// namespace ns3
ns3::Ptr< MobilityModel >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition:
mobility-model.cc:80
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
ns3::MobilityModel::GetPosition
Vector GetPosition(void) const
Definition:
mobility-model.cc:63
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("ItuR1411LosPropagationLossModel")
ns3::ItuR1411LosPropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
itu-r-1411-los-propagation-loss-model.cc:54
ns3::ItuR1411LosPropagationLossModel::SetFrequency
void SetFrequency(double freq)
Set the operating frequency.
Definition:
itu-r-1411-los-propagation-loss-model.cc:82
ns3::ItuR1411LosPropagationLossModel::m_lambda
double m_lambda
Definition:
itu-r-1411-los-propagation-loss-model.h:76
ns3::ItuR1411LosPropagationLossModel::DoCalcRxPower
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
itu-r-1411-los-propagation-loss-model.cc:90
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Definition:
log.h:368
ns3::ItuR1411LosPropagationLossModel::GetTypeId
static TypeId GetTypeId(void)
Definition:
itu-r-1411-los-propagation-loss-model.cc:38
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
Definition:
assert.h:86
itu-r-1411-los-propagation-loss-model.h
ns3::PropagationLossModel
Modelize the propagation loss through a transmission medium.
Definition:
propagation-loss-model.h:49
ns3::ItuR1411LosPropagationLossModel::DoAssignStreams
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
Definition:
itu-r-1411-los-propagation-loss-model.cc:98
ns3::DoubleValue
Hold a floating point type.
Definition:
double.h:41
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
ns3::Vector3D::z
double z
z coordinate of vector
Definition:
vector.h:57
src
propagation
model
itu-r-1411-los-propagation-loss-model.cc
Generated on Sat Apr 19 2014 14:07:07 for ns-3 by
1.8.6