satellite-free-space-loss.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd.
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: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
22 
24 #include "satellite-utils.h"
25 
26 #include <ns3/double.h>
27 #include <ns3/log.h>
28 #include <ns3/string.h>
29 
30 NS_LOG_COMPONENT_DEFINE("SatFreeSpaceLoss");
31 
32 namespace ns3
33 {
34 
35 NS_OBJECT_ENSURE_REGISTERED(SatFreeSpaceLoss);
36 
37 TypeId
39 {
40  static TypeId tid =
41  TypeId("ns3::SatFreeSpaceLoss").SetParent<Object>().AddConstructor<SatFreeSpaceLoss>();
42  return tid;
43 }
44 
46 {
47 }
48 
49 double
50 SatFreeSpaceLoss::GetFsldB(Ptr<MobilityModel> a, Ptr<MobilityModel> b, double frequencyHz) const
51 {
52  NS_LOG_FUNCTION(this << frequencyHz);
53 
54  double fsl_dB;
55 
56  fsl_dB = SatUtils::LinearToDb(GetFsl(a, b, frequencyHz));
57 
58  return fsl_dB;
59 }
60 
61 double
62 SatFreeSpaceLoss::GetFsl(Ptr<MobilityModel> a, Ptr<MobilityModel> b, double frequencyHz) const
63 {
64  NS_LOG_FUNCTION(this << frequencyHz);
65 
66  double fsl;
67  double distance = a->GetDistanceFrom(b);
68 
69  fsl =
70  std::pow(((4.0 * M_PI * distance * frequencyHz) / SatConstVariables::SPEED_OF_LIGHT), 2.0);
71 
72  return fsl;
73 }
74 
75 } // namespace ns3
static TypeId GetTypeId(void)
Get the type ID.
virtual double GetFsl(Ptr< MobilityModel > a, Ptr< MobilityModel > b, double frequencyHz) const
Calculate the free-space loss in linear format.
SatFreeSpaceLoss()
Default constructor.
virtual double GetFsldB(Ptr< MobilityModel > a, Ptr< MobilityModel > b, double frequencyHz) const
Calculate the free-space loss in dB.
static T LinearToDb(T linear)
Converts linear to decibels.
constexpr double SPEED_OF_LIGHT
Constant definition for the speed of light in m/s.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.