29 #include "ns3/cbr-application.h"
30 #include "ns3/cbr-helper.h"
31 #include "ns3/config.h"
33 #include "ns3/packet-sink-helper.h"
34 #include "ns3/packet-sink.h"
35 #include "ns3/satellite-env-variables.h"
36 #include "ns3/satellite-gw-mac.h"
37 #include "ns3/satellite-helper.h"
38 #include "ns3/satellite-id-mapper.h"
39 #include "ns3/satellite-isl-arbiter-unicast.h"
40 #include "ns3/satellite-isl-arbiter.h"
41 #include "ns3/satellite-orbiter-feeder-phy.h"
42 #include "ns3/satellite-orbiter-net-device.h"
43 #include "ns3/satellite-orbiter-user-phy.h"
44 #include "ns3/satellite-phy-rx-carrier.h"
45 #include "ns3/satellite-topology.h"
46 #include "ns3/satellite-ut-mac-state.h"
47 #include "ns3/simulation-helper.h"
48 #include "ns3/simulator.h"
49 #include "ns3/singleton.h"
50 #include "ns3/string.h"
94 virtual void DoRun(
void);
96 std::vector<std::string> Split(std::string s,
char del);
97 void TestFileValue(std::string path, uint32_t time,
double expectedValue);
102 : TestCase(
"This case tests that a application throughputs PerEntity are correct.")
112 std::vector<std::string>
115 std::stringstream ss(s);
117 std::vector<std::string> tokens;
120 std::getline(ss, word, del);
121 tokens.push_back(word);
130 std::ifstream myfile(path);
131 std::string delimiter =
" ";
135 if (myfile.is_open())
138 while (std::getline(myfile, line))
140 std::vector<std::string> tokens =
Split(line,
' ');
141 if (tokens.size() == 2)
143 if ((uint32_t)std::stoi(tokens[0]) == time)
145 NS_TEST_ASSERT_MSG_EQ_TOL(std::stof(tokens[1]),
148 "Incorrect throughput for statistic " << path);
157 NS_TEST_ASSERT_MSG_EQ(0, 1,
"Cannot find time " << time <<
" for trace file " << path);
162 NS_TEST_ASSERT_MSG_EQ(0, 1,
"Cannot read trace file " << path);
173 Singleton<SatIdMapper>::Get()->Reset();
176 Singleton<SatEnvVariables>::Get()->DoInitialize();
177 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-handover",
"test1",
true);
180 Config::SetDefault(
"ns3::SatConf::ForwardLinkRegenerationMode",
181 EnumValue(SatEnums::REGENERATION_NETWORK));
182 Config::SetDefault(
"ns3::SatConf::ReturnLinkRegenerationMode",
183 EnumValue(SatEnums::REGENERATION_NETWORK));
185 Config::SetDefault(
"ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
187 Config::SetDefault(
"ns3::SatHelper::HandoversEnabled", BooleanValue(
true));
188 Config::SetDefault(
"ns3::SatHandoverModule::NumberClosestSats", UintegerValue(2));
190 Config::SetDefault(
"ns3::SatGwMac::DisableSchedulingIfNoDeviceConnected", BooleanValue(
true));
191 Config::SetDefault(
"ns3::SatOrbiterMac::DisableSchedulingIfNoDeviceConnected",
195 Config::SetDefault(
"ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(
true));
198 Config::SetDefault(
"ns3::SatHelper::PacketTraceEnabled", BooleanValue(
true));
199 Ptr<SimulationHelper> simulationHelper =
200 CreateObject<SimulationHelper>(
"test-sat-handover/test1");
201 Ptr<SimulationHelperConf> simulationConf = CreateObject<SimulationHelperConf>();
202 simulationHelper->SetGwUserCount(1);
203 simulationHelper->SetUserCountPerUt(1);
204 simulationHelper->SetBeamSet({0, 20, 21, 22, 32, 33, 34, 35, 36, 37, 44, 45, 46,
205 47, 53, 54, 55, 56, 59, 60, 61, 66, 67, 68, 71, 72});
206 simulationHelper->SetUserCountPerMobileUt(simulationConf->m_utMobileUserCount);
208 simulationHelper->LoadScenario(
"constellation-eutelsat-geo-2-sats-handovers");
210 std::string mobileUtFolder = Singleton<SatEnvVariables>::Get()->LocateDataDirectory() +
211 "/additional-input/utpositions/mobiles/scenario6";
212 simulationHelper->CreateSatScenario(SatHelper::NONE, mobileUtFolder);
214 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
215 SatTrafficHelper::FWD_LINK,
216 SatTrafficHelper::UDP,
219 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
220 Singleton<SatTopology>::Get()->GetUtUserNodes(),
225 Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
227 s->AddPerSatFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
228 s->AddPerBeamFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
229 s->AddPerUtFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
230 s->AddPerGwFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
232 s->AddPerSatFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
233 s->AddPerBeamFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
234 s->AddPerUtFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
235 s->AddPerGwFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
237 simulationHelper->SetSimulationTime(Seconds(30));
238 simulationHelper->RunSimulation();
240 Simulator::Destroy();
243 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
244 "stat-per-sat-fwd-app-throughput-scatter-1.txt",
247 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
248 "stat-per-sat-fwd-app-throughput-scatter-2.txt",
251 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
252 "stat-per-sat-fwd-app-throughput-scatter-1.txt",
255 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
256 "stat-per-sat-fwd-app-throughput-scatter-2.txt",
261 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
262 "stat-per-sat-fwd-user-mac-throughput-scatter-1.txt",
265 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
266 "stat-per-sat-fwd-user-mac-throughput-scatter-2.txt",
269 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
270 "stat-per-sat-fwd-user-mac-throughput-scatter-1.txt",
273 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
274 "stat-per-sat-fwd-user-mac-throughput-scatter-2.txt",
279 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
280 "stat-per-beam-fwd-app-throughput-scatter-1-35.txt",
283 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
284 "stat-per-beam-fwd-app-throughput-scatter-2-20.txt",
287 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
288 "stat-per-beam-fwd-app-throughput-scatter-1-35.txt",
291 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
292 "stat-per-beam-fwd-app-throughput-scatter-2-20.txt",
297 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
298 "stat-per-beam-fwd-user-mac-throughput-scatter-1-35.txt",
301 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
302 "stat-per-beam-fwd-user-mac-throughput-scatter-2-20.txt",
305 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
306 "stat-per-beam-fwd-user-mac-throughput-scatter-1-35.txt",
309 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
310 "stat-per-beam-fwd-user-mac-throughput-scatter-2-20.txt",
315 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
316 "stat-per-gw-fwd-app-throughput-scatter-1.txt",
319 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
320 "stat-per-gw-fwd-app-throughput-scatter-2.txt",
323 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
324 "stat-per-gw-fwd-app-throughput-scatter-1.txt",
327 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
328 "stat-per-gw-fwd-app-throughput-scatter-2.txt",
333 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
334 "stat-per-gw-fwd-user-mac-throughput-scatter-1.txt",
337 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
338 "stat-per-gw-fwd-user-mac-throughput-scatter-2.txt",
341 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
342 "stat-per-gw-fwd-user-mac-throughput-scatter-1.txt",
345 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
346 "stat-per-gw-fwd-user-mac-throughput-scatter-2.txt",
351 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
352 "stat-per-ut-fwd-app-throughput-scatter-1.txt",
355 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
356 "stat-per-ut-fwd-app-throughput-scatter-2.txt",
359 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
360 "stat-per-ut-fwd-app-throughput-scatter-3.txt",
363 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
364 "stat-per-ut-fwd-app-throughput-scatter-4.txt",
367 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
368 "stat-per-ut-fwd-app-throughput-scatter-1.txt",
371 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
372 "stat-per-ut-fwd-app-throughput-scatter-2.txt",
375 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
376 "stat-per-ut-fwd-app-throughput-scatter-3.txt",
379 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
380 "stat-per-ut-fwd-app-throughput-scatter-4.txt",
385 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
386 "stat-per-ut-fwd-user-mac-throughput-scatter-1.txt",
389 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
390 "stat-per-ut-fwd-user-mac-throughput-scatter-2.txt",
393 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
394 "stat-per-ut-fwd-user-mac-throughput-scatter-3.txt",
397 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
398 "stat-per-ut-fwd-user-mac-throughput-scatter-4.txt",
401 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
402 "stat-per-ut-fwd-user-mac-throughput-scatter-1.txt",
405 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
406 "stat-per-ut-fwd-user-mac-throughput-scatter-2.txt",
409 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
410 "stat-per-ut-fwd-user-mac-throughput-scatter-3.txt",
413 TestFileValue(
"contrib/satellite/data/sims/test-sat-handover/test1/"
414 "stat-per-ut-fwd-user-mac-throughput-scatter-4.txt",
433 virtual void DoRun(
void);
438 : TestCase(
"This case tests that communication remains after GW handover.")
451 for (uint32_t i = 0; i < node->GetNApplications(); i++)
453 auto sink = DynamicCast<PacketSink>(node->GetApplication(i));
457 sink->GetAttribute(
"Local", av);
458 if (InetSocketAddress::ConvertFrom(av.Get()).GetPort() == port)
474 Singleton<SatIdMapper>::Get()->Reset();
477 Singleton<SatEnvVariables>::Get()->DoInitialize();
478 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-handover",
"test2",
true);
481 Config::SetDefault(
"ns3::SatConf::ForwardLinkRegenerationMode",
482 EnumValue(SatEnums::REGENERATION_NETWORK));
483 Config::SetDefault(
"ns3::SatConf::ReturnLinkRegenerationMode",
484 EnumValue(SatEnums::REGENERATION_NETWORK));
486 Config::SetDefault(
"ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
488 Config::SetDefault(
"ns3::SatHelper::HandoversEnabled", BooleanValue(
true));
489 Config::SetDefault(
"ns3::SatHandoverModule::NumberClosestSats", UintegerValue(2));
491 Config::SetDefault(
"ns3::SatGwMac::DisableSchedulingIfNoDeviceConnected", BooleanValue(
true));
492 Config::SetDefault(
"ns3::SatOrbiterMac::DisableSchedulingIfNoDeviceConnected",
496 Config::SetDefault(
"ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(
true));
499 Config::SetDefault(
"ns3::SatHelper::PacketTraceEnabled", BooleanValue(
true));
500 Ptr<SimulationHelper> simulationHelper =
501 CreateObject<SimulationHelper>(
"test-sat-handover/test2");
502 Ptr<SimulationHelperConf> simulationConf = CreateObject<SimulationHelperConf>();
503 simulationHelper->SetSimulationTime(Seconds(50));
504 simulationHelper->SetGwUserCount(1);
505 simulationHelper->SetUserCountPerUt(1);
506 std::set<uint32_t> beamSetAll = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
507 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
508 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
509 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
510 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72};
511 simulationHelper->SetBeamSet(beamSetAll);
512 simulationHelper->SetUserCountPerMobileUt(simulationConf->m_utMobileUserCount);
514 simulationHelper->LoadScenario(
"constellation-leo-2-satellites");
516 Ptr<SatHelper> helper = simulationHelper->CreateSatScenario(SatHelper::NONE);
518 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
519 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
521 Config::SetDefault(
"ns3::CbrApplication::Interval", StringValue(
"100ms"));
522 Config::SetDefault(
"ns3::CbrApplication::PacketSize", UintegerValue(512));
525 PacketSinkHelper sinkHelper(
"ns3::UdpSocketFactory", Address());
526 CbrHelper cbrHelper(
"ns3::UdpSocketFactory", Address());
527 ApplicationContainer sinkContainer;
528 ApplicationContainer cbrContainer;
530 for (uint32_t i = 0; i < utUsers.GetN(); i++)
532 InetSocketAddress utUserAddr =
533 InetSocketAddress(helper->GetUserAddress(utUsers.Get(i)), port);
536 sinkHelper.SetAttribute(
"Local", AddressValue(Address(utUserAddr)));
537 sinkContainer.Add(sinkHelper.Install(utUsers.Get(i)));
540 cbrHelper.SetAttribute(
"Remote", AddressValue(Address(utUserAddr)));
541 auto app = cbrHelper.Install(gwUsers.Get(0)).Get(0);
542 app->SetStartTime(Seconds(1.0));
543 cbrContainer.Add(app);
545 sinkContainer.Start(Seconds(1.0));
546 sinkContainer.Stop(Seconds(45.0));
548 simulationHelper->RunSimulation();
550 Simulator::Destroy();
552 for (uint32_t i = 0; i < 5; i++)
554 Ptr<PacketSink> utReceiver = DynamicCast<PacketSink>(sinkContainer.Get(i));
555 Ptr<CbrApplication> gwSender = DynamicCast<CbrApplication>(cbrContainer.Get(i));
557 NS_TEST_ASSERT_MSG_NE(gwSender->GetSent(), 0,
"Nothing sent by GW app " << i <<
"!");
559 NS_TEST_ASSERT_MSG_EQ_TOL(utReceiver->GetTotalRx(),
561 gwSender->GetSent() / 5,
562 "Too many packets were lost to UT!");
577 : TestSuite(
"sat-handover-test", Type::SYSTEM)
580 TestCase::Duration::QUICK);
584 TestCase::Duration::QUICK);
'Handover, test 1 test case implementation.
virtual ~SatHandoverTest1()
std::vector< std::string > Split(std::string s, char del)
void TestFileValue(std::string path, uint32_t time, double expectedValue)
'Handover, test 2 test case implementation.
bool HasSinkInstalled(Ptr< Node > node, uint16_t port)
virtual ~SatHandoverTest2()
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatHandoverTestSuite satHandoverTestSuite