satellite-scenario-creation.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 
31 #include "../helper/satellite-helper.h"
32 #include "../utils/satellite-env-variables.h"
33 
34 #include "ns3/core-module.h"
35 #include "ns3/satellite-id-mapper.h"
36 #include "ns3/simulator.h"
37 #include "ns3/singleton.h"
38 #include "ns3/string.h"
39 #include "ns3/test.h"
40 
41 using namespace ns3;
42 
56 class ScenarioCreationSimple : public TestCase
57 {
58  public:
60  virtual ~ScenarioCreationSimple();
61 
62  private:
63  virtual void DoRun(void);
64 };
65 
66 // Add some help text to this case to describe what it is intended to test
68  : TestCase("'Scenario Creation, Simple' case tests successful creation of Simple test scenario")
69 {
70 }
71 
72 // This destructor does nothing but we include it as a reminder that
73 // the test case should clean up after itself
75 {
76 }
77 
78 //
79 // ScenarioCreationSimple TestCase implementation
80 //
81 void
83 {
84  // Reset singletons
85  Singleton<SatIdMapper>::Get()->Reset();
86 
87  // Set simulation output details
88  Singleton<SatEnvVariables>::Get()->DoInitialize();
89  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-scenario-creation",
90  "simple-scenario",
91  true);
92 
93  // Create simple scenario
94 
95  // Creating the reference system.
96  Ptr<SatHelper> helper = CreateObject<SatHelper>();
97 
98  // Enable creation traces
99  Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
100 
101  helper->CreatePredefinedScenario(SatHelper::SIMPLE);
102 
103  // check results what can be done at this level. More checking done in module level with traces
104  NS_TEST_ASSERT_MSG_EQ(helper->GetGwUsers().GetN(), 1, "GW User count is not what expected!");
105  NS_TEST_ASSERT_MSG_EQ(helper->GetUtUsers().GetN(), 1, "UT User count is not what expected!");
106 
107  Singleton<SatEnvVariables>::Get()->DoDispose();
108 
109  Simulator::Destroy();
110 }
111 
125 class ScenarioCreationLarger : public TestCase
126 {
127  public:
129  virtual ~ScenarioCreationLarger();
130 
131  private:
132  virtual void DoRun(void);
133 };
134 
135 // Add some help text to this case to describe what it is intended to test
137  : TestCase("'Scenario Creation, Larger' case tests successful creation of Larger test scenario")
138 {
139 }
140 
141 // This destructor does nothing but we include it as a reminder that
142 // the test case should clean up after itself
144 {
145 }
146 
147 //
148 // ScenarioCreationLarger TestCase implementation
149 //
150 void
152 {
153  // Reset singletons
154  Singleton<SatIdMapper>::Get()->Reset();
155 
156  // Set simulation output details
157  Singleton<SatEnvVariables>::Get()->DoInitialize();
158  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-scenario-creation",
159  "larger-scenario",
160  true);
161 
162  // Create larger scenario
163 
164  // Creating the reference system.
165  Ptr<SatHelper> helper = CreateObject<SatHelper>();
166 
167  // Enable creation traces
168  Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
169 
170  helper->CreatePredefinedScenario(SatHelper::LARGER);
171 
172  // check results what can be done at this level. More checking done in module level with traces
173  NS_TEST_ASSERT_MSG_EQ(helper->GetGwUsers().GetN(), 1, "GW User count is not what expected!");
174  NS_TEST_ASSERT_MSG_EQ(helper->GetUtUsers().GetN(), 5, "UT User count is not what expected!");
175 
176  Singleton<SatEnvVariables>::Get()->DoDispose();
177 
178  Simulator::Destroy();
179 }
180 
194 class ScenarioCreationFull : public TestCase
195 {
196  public:
198  virtual ~ScenarioCreationFull();
199 
200  private:
201  virtual void DoRun(void);
202 };
203 
204 // Add some help text to this case to describe what it is intended to test
206  : TestCase("'Scenario Creation, Full' case tests successful creation of Full test scenario")
207 {
208 }
209 
210 // This destructor does nothing but we include it as a reminder that
211 // the test case should clean up after itself
213 {
214 }
215 
216 //
217 // ScenarioCreationFull TestCase implementation
218 //
219 void
221 {
222  // Reset singletons
223  Singleton<SatIdMapper>::Get()->Reset();
224 
225  // Set simulation output details
226  Singleton<SatEnvVariables>::Get()->DoInitialize();
227  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-scenario-creation",
228  "full-scenario",
229  true);
230 
231  // Create full scenario
232 
233  // Creating the reference system.
234  Ptr<SatHelper> helper = CreateObject<SatHelper>();
235 
236  // Enable creation traces
237  Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
238 
239  helper->CreatePredefinedScenario(SatHelper::FULL);
240 
241  // check results what can be done at this level. More checking done in module level with traces
242  // reference system includes 98 beams and we create three UTs with three users per UT in full
243  // scenario and five GW users
244 
245  NS_TEST_ASSERT_MSG_EQ(helper->GetGwUsers().GetN(), 5, "GW User count is not what expected!");
246  // NS_TEST_ASSERT_MSG_EQ (helper->GetUtUsers().GetN(), 98*3*3, "UT User count is not what
247  // expected!");
248  NS_TEST_ASSERT_MSG_EQ(helper->GetUtUsers().GetN(),
249  72 * 3 * 3,
250  "UT User count is not what expected!");
251 
252  Singleton<SatEnvVariables>::Get()->DoDispose();
253 
254  Simulator::Destroy();
255 }
256 
272 class ScenarioCreationUser : public TestCase
273 {
274  public:
276  virtual ~ScenarioCreationUser();
277 
278  private:
279  virtual void DoRun(void);
280 };
281 
282 // Add some help text to this case to describe what it is intended to test
284  : TestCase("'Scenario Creation, User defined' case tests successful creation of User defined "
285  "test scenario")
286 {
287 }
288 
289 // This destructor does nothing but we include it as a reminder that
290 // the test case should clean up after itself
292 {
293 }
294 
295 //
296 // ScenarioCreationUser TestCase implementation
297 //
298 void
300 {
301  // Reset singletons
302  Singleton<SatIdMapper>::Get()->Reset();
303 
304  // Set simulation output details
305  Singleton<SatEnvVariables>::Get()->DoInitialize();
306  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-scenario-creation",
307  "user-scenario",
308  true);
309 
310  // Create user scenario
311 
312  // Creating the reference system.
313  Ptr<SatHelper> helper = CreateObject<SatHelper>();
314  SatBeamUserInfo beamInfo = SatBeamUserInfo(1, 1);
315  std::map<std::pair<uint32_t, uint32_t>, SatBeamUserInfo> beamMap;
316  beamMap[std::make_pair(0, 8)] = beamInfo;
317  beamMap[std::make_pair(0, 3)] = beamInfo;
318  beamInfo.AppendUt(2);
319  beamMap[std::make_pair(0, 2)] = beamInfo;
320 
321  // Enable creation traces
322  Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
323 
324  helper->CreateUserDefinedScenario(beamMap);
325 
326  // check results what can be done at this level. More checking done in module level with traces
327  NS_TEST_ASSERT_MSG_EQ(helper->GetGwUsers().GetN(), 5, "GW User count is not what expected!");
328  NS_TEST_ASSERT_MSG_EQ(helper->GetUtUsers().GetN(), 5, "UT User count is not what expected!");
329 
330  Singleton<SatEnvVariables>::Get()->DoDispose();
331 
332  Simulator::Destroy();
333 }
334 
335 // The TestSuite class names the TestSuite as sat-scenario-creation, identifies what type of
336 // TestSuite (SYSTEM), and enables the TestCases to be run. Typically, only the constructor for this
337 // class must be defined
338 //
339 class ScenarioCreationTestSuite : public TestSuite
340 {
341  public:
343 };
344 
346  : TestSuite("sat-scenario-creation", SYSTEM)
347 {
348  // add ScenarioCreationSimple case to suite sat-scenario-creation
349  AddTestCase(new ScenarioCreationSimple, TestCase::QUICK);
350 
351  // add ScenarioCreationLarger case to suite sat-scenario-creation
352  AddTestCase(new ScenarioCreationLarger, TestCase::QUICK);
353 
354  // add ScenarioCreationFull case to suite sat-scenario-creation
355  AddTestCase(new ScenarioCreationFull, TestCase::QUICK);
356 
357  // add ScenarioCreationUser case to suite sat-scenario-creation
358  AddTestCase(new ScenarioCreationUser, TestCase::QUICK);
359 }
360 
361 // Allocate an instance of this TestSuite
'Scenario Creation, Full' test case implementation, id: sc-3 / TN4.
'Scenario Creation, Larger' test case implementation, id: sc-2 / TN4.
'Scenario Creation, Simple' test case implementation, id: sc-1 / TN4.
'Scenario Creation, User Defined' test case implementation, id: tbd / TN4.
Class that holds information for each beam regarding UTs and their users camped in each beam.
void AppendUt(uint32_t userCount)
Appends new UT to end of the list with given user count for the appended UT.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static ScenarioCreationTestSuite scenarioCreationTestSuite