28 #include "../model/satellite-cno-estimator.h"
29 #include "../utils/satellite-env-variables.h"
31 #include "ns3/boolean.h"
32 #include "ns3/config.h"
34 #include "ns3/simulator.h"
35 #include "ns3/singleton.h"
36 #include "ns3/string.h"
38 #include "ns3/timer.h"
60 void AddSample(
double cno);
63 void GetCnoEstimation();
77 m_estimator->AddSample(cno);
83 m_cnoEstimations.push_back(m_estimator->GetCnoEstimation());
89 m_estimator = Create<SatBasicCnoEstimator>(mode, window);
123 virtual void DoRun(
void);
130 Singleton<SatEnvVariables>::Get()->DoInitialize();
131 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-cno-estimator-unit",
136 Simulator::Schedule(Seconds(0.05),
148 Simulator::Schedule(Seconds(0.09),
151 Simulator::Schedule(Seconds(0.19),
154 Simulator::Schedule(Seconds(0.25),
157 Simulator::Schedule(Seconds(0.31),
160 Simulator::Schedule(Seconds(0.41),
165 Simulator::Schedule(Seconds(0.5),
177 Simulator::Schedule(Seconds(0.59),
180 Simulator::Schedule(Seconds(0.69),
183 Simulator::Schedule(Seconds(0.75),
186 Simulator::Schedule(Seconds(0.91),
189 Simulator::Schedule(Seconds(1.39),
192 Simulator::Schedule(Seconds(1.41),
201 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[0]),
true,
"first estimation incorrect");
202 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[1], -5.0,
"second estimation incorrect");
203 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[2], 5.0,
"third estimation incorrect");
204 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[3], -15.0,
"fourth estimation incorrect");
205 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[4]),
true,
"fifth estimation incorrect");
208 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[5]),
true,
"sixth estimation incorrect");
209 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[6], -6.0,
"seventh estimation incorrect");
210 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[7], 1.0,
"eight estimation incorrect");
211 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[8], 1.0,
"ninth estimation incorrect");
212 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[9], -5.0,
"tenth estimation incorrect");
213 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[10]),
true,
"eleventh estimation incorrect");
215 Simulator::Destroy();
217 Singleton<SatEnvVariables>::Get()->DoDispose();
250 virtual void DoRun(
void);
257 Singleton<SatEnvVariables>::Get()->DoInitialize();
258 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-cno-estimator-unit",
263 Simulator::Schedule(Seconds(0.05),
276 Simulator::Schedule(Seconds(0.09),
279 Simulator::Schedule(Seconds(0.19),
282 Simulator::Schedule(Seconds(0.35),
285 Simulator::Schedule(Seconds(0.41),
288 Simulator::Schedule(Seconds(0.49),
291 Simulator::Schedule(Seconds(0.69),
300 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[0]),
true,
"first estimation incorrect");
301 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[1], -4.2,
"second estimation incorrect");
302 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[2], -4.2,
"third estimation incorrect");
303 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[3], 8.1,
"fourth estimation incorrect");
304 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[4], -15.7,
"fifth estimation incorrect");
305 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[5]),
true,
"sixth estimation incorrect");
307 Simulator::Destroy();
309 Singleton<SatEnvVariables>::Get()->DoDispose();
342 virtual void DoRun(
void);
349 Singleton<SatEnvVariables>::Get()->DoInitialize();
350 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-cno-estimator-unit",
355 Simulator::Schedule(Seconds(0.05),
368 Simulator::Schedule(Seconds(0.09),
371 Simulator::Schedule(Seconds(0.19),
374 Simulator::Schedule(Seconds(0.35),
377 Simulator::Schedule(Seconds(0.41),
380 Simulator::Schedule(Seconds(0.49),
383 Simulator::Schedule(Seconds(0.69),
392 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[0]),
true,
"first estimation incorrect");
393 NS_TEST_ASSERT_MSG_EQ_TOL(m_cnoEstimations[1], -4.2, 0.0001,
"second estimation incorrect");
394 NS_TEST_ASSERT_MSG_EQ_TOL(m_cnoEstimations[2],
395 (-4.2 + 8.1 - 15.7) / 3,
397 "third estimation incorrect");
398 NS_TEST_ASSERT_MSG_EQ_TOL(m_cnoEstimations[3],
401 "fourth estimation incorrect");
402 NS_TEST_ASSERT_MSG_EQ_TOL(m_cnoEstimations[4], 2.4, 0.0001,
"fifth estimation incorrect");
403 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[5]),
true,
"sixth estimation incorrect");
405 Simulator::Destroy();
407 Singleton<SatEnvVariables>::Get()->DoDispose();
421 : TestSuite(
"sat-cno-estimator-unit-test", UNIT)
Test suite for Satellite C/N0 estimator unit test cases.
SatBasicCnoEstimatorTestSuite()
Test case to unit test satellite C/N0 estimator with mode AVERAGE.
SatBasicEstimatorAverageTestCase()
virtual ~SatBasicEstimatorAverageTestCase()
Test case to unit test satellite C/N0 estimator with mode LAST.
SatBasicEstimatorLastTestCase()
virtual ~SatBasicEstimatorLastTestCase()
Test case to unit test satellite C/N0 estimator with mode MINIMUM.
virtual ~SatBasicEstimatorMinTestCase()
SatBasicEstimatorMinTestCase()
Ptr< SatCnoEstimator > m_estimator
void AddSample(double cno)
void CreateEstimator(SatCnoEstimator::EstimationMode_t mode, Time window)
SatEstimatorBaseTestCase(std::string info)
virtual ~SatEstimatorBaseTestCase()
virtual void DoRun(void)=0
SatEstimatorBaseTestCase()
std::vector< double > m_cnoEstimations
EstimationMode_t
Definition of modes for estimator.
@ MINIMUM
Minimum value in the given window returned.
@ LAST
Last value in the given window returned.
@ AVERAGE
Average value in the given window returned.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatBasicCnoEstimatorTestSuite satCnoEstimatorUnit