src/devices/wifi/propagation-loss-model.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 28 Oct 2008 13:17:17 +0100
changeset 3907 56e477db65b2
parent 3681 d3c79037d422
child 3908 232d52317a18
permissions -rw-r--r--
add composite capability to PropagationLossModel base class.
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
3907
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    46
PropagationLossModel::PropagationLossModel ()
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    47
  : m_next (0)
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    48
{}
2940
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    49
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
PropagationLossModel::~PropagationLossModel ()
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
{}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
3907
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    53
double 
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    54
PropagationLossModel::GetLoss (Ptr<MobilityModel> a,
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    55
                               Ptr<MobilityModel> b) const
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    56
{
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    57
  double self = DoGetLoss (a, b);
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    58
  if (m_next != 0)
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    59
    {
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    60
      self += m_next->GetLoss (a, b);
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    61
    }
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    62
  return self;
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    63
}
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    64
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    65
2940
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    66
NS_OBJECT_ENSURE_REGISTERED (RandomPropagationLossModel);
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    67
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    68
TypeId 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    69
RandomPropagationLossModel::GetTypeId (void)
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    70
{
2943
cdbcd43a019c add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2940
diff changeset
    71
  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
    72
    .SetParent<PropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    73
    .AddConstructor<RandomPropagationLossModel> ()
3212
0c00342d6a73 improve attribute documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
    74
    .AddAttribute ("Variable", "The random variable used to pick a loss everytime GetLoss is invoked.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2943
diff changeset
    75
                   RandomVariableValue (ConstantVariable (1.0)),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    76
                   MakeRandomVariableAccessor (&RandomPropagationLossModel::m_variable),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    77
                   MakeRandomVariableChecker ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    78
    ;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    79
  return tid;
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    80
}
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    81
RandomPropagationLossModel::RandomPropagationLossModel ()
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    82
{}
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    83
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    84
RandomPropagationLossModel::~RandomPropagationLossModel ()
2336
28ce210b91bb bug 133: automate RandomVariable memory management.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2230
diff changeset
    85
{}
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    86
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    87
double 
3907
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
    88
RandomPropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    89
				     Ptr<MobilityModel> b) const
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    90
{
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    91
  double rxc = -m_variable.GetValue ();
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    92
  NS_LOG_DEBUG ("attenuation coefficent="<<rxc<<"Db");
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
    93
  return rxc;
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    94
}
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
    95
2940
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    96
NS_OBJECT_ENSURE_REGISTERED (FriisPropagationLossModel);
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    97
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    98
TypeId 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
    99
FriisPropagationLossModel::GetTypeId (void)
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   100
{
2943
cdbcd43a019c add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2940
diff changeset
   101
  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
   102
    .SetParent<PropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   103
    .AddConstructor<FriisPropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   104
    .AddAttribute ("Lambda", 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   105
                   "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
   106
                   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
   107
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_lambda),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   108
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   109
    .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
   110
                   DoubleValue (1.0),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   111
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   112
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   113
    .AddAttribute ("MinDistance", 
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   114
                   "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
   115
                   DoubleValue (0.5),
3388
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   116
                   MakeDoubleAccessor (&FriisPropagationLossModel::SetMinDistance,
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   117
                                       &FriisPropagationLossModel::GetMinDistance),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   118
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   119
    ;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   120
  return tid;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   121
}
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   122
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
FriisPropagationLossModel::FriisPropagationLossModel ()
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
{}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
void 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
FriisPropagationLossModel::SetSystemLoss (double systemLoss)
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
  m_systemLoss = systemLoss;
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
double 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
FriisPropagationLossModel::GetSystemLoss (void) const
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
  return m_systemLoss;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
void 
3388
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   136
FriisPropagationLossModel::SetMinDistance (double minDistance)
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   137
{
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   138
  m_minDistance = minDistance;
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   139
}
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   140
double 
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   141
FriisPropagationLossModel::GetMinDistance (void) const
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   142
{
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   143
  return m_minDistance;
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   144
}
0258bd0793ab add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3212
diff changeset
   145
void 
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
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
   147
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
  m_lambda = speed / frequency;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
void 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
FriisPropagationLossModel::SetLambda (double lambda)
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
  m_lambda = lambda;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   154
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
double 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
FriisPropagationLossModel::GetLambda (void) const
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
  return m_lambda;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
double 
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
FriisPropagationLossModel::DbmToW (double dbm) const
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   164
  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
   165
  return mw / 1000.0;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
double
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
FriisPropagationLossModel::DbmFromW (double w) const
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   171
  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
   172
  return dbm;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   173
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   174
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
double 
3907
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
   177
FriisPropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   178
				    Ptr<MobilityModel> b) const
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   179
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   180
  /*
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
   * Friis free space equation:
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   182
   * 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
   183
   * L is in meter units.
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   184
   *
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   185
   *    P     Gt * Gr * (lambda^2)
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   186
   *   --- = ---------------------
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   187
   *    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
   188
   *
2070
377898b9c6f5 clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2065
diff changeset
   189
   * Gt: tx gain (unit-less)
377898b9c6f5 clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2065
diff changeset
   190
   * 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
   191
   * Pt: tx power (W)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
   * d: distance (m)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   193
   * L: system loss
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   194
   * lambda: wavelength (m)
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   195
   *
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   196
   * 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
   197
   * are in dbm:
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   198
   *
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
   199
   *                           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
   200
   * 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
   201
   *                       (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
   202
   *
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   203
   * rx: rx power (dbm)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   204
   * tx: tx power (dbm)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   205
   * d: distance (m)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   206
   * L: system loss
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   207
   * lambda: wavelength (m)
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   208
   */
2031
567dbc2475fc replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1985
diff changeset
   209
  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
   210
  if (distance <= m_minDistance)
2062
88302488c05b Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2044
diff changeset
   211
    {
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   212
      return 0.0;
2062
88302488c05b Document the friis propagation model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2044
diff changeset
   213
    }
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   214
  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
   215
  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
   216
  double pr = 10 * log10 (numerator / denominator);
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   217
  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
   218
  return pr;
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
2940
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
   221
NS_OBJECT_ENSURE_REGISTERED (LogDistancePropagationLossModel);
8fb456039670 add missing TypeId in base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
   222
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   223
TypeId
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   224
LogDistancePropagationLossModel::GetTypeId (void)
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   225
{
2943
cdbcd43a019c add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2940
diff changeset
   226
  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
   227
    .SetParent<PropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   228
    .AddConstructor<LogDistancePropagationLossModel> ()
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   229
    .AddAttribute ("Exponent",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   230
                   "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
   231
                   DoubleValue (3.0),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   232
                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_exponent),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   233
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   234
    .AddAttribute ("ReferenceDistance",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   235
                   "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
   236
                   DoubleValue (1.0),
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   237
                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceDistance),
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   238
                   MakeDoubleChecker<double> ())
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   239
    .AddAttribute ("ReferenceModel",
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   240
                   "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
   241
                   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
   242
                   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
   243
                   MakePointerChecker<PropagationLossModel> ())
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   244
    ;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   245
  return tid;
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   246
                   
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2399
diff changeset
   247
}
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   248
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   249
LogDistancePropagationLossModel::LogDistancePropagationLossModel ()
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   250
{}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   251
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   252
void 
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   253
LogDistancePropagationLossModel::SetPathLossExponent (double n)
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
  m_exponent = n;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
}
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   257
void 
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   258
LogDistancePropagationLossModel::SetReferenceDistance (double referenceDistance)
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   259
{
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   260
  m_referenceDistance = referenceDistance;
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   261
}
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   262
void 
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   263
LogDistancePropagationLossModel::SetReferenceModel (Ptr<PropagationLossModel> model)
1959
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   264
{
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   265
  m_reference = model;
f64684973ea8 support DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1882
diff changeset
   266
}
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   267
double 
2063
8663fe258bce document log distance propagation loss model.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2062
diff changeset
   268
LogDistancePropagationLossModel::GetPathLossExponent (void) const
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   269
{
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   270
  return m_exponent;
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   271
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   272
  
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   273
double 
3907
56e477db65b2 add composite capability to PropagationLossModel base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3681
diff changeset
   274
LogDistancePropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   275
                                          Ptr<MobilityModel> b) const
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   276
{
2031
567dbc2475fc replace distance by a pair of mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1985
diff changeset
   277
  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
   278
  if (distance <= m_referenceDistance)
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   279
    {
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   280
      return 0.0;
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   281
    }
1985
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   282
  /**
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   283
   * The formula is:
2070
377898b9c6f5 clarify the formulas
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2065
diff changeset
   284
   * 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
   285
   *
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   286
   * 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
   287
   * 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
   288
   * d: distance (m)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   289
   * tx: tx power (db)
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   290
   * rx: db
623a90f3fe07 use dbms consistently in the propagation loss models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1959
diff changeset
   291
   *
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
   292
   * 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
   293
   *      
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
   294
   * 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
   295
   */
3681
d3c79037d422 bug 333:The Position attribute is not constructable anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3388
diff changeset
   296
  static Ptr<StaticMobilityModel> zero = CreateObject<StaticMobilityModel> ();
d3c79037d422 bug 333:The Position attribute is not constructable anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3388
diff changeset
   297
  static Ptr<StaticMobilityModel> reference = CreateObject<StaticMobilityModel> ();
d3c79037d422 bug 333:The Position attribute is not constructable anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3388
diff changeset
   298
  zero->SetPosition (Vector (0.0, 0.0, 0.0));
d3c79037d422 bug 333:The Position attribute is not constructable anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3388
diff changeset
   299
  reference->SetPosition (Vector (m_referenceDistance, 0.0, 0.0));
2677
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   300
  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
   301
  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
   302
  double rxc = ref - pathLossDb;
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   303
  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
   304
		"attenuation coefficient="<<rxc<<"dbm");
28dfd0c7510d PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2615
diff changeset
   305
  return rxc;
1882
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   306
}
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   307
061f7f7f9992 start of work towards port of wifi code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   308
} // namespace ns3