Loading...
Searching...
No Matches
satellite-antenna-pattern-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: Jani Puttonen <jani.puttonen@magister.fi>
19 */
20
25
26#include "ns3/log.h"
27#include "ns3/simulator.h"
28#include "ns3/singleton.h"
29#include "ns3/test.h"
30
31using namespace ns3;
32
42class SatAntennaPatternTestCase : public TestCase
43{
44 public:
47
48 private:
49 virtual void DoRun(void);
50};
51
53 : TestCase("Test satellite antenna gain pattern.")
54{
55}
56
60
61void
63{
64 // Set simulation output details
65 SatEnvVariables::GetInstance()->DoInitialize();
66 SatEnvVariables::GetInstance()->SetOutputVariables("test-antenna-gain-pattern", "", true);
67
68 std::cout << "SatEnvVariables::GetCurrentWorkingDirectory()"
69 << SatEnvVariables::GetInstance()->GetCurrentWorkingDirectory() << std::endl;
70
71 // Create antenna gain container
73 1,
74 SatEnvVariables::GetInstance()->LocateDataDirectory() +
75 "/scenarios/geo-33E/antennapatterns");
76
77 GeoCoordinate geoPos = GeoCoordinate(0.0, 33.0, 35786000);
78 Ptr<SatMobilityModel> mobility = CreateObject<SatConstantPositionMobilityModel>();
79 mobility->SetGeoPosition(geoPos);
80 gpContainer.ConfigureBeamsMobility(0, mobility);
81
82 // Test positions (= GW positions from 72 spot-beam reference system)
83 std::vector<GeoCoordinate> coordinates;
84 GeoCoordinate g1 = GeoCoordinate(50.25, 3.75, 0.0);
85 coordinates.push_back(g1);
86 GeoCoordinate g2 = GeoCoordinate(64.00, 8.25, 0.0);
87 coordinates.push_back(g2);
88 GeoCoordinate g3 = GeoCoordinate(42.25, -4.50, 0.0);
89 coordinates.push_back(g3);
90 GeoCoordinate g4 = GeoCoordinate(44.50, 13.50, 0.0);
91 coordinates.push_back(g4);
92 GeoCoordinate g5 = GeoCoordinate(37.25, 23.75, 0.0);
93 coordinates.push_back(g5);
94
95 /* Reference results
96 GW: 1, Lat: 50.25, Lon: 3.75, bestBeamId: 12, gain: 51.5528
97 GW: 2, Lat: 64, Lon: 8.25, bestBeamId: 6, gain: 51.4735
98 GW: 3, Lat: 42.25, Lon: -4.5, bestBeamId: 22, gain: 51.3403
99 GW: 4, Lat: 44.5, Lon: 13.5, bestBeamId: 39, gain: 51.6553
100 GW: 5, Lat: 37.25, Lon: 23.75, bestBeamId: 58, gain: 51.4738
101 */
102
103 // Expected spot-beam gains from beam 3
104 double expectedGains[5] = {51.5528, 51.4735, 51.3403, 51.6553, 51.4738};
105
106 // Expected best spot-beams
107 uint32_t expectedBeamIds[5] = {12, 6, 22, 39, 58};
108
109 // Check that the gains and best beam IDs are as expected
110 double gain(0.0);
111 uint32_t bestBeamId(0);
112 for (uint32_t i = 0; i < coordinates.size(); ++i)
113 {
114 bestBeamId = gpContainer.GetBestBeamId(0, coordinates[i], false);
115
116 Ptr<SatAntennaGainPattern> gainPattern = gpContainer.GetAntennaGainPattern(bestBeamId);
117
118 gain = gainPattern->GetAntennaGain_lin(coordinates[i], mobility);
119 double gain_dB = 10.0 * log10(gain);
120
121 /*
122 std::cout << "GW: " << i+1 <<
123 ", Lat: " << coordinates[i].GetLatitude () <<
124 ", Lon: " << coordinates[i].GetLongitude () <<
125 ", bestBeamId: " << bestBeamId <<
126 ", gain: " << gain_dB << std::endl;
127 */
128
129 NS_TEST_ASSERT_MSG_EQ_TOL(gain_dB,
130 expectedGains[i],
131 0.001,
132 "Expected gain not within tolerance");
133 NS_TEST_ASSERT_MSG_EQ(bestBeamId, expectedBeamIds[i], "Not expected best spot-beam id");
134 }
135
136 SatEnvVariables::GetInstance()->DoDispose();
137}
138
143class SatAntennaPatternTestSuite : public TestSuite
144{
145 public:
147};
148
150 : TestSuite("sat-antenna-gain-pattern-test", Type::UNIT)
151{
152 AddTestCase(new SatAntennaPatternTestCase, TestCase::Duration::QUICK);
153}
154
155// Do allocate an instance of this TestSuite
Satellite antenna pattern test suite.
GeoCoordinate class is used to store and operate with geodetic coordinates.
Antenna gain pattern container holds all antenna patterns related to a satellite system.
Ptr< SatAntennaGainPattern > GetAntennaGainPattern(uint32_t beamId) const
Get the antenna pattern of a specified beam id.
uint32_t GetBestBeamId(uint32_t satelliteId, GeoCoordinate coord, bool ignoreNan)
Get the best beam id based on the antenna patterns in a specified geo coordinate.
void ConfigureBeamsMobility(uint32_t satelliteId, Ptr< SatMobilityModel > mobility)
static Ptr< SatEnvVariables > GetInstance()
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatAntennaPatternTestSuite satSatInterferenceTestSuite