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 
21 #include "../model/satellite-antenna-gain-pattern-container.h"
22 #include "../model/satellite-antenna-gain-pattern.h"
23 #include "../model/satellite-constant-position-mobility-model.h"
24 #include "../utils/satellite-env-variables.h"
25 
26 #include "ns3/log.h"
27 #include "ns3/simulator.h"
28 #include "ns3/singleton.h"
29 #include "ns3/test.h"
30 
31 using namespace ns3;
32 
42 class SatAntennaPatternTestCase : public TestCase
43 {
44  public:
46  virtual ~SatAntennaPatternTestCase();
47 
48  private:
49  virtual void DoRun(void);
50 };
51 
53  : TestCase("Test satellite antenna gain pattern.")
54 {
55 }
56 
58 {
59 }
60 
61 void
63 {
64  // Set simulation output details
65  Singleton<SatEnvVariables>::Get()->DoInitialize();
66  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-antenna-gain-pattern", "", true);
67 
68  // Create antenna gain container
70 
71  GeoCoordinate geoPos = GeoCoordinate(0.0, 33.0, 35786000);
72  Ptr<SatMobilityModel> mobility = CreateObject<SatConstantPositionMobilityModel>();
73  mobility->SetGeoPosition(geoPos);
74  gpContainer.ConfigureBeamsMobility(0, mobility);
75 
76  // Test positions (= GW positions from 72 spot-beam reference system)
77  std::vector<GeoCoordinate> coordinates;
78  GeoCoordinate g1 = GeoCoordinate(50.25, 3.75, 0.0);
79  coordinates.push_back(g1);
80  GeoCoordinate g2 = GeoCoordinate(64.00, 8.25, 0.0);
81  coordinates.push_back(g2);
82  GeoCoordinate g3 = GeoCoordinate(42.25, -4.50, 0.0);
83  coordinates.push_back(g3);
84  GeoCoordinate g4 = GeoCoordinate(44.50, 13.50, 0.0);
85  coordinates.push_back(g4);
86  GeoCoordinate g5 = GeoCoordinate(37.25, 23.75, 0.0);
87  coordinates.push_back(g5);
88 
89  /* Reference results
90  GW: 1, Lat: 50.25, Lon: 3.75, bestBeamId: 12, gain: 51.5528
91  GW: 2, Lat: 64, Lon: 8.25, bestBeamId: 6, gain: 51.4735
92  GW: 3, Lat: 42.25, Lon: -4.5, bestBeamId: 22, gain: 51.3403
93  GW: 4, Lat: 44.5, Lon: 13.5, bestBeamId: 39, gain: 51.6553
94  GW: 5, Lat: 37.25, Lon: 23.75, bestBeamId: 58, gain: 51.4738
95  */
96 
97  // Expected spot-beam gains from beam 3
98  double expectedGains[5] = {51.5528, 51.4735, 51.3403, 51.6553, 51.4738};
99 
100  // Expected best spot-beams
101  uint32_t expectedBeamIds[5] = {12, 6, 22, 39, 58};
102 
103  // Check that the gains and best beam IDs are as expected
104  double gain(0.0);
105  uint32_t bestBeamId(0);
106  for (uint32_t i = 0; i < coordinates.size(); ++i)
107  {
108  bestBeamId = gpContainer.GetBestBeamId(0, coordinates[i], false);
109 
110  Ptr<SatAntennaGainPattern> gainPattern = gpContainer.GetAntennaGainPattern(bestBeamId);
111 
112  gain = gainPattern->GetAntennaGain_lin(coordinates[i], mobility);
113  double gain_dB = 10.0 * log10(gain);
114 
115  /*
116  std::cout << "GW: " << i+1 <<
117  ", Lat: " << coordinates[i].GetLatitude () <<
118  ", Lon: " << coordinates[i].GetLongitude () <<
119  ", bestBeamId: " << bestBeamId <<
120  ", gain: " << gain_dB << std::endl;
121  */
122 
123  NS_TEST_ASSERT_MSG_EQ_TOL(gain_dB,
124  expectedGains[i],
125  0.001,
126  "Expected gain not within tolerance");
127  NS_TEST_ASSERT_MSG_EQ(bestBeamId, expectedBeamIds[i], "Not expected best spot-beam id");
128  }
129 
130  Singleton<SatEnvVariables>::Get()->DoDispose();
131 }
132 
137 class SatAntennaPatternTestSuite : public TestSuite
138 {
139  public:
141 };
142 
144  : TestSuite("sat-antenna-gain-pattern-test", UNIT)
145 {
146  AddTestCase(new SatAntennaPatternTestCase, TestCase::QUICK);
147 }
148 
149 // 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)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatAntennaPatternTestSuite satSatInterferenceTestSuite