author | Kirill Andreev <andreev@iitp.ru> |
Mon, 03 Aug 2009 19:13:46 +0400 | |
changeset 5145 | 7f50ab7ce59d |
parent 4469 | af124ed35b94 |
permissions | -rw-r--r-- |
2034
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
2 |
/* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
3 |
* Copyright (c) 2005,2006,2007 INRIA |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
4 |
* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
7 |
* published by the Free Software Foundation; |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
8 |
* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
12 |
* GNU General Public License for more details. |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
13 |
* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
17 |
* |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
19 |
* Contributions: Timo Bingmann <timo.bingmann@student.kit.edu> |
2034
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
20 |
*/ |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
21 |
|
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#include "propagation-loss-model.h" |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
23 |
#include "ns3/log.h" |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
24 |
#include "ns3/mobility-model.h" |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
25 |
#include "ns3/boolean.h" |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
26 |
#include "ns3/double.h" |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
#include <math.h> |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
|
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
29 |
NS_LOG_COMPONENT_DEFINE ("PropagationLossModel"); |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
30 |
|
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
namespace ns3 { |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
33 |
// ------------------------------------------------------------------------- // |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
|
2940
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
35 |
NS_OBJECT_ENSURE_REGISTERED (PropagationLossModel); |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
36 |
|
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
37 |
TypeId |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
38 |
PropagationLossModel::GetTypeId (void) |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
39 |
{ |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
40 |
static TypeId tid = TypeId ("ns3::PropagationLossModel") |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
41 |
.SetParent<Object> () |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
42 |
; |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
43 |
return tid; |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
44 |
} |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
45 |
|
3907
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
46 |
PropagationLossModel::PropagationLossModel () |
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
47 |
: m_next (0) |
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
48 |
{} |
2940
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
49 |
|
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
PropagationLossModel::~PropagationLossModel () |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
{} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
|
3911
a9bd53792bc1
implement missing method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3909
diff
changeset
|
53 |
void |
a9bd53792bc1
implement missing method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3909
diff
changeset
|
54 |
PropagationLossModel::SetNext (Ptr<PropagationLossModel> next) |
a9bd53792bc1
implement missing method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3909
diff
changeset
|
55 |
{ |
a9bd53792bc1
implement missing method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3909
diff
changeset
|
56 |
m_next = next; |
a9bd53792bc1
implement missing method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3909
diff
changeset
|
57 |
} |
a9bd53792bc1
implement missing method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3909
diff
changeset
|
58 |
|
3907
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
59 |
double |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
60 |
PropagationLossModel::CalcRxPower (double txPowerDbm, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
61 |
Ptr<MobilityModel> a, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
62 |
Ptr<MobilityModel> b) const |
3907
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
63 |
{ |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
64 |
double self = DoCalcRxPower (txPowerDbm, a, b); |
3907
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
65 |
if (m_next != 0) |
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
66 |
{ |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
67 |
self = m_next->CalcRxPower (self, a, b); |
3907
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
68 |
} |
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
69 |
return self; |
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
70 |
} |
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
71 |
|
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
72 |
// ------------------------------------------------------------------------- // |
3907
56e477db65b2
add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3681
diff
changeset
|
73 |
|
2940
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
74 |
NS_OBJECT_ENSURE_REGISTERED (RandomPropagationLossModel); |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
75 |
|
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
76 |
TypeId |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
77 |
RandomPropagationLossModel::GetTypeId (void) |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
78 |
{ |
2943
cdbcd43a019c
add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2940
diff
changeset
|
79 |
static TypeId tid = TypeId ("ns3::RandomPropagationLossModel") |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
80 |
.SetParent<PropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
81 |
.AddConstructor<RandomPropagationLossModel> () |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
82 |
.AddAttribute ("Variable", "The random variable used to pick a loss everytime CalcRxPower is invoked.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2943
diff
changeset
|
83 |
RandomVariableValue (ConstantVariable (1.0)), |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
84 |
MakeRandomVariableAccessor (&RandomPropagationLossModel::m_variable), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
85 |
MakeRandomVariableChecker ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
86 |
; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
87 |
return tid; |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
88 |
} |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
89 |
RandomPropagationLossModel::RandomPropagationLossModel () |
3908
232d52317a18
fix build.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3907
diff
changeset
|
90 |
: PropagationLossModel () |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
91 |
{} |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
92 |
|
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
93 |
RandomPropagationLossModel::~RandomPropagationLossModel () |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
94 |
{} |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
95 |
|
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
96 |
double |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
97 |
RandomPropagationLossModel::DoCalcRxPower (double txPowerDbm, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
98 |
Ptr<MobilityModel> a, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
99 |
Ptr<MobilityModel> b) const |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
100 |
{ |
2677
28dfd0c7510d
PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents:
2615
diff
changeset
|
101 |
double rxc = -m_variable.GetValue (); |
28dfd0c7510d
PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents:
2615
diff
changeset
|
102 |
NS_LOG_DEBUG ("attenuation coefficent="<<rxc<<"Db"); |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
103 |
return txPowerDbm + rxc; |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
104 |
} |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
105 |
|
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
106 |
// ------------------------------------------------------------------------- // |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
107 |
|
2940
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
108 |
NS_OBJECT_ENSURE_REGISTERED (FriisPropagationLossModel); |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
109 |
|
4464
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
110 |
const double FriisPropagationLossModel::PI = 3.14159265358979323846; |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
111 |
|
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
112 |
TypeId |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
113 |
FriisPropagationLossModel::GetTypeId (void) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
114 |
{ |
2943
cdbcd43a019c
add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2940
diff
changeset
|
115 |
static TypeId tid = TypeId ("ns3::FriisPropagationLossModel") |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
116 |
.SetParent<PropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
117 |
.AddConstructor<FriisPropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
118 |
.AddAttribute ("Lambda", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
119 |
"The wavelength (default is 5.15 GHz at 300 000 km/s).", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2943
diff
changeset
|
120 |
DoubleValue (300000000.0 / 5.150e9), |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
121 |
MakeDoubleAccessor (&FriisPropagationLossModel::m_lambda), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
122 |
MakeDoubleChecker<double> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
123 |
.AddAttribute ("SystemLoss", "The system loss", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2943
diff
changeset
|
124 |
DoubleValue (1.0), |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
125 |
MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
126 |
MakeDoubleChecker<double> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
127 |
.AddAttribute ("MinDistance", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
128 |
"The distance under which the propagation model refuses to give results (m)", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2943
diff
changeset
|
129 |
DoubleValue (0.5), |
3388
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
130 |
MakeDoubleAccessor (&FriisPropagationLossModel::SetMinDistance, |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
131 |
&FriisPropagationLossModel::GetMinDistance), |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
132 |
MakeDoubleChecker<double> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
133 |
; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
134 |
return tid; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
135 |
} |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
136 |
|
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
137 |
FriisPropagationLossModel::FriisPropagationLossModel () |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
138 |
{} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
139 |
void |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
140 |
FriisPropagationLossModel::SetSystemLoss (double systemLoss) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
141 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
142 |
m_systemLoss = systemLoss; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
143 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
144 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
145 |
FriisPropagationLossModel::GetSystemLoss (void) const |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
146 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
147 |
return m_systemLoss; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
148 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
149 |
void |
3388
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
150 |
FriisPropagationLossModel::SetMinDistance (double minDistance) |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
151 |
{ |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
152 |
m_minDistance = minDistance; |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
153 |
} |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
154 |
double |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
155 |
FriisPropagationLossModel::GetMinDistance (void) const |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
156 |
{ |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
157 |
return m_minDistance; |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
158 |
} |
0258bd0793ab
add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
159 |
void |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
160 |
FriisPropagationLossModel::SetLambda (double frequency, double speed) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
161 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
162 |
m_lambda = speed / frequency; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
163 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
164 |
void |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
165 |
FriisPropagationLossModel::SetLambda (double lambda) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
166 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
167 |
m_lambda = lambda; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
168 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
169 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
170 |
FriisPropagationLossModel::GetLambda (void) const |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
171 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
172 |
return m_lambda; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
173 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
174 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
175 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
176 |
FriisPropagationLossModel::DbmToW (double dbm) const |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
177 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
178 |
double mw = pow(10.0,dbm/10.0); |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
179 |
return mw / 1000.0; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
180 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
181 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
182 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
183 |
FriisPropagationLossModel::DbmFromW (double w) const |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
184 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
185 |
double dbm = log10 (w * 1000.0) * 10.0; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
186 |
return dbm; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
187 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
188 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
189 |
double |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
190 |
FriisPropagationLossModel::DoCalcRxPower (double txPowerDbm, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
191 |
Ptr<MobilityModel> a, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
192 |
Ptr<MobilityModel> b) const |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
193 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
194 |
/* |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
195 |
* Friis free space equation: |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
196 |
* where Pt, Gr, Gr and P are in Watt units |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
197 |
* L is in meter units. |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
198 |
* |
2677
28dfd0c7510d
PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents:
2615
diff
changeset
|
199 |
* P Gt * Gr * (lambda^2) |
28dfd0c7510d
PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents:
2615
diff
changeset
|
200 |
* --- = --------------------- |
28dfd0c7510d
PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents:
2615
diff
changeset
|
201 |
* Pt (4 * pi * d)^2 * L |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
202 |
* |
2070
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
203 |
* Gt: tx gain (unit-less) |
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
204 |
* Gr: rx gain (unit-less) |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
205 |
* Pt: tx power (W) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
206 |
* d: distance (m) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
207 |
* L: system loss |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
208 |
* lambda: wavelength (m) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
209 |
* |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
210 |
* Here, we ignore tx and rx gain and the input and output values |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
211 |
* are in dB or dBm: |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
212 |
* |
2073
6e1e046b323a
simplify the code a bit. Make sure we handle correctly the calculation of the reference rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2070
diff
changeset
|
213 |
* lambda^2 |
6e1e046b323a
simplify the code a bit. Make sure we handle correctly the calculation of the reference rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2070
diff
changeset
|
214 |
* rx = tx + 10 log10 (-------------------) |
6e1e046b323a
simplify the code a bit. Make sure we handle correctly the calculation of the reference rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2070
diff
changeset
|
215 |
* (4 * pi * d)^2 * L |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
216 |
* |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
217 |
* rx: rx power (dB) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
218 |
* tx: tx power (dB) |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
219 |
* d: distance (m) |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
220 |
* L: system loss (unit-less) |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
221 |
* lambda: wavelength (m) |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
222 |
*/ |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
223 |
double distance = a->GetDistanceFrom (b); |
2064
a1adc9960e50
handle min distance for friis model in a saner way
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2063
diff
changeset
|
224 |
if (distance <= m_minDistance) |
2062
88302488c05b
Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2044
diff
changeset
|
225 |
{ |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
226 |
return txPowerDbm; |
2062
88302488c05b
Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2044
diff
changeset
|
227 |
} |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
228 |
double numerator = m_lambda * m_lambda; |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
229 |
double denominator = 16 * PI * PI * distance * distance * m_systemLoss; |
2073
6e1e046b323a
simplify the code a bit. Make sure we handle correctly the calculation of the reference rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2070
diff
changeset
|
230 |
double pr = 10 * log10 (numerator / denominator); |
2677
28dfd0c7510d
PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents:
2615
diff
changeset
|
231 |
NS_LOG_DEBUG ("distance="<<distance<<"m, attenuation coefficient="<<pr<<"dB"); |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
232 |
return txPowerDbm + pr; |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
233 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
234 |
|
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
235 |
// ------------------------------------------------------------------------- // |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
236 |
|
2940
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
237 |
NS_OBJECT_ENSURE_REGISTERED (LogDistancePropagationLossModel); |
8fb456039670
add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2927
diff
changeset
|
238 |
|
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
239 |
TypeId |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
240 |
LogDistancePropagationLossModel::GetTypeId (void) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
241 |
{ |
2943
cdbcd43a019c
add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2940
diff
changeset
|
242 |
static TypeId tid = TypeId ("ns3::LogDistancePropagationLossModel") |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
243 |
.SetParent<PropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
244 |
.AddConstructor<LogDistancePropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
245 |
.AddAttribute ("Exponent", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
246 |
"The exponent of the Path Loss propagation model", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2943
diff
changeset
|
247 |
DoubleValue (3.0), |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
248 |
MakeDoubleAccessor (&LogDistancePropagationLossModel::m_exponent), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
249 |
MakeDoubleChecker<double> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
250 |
.AddAttribute ("ReferenceDistance", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
251 |
"The distance at which the reference loss is calculated (m)", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2943
diff
changeset
|
252 |
DoubleValue (1.0), |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
253 |
MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceDistance), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
254 |
MakeDoubleChecker<double> ()) |
3909
4e7e594b0b7e
get rid of reference model for log distance model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3908
diff
changeset
|
255 |
.AddAttribute ("ReferenceLoss", |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
256 |
"The reference loss at reference distance (dB). (Default is Friis at 1m with 5.15 GHz)", |
3909
4e7e594b0b7e
get rid of reference model for log distance model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3908
diff
changeset
|
257 |
DoubleValue (46.6777), |
3913 | 258 |
MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceLoss), |
3909
4e7e594b0b7e
get rid of reference model for log distance model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3908
diff
changeset
|
259 |
MakeDoubleChecker<double> ()) |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
260 |
; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
261 |
return tid; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
262 |
|
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
263 |
} |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
264 |
|
2063
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
265 |
LogDistancePropagationLossModel::LogDistancePropagationLossModel () |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
266 |
{} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
267 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
268 |
void |
2063
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
269 |
LogDistancePropagationLossModel::SetPathLossExponent (double n) |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
270 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
271 |
m_exponent = n; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
272 |
} |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
273 |
void |
3909
4e7e594b0b7e
get rid of reference model for log distance model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3908
diff
changeset
|
274 |
LogDistancePropagationLossModel::SetReference (double referenceDistance, double referenceLoss) |
2063
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
275 |
{ |
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
276 |
m_referenceDistance = referenceDistance; |
3909
4e7e594b0b7e
get rid of reference model for log distance model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3908
diff
changeset
|
277 |
m_referenceLoss = referenceLoss; |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
278 |
} |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
279 |
double |
2063
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
280 |
LogDistancePropagationLossModel::GetPathLossExponent (void) const |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
281 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
282 |
return m_exponent; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
283 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
284 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
285 |
double |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
286 |
LogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
287 |
Ptr<MobilityModel> a, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
288 |
Ptr<MobilityModel> b) const |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
289 |
{ |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
290 |
double distance = a->GetDistanceFrom (b); |
2073
6e1e046b323a
simplify the code a bit. Make sure we handle correctly the calculation of the reference rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2070
diff
changeset
|
291 |
if (distance <= m_referenceDistance) |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
292 |
{ |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
293 |
return txPowerDbm; |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
294 |
} |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
295 |
/** |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
296 |
* The formula is: |
2070
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
297 |
* rx = 10 * log (Pr0(tx)) - n * 10 * log (d/d0) |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
298 |
* |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
299 |
* Pr0: rx power at reference distance d0 (W) |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
300 |
* d0: reference distance: 1.0 (m) |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
301 |
* d: distance (m) |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
302 |
* tx: tx power (dB) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
303 |
* rx: dB |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
304 |
* |
2073
6e1e046b323a
simplify the code a bit. Make sure we handle correctly the calculation of the reference rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2070
diff
changeset
|
305 |
* Which, in our case is: |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
306 |
* |
2073
6e1e046b323a
simplify the code a bit. Make sure we handle correctly the calculation of the reference rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2070
diff
changeset
|
307 |
* rx = rx0(tx) - 10 * n * log (d/d0) |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
308 |
*/ |
2073
6e1e046b323a
simplify the code a bit. Make sure we handle correctly the calculation of the reference rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2070
diff
changeset
|
309 |
double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance); |
3909
4e7e594b0b7e
get rid of reference model for log distance model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3908
diff
changeset
|
310 |
double rxc = -m_referenceLoss - pathLossDb; |
4e7e594b0b7e
get rid of reference model for log distance model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3908
diff
changeset
|
311 |
NS_LOG_DEBUG ("distance="<<distance<<"m, reference-attenuation="<<-m_referenceLoss<<"dB, "<< |
4e7e594b0b7e
get rid of reference model for log distance model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3908
diff
changeset
|
312 |
"attenuation coefficient="<<rxc<<"db"); |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
313 |
return txPowerDbm + rxc; |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
314 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
315 |
|
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
316 |
// ------------------------------------------------------------------------- // |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
317 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
318 |
NS_OBJECT_ENSURE_REGISTERED (ThreeLogDistancePropagationLossModel); |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
319 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
320 |
TypeId |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
321 |
ThreeLogDistancePropagationLossModel::GetTypeId (void) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
322 |
{ |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
323 |
static TypeId tid = TypeId ("ns3::ThreeLogDistancePropagationLossModel") |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
324 |
.SetParent<PropagationLossModel> () |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
325 |
.AddConstructor<ThreeLogDistancePropagationLossModel> () |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
326 |
.AddAttribute ("Distance0", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
327 |
"Beginning of the first (near) distance field", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
328 |
DoubleValue (1.0), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
329 |
MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance0), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
330 |
MakeDoubleChecker<double> ()) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
331 |
.AddAttribute ("Distance1", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
332 |
"Beginning of the second (middle) distance field.", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
333 |
DoubleValue (200.0), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
334 |
MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance1), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
335 |
MakeDoubleChecker<double> ()) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
336 |
.AddAttribute ("Distance2", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
337 |
"Beginning of the third (far) distance field.", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
338 |
DoubleValue (500.0), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
339 |
MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance2), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
340 |
MakeDoubleChecker<double> ()) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
341 |
.AddAttribute ("Exponent0", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
342 |
"The exponent for the first field.", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
343 |
DoubleValue (1.9), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
344 |
MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent0), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
345 |
MakeDoubleChecker<double> ()) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
346 |
.AddAttribute ("Exponent1", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
347 |
"The exponent for the second field.", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
348 |
DoubleValue (3.8), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
349 |
MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent1), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
350 |
MakeDoubleChecker<double> ()) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
351 |
.AddAttribute ("Exponent2", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
352 |
"The exponent for the third field.", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
353 |
DoubleValue (3.8), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
354 |
MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent2), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
355 |
MakeDoubleChecker<double> ()) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
356 |
.AddAttribute ("ReferenceLoss", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
357 |
"The reference loss at distance d0 (dB). (Default is Friis at 1m with 5.15 GHz)", |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
358 |
DoubleValue (46.6777), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
359 |
MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_referenceLoss), |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
360 |
MakeDoubleChecker<double> ()) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
361 |
; |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
362 |
return tid; |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
363 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
364 |
} |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
365 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
366 |
ThreeLogDistancePropagationLossModel::ThreeLogDistancePropagationLossModel () |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
367 |
{ |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
368 |
} |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
369 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
370 |
double |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
371 |
ThreeLogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
372 |
Ptr<MobilityModel> a, |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
373 |
Ptr<MobilityModel> b) const |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
374 |
{ |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
375 |
double distance = a->GetDistanceFrom (b); |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
376 |
NS_ASSERT(distance >= 0); |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
377 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
378 |
// See doxygen comments for the formula and explanation |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
379 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
380 |
double pathLossDb; |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
381 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
382 |
if (distance < m_distance0) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
383 |
{ |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
384 |
pathLossDb = 0; |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
385 |
} |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
386 |
else if (distance < m_distance1) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
387 |
{ |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
388 |
pathLossDb = m_referenceLoss |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
389 |
+ 10 * m_exponent0 * log10(distance / m_distance0); |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
390 |
} |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
391 |
else if (distance < m_distance2) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
392 |
{ |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
393 |
pathLossDb = m_referenceLoss |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
394 |
+ 10 * m_exponent0 * log10(m_distance1 / m_distance0) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
395 |
+ 10 * m_exponent1 * log10(distance / m_distance1); |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
396 |
} |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
397 |
else |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
398 |
{ |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
399 |
pathLossDb = m_referenceLoss |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
400 |
+ 10 * m_exponent0 * log10(m_distance1 / m_distance0) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
401 |
+ 10 * m_exponent1 * log10(m_distance2 / m_distance1) |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
402 |
+ 10 * m_exponent2 * log10(distance / m_distance2); |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
403 |
} |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
404 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
405 |
NS_LOG_DEBUG ("ThreeLogDistance distance=" << distance << "m, " << |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
406 |
"attenuation=" << pathLossDb << "dB"); |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
407 |
|
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
408 |
return txPowerDbm - pathLossDb; |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
409 |
} |
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
410 |
|
4464
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
411 |
// ------------------------------------------------------------------------- // |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
412 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
413 |
NS_OBJECT_ENSURE_REGISTERED (NakagamiPropagationLossModel); |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
414 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
415 |
TypeId |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
416 |
NakagamiPropagationLossModel::GetTypeId (void) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
417 |
{ |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
418 |
static TypeId tid = TypeId ("ns3::NakagamiPropagationLossModel") |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
419 |
.SetParent<PropagationLossModel> () |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
420 |
.AddConstructor<NakagamiPropagationLossModel> () |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
421 |
.AddAttribute ("Distance1", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
422 |
"Beginning of the second distance field. Default is 80m.", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
423 |
DoubleValue (80.0), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
424 |
MakeDoubleAccessor (&NakagamiPropagationLossModel::m_distance1), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
425 |
MakeDoubleChecker<double> ()) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
426 |
.AddAttribute ("Distance2", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
427 |
"Beginning of the third distance field. Default is 200m.", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
428 |
DoubleValue (200.0), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
429 |
MakeDoubleAccessor (&NakagamiPropagationLossModel::m_distance2), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
430 |
MakeDoubleChecker<double> ()) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
431 |
.AddAttribute ("m0", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
432 |
"m0 for distances smaller than Distance1. Default is 1.5.", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
433 |
DoubleValue (1.5), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
434 |
MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m0), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
435 |
MakeDoubleChecker<double> ()) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
436 |
.AddAttribute ("m1", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
437 |
"m1 for distances smaller than Distance2. Default is 0.75.", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
438 |
DoubleValue (0.75), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
439 |
MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m1), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
440 |
MakeDoubleChecker<double> ()) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
441 |
.AddAttribute ("m2", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
442 |
"m2 for distances greater than Distance2. Default is 0.75.", |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
443 |
DoubleValue (0.75), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
444 |
MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m2), |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
445 |
MakeDoubleChecker<double> ()) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
446 |
; |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
447 |
return tid; |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
448 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
449 |
} |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
450 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
451 |
NakagamiPropagationLossModel::NakagamiPropagationLossModel () |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
452 |
{} |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
453 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
454 |
double |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
455 |
NakagamiPropagationLossModel::DoCalcRxPower (double txPowerDbm, |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
456 |
Ptr<MobilityModel> a, |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
457 |
Ptr<MobilityModel> b) const |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
458 |
{ |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
459 |
// select m parameter |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
460 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
461 |
double distance = a->GetDistanceFrom (b); |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
462 |
NS_ASSERT(distance >= 0); |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
463 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
464 |
double m; |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
465 |
if (distance < m_distance1) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
466 |
{ |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
467 |
m = m_m0; |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
468 |
} |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
469 |
else if (distance < m_distance2) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
470 |
{ |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
471 |
m = m_m1; |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
472 |
} |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
473 |
else |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
474 |
{ |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
475 |
m = m_m2; |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
476 |
} |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
477 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
478 |
// the current power unit is dBm, but Watt is put into the Nakagami / |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
479 |
// Rayleigh distribution. |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
480 |
double powerW = pow(10, (txPowerDbm - 30) / 10); |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
481 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
482 |
double resultPowerW; |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
483 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
484 |
// switch between Erlang- and Gamma distributions: this is only for |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
485 |
// speed. (Gamma is equal to Erlang for any positive integer m.) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
486 |
unsigned int int_m = static_cast<unsigned int>(floor(m)); |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
487 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
488 |
if (int_m == m) |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
489 |
{ |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
490 |
resultPowerW = m_erlangRandomVariable.GetValue(int_m, powerW / m); |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
491 |
} |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
492 |
else |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
493 |
{ |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
494 |
resultPowerW = m_gammaRandomVariable.GetValue(m, powerW / m); |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
495 |
} |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
496 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
497 |
double resultPowerDbm = 10 * log10(resultPowerW) + 30; |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
498 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
499 |
NS_LOG_DEBUG ("Nakagami distance=" << distance << "m, " << |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
500 |
"power=" << powerW <<"W, " << |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
501 |
"resultPower=" << resultPowerW << "W=" << resultPowerDbm << "dBm"); |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
502 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
503 |
return resultPowerDbm; |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
504 |
} |
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
505 |
|
be1414b398a0
Nakagami propagation loss model from ns2
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4257
diff
changeset
|
506 |
// ------------------------------------------------------------------------- // |
4059
251351372d8d
PropagationLossModel::GetLoss -> CalcRxPower. Add ThreeLogDistancePropagationLossModel.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3913
diff
changeset
|
507 |
|
4469
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
508 |
NS_OBJECT_ENSURE_REGISTERED (FixedRssLossModel); |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
509 |
|
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
510 |
TypeId |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
511 |
FixedRssLossModel::GetTypeId (void) |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
512 |
{ |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
513 |
static TypeId tid = TypeId ("ns3::FixedRssLossModel") |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
514 |
.SetParent<PropagationLossModel> () |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
515 |
.AddConstructor<FixedRssLossModel> () |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
516 |
.AddAttribute ("Rss", "The fixed receiver Rss.", |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
517 |
DoubleValue (-150.0), |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
518 |
MakeDoubleAccessor (&FixedRssLossModel::m_rss), |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
519 |
MakeDoubleChecker<double> ()) |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
520 |
; |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
521 |
return tid; |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
522 |
} |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
523 |
FixedRssLossModel::FixedRssLossModel () |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
524 |
: PropagationLossModel () |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
525 |
{} |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
526 |
|
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
527 |
FixedRssLossModel::~FixedRssLossModel () |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
528 |
{} |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
529 |
|
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
530 |
void |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
531 |
FixedRssLossModel::SetRss (double rss) |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
532 |
{ |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
533 |
m_rss = rss; |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
534 |
} |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
535 |
|
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
536 |
double |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
537 |
FixedRssLossModel::DoCalcRxPower (double txPowerDbm, |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
538 |
Ptr<MobilityModel> a, |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
539 |
Ptr<MobilityModel> b) const |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
540 |
{ |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
541 |
return m_rss; |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
542 |
} |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
543 |
|
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
544 |
// ------------------------------------------------------------------------- // |
af124ed35b94
Fixed propagation loss model
Gary Pei <guangyu.pei@boeing.com>
parents:
4464
diff
changeset
|
545 |
|
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
546 |
} // namespace ns3 |