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"
62 void AddSample(
double cno);
65 void GetCnoEstimation();
79 m_estimator->AddSample(cno);
85 m_cnoEstimations.push_back(m_estimator->GetCnoEstimation());
91 m_estimator = Create<SatBasicCnoEstimator>(mode, window);
125 virtual void DoRun(
void);
132 Singleton<SatEnvVariables>::Get()->DoInitialize();
133 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-cno-estimator-unit",
138 Simulator::Schedule(Seconds(0.05),
150 Simulator::Schedule(Seconds(0.09),
153 Simulator::Schedule(Seconds(0.19),
156 Simulator::Schedule(Seconds(0.25),
159 Simulator::Schedule(Seconds(0.31),
162 Simulator::Schedule(Seconds(0.41),
167 Simulator::Schedule(Seconds(0.5),
179 Simulator::Schedule(Seconds(0.59),
182 Simulator::Schedule(Seconds(0.69),
185 Simulator::Schedule(Seconds(0.75),
188 Simulator::Schedule(Seconds(0.91),
191 Simulator::Schedule(Seconds(1.39),
194 Simulator::Schedule(Seconds(1.41),
203 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[0]),
true,
"first estimation incorrect");
204 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[1], -5.0,
"second estimation incorrect");
205 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[2], 5.0,
"third estimation incorrect");
206 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[3], -15.0,
"fourth estimation incorrect");
207 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[4]),
true,
"fifth estimation incorrect");
210 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[5]),
true,
"sixth estimation incorrect");
211 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[6], -6.0,
"seventh estimation incorrect");
212 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[7], 1.0,
"eight estimation incorrect");
213 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[8], 1.0,
"ninth estimation incorrect");
214 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[9], -5.0,
"tenth estimation incorrect");
215 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[10]),
true,
"eleventh estimation incorrect");
217 Simulator::Destroy();
219 Singleton<SatEnvVariables>::Get()->DoDispose();
252 virtual void DoRun(
void);
259 Singleton<SatEnvVariables>::Get()->DoInitialize();
260 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-cno-estimator-unit",
265 Simulator::Schedule(Seconds(0.05),
278 Simulator::Schedule(Seconds(0.09),
281 Simulator::Schedule(Seconds(0.19),
284 Simulator::Schedule(Seconds(0.35),
287 Simulator::Schedule(Seconds(0.41),
290 Simulator::Schedule(Seconds(0.49),
293 Simulator::Schedule(Seconds(0.69),
302 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[0]),
true,
"first estimation incorrect");
303 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[1], -4.2,
"second estimation incorrect");
304 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[2], -4.2,
"third estimation incorrect");
305 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[3], 8.1,
"fourth estimation incorrect");
306 NS_TEST_ASSERT_MSG_EQ(m_cnoEstimations[4], -15.7,
"fifth estimation incorrect");
307 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[5]),
true,
"sixth estimation incorrect");
309 Simulator::Destroy();
311 Singleton<SatEnvVariables>::Get()->DoDispose();
344 virtual void DoRun(
void);
351 Singleton<SatEnvVariables>::Get()->DoInitialize();
352 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-cno-estimator-unit",
357 Simulator::Schedule(Seconds(0.05),
370 Simulator::Schedule(Seconds(0.09),
373 Simulator::Schedule(Seconds(0.19),
376 Simulator::Schedule(Seconds(0.35),
379 Simulator::Schedule(Seconds(0.41),
382 Simulator::Schedule(Seconds(0.49),
385 Simulator::Schedule(Seconds(0.69),
394 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[0]),
true,
"first estimation incorrect");
395 NS_TEST_ASSERT_MSG_EQ_TOL(m_cnoEstimations[1], -4.2, 0.0001,
"second estimation incorrect");
396 NS_TEST_ASSERT_MSG_EQ_TOL(m_cnoEstimations[2],
397 (-4.2 + 8.1 - 15.7) / 3,
399 "third estimation incorrect");
400 NS_TEST_ASSERT_MSG_EQ_TOL(m_cnoEstimations[3],
403 "fourth estimation incorrect");
404 NS_TEST_ASSERT_MSG_EQ_TOL(m_cnoEstimations[4], 2.4, 0.0001,
"fifth estimation incorrect");
405 NS_TEST_ASSERT_MSG_EQ(std::isnan(m_cnoEstimations[5]),
true,
"sixth estimation incorrect");
407 Simulator::Destroy();
409 Singleton<SatEnvVariables>::Get()->DoDispose();
423 : TestSuite(
"sat-cno-estimator-unit-test", Type::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