Loading...
Searching...
No Matches
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
30
31#include "ns3/core-module.h"
32#include "ns3/satellite-env-variables.h"
33#include "ns3/satellite-helper.h"
34#include "ns3/satellite-id-mapper.h"
35#include "ns3/satellite-topology.h"
36#include "ns3/simulator.h"
37#include "ns3/singleton.h"
38#include "ns3/string.h"
39#include "ns3/test.h"
40
41using namespace ns3;
42
56class ScenarioCreationSimple : public TestCase
57{
58 public:
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
77
78//
79// ScenarioCreationSimple TestCase implementation
80//
81void
83{
84 // Reset singletons
85 Singleton<SatIdMapper>::Get()->Reset();
86
87 // Set simulation output details
88 SatEnvVariables::GetInstance()->DoInitialize();
89 SatEnvVariables::GetInstance()->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 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/scenarios/geo-33E");
98
99 // Enable creation traces
100 Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
101
102 helper->CreatePredefinedScenario(SatHelper::SIMPLE);
103
104 // check results what can be done at this level. More checking done in module level with traces
105 NS_TEST_ASSERT_MSG_EQ(Singleton<SatTopology>::Get()->GetGwUserNodes().GetN(),
106 1,
107 "GW User count is not what expected!");
108 NS_TEST_ASSERT_MSG_EQ(Singleton<SatTopology>::Get()->GetNUtUserNodes(),
109 1,
110 "UT User count is not what expected!");
111
112 SatEnvVariables::GetInstance()->DoDispose();
113
114 Simulator::Destroy();
115}
116
130class ScenarioCreationLarger : public TestCase
131{
132 public:
134 virtual ~ScenarioCreationLarger();
135
136 private:
137 virtual void DoRun(void);
138};
139
140// Add some help text to this case to describe what it is intended to test
142 : TestCase("'Scenario Creation, Larger' case tests successful creation of Larger test scenario")
143{
144}
145
146// This destructor does nothing but we include it as a reminder that
147// the test case should clean up after itself
151
152//
153// ScenarioCreationLarger TestCase implementation
154//
155void
157{
158 // Reset singletons
159 Singleton<SatIdMapper>::Get()->Reset();
160
161 // Set simulation output details
162 SatEnvVariables::GetInstance()->DoInitialize();
163 SatEnvVariables::GetInstance()->SetOutputVariables("test-scenario-creation",
164 "larger-scenario",
165 true);
166
167 // Create larger scenario
168
169 // Creating the reference system.
170 Ptr<SatHelper> helper = CreateObject<SatHelper>(
171 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/scenarios/geo-33E");
172
173 // Enable creation traces
174 Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
175
176 helper->CreatePredefinedScenario(SatHelper::LARGER);
177
178 // check results what can be done at this level. More checking done in module level with traces
179 NS_TEST_ASSERT_MSG_EQ(Singleton<SatTopology>::Get()->GetGwUserNodes().GetN(),
180 1,
181 "GW User count is not what expected!");
182 NS_TEST_ASSERT_MSG_EQ(Singleton<SatTopology>::Get()->GetNUtUserNodes(),
183 5,
184 "UT User count is not what expected!");
185
186 SatEnvVariables::GetInstance()->DoDispose();
187
188 Simulator::Destroy();
189}
190
204class ScenarioCreationFull : public TestCase
205{
206 public:
208 virtual ~ScenarioCreationFull();
209
210 private:
211 virtual void DoRun(void);
212};
213
214// Add some help text to this case to describe what it is intended to test
216 : TestCase("'Scenario Creation, Full' case tests successful creation of Full test scenario")
217{
218}
219
220// This destructor does nothing but we include it as a reminder that
221// the test case should clean up after itself
225
226//
227// ScenarioCreationFull TestCase implementation
228//
229void
231{
232 // Reset singletons
233 Singleton<SatIdMapper>::Get()->Reset();
234
235 // Set simulation output details
236 SatEnvVariables::GetInstance()->DoInitialize();
237 SatEnvVariables::GetInstance()->SetOutputVariables("test-scenario-creation",
238 "full-scenario",
239 true);
240
241 // Create full scenario
242
243 // Creating the reference system.
244 Ptr<SatHelper> helper = CreateObject<SatHelper>(
245 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/scenarios/geo-33E");
246
247 // Enable creation traces
248 Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
249
250 helper->CreatePredefinedScenario(SatHelper::FULL);
251
252 // check results what can be done at this level. More checking done in module level with traces
253 // reference system includes 98 beams and we create three UTs with three users per UT in full
254 // scenario and five GW users
255
256 NS_TEST_ASSERT_MSG_EQ(Singleton<SatTopology>::Get()->GetGwUserNodes().GetN(),
257 5,
258 "GW User count is not what expected!");
259 // NS_TEST_ASSERT_MSG_EQ (Singleton<SatTopology>::Get()->GetNUtUserNodes(), 98*3*3, "UT User
260 // count is not what expected!");
261 NS_TEST_ASSERT_MSG_EQ(Singleton<SatTopology>::Get()->GetNUtUserNodes(),
262 72 * 3 * 3,
263 "UT User count is not what expected!");
264
265 SatEnvVariables::GetInstance()->DoDispose();
266
267 Simulator::Destroy();
268}
269
285class ScenarioCreationUser : public TestCase
286{
287 public:
289 virtual ~ScenarioCreationUser();
290
291 private:
292 virtual void DoRun(void);
293};
294
295// Add some help text to this case to describe what it is intended to test
297 : TestCase("'Scenario Creation, User defined' case tests successful creation of User defined "
298 "test scenario")
299{
300}
301
302// This destructor does nothing but we include it as a reminder that
303// the test case should clean up after itself
307
308//
309// ScenarioCreationUser TestCase implementation
310//
311void
313{
314 // Reset singletons
315 Singleton<SatIdMapper>::Get()->Reset();
316
317 // Set simulation output details
318 SatEnvVariables::GetInstance()->DoInitialize();
319 SatEnvVariables::GetInstance()->SetOutputVariables("test-scenario-creation",
320 "user-scenario",
321 true);
322
323 // Create user scenario
324
325 // Creating the reference system.
326 Ptr<SatHelper> helper = CreateObject<SatHelper>(
327 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/scenarios/geo-33E");
328 SatBeamUserInfo beamInfo = SatBeamUserInfo(1, 1);
329 std::map<std::pair<uint32_t, uint32_t>, SatBeamUserInfo> beamMap;
330 beamMap[std::make_pair(0, 8)] = beamInfo;
331 beamMap[std::make_pair(0, 3)] = beamInfo;
332 beamInfo.AppendUt(2);
333 beamMap[std::make_pair(0, 2)] = beamInfo;
334
335 // Enable creation traces
336 Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
337
338 helper->CreateUserDefinedScenario(beamMap);
339
340 // check results what can be done at this level. More checking done in module level with traces
341 NS_TEST_ASSERT_MSG_EQ(Singleton<SatTopology>::Get()->GetGwUserNodes().GetN(),
342 5,
343 "GW User count is not what expected!");
344 NS_TEST_ASSERT_MSG_EQ(Singleton<SatTopology>::Get()->GetNUtUserNodes(),
345 5,
346 "UT User count is not what expected!");
347
348 SatEnvVariables::GetInstance()->DoDispose();
349
350 Simulator::Destroy();
351}
352
353// The TestSuite class names the TestSuite as sat-scenario-creation, identifies what type of
354// TestSuite (Type::SYSTEM), and enables the TestCases to be run. Typically, only the constructor
355// for this class must be defined
356//
357class ScenarioCreationTestSuite : public TestSuite
358{
359 public:
361};
362
364 : TestSuite("sat-scenario-creation", Type::SYSTEM)
365{
366 // add ScenarioCreationSimple case to suite sat-scenario-creation
367 AddTestCase(new ScenarioCreationSimple, TestCase::Duration::QUICK);
368
369 // add ScenarioCreationLarger case to suite sat-scenario-creation
370 AddTestCase(new ScenarioCreationLarger, TestCase::Duration::QUICK);
371
372 // add ScenarioCreationFull case to suite sat-scenario-creation
373 AddTestCase(new ScenarioCreationFull, TestCase::Duration::QUICK);
374
375 // add ScenarioCreationUser case to suite sat-scenario-creation
376 AddTestCase(new ScenarioCreationUser, TestCase::Duration::QUICK);
377}
378
379// 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.
static Ptr< SatEnvVariables > GetInstance()
@ LARGER
LARGER Larger scenario used as base.
@ FULL
FULL Full scenario used as base.
@ SIMPLE
SIMPLE Simple scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static ScenarioCreationTestSuite scenarioCreationTestSuite