Loading...
Searching...
No Matches
satellite-fsl-test.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
26
27#include "ns3/log.h"
28#include "ns3/satellite-env-variables.h"
29#include "ns3/satellite-free-space-loss.h"
30#include "ns3/satellite-helper.h"
31#include "ns3/satellite-mobility-model.h"
32#include "ns3/satellite-topology.h"
33#include "ns3/simulator.h"
34#include "ns3/singleton.h"
35#include "ns3/test.h"
36
37#include <stdint.h>
38
39using namespace ns3;
40
55class SatFreeSpaceLossTestCase : public TestCase
56{
57 public:
60
61 private:
62 virtual void DoRun(void);
63};
64
66 : TestCase("Test satellite free space loss model.")
67{
68}
69
73
74void
76{
77 // Set simulation output details
78 SatEnvVariables::GetInstance()->DoInitialize();
79 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-fsl", "", true);
80
82 double frequency = 17.9 * std::pow(10.0, 9); // reference frequency
83
84 // Create simple scenario
85
86 // Creating the reference system.
87 Ptr<SatHelper> helper = CreateObject<SatHelper>(
88 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/scenarios/geo-33E");
89
90 helper->CreatePredefinedScenario(SatHelper::SIMPLE);
91
92 NodeContainer gw = Singleton<SatTopology>::Get()->GetGwNodes();
93 NodeContainer ut = Singleton<SatTopology>::Get()->GetUtNodes();
94 Ptr<Node> sat = Singleton<SatTopology>::Get()->GetOrbiterNode(0);
95
96 // get mobilities
97 Ptr<SatMobilityModel> gwMob = gw.Get(0)->GetObject<SatMobilityModel>();
98 Ptr<SatMobilityModel> utMob = ut.Get(0)->GetObject<SatMobilityModel>();
99 Ptr<SatMobilityModel> satMob = sat->GetObject<SatMobilityModel>();
100
101 // set reference positions for test
102 gwMob->SetGeoPosition(GeoCoordinate(25.28, 54.689444, 0.0));
103 utMob->SetGeoPosition(GeoCoordinate(25.00, -26.20, 230.0));
104 satMob->SetGeoPosition(GeoCoordinate(0.0, 33.0, 35786000.0));
105
106 // test fsl calculation in path UT - Geo Satellite
107 // double fsl_ratio = fsl.GetFsl(utMob, satMob, frequency);
108 double fsl_dB = fsl.GetFsldB(utMob, satMob, frequency);
109
110 // Calculations with big double numbers there will produce results
111 // with different precisions when compiled with optimized and debug flags.
112 // TODO: check whether we could change e.g. the waf configure to avoid the precision problem.
113 // NS_TEST_ASSERT_MSG_EQ_TOL( fsl_ratio, 883122910318077150000.0, 1.1, "FSL (UT-GEO) ratio
114 // incorrect");
115 NS_TEST_ASSERT_MSG_EQ_TOL(fsl_dB, 209.460211515483, 0.1, "FSL (UT-GEO) in dBs incorrect");
116
117 // test fsl calculation in path GW - Geo Satellite
118 // fsl_ratio = fsl.GetFsl(gwMob, satMob, frequency);
119 fsl_dB = fsl.GetFsldB(gwMob, satMob, frequency);
120
121 // Calculations with big double numbers there will produce results
122 // with different precisions when compiled with optimized and debug flags.
123 // TODO: check whether we could change e.g. the waf configure to avoid the precision problem.
124 // NS_TEST_ASSERT_MSG_EQ_TOL( fsl_ratio, 769159080122215960000.0, 1.1, "FSL (GW-GEO) ratio
125 // incorrect");
126 NS_TEST_ASSERT_MSG_EQ_TOL(fsl_dB, 208.86016171367487, 0.1, "FSL (GW-GEO) in dBs incorrect");
127
128 Simulator::Destroy();
129
130 SatEnvVariables::GetInstance()->DoDispose();
131}
132
136class SatFreeSpaceLossTestSuite : public TestSuite
137{
138 public:
140};
141
143 : TestSuite("sat-fsl-test", Type::UNIT)
144{
145 AddTestCase(new SatFreeSpaceLossTestCase, TestCase::Duration::QUICK);
146}
147
148// Do allocate an instance of this TestSuite
Test case to unit test satellite free space loss (FSL) model.
Test suite for Satellite free space loss unit test cases.
GeoCoordinate class is used to store and operate with geodetic coordinates.
static Ptr< SatEnvVariables > GetInstance()
This class is responsible of calculating the free space loss (FSL) based on two given node positions ...
virtual double GetFsldB(Ptr< MobilityModel > a, Ptr< MobilityModel > b, double frequencyHz) const
Calculate the free-space loss in dB.
@ SIMPLE
SIMPLE Simple scenario used as base.
Keep track of the current position and velocity of an object in satellite network.
void SetGeoPosition(const GeoCoordinate &position)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatFreeSpaceLossTestSuite satFslTestSuite