28 #include "../model/satellite-control-message.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 AddMessage(Ptr<SatControlMessage> msg);
63 void GetMessage(uint32_t msgId);
77 uint32_t sendId = m_container->ReserveIdAndStore(msg);
78 uint32_t recvId = m_container->Send(sendId);
80 m_recvIds.push_back(recvId);
86 m_msgsRead.push_back(m_container->Read(msgId));
111 "Test satellite control message container with flag deletedOnRead set.")
120 virtual void DoRun(
void);
127 Singleton<SatEnvVariables>::Get()->DoInitialize();
128 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-ctrl-msg-container-unit",
133 m_container = Create<SatControlMsgContainer>(Seconds(0.10),
true);
134 Ptr<SatControlMessage> crMsg = Create<SatCrMessage>();
135 Ptr<SatControlMessage> tbtpMsg = Create<SatTbtpMessage>();
138 Simulator::Schedule(Seconds(0.09),
142 Simulator::Schedule(Seconds(0.20),
146 Simulator::Schedule(Seconds(0.31),
150 Simulator::Schedule(Seconds(0.40),
156 Simulator::Schedule(Seconds(0.10),
160 Simulator::Schedule(Seconds(0.21),
164 Simulator::Schedule(Seconds(0.35),
168 Simulator::Schedule(Seconds(0.43),
178 NS_TEST_ASSERT_MSG_EQ((crMsg ==
nullptr),
false,
"CR message creation failed");
179 NS_TEST_ASSERT_MSG_EQ((tbtpMsg ==
nullptr),
false,
"TBTP message failed");
182 NS_TEST_ASSERT_MSG_EQ((m_msgsRead[0] == crMsg),
true,
"first message incorrect");
183 NS_TEST_ASSERT_MSG_EQ((m_msgsRead[1] == tbtpMsg),
true,
"second message incorrect");
184 NS_TEST_ASSERT_MSG_EQ((m_msgsRead[2] == tbtpMsg),
true,
"third message incorrect");
185 NS_TEST_ASSERT_MSG_EQ((m_msgsRead[3] == crMsg),
true,
"fourth message incorrect");
187 Simulator::Destroy();
189 Singleton<SatEnvVariables>::Get()->DoDispose();
214 "Test satellite control message container with flag deletedOnRead NOT set.")
223 virtual void DoRun(
void);
230 Singleton<SatEnvVariables>::Get()->DoInitialize();
231 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-ctrl-msg-container-unit",
236 m_container = Create<SatControlMsgContainer>(Seconds(0.10),
false);
237 Ptr<SatControlMessage> crMsg = Create<SatCrMessage>();
238 Ptr<SatControlMessage> tbtpMsg = Create<SatTbtpMessage>();
241 Simulator::Schedule(Seconds(0.09),
245 Simulator::Schedule(Seconds(0.20),
249 Simulator::Schedule(Seconds(0.31),
253 Simulator::Schedule(Seconds(0.40),
259 Simulator::Schedule(Seconds(0.10),
263 Simulator::Schedule(Seconds(0.21),
267 Simulator::Schedule(Seconds(0.40),
271 Simulator::Schedule(Seconds(0.49),
281 NS_TEST_ASSERT_MSG_EQ((crMsg ==
nullptr),
false,
"CR message creation failed");
282 NS_TEST_ASSERT_MSG_EQ((tbtpMsg ==
nullptr),
false,
"TBTP message failed");
285 NS_TEST_ASSERT_MSG_EQ((m_msgsRead[0] == crMsg),
true,
"first message incorrect");
286 NS_TEST_ASSERT_MSG_EQ((m_msgsRead[1] == tbtpMsg),
true,
"second message incorrect");
287 NS_TEST_ASSERT_MSG_EQ((m_msgsRead[2] == tbtpMsg),
true,
"third message incorrect");
288 NS_TEST_ASSERT_MSG_EQ((m_msgsRead[3] == crMsg),
true,
"fourth message incorrect");
290 Simulator::Destroy();
292 Singleton<SatEnvVariables>::Get()->DoDispose();
306 : TestSuite(
"sat-ctrl-msg-container-unit-test", Type::UNIT)
SatCtrlMsgContBaseTestCase(std::string info)
std::vector< uint32_t > m_recvIds
virtual void DoRun(void)=0
void AddMessage(Ptr< SatControlMessage > msg)
Ptr< SatControlMsgContainer > m_container
void GetMessage(uint32_t msgId)
std::vector< Ptr< SatControlMessage > > m_msgsRead
virtual ~SatCtrlMsgContBaseTestCase()
SatCtrlMsgContBaseTestCase()
Test case to unit test satellite control message container with flag deletedOnRead not set.
virtual ~SatCtrlMsgContDelOffTestCase()
SatCtrlMsgContDelOffTestCase()
Test case to unit test satellite control message container with flag deletedOnRead set.
SatCtrlMsgContDelOnTestCase()
virtual ~SatCtrlMsgContDelOnTestCase()
Test suite for Satellite control message container unit test cases.
SatCtrlMsgContainerTestSuite()
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatCtrlMsgContainerTestSuite satCtrlMsgContUnit