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 
25 #include "satellite-utils.h"
26 
27 #include <ns3/double.h>
28 #include <ns3/log.h>
29 #include <ns3/string.h>
30 
31 #include <cmath>
32 #include <stdint.h>
33 
34 NS_LOG_COMPONENT_DEFINE("SatFreeSpaceLoss");
35 
36 namespace ns3
37 {
38 
39 NS_OBJECT_ENSURE_REGISTERED(SatFreeSpaceLoss);
40 
41 TypeId
43 {
44  static TypeId tid =
45  TypeId("ns3::SatFreeSpaceLoss").SetParent<Object>().AddConstructor<SatFreeSpaceLoss>();
46  return tid;
47 }
48 
50 {
51 }
52 
53 double
54 SatFreeSpaceLoss::GetFsldB(Ptr<MobilityModel> a, Ptr<MobilityModel> b, double frequencyHz) const
55 {
56  NS_LOG_FUNCTION(this << frequencyHz);
57 
58  double fsl_dB;
59 
60  fsl_dB = SatUtils::LinearToDb(GetFsl(a, b, frequencyHz));
61 
62  return fsl_dB;
63 }
64 
65 double
66 SatFreeSpaceLoss::GetFsl(Ptr<MobilityModel> a, Ptr<MobilityModel> b, double frequencyHz) const
67 {
68  NS_LOG_FUNCTION(this << frequencyHz);
69 
70  double fsl;
71  double distance =
72  DynamicCast<SatMobilityModel>(a)->GetDistanceFrom(DynamicCast<SatMobilityModel>(b));
73 
74  fsl =
75  std::pow(((4.0 * M_PI * distance * frequencyHz) / SatConstVariables::SPEED_OF_LIGHT), 2.0);
76 
77  return fsl;
78 }
79 
80 } // 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.