src/devices/wifi/propagation-loss-model.cc
author Federico Maguolo <maguolof@dei.unipd.it>
Fri, 21 Mar 2008 04:49:23 +0100
changeset 2677 28dfd0c7510d
parent 2615 09e459167dc3
child 2927 73b47ce1d805
permissions -rw-r--r--
PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    57
RandomPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    58
				     Ptr<MobilityModel> b) const
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    59
{
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    60
  double rxc = -m_variable.GetValue ();
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    61
  NS_LOG_DEBUG ("attenuation coefficent="<<rxc<<"Db");
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    62
  return rxc;
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    63
}
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    64
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    65
TypeId 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    66
FriisPropagationLossModel::GetTypeId (void)
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    67
{
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    68
  static TypeId tid = TypeId ("FriisPropagationLossModel")
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    69
    .SetParent<PropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    70
    .AddConstructor<FriisPropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    71
    .AddAttribute ("Lambda", 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    72
                   "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
    73
                   Double (300000000.0 / 5.150e9),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    74
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_lambda),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    75
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    76
    .AddAttribute ("SystemLoss", "The system loss",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    77
                   Double (1.0),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    78
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    79
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    80
    .AddAttribute ("MinDistance", 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    81
                   "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
    82
                   Double (0.5),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    83
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_minDistance),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    84
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    85
    ;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    86
  return tid;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    87
}
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    88
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
FriisPropagationLossModel::FriisPropagationLossModel ()
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
{}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
void 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
FriisPropagationLossModel::SetSystemLoss (double systemLoss)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
  m_systemLoss = systemLoss;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
double 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
FriisPropagationLossModel::GetSystemLoss (void) const
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
  return m_systemLoss;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
void 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
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
   103
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
  m_lambda = speed / frequency;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
void 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
FriisPropagationLossModel::SetLambda (double lambda)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
  m_lambda = lambda;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
double 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
FriisPropagationLossModel::GetLambda (void) const
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
  return m_lambda;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
}
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
double 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
FriisPropagationLossModel::DbmToW (double dbm) const
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
  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
   121
  return mw / 1000.0;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
}
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
double
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
FriisPropagationLossModel::DbmFromW (double w) const
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
  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
   128
  return dbm;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
}
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
double 
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   133
FriisPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   134
				    Ptr<MobilityModel> b) const
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
  /*
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
   * Friis free space equation:
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
   * 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
   139
   * L is in meter units.
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
   *
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   141
   *    P     Gt * Gr * (lambda^2)
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   142
   *   --- = ---------------------
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   143
   *    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
   144
   *
2070
377898b9c6f5 clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2065
diff changeset
   145
   * Gt: tx gain (unit-less)
377898b9c6f5 clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2065
diff changeset
   146
   * 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
   147
   * Pt: tx power (W)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
   * d: distance (m)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
   * L: system loss
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
   * lambda: wavelength (m)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
   *
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   152
   * 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
   153
   * are in dbm:
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   154
   *
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
   155
   *                           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
   156
   * 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
   157
   *                       (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
   158
   *
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   159
   * rx: rx power (dbm)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   160
   * tx: tx power (dbm)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   161
   * d: distance (m)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   162
   * L: system loss
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   163
   * lambda: wavelength (m)
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   164
   */
2031
567dbc2475fc replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1985
diff changeset
   165
  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
   166
  if (distance <= m_minDistance)
2062
88302488c05b Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2044
diff changeset
   167
    {
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   168
      return 0.0;
2062
88302488c05b Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2044
diff changeset
   169
    }
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   170
  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
   171
  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
   172
  double pr = 10 * log10 (numerator / denominator);
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   173
  NS_LOG_DEBUG ("distance="<<distance<<"m, attenuation coefficient="<<pr<<"dB");
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   174
  return pr;
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   177
TypeId
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   178
LogDistancePropagationLossModel::GetTypeId (void)
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   179
{
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   180
  static TypeId tid = TypeId ("LogDistancePropagationLossModel")
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   181
    .SetParent<PropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   182
    .AddConstructor<LogDistancePropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   183
    .AddAttribute ("Exponent",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   184
                   "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
   185
                   Double (3.0),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   186
                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_exponent),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   187
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   188
    .AddAttribute ("ReferenceDistance",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   189
                   "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
   190
                   Double (1.0),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   191
                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceDistance),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   192
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   193
    .AddAttribute ("ReferenceModel",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   194
                   "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
   195
                   Ptr<PropagationLossModel> (0),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   196
                   MakePtrAccessor (&LogDistancePropagationLossModel::m_reference),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   197
                   MakePtrChecker<PropagationLossModel> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   198
    ;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   199
  return tid;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   200
                   
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   201
}
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   203
LogDistancePropagationLossModel::LogDistancePropagationLossModel ()
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
{}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   205
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   206
void 
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   207
LogDistancePropagationLossModel::SetPathLossExponent (double n)
1882
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
  m_exponent = n;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   210
}
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   211
void 
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   212
LogDistancePropagationLossModel::SetReferenceDistance (double referenceDistance)
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   213
{
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   214
  m_referenceDistance = referenceDistance;
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   215
}
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   216
void 
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   217
LogDistancePropagationLossModel::SetReferenceModel (Ptr<PropagationLossModel> model)
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   218
{
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   219
  m_reference = model;
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   220
}
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
double 
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   222
LogDistancePropagationLossModel::GetPathLossExponent (void) const
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   223
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   224
  return m_exponent;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   225
}
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
double 
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   228
LogDistancePropagationLossModel::GetLoss (Ptr<MobilityModel> a,
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   229
                                          Ptr<MobilityModel> b) const
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   230
{
2031
567dbc2475fc replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1985
diff changeset
   231
  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
   232
  if (distance <= m_referenceDistance)
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   233
    {
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   234
      return 0.0;
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   235
    }
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   236
  /**
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   237
   * The formula is:
2070
377898b9c6f5 clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2065
diff changeset
   238
   * 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
   239
   *
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   240
   * 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
   241
   * 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
   242
   * d: distance (m)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   243
   * tx: tx power (db)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   244
   * rx: db
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   245
   *
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
   246
   * 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
   247
   *      
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
   248
   * 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
   249
   */
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
   250
  static Ptr<StaticMobilityModel> zero = 
2615
09e459167dc3 use the right position attribute name.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   251
    CreateObject<StaticMobilityModel> ("Position", 
09e459167dc3 use the right position attribute name.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   252
                                       Vector (0.0, 0.0, 0.0));
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
   253
  static Ptr<StaticMobilityModel> reference = 
2615
09e459167dc3 use the right position attribute name.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   254
    CreateObject<StaticMobilityModel> ("Position", 
09e459167dc3 use the right position attribute name.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   255
                                       Vector (m_referenceDistance, 0.0, 0.0));
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   256
  double ref = m_reference->GetLoss (zero, reference);
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
   257
  double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance);
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   258
  double rxc = ref - pathLossDb;
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   259
  NS_LOG_DEBUG ("distance="<<distance<<"m, reference-attenuation="<<ref<<"dB, "<<
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   260
		"attenuation coefficient="<<rxc<<"dbm");
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   261
  return rxc;
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   262
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   264
} // namespace ns3