src/propagation/model/propagation-loss-model.cc
author Pavel Boyko <boyko@iitp.ru>
Sun, 06 Feb 2011 12:42:35 +0300
changeset 6803 f07c4f00b07e
parent 6794 5dce93cfc499
child 7188 ea48206d68bd
permissions -rw-r--r--
Bug 1048: MatrixPropagationLossModel API changed from Ptr<Object> to Ptr<MobilityModel>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5944
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     2
/*
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005,2006,2007 INRIA
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     4
 *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     8
 *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    13
 *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    17
 *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    19
 * Contributions: Timo Bingmann <timo.bingmann@student.kit.edu>
5972
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
    20
 * Contributions: Tom Hewer <tomhewer@mac.com> for Two Ray Ground Model
6115
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
    21
 *                Pavel Boyko <boyko@iitp.ru> for matrix
5944
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    22
 */
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    23
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    24
#include "propagation-loss-model.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    25
#include "ns3/log.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    26
#include "ns3/mobility-model.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    27
#include "ns3/boolean.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    28
#include "ns3/double.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    29
#include <math.h>
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    30
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    31
NS_LOG_COMPONENT_DEFINE ("PropagationLossModel");
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    32
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    33
namespace ns3 {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    34
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    35
// ------------------------------------------------------------------------- //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    36
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    37
NS_OBJECT_ENSURE_REGISTERED (PropagationLossModel);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    38
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    39
TypeId 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    40
PropagationLossModel::GetTypeId (void)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    41
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    42
  static TypeId tid = TypeId ("ns3::PropagationLossModel")
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    43
    .SetParent<Object> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    44
    ;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    45
  return tid;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    46
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    47
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    48
PropagationLossModel::PropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    49
  : m_next (0)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    50
{}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    51
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    52
PropagationLossModel::~PropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    53
{}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    54
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    55
void 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    56
PropagationLossModel::SetNext (Ptr<PropagationLossModel> next)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    57
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    58
  m_next = next;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    59
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    60
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    61
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    62
PropagationLossModel::CalcRxPower (double txPowerDbm,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    63
                                   Ptr<MobilityModel> a,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    64
                                   Ptr<MobilityModel> b) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    65
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    66
  double self = DoCalcRxPower (txPowerDbm, a, b);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    67
  if (m_next != 0)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    68
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    69
      self = m_next->CalcRxPower (self, a, b);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    70
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    71
  return self;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    72
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    73
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    74
// ------------------------------------------------------------------------- //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    75
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    76
NS_OBJECT_ENSURE_REGISTERED (RandomPropagationLossModel);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    77
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    78
TypeId 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    79
RandomPropagationLossModel::GetTypeId (void)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    80
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    81
  static TypeId tid = TypeId ("ns3::RandomPropagationLossModel")
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    82
    .SetParent<PropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    83
    .AddConstructor<RandomPropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    84
    .AddAttribute ("Variable", "The random variable used to pick a loss everytime CalcRxPower is invoked.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    85
                   RandomVariableValue (ConstantVariable (1.0)),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    86
                   MakeRandomVariableAccessor (&RandomPropagationLossModel::m_variable),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    87
                   MakeRandomVariableChecker ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    88
    ;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    89
  return tid;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    90
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    91
RandomPropagationLossModel::RandomPropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    92
  : PropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    93
{}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    94
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    95
RandomPropagationLossModel::~RandomPropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    96
{}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    97
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    98
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    99
RandomPropagationLossModel::DoCalcRxPower (double txPowerDbm,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   100
                                           Ptr<MobilityModel> a,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   101
                                           Ptr<MobilityModel> b) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   102
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   103
  double rxc = -m_variable.GetValue ();
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   104
  NS_LOG_DEBUG ("attenuation coefficent="<<rxc<<"Db");
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   105
  return txPowerDbm + rxc;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   106
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   107
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   108
// ------------------------------------------------------------------------- //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   109
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   110
NS_OBJECT_ENSURE_REGISTERED (FriisPropagationLossModel);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   111
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   112
const double FriisPropagationLossModel::PI = 3.14159265358979323846;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   113
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   114
TypeId 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   115
FriisPropagationLossModel::GetTypeId (void)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   116
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   117
  static TypeId tid = TypeId ("ns3::FriisPropagationLossModel")
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   118
    .SetParent<PropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   119
    .AddConstructor<FriisPropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   120
    .AddAttribute ("Lambda", 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   121
                   "The wavelength  (default is 5.15 GHz at 300 000 km/s).",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   122
                   DoubleValue (300000000.0 / 5.150e9),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   123
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_lambda),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   124
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   125
    .AddAttribute ("SystemLoss", "The system loss",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   126
                   DoubleValue (1.0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   127
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   128
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   129
    .AddAttribute ("MinDistance", 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   130
                   "The distance under which the propagation model refuses to give results (m)",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   131
                   DoubleValue (0.5),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   132
                   MakeDoubleAccessor (&FriisPropagationLossModel::SetMinDistance,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   133
                                       &FriisPropagationLossModel::GetMinDistance),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   134
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   135
    ;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   136
  return tid;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   137
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   138
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   139
FriisPropagationLossModel::FriisPropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   140
{}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   141
void 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   142
FriisPropagationLossModel::SetSystemLoss (double systemLoss)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   143
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   144
  m_systemLoss = systemLoss;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   145
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   146
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   147
FriisPropagationLossModel::GetSystemLoss (void) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   148
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   149
  return m_systemLoss;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   150
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   151
void 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   152
FriisPropagationLossModel::SetMinDistance (double minDistance)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   153
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   154
  m_minDistance = minDistance;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   155
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   156
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   157
FriisPropagationLossModel::GetMinDistance (void) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   158
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   159
  return m_minDistance;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   160
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   161
void 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   162
FriisPropagationLossModel::SetLambda (double frequency, double speed)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   163
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   164
  m_lambda = speed / frequency;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   165
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   166
void 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   167
FriisPropagationLossModel::SetLambda (double lambda)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   168
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   169
  m_lambda = lambda;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   170
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   171
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   172
FriisPropagationLossModel::GetLambda (void) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   173
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   174
  return m_lambda;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   175
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   176
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   177
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   178
FriisPropagationLossModel::DbmToW (double dbm) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   179
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   180
  double mw = pow(10.0,dbm/10.0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   181
  return mw / 1000.0;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   182
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   183
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   184
double
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   185
FriisPropagationLossModel::DbmFromW (double w) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   186
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   187
  double dbm = log10 (w * 1000.0) * 10.0;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   188
  return dbm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   189
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   190
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   191
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   192
FriisPropagationLossModel::DoCalcRxPower (double txPowerDbm,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   193
                                          Ptr<MobilityModel> a,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   194
                                          Ptr<MobilityModel> b) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   195
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   196
  /*
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   197
   * Friis free space equation:
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   198
   * where Pt, Gr, Gr and P are in Watt units
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   199
   * L is in meter units.
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   200
   *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   201
   *    P     Gt * Gr * (lambda^2)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   202
   *   --- = ---------------------
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   203
   *    Pt     (4 * pi * d)^2 * L
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   204
   *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   205
   * Gt: tx gain (unit-less)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   206
   * Gr: rx gain (unit-less)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   207
   * Pt: tx power (W)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   208
   * d: distance (m)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   209
   * L: system loss
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   210
   * lambda: wavelength (m)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   211
   *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   212
   * Here, we ignore tx and rx gain and the input and output values 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   213
   * are in dB or dBm:
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   214
   *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   215
   *                           lambda^2
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   216
   * rx = tx +  10 log10 (-------------------)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   217
   *                       (4 * pi * d)^2 * L
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   218
   *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   219
   * rx: rx power (dB)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   220
   * tx: tx power (dB)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   221
   * d: distance (m)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   222
   * L: system loss (unit-less)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   223
   * lambda: wavelength (m)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   224
   */
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   225
  double distance = a->GetDistanceFrom (b);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   226
  if (distance <= m_minDistance)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   227
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   228
      return txPowerDbm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   229
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   230
  double numerator = m_lambda * m_lambda;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   231
  double denominator = 16 * PI * PI * distance * distance * m_systemLoss;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   232
  double pr = 10 * log10 (numerator / denominator);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   233
  NS_LOG_DEBUG ("distance="<<distance<<"m, attenuation coefficient="<<pr<<"dB");
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   234
  return txPowerDbm + pr;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   235
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   236
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   237
// ------------------------------------------------------------------------- //
5972
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   238
// -- Two-Ray Ground Model ported from NS-2 -- tomhewer@mac.com -- Nov09 //
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   239
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   240
NS_OBJECT_ENSURE_REGISTERED (TwoRayGroundPropagationLossModel);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   241
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   242
const double TwoRayGroundPropagationLossModel::PI = 3.14159265358979323846;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   243
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   244
TypeId 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   245
TwoRayGroundPropagationLossModel::GetTypeId (void)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   246
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   247
  static TypeId tid = TypeId ("ns3::TwoRayGroundPropagationLossModel")
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   248
    .SetParent<PropagationLossModel> ()
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   249
    .AddConstructor<TwoRayGroundPropagationLossModel> ()
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   250
    .AddAttribute ("Lambda",
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   251
                   "The wavelength  (default is 5.15 GHz at 300 000 km/s).",
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   252
                   DoubleValue (300000000.0 / 5.150e9),
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   253
                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::m_lambda),
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   254
                   MakeDoubleChecker<double> ())
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   255
    .AddAttribute ("SystemLoss", "The system loss",
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   256
                   DoubleValue (1.0),
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   257
                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::m_systemLoss),
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   258
                   MakeDoubleChecker<double> ())
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   259
    .AddAttribute ("MinDistance",
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   260
                   "The distance under which the propagation model refuses to give results (m)",
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   261
                   DoubleValue (0.5),
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   262
                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::SetMinDistance,
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   263
                                       &TwoRayGroundPropagationLossModel::GetMinDistance),
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   264
                   MakeDoubleChecker<double> ())
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   265
    .AddAttribute ("HeightAboveZ",
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   266
                   "The height of the antenna (m) above the node's Z coordinate",
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   267
                   DoubleValue (0),
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   268
                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::m_heightAboveZ),
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   269
                   MakeDoubleChecker<double> ())
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   270
  ;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   271
  return tid;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   272
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   273
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   274
TwoRayGroundPropagationLossModel::TwoRayGroundPropagationLossModel ()
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   275
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   276
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   277
void
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   278
TwoRayGroundPropagationLossModel::SetSystemLoss (double systemLoss)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   279
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   280
  m_systemLoss = systemLoss;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   281
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   282
double
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   283
TwoRayGroundPropagationLossModel::GetSystemLoss (void) const
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   284
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   285
  return m_systemLoss;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   286
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   287
void
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   288
TwoRayGroundPropagationLossModel::SetMinDistance (double minDistance)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   289
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   290
  m_minDistance = minDistance;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   291
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   292
double
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   293
TwoRayGroundPropagationLossModel::GetMinDistance (void) const
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   294
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   295
  return m_minDistance;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   296
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   297
void
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   298
TwoRayGroundPropagationLossModel::SetHeightAboveZ (double heightAboveZ)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   299
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   300
  m_heightAboveZ = heightAboveZ;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   301
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   302
void 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   303
TwoRayGroundPropagationLossModel::SetLambda (double frequency, double speed)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   304
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   305
  m_lambda = speed / frequency;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   306
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   307
void 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   308
TwoRayGroundPropagationLossModel::SetLambda (double lambda)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   309
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   310
  m_lambda = lambda;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   311
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   312
double 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   313
TwoRayGroundPropagationLossModel::GetLambda (void) const
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   314
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   315
  return m_lambda;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   316
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   317
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   318
double 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   319
TwoRayGroundPropagationLossModel::DbmToW (double dbm) const
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   320
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   321
  double mw = pow (10.0,dbm / 10.0);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   322
  return mw / 1000.0;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   323
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   324
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   325
double
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   326
TwoRayGroundPropagationLossModel::DbmFromW (double w) const
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   327
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   328
  double dbm = log10 (w * 1000.0) * 10.0;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   329
  return dbm;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   330
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   331
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   332
double 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   333
TwoRayGroundPropagationLossModel::DoCalcRxPower (double txPowerDbm,
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   334
                                                 Ptr<MobilityModel> a,
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   335
                                                 Ptr<MobilityModel> b) const
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   336
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   337
  /*
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   338
   * Two-Ray Ground equation:
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   339
   *
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   340
   * where Pt, Gt and Gr are in dBm units
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   341
   * L, Ht and Hr are in meter units.
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   342
   *
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   343
   *   Pr      Gt * Gr * (Ht^2 * Hr^2)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   344
   *   -- =  (-------------------------)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   345
   *   Pt            d^4 * L
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   346
   *
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   347
   * Gt: tx gain (unit-less)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   348
   * Gr: rx gain (unit-less)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   349
   * Pt: tx power (dBm)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   350
   * d: distance (m)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   351
   * L: system loss
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   352
   * Ht: Tx antenna height (m)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   353
   * Hr: Rx antenna height (m)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   354
   * lambda: wavelength (m)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   355
   *
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   356
   * As with the Friis model we ignore tx and rx gain and output values
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   357
   * are in dB or dBm
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   358
   *
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   359
   *                      (Ht * Ht) * (Hr * Hr)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   360
   * rx = tx + 10 log10 (-----------------------)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   361
   *                      (d * d * d * d) * L
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   362
   */
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   363
  double distance = a->GetDistanceFrom (b);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   364
  if (distance <= m_minDistance)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   365
    {
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   366
      return txPowerDbm;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   367
    }
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   368
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   369
  // Set the height of the Tx and Rx antennae
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   370
  double txAntHeight = a->GetPosition ().z + m_heightAboveZ;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   371
  double rxAntHeight = b->GetPosition ().z + m_heightAboveZ;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   372
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   373
  // Calculate a crossover distance, under which we use Friis
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   374
  /*
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   375
   * 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   376
   * dCross = (4 * pi * Ht * Hr) / lambda
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   377
   *
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   378
   */
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   379
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   380
  double dCross = (4 * PI * txAntHeight * rxAntHeight) / GetLambda ();
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   381
  double tmp = 0;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   382
  if (distance <= dCross)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   383
    {
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   384
      // We use Friis
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   385
      double numerator = m_lambda * m_lambda;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   386
      tmp = PI * distance;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   387
      double denominator = 16 * tmp * tmp * m_systemLoss;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   388
      double pr = 10 * log10 (numerator / denominator);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   389
      NS_LOG_DEBUG ("Receiver within crossover (" << dCross << "m) for Two_ray path; using Friis");
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   390
      NS_LOG_DEBUG ("distance=" << distance << "m, attenuation coefficient=" << pr << "dB");
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   391
      return txPowerDbm + pr;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   392
    }
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   393
  else   // Use Two-Ray Pathloss
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   394
    {
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   395
      tmp = txAntHeight * rxAntHeight;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   396
      double rayNumerator = tmp * tmp;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   397
      tmp = distance * distance;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   398
      double rayDenominator = tmp * tmp * m_systemLoss;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   399
      double rayPr = 10 * log10 (rayNumerator / rayDenominator);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   400
      NS_LOG_DEBUG ("distance=" << distance << "m, attenuation coefficient=" << rayPr << "dB");
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   401
      return txPowerDbm + rayPr;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   402
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   403
    }
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   404
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   405
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   406
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   407
// ------------------------------------------------------------------------- //
5944
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   408
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   409
NS_OBJECT_ENSURE_REGISTERED (LogDistancePropagationLossModel);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   410
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   411
TypeId
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   412
LogDistancePropagationLossModel::GetTypeId (void)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   413
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   414
  static TypeId tid = TypeId ("ns3::LogDistancePropagationLossModel")
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   415
    .SetParent<PropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   416
    .AddConstructor<LogDistancePropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   417
    .AddAttribute ("Exponent",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   418
                   "The exponent of the Path Loss propagation model",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   419
                   DoubleValue (3.0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   420
                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_exponent),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   421
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   422
    .AddAttribute ("ReferenceDistance",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   423
                   "The distance at which the reference loss is calculated (m)",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   424
                   DoubleValue (1.0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   425
                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceDistance),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   426
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   427
    .AddAttribute ("ReferenceLoss",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   428
                   "The reference loss at reference distance (dB). (Default is Friis at 1m with 5.15 GHz)",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   429
                   DoubleValue (46.6777),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   430
                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceLoss),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   431
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   432
    ;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   433
  return tid;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   434
                   
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   435
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   436
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   437
LogDistancePropagationLossModel::LogDistancePropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   438
{}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   439
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   440
void 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   441
LogDistancePropagationLossModel::SetPathLossExponent (double n)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   442
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   443
  m_exponent = n;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   444
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   445
void 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   446
LogDistancePropagationLossModel::SetReference (double referenceDistance, double referenceLoss)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   447
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   448
  m_referenceDistance = referenceDistance;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   449
  m_referenceLoss = referenceLoss;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   450
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   451
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   452
LogDistancePropagationLossModel::GetPathLossExponent (void) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   453
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   454
  return m_exponent;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   455
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   456
  
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   457
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   458
LogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   459
                                                Ptr<MobilityModel> a,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   460
                                                Ptr<MobilityModel> b) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   461
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   462
  double distance = a->GetDistanceFrom (b);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   463
  if (distance <= m_referenceDistance)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   464
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   465
      return txPowerDbm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   466
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   467
  /**
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   468
   * The formula is:
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   469
   * rx = 10 * log (Pr0(tx)) - n * 10 * log (d/d0)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   470
   *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   471
   * Pr0: rx power at reference distance d0 (W)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   472
   * d0: reference distance: 1.0 (m)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   473
   * d: distance (m)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   474
   * tx: tx power (dB)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   475
   * rx: dB
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   476
   *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   477
   * Which, in our case is:
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   478
   *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   479
   * rx = rx0(tx) - 10 * n * log (d/d0)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   480
   */
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   481
  double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   482
  double rxc = -m_referenceLoss - pathLossDb;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   483
  NS_LOG_DEBUG ("distance="<<distance<<"m, reference-attenuation="<<-m_referenceLoss<<"dB, "<<
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   484
		"attenuation coefficient="<<rxc<<"db");
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   485
  return txPowerDbm + rxc;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   486
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   487
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   488
// ------------------------------------------------------------------------- //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   489
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   490
NS_OBJECT_ENSURE_REGISTERED (ThreeLogDistancePropagationLossModel);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   491
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   492
TypeId
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   493
ThreeLogDistancePropagationLossModel::GetTypeId (void)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   494
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   495
  static TypeId tid = TypeId ("ns3::ThreeLogDistancePropagationLossModel")
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   496
    .SetParent<PropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   497
    .AddConstructor<ThreeLogDistancePropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   498
    .AddAttribute ("Distance0",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   499
                   "Beginning of the first (near) distance field",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   500
                   DoubleValue (1.0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   501
                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   502
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   503
    .AddAttribute ("Distance1",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   504
                   "Beginning of the second (middle) distance field.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   505
                   DoubleValue (200.0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   506
                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance1),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   507
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   508
    .AddAttribute ("Distance2",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   509
                   "Beginning of the third (far) distance field.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   510
                   DoubleValue (500.0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   511
                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance2),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   512
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   513
    .AddAttribute ("Exponent0",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   514
                   "The exponent for the first field.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   515
                   DoubleValue (1.9),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   516
                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   517
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   518
    .AddAttribute ("Exponent1",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   519
                   "The exponent for the second field.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   520
                   DoubleValue (3.8),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   521
                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent1),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   522
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   523
    .AddAttribute ("Exponent2",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   524
                   "The exponent for the third field.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   525
                   DoubleValue (3.8),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   526
                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent2),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   527
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   528
    .AddAttribute ("ReferenceLoss",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   529
                   "The reference loss at distance d0 (dB). (Default is Friis at 1m with 5.15 GHz)",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   530
                   DoubleValue (46.6777),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   531
                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_referenceLoss),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   532
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   533
    ;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   534
  return tid;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   535
                   
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   536
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   537
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   538
ThreeLogDistancePropagationLossModel::ThreeLogDistancePropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   539
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   540
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   541
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   542
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   543
ThreeLogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   544
                                                     Ptr<MobilityModel> a,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   545
                                                     Ptr<MobilityModel> b) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   546
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   547
  double distance = a->GetDistanceFrom (b);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   548
  NS_ASSERT(distance >= 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   549
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   550
  // See doxygen comments for the formula and explanation
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   551
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   552
  double pathLossDb;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   553
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   554
  if (distance < m_distance0)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   555
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   556
      pathLossDb = 0;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   557
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   558
  else if (distance < m_distance1)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   559
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   560
      pathLossDb = m_referenceLoss
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   561
        + 10 * m_exponent0 * log10(distance / m_distance0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   562
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   563
  else if (distance < m_distance2)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   564
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   565
      pathLossDb = m_referenceLoss
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   566
        + 10 * m_exponent0 * log10(m_distance1 / m_distance0)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   567
        + 10 * m_exponent1 * log10(distance / m_distance1);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   568
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   569
  else
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   570
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   571
      pathLossDb = m_referenceLoss
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   572
        + 10 * m_exponent0 * log10(m_distance1 / m_distance0)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   573
        + 10 * m_exponent1 * log10(m_distance2 / m_distance1)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   574
        + 10 * m_exponent2 * log10(distance / m_distance2);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   575
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   576
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   577
  NS_LOG_DEBUG ("ThreeLogDistance distance=" << distance << "m, " <<
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   578
                "attenuation=" << pathLossDb << "dB");
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   579
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   580
  return txPowerDbm - pathLossDb;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   581
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   582
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   583
// ------------------------------------------------------------------------- //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   584
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   585
NS_OBJECT_ENSURE_REGISTERED (NakagamiPropagationLossModel);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   586
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   587
TypeId
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   588
NakagamiPropagationLossModel::GetTypeId (void)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   589
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   590
  static TypeId tid = TypeId ("ns3::NakagamiPropagationLossModel")
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   591
    .SetParent<PropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   592
    .AddConstructor<NakagamiPropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   593
    .AddAttribute ("Distance1",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   594
                   "Beginning of the second distance field. Default is 80m.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   595
                   DoubleValue (80.0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   596
                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_distance1),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   597
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   598
    .AddAttribute ("Distance2",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   599
                   "Beginning of the third distance field. Default is 200m.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   600
                   DoubleValue (200.0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   601
                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_distance2),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   602
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   603
    .AddAttribute ("m0",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   604
                   "m0 for distances smaller than Distance1. Default is 1.5.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   605
                   DoubleValue (1.5),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   606
                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   607
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   608
    .AddAttribute ("m1",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   609
                   "m1 for distances smaller than Distance2. Default is 0.75.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   610
                   DoubleValue (0.75),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   611
                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m1),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   612
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   613
    .AddAttribute ("m2",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   614
                   "m2 for distances greater than Distance2. Default is 0.75.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   615
                   DoubleValue (0.75),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   616
                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m2),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   617
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   618
    ;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   619
  return tid;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   620
                   
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   621
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   622
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   623
NakagamiPropagationLossModel::NakagamiPropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   624
{}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   625
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   626
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   627
NakagamiPropagationLossModel::DoCalcRxPower (double txPowerDbm,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   628
                                             Ptr<MobilityModel> a,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   629
                                             Ptr<MobilityModel> b) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   630
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   631
  // select m parameter
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   632
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   633
  double distance = a->GetDistanceFrom (b);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   634
  NS_ASSERT(distance >= 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   635
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   636
  double m;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   637
  if (distance < m_distance1)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   638
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   639
      m = m_m0;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   640
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   641
  else if (distance < m_distance2)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   642
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   643
      m = m_m1;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   644
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   645
  else
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   646
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   647
      m = m_m2;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   648
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   649
  
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   650
  // the current power unit is dBm, but Watt is put into the Nakagami /
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   651
  // Rayleigh distribution.
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   652
  double powerW = pow(10, (txPowerDbm - 30) / 10);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   653
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   654
  double resultPowerW;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   655
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   656
  // switch between Erlang- and Gamma distributions: this is only for
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   657
  // speed. (Gamma is equal to Erlang for any positive integer m.)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   658
  unsigned int int_m = static_cast<unsigned int>(floor(m));
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   659
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   660
  if (int_m == m)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   661
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   662
      resultPowerW = m_erlangRandomVariable.GetValue(int_m, powerW / m);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   663
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   664
  else
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   665
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   666
      resultPowerW = m_gammaRandomVariable.GetValue(m, powerW / m);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   667
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   668
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   669
  double resultPowerDbm = 10 * log10(resultPowerW) + 30;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   670
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   671
  NS_LOG_DEBUG ("Nakagami distance=" << distance << "m, " <<
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   672
                "power=" << powerW <<"W, " <<
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   673
                "resultPower=" << resultPowerW << "W=" << resultPowerDbm << "dBm");
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   674
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   675
  return resultPowerDbm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   676
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   677
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   678
// ------------------------------------------------------------------------- //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   679
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   680
NS_OBJECT_ENSURE_REGISTERED (FixedRssLossModel);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   681
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   682
TypeId 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   683
FixedRssLossModel::GetTypeId (void)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   684
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   685
  static TypeId tid = TypeId ("ns3::FixedRssLossModel")
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   686
    .SetParent<PropagationLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   687
    .AddConstructor<FixedRssLossModel> ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   688
    .AddAttribute ("Rss", "The fixed receiver Rss.",
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   689
                   DoubleValue (-150.0),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   690
                   MakeDoubleAccessor (&FixedRssLossModel::m_rss),
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   691
                   MakeDoubleChecker<double> ())
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   692
    ;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   693
  return tid;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   694
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   695
FixedRssLossModel::FixedRssLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   696
  : PropagationLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   697
{}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   698
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   699
FixedRssLossModel::~FixedRssLossModel ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   700
{}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   701
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   702
void 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   703
FixedRssLossModel::SetRss (double rss)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   704
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   705
  m_rss = rss;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   706
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   707
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   708
double 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   709
FixedRssLossModel::DoCalcRxPower (double txPowerDbm,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   710
                                           Ptr<MobilityModel> a,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   711
                                           Ptr<MobilityModel> b) const
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   712
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   713
  return m_rss;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   714
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   715
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   716
// ------------------------------------------------------------------------- //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   717
6115
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   718
NS_OBJECT_ENSURE_REGISTERED (MatrixPropagationLossModel);
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   719
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   720
TypeId 
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   721
MatrixPropagationLossModel::GetTypeId (void)
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   722
{
6445
43d91786d268 simple doxygen fixes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6115
diff changeset
   723
  static TypeId tid = TypeId ("ns3::MatrixPropagationLossModel")
6115
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   724
    .SetParent<PropagationLossModel> ()
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   725
    .AddConstructor<MatrixPropagationLossModel> ()
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   726
    .AddAttribute ("DefaultLoss", "The default value for propagation loss, dB.",
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   727
                   DoubleValue (std::numeric_limits<double>::max ()),
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   728
                   MakeDoubleAccessor (&MatrixPropagationLossModel::m_default),
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   729
                   MakeDoubleChecker<double> ())
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   730
    ;
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   731
  return tid;
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   732
}
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   733
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   734
MatrixPropagationLossModel::MatrixPropagationLossModel ()
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   735
  : PropagationLossModel (), m_default (std::numeric_limits<double>::max ())
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   736
{
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   737
}
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   738
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   739
MatrixPropagationLossModel::~MatrixPropagationLossModel ()
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   740
{
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   741
}
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   742
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   743
void 
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   744
MatrixPropagationLossModel::SetDefaultLoss (double loss)
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   745
{
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   746
  m_default = loss;
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   747
}
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   748
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   749
void
6803
f07c4f00b07e Bug 1048: MatrixPropagationLossModel API changed from Ptr<Object> to Ptr<MobilityModel>
Pavel Boyko <boyko@iitp.ru>
parents: 6794
diff changeset
   750
MatrixPropagationLossModel::SetLoss (Ptr<MobilityModel> ma, Ptr<MobilityModel> mb, double loss, bool symmetric)
6115
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   751
{
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   752
  NS_ASSERT (ma != 0 && mb != 0);
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   753
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   754
  MobilityPair p = std::make_pair(ma, mb);
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   755
  std::map<MobilityPair, double>::iterator i = m_loss.find (p);
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   756
  
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   757
  if (i == m_loss.end ())
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   758
    {
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   759
      m_loss.insert (std::make_pair (p, loss));
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   760
    }
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   761
  else
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   762
    {
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   763
      i->second = loss;
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   764
    }
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   765
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   766
  if (symmetric)
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   767
    {
6803
f07c4f00b07e Bug 1048: MatrixPropagationLossModel API changed from Ptr<Object> to Ptr<MobilityModel>
Pavel Boyko <boyko@iitp.ru>
parents: 6794
diff changeset
   768
      SetLoss (mb, ma, loss, false);
6115
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   769
    }
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   770
}
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   771
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   772
double 
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   773
MatrixPropagationLossModel::DoCalcRxPower (double txPowerDbm,
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   774
                                           Ptr<MobilityModel> a,
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   775
                                           Ptr<MobilityModel> b) const
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   776
{
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   777
  std::map<MobilityPair, double>::const_iterator i = m_loss.find (std::make_pair (a, b));
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   778
  
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   779
  if (i != m_loss.end ())
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   780
    {
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   781
      return txPowerDbm - i->second;
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   782
    }
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   783
  else
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   784
    {
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   785
      return txPowerDbm - m_default;
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   786
    }
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   787
}
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   788
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   789
// ------------------------------------------------------------------------- //
edc1648e5ad4 Matrix propagation loss model added
Pavel Boyko <boyko@iitp.ru>
parents: 5972
diff changeset
   790
6461
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   791
NS_OBJECT_ENSURE_REGISTERED (RangePropagationLossModel);
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   792
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   793
TypeId
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   794
RangePropagationLossModel::GetTypeId (void)
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   795
{
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   796
  static TypeId tid = TypeId ("ns3::RangePropagationLossModel")
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   797
    .SetParent<PropagationLossModel> ()
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   798
    .AddConstructor<RangePropagationLossModel> ()
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   799
    .AddAttribute ("MaxRange",
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   800
                   "Maximum Transmission Range (meters)",
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   801
                   DoubleValue (250),
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   802
                   MakeDoubleAccessor (&RangePropagationLossModel::m_range),
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   803
                   MakeDoubleChecker<double> ())
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   804
  ;
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   805
  return tid;
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   806
}
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   807
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   808
RangePropagationLossModel::RangePropagationLossModel ()
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   809
{
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   810
}
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   811
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   812
double
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   813
RangePropagationLossModel::DoCalcRxPower (double txPowerDbm,
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   814
                                          Ptr<MobilityModel> a,
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   815
                                          Ptr<MobilityModel> b) const
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   816
{
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   817
  double distance = a->GetDistanceFrom (b);
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   818
  if (distance <= m_range)
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   819
    {
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   820
      return txPowerDbm;
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   821
    }
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   822
  else
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   823
    {
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   824
      return -1000;
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   825
    }
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   826
}
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   827
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   828
// ------------------------------------------------------------------------- //
99dd2b53fbfd Range-based propagation loss model added
Tom Henderson <tomh@tomh.org>
parents: 6445
diff changeset
   829
5944
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   830
} // namespace ns3