src/lte/model/path-loss-model.cc
changeset 8749 4462ac63d4cf
parent 8748 87a141a38088
parent 8747 2aec19a85c73
child 8750 b3db7d51f260
child 8765 b89660102b63
equal deleted inserted replaced
8748:87a141a38088 8749:4462ac63d4cf
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License version 2 as
       
     7  * published by the Free Software Foundation;
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    17  *
       
    18  * Author: Giuseppe Piro  <g.piro@poliba.it>
       
    19  */
       
    20 
       
    21 
       
    22 #include <ns3/log.h>
       
    23 #include <cmath>
       
    24 #include "path-loss-model.h"
       
    25 #include <ns3/mobility-model.h>
       
    26 #include <ns3/vector.h>
       
    27 
       
    28 
       
    29 NS_LOG_COMPONENT_DEFINE ("PathLossModel");
       
    30 
       
    31 namespace ns3 {
       
    32 
       
    33 
       
    34 NS_OBJECT_ENSURE_REGISTERED (PathLossModel);
       
    35 
       
    36 PathLossModel::PathLossModel ()
       
    37 {
       
    38   NS_LOG_FUNCTION (this);
       
    39   SetLastUpdate ();
       
    40   SetSamplingPeriod (0.5); // defauld value
       
    41   m_pl = 0;
       
    42 }
       
    43 
       
    44 
       
    45 TypeId
       
    46 PathLossModel::GetTypeId (void)
       
    47 {
       
    48   static TypeId tid = TypeId ("ns3::PathLossModel")
       
    49     .SetParent<DiscreteTimeLossModel> ()
       
    50     .AddConstructor<PathLossModel> ()
       
    51   ;
       
    52   return tid;
       
    53 }
       
    54 
       
    55 
       
    56 PathLossModel::~PathLossModel ()
       
    57 {
       
    58 }
       
    59 
       
    60 
       
    61 void
       
    62 PathLossModel::SetValue (double pl)
       
    63 {
       
    64   NS_LOG_FUNCTION (this << pl);
       
    65   m_pl = pl;
       
    66 }
       
    67 
       
    68 
       
    69 double
       
    70 PathLossModel::GetValue (Ptr<const MobilityModel> a, Ptr<const MobilityModel> b)
       
    71 {
       
    72   NS_LOG_FUNCTION (this << a << b);
       
    73   /*
       
    74    * According to  ---  insert standard 3gpp ---
       
    75    * the Path Loss Model For Urban Environment is
       
    76    * L = I + 37.6log10(R)
       
    77    * R, in kilometers, is the distance between two nodes
       
    78    * I = 128.1 at 2GHz
       
    79    */
       
    80   double distance = CalculateDistance (a->GetPosition (), b->GetPosition ());
       
    81   SetValue (128.1 + (37.6 * log10 (distance * 0.001)));
       
    82   return m_pl;
       
    83 }
       
    84 
       
    85 
       
    86 } // namespace ns3