author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Tue, 11 Mar 2008 13:30:12 -0700 | |
changeset 2592 | 3ebf97150166 |
parent 2549 | fe90cf0b2c63 |
child 2615 | 09e459167dc3 |
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> |
8664ab76ff85
add missing headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2031
diff
changeset
|
19 |
*/ |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#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
|
21 |
#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
|
22 |
#include "ns3/mobility-model.h" |
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
23 |
#include "ns3/static-mobility-model.h" |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
24 |
#include "ns3/double.h" |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include <math.h> |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
|
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
27 |
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
|
28 |
|
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
namespace ns3 { |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
|
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
31 |
|
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
const double FriisPropagationLossModel::PI = 3.1415; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
PropagationLossModel::~PropagationLossModel () |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
{} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
|
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
37 |
TypeId |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
38 |
RandomPropagationLossModel::GetTypeId (void) |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
39 |
{ |
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
40 |
static TypeId tid = TypeId ("RandomPropagationLossModel") |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
41 |
.SetParent<PropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
42 |
.AddConstructor<RandomPropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
43 |
.AddAttribute ("Variable", "XXX", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
44 |
ConstantVariable (1.0), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
45 |
MakeRandomVariableAccessor (&RandomPropagationLossModel::m_variable), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
46 |
MakeRandomVariableChecker ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
47 |
; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
48 |
return tid; |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
49 |
} |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
50 |
RandomPropagationLossModel::RandomPropagationLossModel () |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
51 |
{} |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
52 |
|
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
53 |
RandomPropagationLossModel::~RandomPropagationLossModel () |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
54 |
{} |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
55 |
|
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
56 |
double |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
57 |
RandomPropagationLossModel::GetRxPower (double txPowerDbm, |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
58 |
Ptr<MobilityModel> a, |
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
59 |
Ptr<MobilityModel> b) const |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
60 |
{ |
2336
28ce210b91bb
bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
61 |
double rxPower = txPowerDbm - m_variable.GetValue (); |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
62 |
NS_LOG_DEBUG ("tx power="<<txPowerDbm<<"dbm, rx power="<<rxPower<<"Dbm"); |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
63 |
return rxPower; |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
64 |
} |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
65 |
|
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
66 |
TypeId |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
67 |
FriisPropagationLossModel::GetTypeId (void) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
68 |
{ |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
69 |
static TypeId tid = TypeId ("FriisPropagationLossModel") |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
70 |
.SetParent<PropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
71 |
.AddConstructor<FriisPropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
72 |
.AddAttribute ("Lambda", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
73 |
"The wavelength (default is 5.15 GHz at 300 000 km/s).", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
74 |
Double (300000000.0 / 5.150e9), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
75 |
MakeDoubleAccessor (&FriisPropagationLossModel::m_lambda), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
76 |
MakeDoubleChecker<double> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
77 |
.AddAttribute ("SystemLoss", "The system loss", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
78 |
Double (1.0), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
79 |
MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
80 |
MakeDoubleChecker<double> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
81 |
.AddAttribute ("MinDistance", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
82 |
"The distance under which the propagation model refuses to give results (m)", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
83 |
Double (0.5), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
84 |
MakeDoubleAccessor (&FriisPropagationLossModel::m_minDistance), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
85 |
MakeDoubleChecker<double> ()) |
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; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
88 |
} |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
89 |
|
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
90 |
FriisPropagationLossModel::FriisPropagationLossModel () |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
91 |
{} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
92 |
void |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
93 |
FriisPropagationLossModel::SetSystemLoss (double systemLoss) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
94 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
95 |
m_systemLoss = systemLoss; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
96 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
97 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
98 |
FriisPropagationLossModel::GetSystemLoss (void) const |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
99 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
100 |
return m_systemLoss; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
101 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
102 |
void |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
103 |
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
|
104 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
105 |
m_lambda = speed / frequency; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
106 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
107 |
void |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
108 |
FriisPropagationLossModel::SetLambda (double lambda) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
109 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
110 |
m_lambda = lambda; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
111 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
112 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
113 |
FriisPropagationLossModel::GetLambda (void) const |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
114 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
115 |
return m_lambda; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
116 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
117 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
118 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
119 |
FriisPropagationLossModel::DbmToW (double dbm) const |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
120 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
121 |
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
|
122 |
return mw / 1000.0; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
123 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
124 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
125 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
126 |
FriisPropagationLossModel::DbmFromW (double w) const |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
127 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
128 |
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
|
129 |
return dbm; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
130 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
131 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
132 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
133 |
double |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
134 |
FriisPropagationLossModel::GetRxPower (double txPowerDbm, |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
135 |
Ptr<MobilityModel> a, |
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
136 |
Ptr<MobilityModel> b) const |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
137 |
{ |
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 |
* Friis free space equation: |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
140 |
* 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
|
141 |
* L is in meter units. |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
142 |
* |
2070
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
143 |
* Gt * Gr * (lambda^2) |
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
144 |
* P = Pt --------------------- |
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
145 |
* (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
|
146 |
* |
2070
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
147 |
* Gt: tx gain (unit-less) |
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
148 |
* 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
|
149 |
* Pt: tx power (W) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
150 |
* d: distance (m) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
151 |
* L: system loss |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
152 |
* lambda: wavelength (m) |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
153 |
* |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
154 |
* Here, we ignore tx and rx gain and the input and output values |
2070
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
155 |
* are in dbm: |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
156 |
* |
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
|
157 |
* 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
|
158 |
* 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
|
159 |
* (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
|
160 |
* |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
161 |
* rx: rx power (dbm) |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
162 |
* tx: tx power (dbm) |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
163 |
* d: distance (m) |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
164 |
* L: system loss |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
165 |
* lambda: wavelength (m) |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
166 |
*/ |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
167 |
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
|
168 |
if (distance <= m_minDistance) |
2062
88302488c05b
Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2044
diff
changeset
|
169 |
{ |
2064
a1adc9960e50
handle min distance for friis model in a saner way
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2063
diff
changeset
|
170 |
return txPowerDbm; |
2062
88302488c05b
Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2044
diff
changeset
|
171 |
} |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
172 |
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
|
173 |
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
|
174 |
double pr = 10 * log10 (numerator / denominator); |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
175 |
double rxPowerDbm = txPowerDbm + pr; |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
176 |
NS_LOG_DEBUG ("distance="<<distance<<"m, tx power="<<txPowerDbm<<"dbm, rx power="<<rxPowerDbm<<"dbm"); |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
177 |
return rxPowerDbm; |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
178 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
179 |
|
2549
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
180 |
TypeId |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
181 |
LogDistancePropagationLossModel::GetTypeId (void) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
182 |
{ |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
183 |
static TypeId tid = TypeId ("LogDistancePropagationLossModel") |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
184 |
.SetParent<PropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
185 |
.AddConstructor<LogDistancePropagationLossModel> () |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
186 |
.AddAttribute ("Exponent", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
187 |
"The exponent of the Path Loss propagation model", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
188 |
Double (3.0), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
189 |
MakeDoubleAccessor (&LogDistancePropagationLossModel::m_exponent), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
190 |
MakeDoubleChecker<double> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
191 |
.AddAttribute ("ReferenceDistance", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
192 |
"The distance at which the reference loss is calculated (m)", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
193 |
Double (1.0), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
194 |
MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceDistance), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
195 |
MakeDoubleChecker<double> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
196 |
.AddAttribute ("ReferenceModel", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
197 |
"The reference model at the reference distance.", |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
198 |
Ptr<PropagationLossModel> (0), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
199 |
MakePtrAccessor (&LogDistancePropagationLossModel::m_reference), |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
200 |
MakePtrChecker<PropagationLossModel> ()) |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
201 |
; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
202 |
return tid; |
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
203 |
|
fe90cf0b2c63
port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2399
diff
changeset
|
204 |
} |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
205 |
|
2063
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
206 |
LogDistancePropagationLossModel::LogDistancePropagationLossModel () |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
207 |
{} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
208 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
209 |
void |
2063
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
210 |
LogDistancePropagationLossModel::SetPathLossExponent (double n) |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
211 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
212 |
m_exponent = n; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
213 |
} |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
214 |
void |
2063
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
215 |
LogDistancePropagationLossModel::SetReferenceDistance (double referenceDistance) |
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
216 |
{ |
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
217 |
m_referenceDistance = referenceDistance; |
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
218 |
} |
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
219 |
void |
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
220 |
LogDistancePropagationLossModel::SetReferenceModel (Ptr<PropagationLossModel> model) |
1959
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
221 |
{ |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
222 |
m_reference = model; |
f64684973ea8
support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1882
diff
changeset
|
223 |
} |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
224 |
double |
2063
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
225 |
LogDistancePropagationLossModel::GetPathLossExponent (void) const |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
226 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
227 |
return m_exponent; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
228 |
} |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
229 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
230 |
double |
2063
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
231 |
LogDistancePropagationLossModel::GetRxPower (double txPowerDbm, |
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
232 |
Ptr<MobilityModel> a, |
8663fe258bce
document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2062
diff
changeset
|
233 |
Ptr<MobilityModel> b) const |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
234 |
{ |
2031
567dbc2475fc
replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1985
diff
changeset
|
235 |
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
|
236 |
if (distance <= m_referenceDistance) |
1882
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
237 |
{ |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
238 |
return txPowerDbm; |
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
239 |
} |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
240 |
/** |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
241 |
* The formula is: |
2070
377898b9c6f5
clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2065
diff
changeset
|
242 |
* 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
|
243 |
* |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
244 |
* 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
|
245 |
* 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
|
246 |
* d: distance (m) |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
247 |
* tx: tx power (db) |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
248 |
* rx: db |
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
249 |
* |
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
|
250 |
* Which, in our case is: |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
251 |
* |
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
|
252 |
* 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
|
253 |
*/ |
2399
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
254 |
static Ptr<StaticMobilityModel> zero = |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2549
diff
changeset
|
255 |
CreateObject<StaticMobilityModel> ("position", |
2399
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
256 |
Vector (0.0, 0.0, 0.0)); |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
257 |
static Ptr<StaticMobilityModel> reference = |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2549
diff
changeset
|
258 |
CreateObject<StaticMobilityModel> ("position", |
2399
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2336
diff
changeset
|
259 |
Vector (m_referenceDistance, 0.0, 0.0)); |
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
|
260 |
double rx0 = m_reference->GetRxPower (txPowerDbm, zero, reference); |
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
|
261 |
double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance); |
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
|
262 |
double rxPowerDbm = rx0 - pathLossDb; |
2065
962441fa9c06
calculate correctly rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2064
diff
changeset
|
263 |
NS_LOG_DEBUG ("distance="<<distance<<"m, tx-power="<<txPowerDbm<<"dbm, "<< |
962441fa9c06
calculate correctly rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2064
diff
changeset
|
264 |
"reference-rx-power="<<rx0<<"dbm, "<< |
962441fa9c06
calculate correctly rx power
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2064
diff
changeset
|
265 |
"rx-power="<<rxPowerDbm<<"dbm"); |
1985
623a90f3fe07
use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1959
diff
changeset
|
266 |
return rxPowerDbm; |
1882
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 |
|
061f7f7f9992
start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
269 |
} // namespace ns3 |