Loading...
Searching...
No Matches
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
26
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
39using namespace ns3;
40
48{
49 public:
52
53 void TestGetFading(Ptr<SatFadingExternalInputTraceContainer> traceContainer,
54 uint32_t nodeId,
55 SatEnums::ChannelType_t channelType);
56
57 private:
58 virtual void DoRun(void);
59
60 std::vector<double> m_results;
61};
62
64 : TestCase("Test satellite fading external input trace and container.")
65{
66}
67
71
72void
74 Ptr<SatFadingExternalInputTraceContainer> traceContainer,
75 uint32_t nodeId,
76 SatEnums::ChannelType_t channelType)
77{
78 Ptr<SatMobilityModel> mobility;
79
80 Ptr<SatFadingExternalInputTrace> trace =
81 traceContainer->GetFadingTrace(nodeId, channelType, mobility);
82 double fading = trace->GetFading();
83 m_results.push_back(fading);
84}
85
86void
88{
89 uint32_t numUts(2);
90 uint32_t numGws(5);
91
92 // Set simulation output details
93 SatEnvVariables::GetInstance()->DoInitialize();
94 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-fading-external-input-trace",
95 "",
96 true);
97
98 // Test the fading traces
99 Ptr<SatFadingExternalInputTraceContainer> traceContainer =
100 CreateObject<SatFadingExternalInputTraceContainer>();
101 bool success = traceContainer->TestFadingTraces(numUts, numGws);
102 NS_TEST_ASSERT_MSG_EQ(success, true, "SatChannelFadingTrace test failed");
103
104 double time[4] = {1.434, 40.923, 80.503, 140.3};
105 double preCalcRes[4] = {1.020, 1.008, 1.006, 1.012};
106
107 Simulator::Schedule(Seconds(time[0]),
109 this,
110 traceContainer,
111 1,
113 Simulator::Schedule(Seconds(time[1]),
115 this,
116 traceContainer,
117 2,
119 Simulator::Schedule(Seconds(time[2]),
121 this,
122 traceContainer,
123 1,
125 Simulator::Schedule(Seconds(time[3]),
127 this,
128 traceContainer,
129 2,
131
132 Simulator::Run();
133
134 for (uint32_t i = 0; i < 4; ++i)
135 {
136 NS_TEST_ASSERT_MSG_EQ_TOL(m_results[i],
137 preCalcRes[i],
138 0.001,
139 "Fading not within expected tolerance");
140 }
141
142 Simulator::Destroy();
143
144 SatEnvVariables::GetInstance()->DoDispose();
145}
146
152{
153 public:
155};
156
158 : TestSuite("sat-fading-external-input-trace-test", Type::UNIT)
159{
160 AddTestCase(new SatFadingExternalInputTraceTestCase, TestCase::Duration::QUICK);
161}
162
163// Do allocate an instance of this TestSuite
Test case to unit test satellite fading external input trace and container for these objects.
void TestGetFading(Ptr< SatFadingExternalInputTraceContainer > traceContainer, uint32_t nodeId, SatEnums::ChannelType_t channelType)
Test suite for satellite fading external input trace.
ChannelType_t
Types of channel.
static Ptr< SatEnvVariables > GetInstance()
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatAntennaPatternTestSuite satSatInterferenceTestSuite