src/devices/wifi/propagation-loss-model.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 17 Apr 2008 13:42:25 -0700
changeset 2965 4b28e9740e3b
parent 2943 cdbcd43a019c
child 3212 0c00342d6a73
permissions -rw-r--r--
get rid of Attribute class. Use AttributeValue subclasses directly.
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"
2927
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2677
diff changeset
    25
#include "ns3/pointer.h"
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include <math.h>
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
    28
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
    29
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
namespace ns3 {
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    32
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
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
    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
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    46
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
PropagationLossModel::~PropagationLossModel ()
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
{}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
2940
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    50
NS_OBJECT_ENSURE_REGISTERED (RandomPropagationLossModel);
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    51
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    52
TypeId 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    53
RandomPropagationLossModel::GetTypeId (void)
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    54
{
2943
cdbcd43a019c add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2940
diff changeset
    55
  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
    56
    .SetParent<PropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    57
    .AddConstructor<RandomPropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    58
    .AddAttribute ("Variable", "XXX",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2943
diff changeset
    59
                   RandomVariableValue (ConstantVariable (1.0)),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    60
                   MakeRandomVariableAccessor (&RandomPropagationLossModel::m_variable),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    61
                   MakeRandomVariableChecker ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    62
    ;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    63
  return tid;
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
RandomPropagationLossModel::RandomPropagationLossModel ()
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    66
{}
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    67
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    68
RandomPropagationLossModel::~RandomPropagationLossModel ()
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2230
diff changeset
    69
{}
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    70
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    71
double 
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    72
RandomPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    73
				     Ptr<MobilityModel> b) const
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    74
{
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    75
  double rxc = -m_variable.GetValue ();
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    76
  NS_LOG_DEBUG ("attenuation coefficent="<<rxc<<"Db");
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    77
  return rxc;
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    78
}
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    79
2940
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    80
NS_OBJECT_ENSURE_REGISTERED (FriisPropagationLossModel);
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    81
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    82
TypeId 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    83
FriisPropagationLossModel::GetTypeId (void)
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    84
{
2943
cdbcd43a019c add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2940
diff changeset
    85
  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
    86
    .SetParent<PropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    87
    .AddConstructor<FriisPropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    88
    .AddAttribute ("Lambda", 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    89
                   "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
    90
                   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
    91
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_lambda),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    92
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    93
    .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
    94
                   DoubleValue (1.0),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    95
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    96
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    97
    .AddAttribute ("MinDistance", 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    98
                   "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
    99
                   DoubleValue (0.5),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   100
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_minDistance),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   101
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   102
    ;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   103
  return tid;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   104
}
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   105
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
FriisPropagationLossModel::FriisPropagationLossModel ()
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
{}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
void 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
FriisPropagationLossModel::SetSystemLoss (double systemLoss)
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
  m_systemLoss = systemLoss;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
double 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
FriisPropagationLossModel::GetSystemLoss (void) const
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
  return m_systemLoss;
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
void 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
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
   120
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
  m_lambda = speed / frequency;
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
void 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
FriisPropagationLossModel::SetLambda (double lambda)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
  m_lambda = lambda;
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 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
FriisPropagationLossModel::GetLambda (void) const
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
  return m_lambda;
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
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
double 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
FriisPropagationLossModel::DbmToW (double dbm) const
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
  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
   138
  return mw / 1000.0;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
double
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
FriisPropagationLossModel::DbmFromW (double w) const
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 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
   145
  return dbm;
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
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
double 
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   150
FriisPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   151
				    Ptr<MobilityModel> b) const
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
  /*
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   154
   * Friis free space equation:
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
   * 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
   156
   * L is in meter units.
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
   *
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   158
   *    P     Gt * Gr * (lambda^2)
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   159
   *   --- = ---------------------
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   160
   *    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
   161
   *
2070
377898b9c6f5 clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2065
diff changeset
   162
   * Gt: tx gain (unit-less)
377898b9c6f5 clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2065
diff changeset
   163
   * 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
   164
   * Pt: tx power (W)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   165
   * d: distance (m)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
   * L: system loss
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
   * lambda: wavelength (m)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
   *
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   169
   * 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
   170
   * are in dbm:
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   171
   *
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
   *                           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
   173
   * 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
   174
   *                       (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
   175
   *
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   176
   * rx: rx power (dbm)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   177
   * tx: tx power (dbm)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   178
   * d: distance (m)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   179
   * L: system loss
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   180
   * lambda: wavelength (m)
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
   */
2031
567dbc2475fc replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1985
diff changeset
   182
  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
   183
  if (distance <= m_minDistance)
2062
88302488c05b Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2044
diff changeset
   184
    {
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   185
      return 0.0;
2062
88302488c05b Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2044
diff changeset
   186
    }
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   187
  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
   188
  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
   189
  double pr = 10 * log10 (numerator / denominator);
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   190
  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
   191
  return pr;
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   193
2940
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
   194
NS_OBJECT_ENSURE_REGISTERED (LogDistancePropagationLossModel);
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
   195
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   196
TypeId
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   197
LogDistancePropagationLossModel::GetTypeId (void)
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   198
{
2943
cdbcd43a019c add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2940
diff changeset
   199
  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
   200
    .SetParent<PropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   201
    .AddConstructor<LogDistancePropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   202
    .AddAttribute ("Exponent",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   203
                   "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
   204
                   DoubleValue (3.0),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   205
                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_exponent),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   206
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   207
    .AddAttribute ("ReferenceDistance",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   208
                   "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
   209
                   DoubleValue (1.0),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   210
                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceDistance),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   211
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   212
    .AddAttribute ("ReferenceModel",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   213
                   "The reference model at the reference distance.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2943
diff changeset
   214
                   PointerValue (),
2927
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2677
diff changeset
   215
                   MakePointerAccessor (&LogDistancePropagationLossModel::m_reference),
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2677
diff changeset
   216
                   MakePointerChecker<PropagationLossModel> ())
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   217
    ;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   218
  return tid;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   219
                   
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   220
}
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   222
LogDistancePropagationLossModel::LogDistancePropagationLossModel ()
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
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   225
void 
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   226
LogDistancePropagationLossModel::SetPathLossExponent (double n)
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   227
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   228
  m_exponent = n;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
}
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   230
void 
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   231
LogDistancePropagationLossModel::SetReferenceDistance (double referenceDistance)
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   232
{
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   233
  m_referenceDistance = referenceDistance;
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   234
}
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   235
void 
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   236
LogDistancePropagationLossModel::SetReferenceModel (Ptr<PropagationLossModel> model)
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   237
{
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   238
  m_reference = model;
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   239
}
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
double 
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   241
LogDistancePropagationLossModel::GetPathLossExponent (void) const
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   242
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
  return m_exponent;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   244
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   245
  
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   246
double 
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   247
LogDistancePropagationLossModel::GetLoss (Ptr<MobilityModel> a,
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   248
                                          Ptr<MobilityModel> b) const
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   249
{
2031
567dbc2475fc replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1985
diff changeset
   250
  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
   251
  if (distance <= m_referenceDistance)
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   252
    {
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   253
      return 0.0;
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
    }
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   255
  /**
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   256
   * The formula is:
2070
377898b9c6f5 clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2065
diff changeset
   257
   * 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
   258
   *
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   259
   * 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
   260
   * 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
   261
   * d: distance (m)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   262
   * tx: tx power (db)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   263
   * rx: db
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   264
   *
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
   265
   * 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
   266
   *      
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
   267
   * 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
   268
   */
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2336
diff changeset
   269
  static Ptr<StaticMobilityModel> zero = 
2615
09e459167dc3 use the right position attribute name.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   270
    CreateObject<StaticMobilityModel> ("Position", 
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2943
diff changeset
   271
                                       VectorValue (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
   272
  static Ptr<StaticMobilityModel> reference = 
2615
09e459167dc3 use the right position attribute name.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   273
    CreateObject<StaticMobilityModel> ("Position", 
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2943
diff changeset
   274
                                       VectorValue (Vector (m_referenceDistance, 0.0, 0.0)));
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   275
  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
   276
  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
   277
  double rxc = ref - pathLossDb;
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   278
  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
   279
		"attenuation coefficient="<<rxc<<"dbm");
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   280
  return rxc;
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
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   283
} // namespace ns3