satellite-fading-external-input-trace-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 
27 #include "../model/satellite-channel.h"
28 #include "../model/satellite-fading-external-input-trace-container.h"
29 #include "../utils/satellite-env-variables.h"
30 
31 #include "ns3/log.h"
32 #include "ns3/simulator.h"
33 #include "ns3/singleton.h"
34 #include "ns3/test.h"
35 #include "ns3/timer.h"
36 
37 #include <vector>
38 
39 using namespace ns3;
40 
47 class SatFadingExternalInputTraceTestCase : public TestCase
48 {
49  public:
52 
53  void TestGetFading(uint32_t nodeId, SatEnums::ChannelType_t channelType);
54 
55  private:
56  virtual void DoRun(void);
57 
58  std::vector<double> m_results;
59 };
60 
62  : TestCase("Test satellite fading external input trace and container.")
63 {
64 }
65 
67 {
68 }
69 
70 void
72  SatEnums::ChannelType_t channelType)
73 {
74  Ptr<SatMobilityModel> mobility;
75 
76  Ptr<SatFadingExternalInputTrace> trace =
77  Singleton<SatFadingExternalInputTraceContainer>::Get()->GetFadingTrace(nodeId,
78  channelType,
79  mobility);
80  double fading = trace->GetFading();
81  m_results.push_back(fading);
82 }
83 
84 void
86 {
87  uint32_t numUts(2);
88  uint32_t numGws(5);
89 
90  // Set simulation output details
91  Singleton<SatEnvVariables>::Get()->DoInitialize();
92  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-fading-external-input-trace",
93  "",
94  true);
95 
96  // Test the fading traces
97  bool success =
98  Singleton<SatFadingExternalInputTraceContainer>::Get()->TestFadingTraces(numUts, numGws);
99  NS_TEST_ASSERT_MSG_EQ(success, true, "SatChannelFadingTrace test failed");
100 
101  double time[4] = {1.434, 40.923, 80.503, 140.3};
102  double preCalcRes[4] = {1.020, 1.008, 1.006, 1.012};
103 
104  Simulator::Schedule(Seconds(time[0]),
106  this,
107  1,
108  SatEnums::RETURN_USER_CH);
109  Simulator::Schedule(Seconds(time[1]),
111  this,
112  2,
113  SatEnums::RETURN_FEEDER_CH);
114  Simulator::Schedule(Seconds(time[2]),
116  this,
117  1,
118  SatEnums::FORWARD_USER_CH);
119  Simulator::Schedule(Seconds(time[3]),
121  this,
122  2,
123  SatEnums::FORWARD_FEEDER_CH);
124 
125  Simulator::Run();
126 
127  for (uint32_t i = 0; i < 4; ++i)
128  {
129  NS_TEST_ASSERT_MSG_EQ_TOL(m_results[i],
130  preCalcRes[i],
131  0.001,
132  "Fading not within expected tolerance");
133  }
134 
135  Simulator::Destroy();
136 
137  Singleton<SatEnvVariables>::Get()->DoDispose();
138 }
139 
144 class SatFadingExternalInputTraceTestSuite : public TestSuite
145 {
146  public:
148 };
149 
151  : TestSuite("sat-fading-external-input-trace-test", UNIT)
152 {
153  AddTestCase(new SatFadingExternalInputTraceTestCase, TestCase::QUICK);
154 }
155 
156 // Do allocate an instance of this TestSuite
Test case to unit test satellite fading external input trace and container for these objects.
void TestGetFading(uint32_t nodeId, SatEnums::ChannelType_t channelType)
Test suite for satellite fading external input trace.
ChannelType_t
Types of channel.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatFadingExternalInputTraceTestSuite satSatInterferenceTestSuite