Loading...
Searching...
No Matches
satellite-helper.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: Sami Rantanen <sami.rantanen@magister.fi>
19 */
20
21#include "satellite-helper.h"
22
25#include "satellite-lora-conf.h"
26
27#include "ns3/arp-cache.h"
28#include "ns3/csma-helper.h"
29#include "ns3/double.h"
30#include "ns3/internet-stack-helper.h"
31#include "ns3/ipv4-interface.h"
32#include "ns3/ipv4-routing-table-entry.h"
33#include "ns3/ipv4-static-routing-helper.h"
34#include "ns3/log.h"
35#include "ns3/lora-device-address-generator.h"
36#include "ns3/mobility-helper.h"
37#include "ns3/names.h"
38#include "ns3/queue.h"
39#include "ns3/satellite-env-variables.h"
40#include "ns3/satellite-handover-module.h"
41#include "ns3/satellite-id-mapper.h"
42#include "ns3/satellite-log.h"
43#include "ns3/satellite-point-to-point-isl-net-device.h"
44#include "ns3/satellite-position-allocator.h"
45#include "ns3/satellite-position-input-trace-container.h"
46#include "ns3/satellite-rtn-link-time.h"
47#include "ns3/satellite-sgp4-mobility-model.h"
48#include "ns3/satellite-topology.h"
49#include "ns3/satellite-traced-mobility-model.h"
50#include "ns3/satellite-typedefs.h"
51#include "ns3/singleton.h"
52#include "ns3/string.h"
53#include "ns3/system-path.h"
54#include "ns3/type-id.h"
55
56#include <cmath>
57#include <fstream>
58#include <iostream>
59#include <map>
60#include <set>
61#include <sstream>
62#include <string>
63#include <sys/stat.h>
64#include <utility>
65#include <vector>
66
67NS_LOG_COMPONENT_DEFINE("SatHelper");
68
69namespace ns3
70{
71
72NS_OBJECT_ENSURE_REGISTERED(SatHelper);
73
74TypeId
76{
77 static TypeId tid =
78 TypeId("ns3::SatHelper")
79 .SetParent<Object>()
80 .AddConstructor<SatHelper>()
81 .AddAttribute("UtCount",
82 "The count of created UTs in beam (full or user-defined GEO scenario)",
83 UintegerValue(3),
84 MakeUintegerAccessor(&SatHelper::m_utsInBeam),
85 MakeUintegerChecker<uint32_t>(1))
86 .AddAttribute("GwUsers",
87 "The number of created GW users (full or user-defined scenario)",
88 UintegerValue(5),
89 MakeUintegerAccessor(&SatHelper::m_gwUsers),
90 MakeUintegerChecker<uint32_t>(1))
91 .AddAttribute("UtUsers",
92 "The number of created UT users per UT (full or user-defined scenario)",
93 UintegerValue(3),
94 MakeUintegerAccessor(&SatHelper::m_utUsers),
95 MakeUintegerChecker<uint32_t>(1))
96 .AddAttribute(
97 "BeamNetworkAddress",
98 "Initial network number to use "
99 "during allocation of satellite devices "
100 "(mask set by attribute 'BeamNetworkMask' will be used as the network mask)",
101 Ipv4AddressValue("40.1.0.0"),
102 MakeIpv4AddressAccessor(&SatHelper::m_beamNetworkAddress),
103 MakeIpv4AddressChecker())
104 .AddAttribute("BeamNetworkMask",
105 "Network mask to use during allocation of satellite devices.",
106 Ipv4MaskValue("255.255.0.0"),
107 MakeIpv4MaskAccessor(&SatHelper::m_beamNetworkMask),
108 MakeIpv4MaskChecker())
109 .AddAttribute(
110 "GwNetworkAddress",
111 "Initial network number to use "
112 "during allocation of GW, router, and GW users "
113 "(mask set by attribute 'GwNetworkMask' will be used as the network mask)",
114 Ipv4AddressValue("90.1.0.0"),
115 MakeIpv4AddressAccessor(&SatHelper::m_gwNetworkAddress),
116 MakeIpv4AddressChecker())
117 .AddAttribute("GwNetworkMask",
118 "Network mask to use during allocation of GW, router, and GW users.",
119 Ipv4MaskValue("255.255.0.0"),
120 MakeIpv4MaskAccessor(&SatHelper::m_gwNetworkMask),
121 MakeIpv4MaskChecker())
122 .AddAttribute(
123 "UtNetworkAddress",
124 "Initial network number to use "
125 "during allocation of UT and UT users "
126 "(mask set by attribute 'UtNetworkMask' will be used as the network mask)",
127 Ipv4AddressValue("10.1.0.0"),
128 MakeIpv4AddressAccessor(&SatHelper::m_utNetworkAddress),
129 MakeIpv4AddressChecker())
130 .AddAttribute("UtNetworkMask",
131 "Network mask to use during allocation of UT and UT users.",
132 Ipv4MaskValue("255.255.0.0"),
133 MakeIpv4MaskAccessor(&SatHelper::m_utNetworkMask),
134 MakeIpv4MaskChecker())
135 .AddAttribute("HandoversEnabled",
136 "Enable handovers for all UTs and GWs. If false, only moving UTs can "
137 "perform handovers.",
138 BooleanValue(false),
139 MakeBooleanAccessor(&SatHelper::m_handoversEnabled),
140 MakeBooleanChecker())
141 .AddAttribute("PacketTraceEnabled",
142 "Packet tracing enable status.",
143 BooleanValue(false),
144 MakeBooleanAccessor(&SatHelper::m_packetTraces),
145 MakeBooleanChecker())
146 .AddAttribute("ScenarioCreationTraceEnabled",
147 "Scenario creation trace output enable status.",
148 BooleanValue(false),
149 MakeBooleanAccessor(&SatHelper::m_creationTraces),
150 MakeBooleanChecker())
151 .AddAttribute("DetailedScenarioCreationTraceEnabled",
152 "Detailed scenario creation trace output enable status.",
153 BooleanValue(false),
154 MakeBooleanAccessor(&SatHelper::m_detailedCreationTraces),
155 MakeBooleanChecker())
156 .AddAttribute("ScenarioCreationTraceFileName",
157 "File name for the scenario creation trace output",
158 StringValue("CreationTraceScenario"),
159 MakeStringAccessor(&SatHelper::m_scenarioCreationFileName),
160 MakeStringChecker())
161 .AddAttribute("UtCreationTraceFileName",
162 "File name for the UT creation trace output",
163 StringValue("CreationTraceUt"),
164 MakeStringAccessor(&SatHelper::m_utCreationFileName),
165 MakeStringChecker())
166 .AddTraceSource("Creation",
167 "Creation traces",
168 MakeTraceSourceAccessor(&SatHelper::m_creationDetailsTrace),
169 "ns3::SatTypedefs::CreationCallback")
170 .AddTraceSource("CreationSummary",
171 "Creation summary traces",
172 MakeTraceSourceAccessor(&SatHelper::m_creationSummaryTrace),
173 "ns3::SatTypedefs::CreationCallback");
174 return tid;
175}
176
178{
179 NS_LOG_FUNCTION(this);
180
181 NS_FATAL_ERROR("Constructor not in use");
182}
183
184SatHelper::SatHelper(std::string scenarioPath)
186 m_handoversEnabled(false),
187 m_scenarioCreated(false),
188 m_creationTraces(false),
190 m_packetTraces(false),
191 m_utsInBeam(0),
192 m_gwUsers(0),
193 m_utUsers(0),
197{
198 NS_LOG_FUNCTION(this << scenarioPath);
199
200 m_scenarioPath = scenarioPath;
201
202 m_rtnConfFileName = m_scenarioPath + "/beams/rtnConf.txt";
203 m_fwdConfFileName = m_scenarioPath + "/beams/fwdConf.txt";
204
205 m_gwPosFileName = m_scenarioPath + "/positions/gw_positions.txt";
206 m_satPosFileName = m_scenarioPath + "/positions/sat_positions.txt";
207 m_utPosFileName = m_scenarioPath + "/positions/ut_positions.txt";
208
210
211 ReadStandard(m_scenarioPath + "/standard/standard.txt");
212
213 if (SatEnvVariables::GetInstance()->IsValidFile(m_scenarioPath + "/positions/tles.txt"))
214 {
215 NS_ASSERT_MSG(!SatEnvVariables::GetInstance()->IsValidFile(m_scenarioPath +
216 "/positions/sat_positions.txt"),
217 "position subfolder of scenario cannot have both contain tles.txt and "
218 "sat_positions.txt");
220 }
221 else if (!SatEnvVariables::GetInstance()->IsValidFile(m_scenarioPath +
222 "/positions/sat_positions.txt"))
223 {
224 NS_FATAL_ERROR("position subfolder of scenario must contain tles.txt or sat_positions.txt");
225 }
226}
227
228void
230{
231 NS_LOG_FUNCTION(this);
232
233 Object::NotifyConstructionCompleted();
234
235 SatEnvVariables::GetInstance()->Initialize();
236 Singleton<SatIdMapper>::Get()->Reset();
237 Singleton<SatTopology>::Get()->Reset();
238
239 m_satConf = CreateObject<SatConf>();
240
242 {
243 Ptr<SatLoraConf> satLoraConf = CreateObject<SatLoraConf>();
244 satLoraConf->setSatConfAttributes(m_satConf);
245 }
246
247 std::vector<std::pair<uint32_t, uint32_t>> isls;
248
250 {
251 std::vector<std::string> tles;
252
253 LoadConstellationTopology(tles, isls);
254
255 if (Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() !=
257 {
258 NS_FATAL_ERROR("Forward regeneration must be network when using constellations");
259 }
260 if (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() !=
262 {
263 NS_FATAL_ERROR("Return regeneration must be network when using constellations");
264 }
265
267 CreateObject<SatAntennaGainPatternContainer>(tles.size(),
268 m_scenarioPath + "/antennapatterns");
269
270 for (uint32_t i = 0; i < tles.size(); i++)
271 {
272 // create Satellite node, set mobility to it
273 Ptr<Node> satNode = CreateObject<Node>();
274
275 SetSatMobility(satNode, tles[i]);
276
277 Ptr<SatMobilityModel> mobility = satNode->GetObject<SatMobilityModel>();
278 m_antennaGainPatterns->ConfigureBeamsMobility(i, mobility);
279
280 Singleton<SatTopology>::Get()->AddOrbiterNode(satNode);
281 }
282 }
283 else
284 {
286 CreateObject<SatAntennaGainPatternContainer>(1, m_scenarioPath + "/antennapatterns");
287
288 // In case of constellations, all satellites have the same features, read in same
289 // configuration file
290 m_satConf->Initialize(m_rtnConfFileName,
296
297 // create Satellite node, set mobility to it
298 Ptr<Node> satNode = CreateObject<Node>();
299
300 SetSatMobility(satNode);
301
302 Ptr<SatMobilityModel> mobility = satNode->GetObject<SatMobilityModel>();
303 m_antennaGainPatterns->ConfigureBeamsMobility(0, mobility);
304
305 Singleton<SatTopology>::Get()->AddOrbiterNode(satNode);
306 }
307
309 CreateObject<SatBeamHelper>(isls,
311 m_satConf->GetRtnLinkCarrierCount(),
312 m_satConf->GetFwdLinkCarrierCount(),
313 m_satConf->GetSuperframeSeq());
314
315 m_beamHelper->SetAntennaGainPatterns(m_antennaGainPatterns);
316
317 Ptr<SatRtnLinkTime> rtnTime = Singleton<SatRtnLinkTime>::Get();
318 rtnTime->Initialize(m_satConf->GetSuperframeSeq());
319
322 m_beamHelper->SetAttribute("CarrierFrequencyConverter", CallbackValue(converterCb));
323
324 m_userHelper = CreateObject<SatUserHelper>();
327 m_userHelper->SetAttribute("PropagationDelayGetter", CallbackValue(delayModelCb));
328}
329
330void
332{
333 NS_LOG_FUNCTION(this);
334
335 switch (scenario)
336 {
337 case SIMPLE:
339 break;
340
341 case LARGER:
343 break;
344
345 case FULL:
347 break;
348
349 default:
350 NS_FATAL_ERROR("Not supported predefined scenario.");
351 break;
352 }
353}
354
355void
357{
358 NS_LOG_FUNCTION(this);
359
360 AsciiTraceHelper asciiTraceHelper;
361
362 std::stringstream outputPathCreation;
363 std::stringstream outputPathUt;
364 outputPathCreation << SatEnvVariables::GetInstance()->GetOutputPath() << "/"
365 << m_scenarioCreationFileName << ".log";
366 outputPathUt << SatEnvVariables::GetInstance()->GetOutputPath() << "/" << m_utCreationFileName
367 << ".log";
368
369 m_creationTraceStream = asciiTraceHelper.CreateFileStream(outputPathCreation.str());
370 m_utTraceStream = asciiTraceHelper.CreateFileStream(outputPathUt.str());
371
372 TraceConnectWithoutContext("CreationSummary",
373 MakeCallback(&SatHelper::CreationSummarySink, this));
374
376 {
378 }
379}
380
381void
383{
384 m_beamHelper->EnablePacketTrace();
385}
386
387void
388SatHelper::LoadConstellationTopology(std::vector<std::string>& tles,
389 std::vector<std::pair<uint32_t, uint32_t>>& isls)
390{
391 NS_LOG_FUNCTION(this);
392
393 m_satConf->Initialize(m_rtnConfFileName,
399 true);
400
401 tles = m_satConf->LoadTles(m_scenarioPath + "/positions/tles.txt",
402 m_scenarioPath + "/positions/start_date.txt");
403
404 if (SatEnvVariables::GetInstance()->IsValidFile(m_scenarioPath + "/positions/isls.txt"))
405 {
406 isls = m_satConf->LoadIsls(m_scenarioPath + "/positions/isls.txt");
407 }
408}
409
410void
412{
413 NS_LOG_FUNCTION(this);
414
415 CallbackBase creationCb =
417 TraceConnect("Creation", "SatHelper", creationCb);
418
419 m_userHelper->EnableCreationTraces(m_creationTraceStream, creationCb);
420 m_beamHelper->EnableCreationTraces(m_creationTraceStream, creationCb);
421}
422
423Ipv4Address
425{
426 NS_LOG_FUNCTION(this);
427
428 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4>(); // Get Ipv4 instance of the node
429
430 return ipv4->GetAddress(1, 0)
431 .GetLocal(); // Get Ipv4InterfaceAddress of interface csma interface.
432}
433
434Ptr<SatBeamHelper>
436{
437 NS_LOG_FUNCTION(this);
438 return m_beamHelper;
439}
440
441Ptr<SatGroupHelper>
443{
444 NS_LOG_FUNCTION(this);
445 return m_groupHelper;
446}
447
448void
449SatHelper::SetGroupHelper(Ptr<SatGroupHelper> groupHelper)
450{
451 NS_LOG_FUNCTION(this << groupHelper);
452 m_groupHelper = groupHelper;
453}
454
455void
456SatHelper::SetAntennaGainPatterns(Ptr<SatAntennaGainPatternContainer> antennaGainPatterns)
457{
458 NS_LOG_FUNCTION(this);
459 m_antennaGainPatterns = antennaGainPatterns;
460}
461
462Ptr<SatAntennaGainPatternContainer>
467
468Ptr<SatUserHelper>
470{
471 NS_LOG_FUNCTION(this);
472 return m_userHelper;
473}
474
475uint32_t
477{
478 NS_LOG_FUNCTION(this);
479
480 return m_satConf->GetBeamCount();
481}
482
483void
485{
486 NS_LOG_FUNCTION(this);
487
488 SatBeamUserInfo beamInfo = SatBeamUserInfo(1, 1);
489 BeamUserInfoMap_t beamUserInfos;
490 beamUserInfos[std::make_pair(0, 8)] = beamInfo;
491
492 DoCreateScenario(beamUserInfos, 1);
493
494 m_creationSummaryTrace("*** Simple Scenario Creation Summary ***");
495}
496
497void
499{
500 NS_LOG_FUNCTION(this);
501
502 // install one user for UTs in beams 12 and 22
503 SatBeamUserInfo beamInfo = SatBeamUserInfo(1, 1);
504 BeamUserInfoMap_t beamUserInfos;
505
506 beamUserInfos[std::make_pair(0, 12)] = beamInfo;
507 beamUserInfos[std::make_pair(0, 22)] = beamInfo;
508
509 // install two users for UT1 and one for UT2 in beam 3
510 beamInfo.SetUtUserCount(0, 2);
511 beamInfo.AppendUt(1);
512
513 beamUserInfos[std::make_pair(0, 3)] = beamInfo;
514
515 DoCreateScenario(beamUserInfos, 1);
516
517 m_creationSummaryTrace("*** Larger Scenario Creation Summary ***");
518}
519
520void
522{
523 NS_LOG_FUNCTION(this);
524
525 uint32_t beamCount = m_satConf->GetBeamCount();
526 BeamUserInfoMap_t beamUserInfos;
527
528 for (uint32_t i = 1; i < (beamCount + 1); i++)
529 {
530 BeamUserInfoMap_t::iterator beamInfo = m_beamUserInfos.find(std::make_pair(0, i));
531 SatBeamUserInfo info;
532
533 if (beamInfo != m_beamUserInfos.end())
534 {
535 info = beamInfo->second;
536 }
537 else
538 {
540 }
541
542 beamUserInfos[std::make_pair(0, i)] = info;
543 }
544
545 DoCreateScenario(beamUserInfos, m_gwUsers);
546
547 m_creationSummaryTrace("*** Full Scenario Creation Summary ***");
548}
549
550void
552{
553 NS_LOG_FUNCTION(this);
554
555 // create as user wants
557
558 m_creationSummaryTrace("*** User Defined Scenario Creation Summary ***");
559}
560
561void
562SatHelper::SetCustomUtPositionAllocator(Ptr<SatListPositionAllocator> posAllocator)
563{
564 NS_LOG_FUNCTION(this);
565 m_utPositions = posAllocator;
566}
567
568void
570 Ptr<SatListPositionAllocator> posAllocator)
571{
572 NS_LOG_FUNCTION(this << beamId);
573 m_utPositionsByBeam[beamId] = posAllocator;
574}
575
576void
578 BeamUserInfoMap_t& infos,
579 std::string inputFileUtListPositions,
580 bool checkBeam)
581{
582 NS_LOG_FUNCTION(this);
583
584 uint32_t positionIndex = 1;
585
586 // construct list position allocator and fill it with position
587 // configured through SatConf
588
589 m_utPosFileName = inputFileUtListPositions;
590
591 m_satConf->SetUtPositionsPath(m_utPosFileName);
592
593 m_utPositions = CreateObject<SatListPositionAllocator>();
594
595 for (BeamUserInfoMap_t::iterator it = infos.begin(); it != infos.end(); it++)
596 {
597 for (uint32_t i = 0; i < it->second.GetUtCount(); i++)
598 {
599 if (positionIndex > m_satConf->GetUtCount())
600 {
601 NS_FATAL_ERROR("Not enough positions available in SatConf for UTs!!!");
602 }
603
604 GeoCoordinate position = m_satConf->GetUtPosition(positionIndex);
605 m_utPositions->Add(position);
606 positionIndex++;
607
608 // if requested, check that the given beam is the best in the configured position
609 if (checkBeam)
610 {
611 uint32_t bestBeamId = m_antennaGainPatterns->GetBestBeamId(satId, position, false);
612
613 if (bestBeamId != it->first.second)
614 {
615 NS_FATAL_ERROR("The beam: " << it->first << " is not the best beam ("
616 << bestBeamId
617 << ") for the position: " << position);
618 }
619 }
620 }
621 }
622
623 // create as user wants
625
626 m_creationSummaryTrace("*** User Defined Scenario with List Positions Creation Summary ***");
627}
628
629void
631 GetNextUtUserCountCallback getNextUtUserCountCallback)
632{
633 NS_LOG_FUNCTION(this);
634
635 NS_ASSERT_MSG(info.size() > 0, "There must be at least one beam satellite");
636
637 m_antennaGainPatterns->SetEnabledBeams(info);
638
639 for (uint32_t i = 0; i < m_satConf->GetUtCount(); i++)
640 {
641 GeoCoordinate position = m_satConf->GetUtPosition(i + 1);
642
643 uint32_t satId = Singleton<SatTopology>::Get()->GetClosestSat(position);
644
645 uint32_t bestBeamId = m_antennaGainPatterns->GetBestBeamId(satId, position, true);
646
647 if (bestBeamId == 0)
648 {
649 NS_LOG_WARN("UT at " << position << " is too far away from any beam");
650 continue;
651 }
652
653 std::vector<std::pair<GeoCoordinate, uint32_t>> positions =
654 info.at(std::pair(satId, bestBeamId)).GetPositions();
655 positions.push_back(std::make_pair(position, 0));
656 info.at(std::pair(satId, bestBeamId)).SetPositions(positions);
657 uint32_t nbUsers = getNextUtUserCountCallback();
658 info.at(std::pair(satId, bestBeamId)).AppendUt(nbUsers);
659 }
660
661 for (uint32_t i = 0; i < m_satConf->GetGwCount(); i++)
662 {
663 GeoCoordinate position = m_satConf->GetGwPosition(i + 1);
664 uint32_t satId = Singleton<SatTopology>::Get()->GetClosestSat(position);
665
666 m_gwSats[i] = satId;
667 }
668
669 m_groupHelper->SetSatConstellationEnabled();
670}
671
672void
674{
675 NS_LOG_FUNCTION(this);
676
678 {
679 Singleton<SatLog>::Get()->AddToLog(
681 "",
682 "Scenario tried to re-create with SatHelper. Creation can be done only once.");
683 }
684 else
685 {
686 SetNetworkAddresses(beamInfos, gwUsers);
687
689 {
691 }
692
693 m_beamHelper->SetNccRoutingCallback(
695
696 InternetStackHelper internet;
697
698 // create all possible GW nodes, set mobility to them and install to Internet
699 NodeContainer gwNodes;
700 gwNodes.Create(m_satConf->GetGwCount());
701 internet.Install(gwNodes);
702
703 SetGwMobility(gwNodes);
704
705 std::set<uint32_t> beams;
706
707 // Create beams explicitly required for this scenario
708 for (BeamUserInfoMap_t::iterator info = beamInfos.begin(); info != beamInfos.end(); info++)
709 {
710 uint32_t satId = info->first.first;
711 uint32_t beamId = info->first.second;
712
713 beams.insert(beamId);
714
715 // create UTs of the beam, set mobility to them
716 std::vector<std::pair<GeoCoordinate, uint32_t>> positionsAndGroupId =
717 info->second.GetPositions();
718 NodeContainer uts;
719 uts.Create(info->second.GetUtCount() - positionsAndGroupId.size());
720 SetUtMobility(uts, satId, beamId);
721
722 NodeContainer utsFromPosition;
723 utsFromPosition.Create(positionsAndGroupId.size());
724 SetUtMobilityFromPosition(utsFromPosition, satId, beamId, positionsAndGroupId);
725 uts.Add(utsFromPosition);
726
727 // Add mobile UTs starting at this beam
728 std::map<uint32_t, NodeContainer>::iterator mobileUts = m_mobileUtsByBeam.find(beamId);
729 if (mobileUts != m_mobileUtsByBeam.end())
730 {
731 uts.Add(mobileUts->second);
732 m_mobileUtsByBeam.erase(mobileUts);
733 }
734
735 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); it++)
736 {
737 Singleton<SatTopology>::Get()->AddUtNode(*it);
738 }
739
740 // install the whole fleet to Internet
741 internet.Install(uts);
742
743 for (uint32_t i = 0; i < info->second.GetUtCount(); ++i)
744 {
745 // create and install needed users
746 m_userHelper->InstallUt(uts.Get(i), info->second.GetUtUserCount(i));
747 }
748
749 std::pair<std::multimap<uint32_t, uint32_t>::iterator,
750 std::multimap<uint32_t, uint32_t>::iterator>
751 mobileUsers;
752 mobileUsers = m_mobileUtsUsersByBeam.equal_range(beamId);
753 std::multimap<uint32_t, uint32_t>::iterator it = mobileUsers.first;
754 for (uint32_t i = info->second.GetUtCount(); i < uts.GetN() && it != mobileUsers.second;
755 ++i, ++it)
756 {
757 // create and install needed mobile users
758 m_userHelper->InstallUt(uts.Get(i), it->second);
759 }
760
761 std::vector<uint32_t> rtnConf =
762 m_satConf->GetBeamConfiguration(beamId, SatEnums::LD_RETURN);
763 std::vector<uint32_t> fwdConf =
764 m_satConf->GetBeamConfiguration(beamId, SatEnums::LD_FORWARD);
765
770 NS_ASSERT(rtnConf[SatConf::GW_ID_INDEX] == fwdConf[SatConf::GW_ID_INDEX]);
771 NS_ASSERT(rtnConf[SatConf::BEAM_ID_INDEX] == fwdConf[SatConf::BEAM_ID_INDEX]);
772
773 // gw index starts from 1 and we have stored them starting from 0
774 Ptr<Node> gwNode = gwNodes.Get(rtnConf[SatConf::GW_ID_INDEX] - 1);
775
776 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); it++)
777 {
778 Singleton<SatTopology>::Get()->ConnectGwToUt(*it, gwNode);
779 }
780
782 {
783 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); it++)
784 {
785 (*it)->AggregateObject(CreateObject<SatHandoverModule>(
786 *it,
787 Singleton<SatTopology>::Get()->GetOrbiterNodes(),
789 }
790 }
791
792 std::pair<Ptr<NetDevice>, NetDeviceContainer> netDevices =
793 m_beamHelper->Install(uts,
794 gwNode,
795 rtnConf[SatConf::GW_ID_INDEX],
796 satId,
797 rtnConf[SatConf::BEAM_ID_INDEX],
803
804 m_utsDistribution.insert(netDevices);
805 Ptr<NetDevice> gwNetDevice = netDevices.first;
806 NetDeviceContainer utNetDevices = netDevices.second;
807
808 Ptr<SatGwMac> gwMac =
809 DynamicCast<SatGwMac>(DynamicCast<SatNetDevice>(gwNetDevice)->GetMac());
810 uint32_t feederSatId;
811 uint32_t feederBeamId;
812 if (gwMac != nullptr)
813 {
814 feederSatId = gwMac->GetFeederSatId();
815 feederBeamId = gwMac->GetFeederBeamId();
816 }
817 else
818 {
819 feederSatId = 0;
820 feederBeamId = 0;
821 }
822
823 NetDeviceContainer::Iterator itNd;
824 for (itNd = utNetDevices.Begin(); itNd != utNetDevices.End(); itNd++)
825 {
826 Ptr<SatMac> mac = DynamicCast<SatMac>(DynamicCast<SatNetDevice>(*itNd)->GetMac());
827 if (mac != nullptr && gwMac != nullptr)
828 {
829 gwMac->ConnectUt(Mac48Address::ConvertFrom((*itNd)->GetAddress()));
830 }
831 }
832
833 DynamicCast<SatOrbiterNetDevice>(
834 Singleton<SatTopology>::Get()->GetOrbiterNode(feederSatId)->GetDevice(0))
835 ->ConnectGw(Mac48Address::ConvertFrom(netDevices.first->GetAddress()),
836 feederBeamId);
837
838 if (m_satConstellationEnabled == false)
839 {
840 m_userHelper->PopulateBeamRoutings(uts,
841 netDevices.second,
842 gwNode,
843 netDevices.first);
844 }
845
846 for (uint32_t utIndex = 0; utIndex < uts.GetN(); utIndex++)
847 {
848 DynamicCast<SatOrbiterNetDevice>(
849 Singleton<SatTopology>::Get()->GetOrbiterNode(satId)->GetDevice(0))
850 ->ConnectUt(
851 Mac48Address::ConvertFrom(netDevices.second.Get(utIndex)->GetAddress()),
852 beamId);
853 }
854 }
855
856 // TODO remove this ?
858 .clear(); // Release unused resources (mobile UTs starting in non-existent beams)
859
861 {
863 }
864
865 m_userHelper->InstallGw(gwUsers);
866
867 for (uint32_t beamId : beams)
868 {
869 std::vector<uint32_t> fwdConf =
870 m_satConf->GetBeamConfiguration(beamId, SatEnums::LD_FORWARD);
871 Ptr<Node> gwNode = gwNodes.Get(
872 m_satConf->GetBeamConfiguration(beamId, SatEnums::LD_RETURN)[SatConf::GW_ID_INDEX] -
873 1);
874 Singleton<SatTopology>::Get()->ConnectGwToBeam(beamId, gwNode);
875 }
876
878 {
879 m_beamHelper->InstallIsls();
880 m_beamHelper->SetIslRoutes();
881
883
884 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
885 Ptr<Node> ut;
886 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); it++)
887 {
888 ut = *it;
889
890 for (uint32_t j = 0; j < ut->GetNDevices(); j++)
891 {
892 Ptr<SatNetDevice> netDevice = DynamicCast<SatNetDevice>(ut->GetDevice(j));
893 if (netDevice)
894 {
895 Ptr<SatMac> mac = netDevice->GetMac();
896 switch (m_standard)
897 {
898 case SatEnums::DVB: {
899 Ptr<SatUtMac> utMac = DynamicCast<SatUtMac>(mac);
900 utMac->SetUpdateIslCallback(
902 break;
903 }
904 case SatEnums::LORA: {
905 Ptr<LorawanMacEndDevice> endDeviceMac =
906 DynamicCast<LorawanMacEndDevice>(mac);
907 endDeviceMac->SetUpdateIslCallback(
909 break;
910 }
911 default: {
912 NS_FATAL_ERROR("Unknown standard");
913 }
914 }
915 }
916 }
917 }
918
919 for (NodeContainer::Iterator it = gwNodes.Begin(); it != gwNodes.End(); it++)
920 {
921 Ptr<Node> gw = *it;
922
923 for (uint32_t j = 0; j < gw->GetNDevices(); j++)
924 {
925 Ptr<SatNetDevice> netDevice = DynamicCast<SatNetDevice>(gw->GetDevice(j));
926 if (netDevice)
927 {
928 Ptr<SatGwMac> mac = DynamicCast<SatGwMac>(netDevice->GetMac());
929 mac->SetUpdateIslCallback(
931 }
932 }
933 }
934 }
935
937 {
938 // Create the LoraDeviceAddress of the end devices
939 uint8_t nwkId = 54;
940 uint32_t nwkAddr = 1864;
941 Ptr<LoraDeviceAddressGenerator> addrGen =
942 CreateObject<LoraDeviceAddressGenerator>(nwkId, nwkAddr);
943
944 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
945 Ptr<Node> ut;
946 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); it++)
947 {
948 ut = *it;
949 Ptr<SatLorawanNetDevice> dev = ut->GetDevice(2)->GetObject<SatLorawanNetDevice>();
950 dev->GetMac()->GetObject<LorawanMacEndDeviceClassA>()->SetDeviceAddress(
951 addrGen->NextAddress());
952 }
953
954 Ptr<LoraNetworkServerHelper> loraNetworkServerHelper =
955 CreateObject<LoraNetworkServerHelper>();
956 Ptr<LoraForwarderHelper> forHelper = CreateObject<LoraForwarderHelper>();
957
958 NodeContainer networkServer;
959 networkServer.Create(1);
960
961 loraNetworkServerHelper->Install(networkServer);
962
963 forHelper->Install(Singleton<SatTopology>::Get()->GetGwNodes());
964 }
965
966 if (m_packetTraces)
967 {
969 }
970
971 m_scenarioCreated = true;
972 }
973
974 m_beamHelper->Init();
975}
976
977void
979{
980 NS_LOG_FUNCTION(this);
981
982 // Loop on each UT
983 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
984 Ptr<Node> ut;
985 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); it++)
986 {
987 ut = *it;
988 Mac48Address gwAddress = Singleton<SatTopology>::Get()->GetGwAddressInUt(ut->GetId());
989
990 switch (m_standard)
991 {
992 case SatEnums::DVB: {
993 Singleton<SatTopology>::Get()->GetDvbUtMac(ut)->SetGwAddress(gwAddress);
994 break;
995 }
996 case SatEnums::LORA: {
997 Singleton<SatTopology>::Get()->GetLoraUtMac(ut)->SetGwAddress(gwAddress);
998 break;
999 }
1000 default: {
1001 NS_FATAL_ERROR("Unknown standard");
1002 }
1003 }
1004 }
1005}
1006
1007void
1009{
1010 NS_LOG_FUNCTION(this);
1011
1012 NodeContainer gwNodes = Singleton<SatTopology>::Get()->GetGwNodes();
1013 for (NodeContainer::Iterator it = gwNodes.Begin(); it != gwNodes.End(); it++)
1014 {
1015 Ptr<Node> gw = *it;
1016 for (uint32_t ndId = 0; ndId < gw->GetNDevices(); ndId++)
1017 {
1018 if (DynamicCast<SatNetDevice>(gw->GetDevice(ndId)))
1019 {
1020 Ptr<SatNetDevice> gwNd = DynamicCast<SatNetDevice>(gw->GetDevice(ndId));
1021
1022 NetDeviceContainer utNd = m_utsDistribution[gwNd];
1023 NodeContainer ut;
1024 for (uint32_t i = 0; i < utNd.GetN(); i++)
1025 {
1026 ut.Add(utNd.Get(i)->GetNode());
1027 }
1028 m_userHelper->PopulateBeamRoutings(ut, utNd, gw, gwNd);
1029 }
1030 }
1031 }
1032}
1033
1034void
1035SatHelper::LoadMobileUTsFromFolder(const std::string& folderName, Ptr<RandomVariableStream> utUsers)
1036{
1037 NS_LOG_FUNCTION(this << folderName << utUsers);
1038
1039 if (!(SatEnvVariables::GetInstance()->IsValidDirectory(folderName)))
1040 {
1041 NS_LOG_INFO("Directory '" << folderName
1042 << "' does not exist, no mobile UTs will be created.");
1043 return;
1044 }
1045
1046 for (std::string& filename : SystemPath::ReadFiles(folderName))
1047 {
1048 std::string filepath = folderName + "/" + filename;
1049 if (SatEnvVariables::GetInstance()->IsValidDirectory(filepath))
1050 {
1051 NS_LOG_INFO("Skipping directory '" << filename << "'");
1052 continue;
1053 }
1054
1055 Ptr<Node> utNode = LoadMobileUtFromFile(filepath);
1056 uint32_t bestBeamId = utNode->GetObject<SatTracedMobilityModel>()->GetBestBeamId();
1057
1058 // Store Node in the container for the starting beam
1059 std::map<uint32_t, NodeContainer>::iterator it = m_mobileUtsByBeam.find(bestBeamId);
1060 if (it == m_mobileUtsByBeam.end())
1061 {
1062 std::pair<std::map<uint32_t, NodeContainer>::iterator, bool> inserted =
1063 m_mobileUtsByBeam.insert(std::make_pair(bestBeamId, NodeContainer(utNode)));
1064 NS_ASSERT_MSG(inserted.second,
1065 "Failed to create a new beam when reading UT mobility files");
1066 }
1067 else
1068 {
1069 it->second.Add(utNode);
1070 }
1071
1072 // Store amount of users for this UT
1073 m_mobileUtsUsersByBeam.insert(std::make_pair(bestBeamId, utUsers->GetInteger()));
1074 }
1075
1076 for (auto& mobileUtsForBeam : m_mobileUtsByBeam)
1077 {
1078 NS_LOG_INFO("Installing Mobility Observers for mobile UTs starting in beam "
1079 << mobileUtsForBeam.first);
1080 InstallMobilityObserver(0, mobileUtsForBeam.second);
1081 }
1082}
1083
1084Ptr<Node>
1085SatHelper::LoadMobileUtFromFile(const std::string& filename)
1086{
1087 NS_LOG_FUNCTION(this << filename);
1088
1089 if (SatEnvVariables::GetInstance()->IsValidFile(
1090 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/" + filename))
1091 {
1092 NS_FATAL_ERROR(filename << " is not a valid file name");
1093 }
1094
1095 GeoCoordinate initialPosition =
1096 Singleton<SatPositionInputTraceContainer>::Get()->GetPosition(filename,
1098 uint32_t satId = Singleton<SatTopology>::Get()->GetClosestSat(initialPosition);
1099
1100 // Create Node, Mobility and aggregate them
1101 Ptr<SatTracedMobilityModel> mobility =
1102 CreateObject<SatTracedMobilityModel>(satId, filename, m_antennaGainPatterns);
1103
1104 Ptr<Node> utNode = CreateObject<Node>();
1105 utNode->AggregateObject(mobility);
1106 if (!m_handoversEnabled)
1107 {
1108 utNode->AggregateObject(
1109 CreateObject<SatHandoverModule>(utNode,
1110 Singleton<SatTopology>::Get()->GetOrbiterNodes(),
1112 }
1113 return utNode;
1114}
1115
1116Ptr<Node>
1117SatHelper::LoadMobileUtFromFile(uint32_t satId, const std::string& filename)
1118{
1119 NS_LOG_FUNCTION(this << satId << filename);
1120
1121 if (SatEnvVariables::GetInstance()->IsValidFile(
1122 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/" + filename))
1123 {
1124 NS_FATAL_ERROR(filename << " is not a valid file name");
1125 }
1126
1127 // Create Node, Mobility and aggregate them
1128 Ptr<SatTracedMobilityModel> mobility =
1129 CreateObject<SatTracedMobilityModel>(satId, filename, m_antennaGainPatterns);
1130
1131 Ptr<Node> utNode = CreateObject<Node>();
1132 utNode->AggregateObject(mobility);
1133 if (!m_handoversEnabled)
1134 {
1135 utNode->AggregateObject(
1136 CreateObject<SatHandoverModule>(utNode,
1137 Singleton<SatTopology>::Get()->GetOrbiterNodes(),
1139 }
1140 return utNode;
1141}
1142
1143void
1144SatHelper::SetGwMobility(NodeContainer gwNodes)
1145{
1146 NS_LOG_FUNCTION(this);
1147
1148 MobilityHelper mobility;
1149
1150 Ptr<SatListPositionAllocator> gwPosAllocator = CreateObject<SatListPositionAllocator>();
1151
1152 for (uint32_t i = 0; i < gwNodes.GetN(); i++)
1153 {
1154 // GW id start from 1
1155 gwPosAllocator->Add(m_satConf->GetGwPosition(i + 1));
1156 }
1157
1158 mobility.SetPositionAllocator(gwPosAllocator);
1159 mobility.SetMobilityModel("ns3::SatConstantPositionMobilityModel");
1160 mobility.Install(gwNodes);
1161
1162 for (NodeContainer::Iterator it = gwNodes.Begin(); it != gwNodes.End(); it++)
1163 {
1164 Ptr<Node> gwNode = *it;
1165
1167 {
1168 uint32_t gwSatId = Singleton<SatTopology>::Get()->GetClosestSat(
1169 GeoCoordinate(gwNode->GetObject<SatMobilityModel>()->GetPosition()));
1170
1171 InstallMobilityObserver(gwSatId, NodeContainer(gwNode));
1172 }
1173 else
1174 {
1175 InstallMobilityObserver(0, NodeContainer(gwNode));
1176 }
1177
1179 {
1180 Ptr<SatHandoverModule> ho =
1181 CreateObject<SatHandoverModule>(gwNode,
1182 Singleton<SatTopology>::Get()->GetOrbiterNodes(),
1184 NS_LOG_DEBUG("Created Handover Module " << ho << " for GW node " << gwNode);
1185 gwNode->AggregateObject(ho);
1186 }
1187 }
1188}
1189
1190void
1191SatHelper::SetUtMobility(NodeContainer uts, uint32_t satId, uint32_t beamId)
1192{
1193 NS_LOG_FUNCTION(this);
1194
1195 MobilityHelper mobility;
1196
1197 Ptr<SatPositionAllocator> allocator;
1198
1199 // if position allocator (list) for UTs is created by helper already use it,
1200 // in other case use the spot beam position allocator
1201 if (m_utPositionsByBeam.find(beamId) != m_utPositionsByBeam.end())
1202 {
1203 allocator = m_utPositionsByBeam[beamId];
1204 }
1205 else if (m_utPositions != nullptr)
1206 {
1207 allocator = m_utPositions;
1208 }
1209 else
1210 {
1211 // Create new position allocator
1212 allocator = GetBeamAllocator(beamId);
1213 }
1214
1215 mobility.SetPositionAllocator(allocator);
1216 mobility.SetMobilityModel("ns3::SatConstantPositionMobilityModel");
1217 mobility.Install(uts);
1218
1219 InstallMobilityObserver(satId, uts);
1220
1221 for (uint32_t i = 0; i < uts.GetN(); ++i)
1222 {
1223 GeoCoordinate position = uts.Get(i)->GetObject<SatMobilityModel>()->GetGeoPosition();
1224 NS_LOG_INFO("Installing mobility observer on Ut Node at "
1225 << position << " with antenna gain of "
1226 << m_antennaGainPatterns->GetAntennaGainPattern(beamId)->GetAntennaGain_lin(
1227 position,
1228 Singleton<SatTopology>::Get()
1229 ->GetOrbiterNode(satId)
1230 ->GetObject<SatMobilityModel>()));
1231 }
1232}
1233
1234void
1236 NodeContainer uts,
1237 uint32_t satId,
1238 uint32_t beamId,
1239 std::vector<std::pair<GeoCoordinate, uint32_t>> positionsAndGroupId)
1240{
1241 NS_LOG_FUNCTION(this << beamId);
1242
1243 MobilityHelper mobility;
1244
1245 Ptr<SatListPositionAllocator> allocator = CreateObject<SatListPositionAllocator>();
1246
1247 NS_ASSERT_MSG(uts.GetN() == positionsAndGroupId.size(),
1248 "Inconsistent number of nodes and positions");
1249
1250 for (uint32_t i = 0; i < positionsAndGroupId.size(); i++)
1251 {
1252 allocator->Add(positionsAndGroupId[i].first);
1253 m_groupHelper->AddNodeToGroupAfterScenarioCreation(positionsAndGroupId[i].second,
1254 uts.Get(i));
1255 }
1256
1257 mobility.SetPositionAllocator(allocator);
1258 mobility.SetMobilityModel("ns3::SatConstantPositionMobilityModel");
1259 mobility.Install(uts);
1260
1261 InstallMobilityObserver(satId, uts);
1262
1263 for (uint32_t i = 0; i < uts.GetN(); ++i)
1264 {
1265 GeoCoordinate position = uts.Get(i)->GetObject<SatMobilityModel>()->GetGeoPosition();
1266 NS_LOG_INFO("Installing mobility observer on Ut Node at "
1267 << position << " with antenna gain of "
1268 << m_antennaGainPatterns->GetAntennaGainPattern(beamId)->GetAntennaGain_lin(
1269 position,
1270 Singleton<SatTopology>::Get()
1271 ->GetOrbiterNode(satId)
1272 ->GetObject<SatMobilityModel>()));
1273 }
1274}
1275
1276Ptr<SatSpotBeamPositionAllocator>
1278{
1279 NS_LOG_FUNCTION(this << beamId);
1280
1281 GeoCoordinate satPosition;
1283 {
1284 satPosition = Singleton<SatTopology>::Get()
1285 ->GetOrbiterNode(0)
1286 ->GetObject<SatMobilityModel>()
1287 ->GetPosition();
1288 }
1289 else
1290 {
1291 satPosition = m_satConf->GetSatPosition();
1292 }
1293 Ptr<SatSpotBeamPositionAllocator> beamAllocator =
1294 CreateObject<SatSpotBeamPositionAllocator>(beamId, m_antennaGainPatterns, satPosition);
1295
1296 Ptr<UniformRandomVariable> altRnd = CreateObject<UniformRandomVariable>();
1297 altRnd->SetAttribute("Min", DoubleValue(0.0));
1298 altRnd->SetAttribute("Max", DoubleValue(500.0));
1299 beamAllocator->SetAltitude(altRnd);
1300 return beamAllocator;
1301}
1302
1303void
1305{
1306 NS_LOG_FUNCTION(this << node);
1307 MobilityHelper mobility;
1308
1309 Ptr<SatListPositionAllocator> satPosAllocator = CreateObject<SatListPositionAllocator>();
1310 satPosAllocator->Add(m_satConf->GetSatPosition());
1311
1312 mobility.SetPositionAllocator(satPosAllocator);
1313 mobility.SetMobilityModel("ns3::SatConstantPositionMobilityModel");
1314 mobility.Install(node);
1315}
1316
1317void
1318SatHelper::SetSatMobility(Ptr<Node> node, std::string tle)
1319{
1320 NS_LOG_FUNCTION(this);
1321
1322 Ptr<Object> object = node;
1323 Ptr<SatSGP4MobilityModel> model = object->GetObject<SatSGP4MobilityModel>();
1324 if (model == nullptr)
1325 {
1326 ObjectFactory mobilityFactory;
1327 mobilityFactory.SetTypeId("ns3::SatSGP4MobilityModel");
1328 model = mobilityFactory.Create()->GetObject<SatSGP4MobilityModel>();
1329 if (model == nullptr)
1330 {
1331 NS_FATAL_ERROR("The requested mobility model is not a mobility model: \""
1332 << mobilityFactory.GetTypeId().GetName() << "\"");
1333 }
1334 model->SetStartDate(m_satConf->GetStartTimeStr());
1335 object->AggregateObject(model);
1336 }
1337
1338 model->SetTleInfo(tle);
1339}
1340
1341void
1342SatHelper::InstallMobilityObserver(uint32_t satId, NodeContainer nodes) const
1343{
1344 NS_LOG_FUNCTION(this);
1345
1346 for (NodeContainer::Iterator i = nodes.Begin(); i != nodes.End(); i++)
1347 {
1348 Ptr<SatMobilityObserver> observer = (*i)->GetObject<SatMobilityObserver>();
1349
1350 if (observer == nullptr)
1351 {
1352 Ptr<SatMobilityModel> ownMobility = (*i)->GetObject<SatMobilityModel>();
1353 Ptr<SatMobilityModel> satMobility =
1354 Singleton<SatTopology>::Get()->GetOrbiterNode(satId)->GetObject<SatMobilityModel>();
1355
1356 NS_ASSERT(ownMobility != nullptr);
1357 NS_ASSERT(satMobility != nullptr);
1358
1359 observer = CreateObject<SatMobilityObserver>(
1360 ownMobility,
1362 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() !=
1364
1365 (*i)->AggregateObject(observer);
1366 }
1367 }
1368}
1369
1370void
1372 NodeContainer receivers,
1373 Ipv4Address sourceAddress,
1374 Ipv4Address groupAddress)
1375{
1376 NS_LOG_FUNCTION(this);
1377
1378 MulticastBeamInfo_t beamInfo;
1379 Ptr<NetDevice> routerUserOutputDev;
1380 Ptr<Node> sourceUtNode = Singleton<SatTopology>::Get()->GetUtNode(source);
1381
1382 // Construct multicast info from source UT node and receivers. In case that sourceUtNode is
1383 // NULL, source is some GW user. As a result is given flag indicating if traffic shall be
1384 // forwarded to source's own network
1385
1386 if (ConstructMulticastInfo(sourceUtNode, receivers, beamInfo, routerUserOutputDev))
1387 {
1388 // Some multicast receiver belongs to same group with source
1389
1390 // select destination node
1391 Ptr<Node> destNode = m_userHelper->GetRouter();
1392
1393 if (sourceUtNode)
1394 {
1395 destNode = sourceUtNode;
1396 }
1397
1398 // add default route for multicast group to source's network
1399 SetMulticastRouteToSourceNetwork(source, destNode);
1400 }
1401
1402 // set routes outside source's network only when there are receivers
1403 if (!beamInfo.empty() || (sourceUtNode && routerUserOutputDev))
1404 {
1405 Ptr<Node> routerNode = m_userHelper->GetRouter();
1406
1407 Ptr<NetDevice> routerInputDev = nullptr;
1408 Ptr<NetDevice> gwOutputDev = nullptr;
1409
1410 // set multicast routes to satellite network utilizing beam helper
1411 NetDeviceContainer gwInputDevices =
1412 m_beamHelper->AddMulticastGroupRoutes(beamInfo,
1413 sourceUtNode,
1414 sourceAddress,
1415 groupAddress,
1416 (bool)routerUserOutputDev,
1417 gwOutputDev);
1418
1419 Ipv4StaticRoutingHelper multicast;
1420
1421 // select input device in IP router
1422 if (gwOutputDev)
1423 {
1424 // traffic coming from some GW to router (satellite network and source is UT)
1425 // find matching input device using GW output device
1426 routerInputDev = FindMatchingDevice(gwOutputDev, routerNode);
1427 }
1428 else if (!sourceUtNode)
1429 {
1430 // traffic is coming form user network (some GW user)
1431
1432 // find matching device using source node
1433 std::pair<Ptr<NetDevice>, Ptr<NetDevice>> devices;
1434
1435 if (FindMatchingDevices(source, routerNode, devices))
1436 {
1437 routerInputDev = devices.second;
1438 }
1439 }
1440
1441 NetDeviceContainer routerOutputDevices;
1442
1443 if (routerUserOutputDev)
1444 {
1445 routerOutputDevices.Add(routerUserOutputDev);
1446 }
1447
1448 for (NetDeviceContainer::Iterator it = gwInputDevices.Begin(); it != gwInputDevices.End();
1449 it++)
1450 {
1451 Ptr<NetDevice> matchingDevice = FindMatchingDevice(*it, routerNode);
1452
1453 if (matchingDevice)
1454 {
1455 routerOutputDevices.Add(matchingDevice);
1456 }
1457 }
1458
1459 // Add multicast route over IP router
1460 // Input device is getting traffic from user network (GW users) or from some GW
1461 // Output devices are forwarding traffic to user network (GW users) and/or GWs
1462 if (routerInputDev && (routerOutputDevices.GetN() > 0))
1463 {
1464 multicast.AddMulticastRoute(routerNode,
1465 sourceAddress,
1466 groupAddress,
1467 routerInputDev,
1468 routerOutputDevices);
1469 }
1470 }
1471}
1472
1473void
1474SatHelper::CreationDetailsSink(Ptr<OutputStreamWrapper> stream,
1475 std::string context,
1476 std::string info)
1477{
1478 *stream->GetStream() << context << ", " << info << std::endl;
1479}
1480
1481void
1483{
1484 NS_LOG_FUNCTION(this);
1485
1486 *m_creationTraceStream->GetStream() << CreateCreationSummary(title);
1487 *m_utTraceStream->GetStream() << m_beamHelper->GetUtInfo();
1488}
1489
1490std::string
1492{
1493 NS_LOG_FUNCTION(this);
1494
1495 std::ostringstream oss;
1496
1497 oss << std::endl << std::endl << title << std::endl << std::endl;
1498 oss << "--- User Info ---" << std::endl << std::endl;
1499 oss << "Created GW users: " << Singleton<SatTopology>::Get()->GetNGwUserNodes() << ", ";
1500 oss << "Created UT users: " << Singleton<SatTopology>::Get()->GetNUtUserNodes() << std::endl;
1501 oss << m_userHelper->GetRouterInfo() << std::endl << std::endl;
1502 oss << m_beamHelper->GetBeamInfo() << std::endl;
1503
1504 return oss.str();
1505}
1506
1507void
1509{
1510 NS_LOG_FUNCTION(this);
1511
1512 m_userHelper = nullptr;
1513 m_beamHelper->DoDispose();
1514 m_beamHelper = nullptr;
1515 m_antennaGainPatterns = nullptr;
1516 m_utPositionsByBeam.clear();
1517 m_mobileUtsByBeam.clear();
1518 m_mobileUtsUsersByBeam.clear();
1519}
1520
1521bool
1523 Ptr<Node> nodeB,
1524 std::pair<Ptr<NetDevice>, Ptr<NetDevice>>& matchingDevices)
1525{
1526 bool found = false;
1527
1528 for (uint32_t i = 1; ((i < nodeA->GetNDevices()) && !found); i++)
1529 {
1530 Ptr<NetDevice> devA = nodeA->GetDevice(i);
1531 Ptr<NetDevice> devB = FindMatchingDevice(devA, nodeB);
1532
1533 if (devB)
1534 {
1535 matchingDevices = std::make_pair(devA, devB);
1536 found = true;
1537 }
1538 }
1539
1540 return found;
1541}
1542
1543Ptr<NetDevice>
1544SatHelper::FindMatchingDevice(Ptr<NetDevice> devA, Ptr<Node> nodeB)
1545{
1546 Ptr<NetDevice> matchingDevice = nullptr;
1547
1548 Ipv4Address addressA =
1549 devA->GetNode()->GetObject<Ipv4L3Protocol>()->GetAddress(devA->GetIfIndex(), 0).GetLocal();
1550 Ipv4Mask maskA =
1551 devA->GetNode()->GetObject<Ipv4L3Protocol>()->GetAddress(devA->GetIfIndex(), 0).GetMask();
1552
1553 Ipv4Address netAddressA = addressA.CombineMask(maskA);
1554
1555 for (uint32_t j = 1; j < nodeB->GetNDevices(); j++)
1556 {
1557 Ipv4Address addressB = nodeB->GetObject<Ipv4L3Protocol>()->GetAddress(j, 0).GetLocal();
1558 Ipv4Mask maskB = nodeB->GetObject<Ipv4L3Protocol>()->GetAddress(j, 0).GetMask();
1559
1560 Ipv4Address netAddressB = addressB.CombineMask(maskB);
1561
1562 if (netAddressA == netAddressB)
1563 {
1564 matchingDevice = nodeB->GetDevice(j);
1565 }
1566 }
1567
1568 return matchingDevice;
1569}
1570
1571void
1572SatHelper::SetMulticastRouteToSourceNetwork(Ptr<Node> source, Ptr<Node> dest)
1573{
1574 NS_LOG_FUNCTION(this);
1575
1576 std::pair<Ptr<NetDevice>, Ptr<NetDevice>> devices;
1577
1578 if (FindMatchingDevices(source, dest, devices))
1579 {
1580 Ipv4StaticRoutingHelper multicast;
1581 Ptr<Ipv4StaticRouting> staticRouting =
1582 multicast.GetStaticRouting(source->GetObject<ns3::Ipv4>());
1583
1584 // check if default multicast route already exists
1585 bool defaultMulticastRouteExists = false;
1586 Ipv4Address defMulticastNetwork = Ipv4Address("224.0.0.0");
1587 Ipv4Mask defMulticastNetworkMask = Ipv4Mask("240.0.0.0");
1588
1589 for (uint32_t i = 0; i < staticRouting->GetNRoutes(); i++)
1590 {
1591 if (staticRouting->GetRoute(i).GetDestNetwork() == defMulticastNetwork &&
1592 staticRouting->GetRoute(i).GetDestNetworkMask() == defMulticastNetworkMask)
1593 {
1594 defaultMulticastRouteExists = true;
1595 }
1596 }
1597
1598 // add default multicast route only if it does not exist already
1599 if (!defaultMulticastRouteExists)
1600 {
1601 multicast.SetDefaultMulticastRoute(source, devices.first);
1602 }
1603 }
1604}
1605
1606bool
1608 NodeContainer receivers,
1609 MulticastBeamInfo_t& beamInfo,
1610 Ptr<NetDevice>& routerUserOutputDev)
1611{
1612 NS_LOG_FUNCTION(this);
1613
1614 bool routeToSourceNertwork = false;
1615
1616 routerUserOutputDev = nullptr;
1617
1618 // go through all receivers
1619 for (uint32_t i = 0; i < receivers.GetN(); i++)
1620 {
1621 Ptr<Node> receiverNode = receivers.Get(i);
1622 Ptr<Node> utNode = Singleton<SatTopology>::Get()->GetUtNode(receiverNode);
1623
1624 // check if user is connected to UT or GW
1625
1626 if (utNode) // connected to UT
1627 {
1628 uint32_t beamId = m_beamHelper->GetUtBeamId(utNode);
1629
1630 if (beamId != 0) // beam ID is found
1631 {
1632 if (sourceUtNode == utNode)
1633 {
1634 // Source UT node is same than current UT node. Set flag to indicate that
1635 // multicast group traffic shall be routed to source own network.
1636 routeToSourceNertwork = true;
1637 }
1638 else
1639 {
1640 // store other UT nodes beam ID and pointer to multicast group info for later
1641 // routing
1642 MulticastBeamInfo_t::iterator it = beamInfo.find(beamId);
1643
1644 // find or create first storage for the beam
1645 if (it == beamInfo.end())
1646 {
1647 std::pair<MulticastBeamInfo_t::iterator, bool> result =
1648 beamInfo.insert(std::make_pair(beamId, MulticastBeamInfoItem_t()));
1649
1650 if (result.second)
1651 {
1652 it = result.first;
1653 }
1654 else
1655 {
1656 NS_FATAL_ERROR("Cannot insert beam to map container");
1657 }
1658 }
1659
1660 // Add to UT node to beam storage (map)
1661 it->second.insert(utNode);
1662 }
1663 }
1664 else
1665 {
1666 NS_FATAL_ERROR("UT node's beam ID is invalid!!");
1667 }
1668 }
1669 else if (m_userHelper->IsGwUser(receiverNode)) // connected to GW
1670 {
1671 if (!routerUserOutputDev)
1672 {
1673 if (sourceUtNode)
1674 {
1675 std::pair<Ptr<NetDevice>, Ptr<NetDevice>> devices;
1676
1677 if (FindMatchingDevices(receiverNode, m_userHelper->GetRouter(), devices))
1678 {
1679 routerUserOutputDev = devices.second;
1680 }
1681 }
1682 else
1683 {
1684 routeToSourceNertwork = true;
1685 }
1686 }
1687 }
1688 else
1689 {
1690 NS_FATAL_ERROR("Multicast receiver node is expected to be connected UT or GW node!!!");
1691 }
1692 }
1693
1694 return routeToSourceNertwork;
1695}
1696
1697void
1699{
1700 NS_LOG_FUNCTION(this);
1701
1702 std::set<uint32_t> networkAddresses;
1703 std::pair<std::set<uint32_t>::const_iterator, bool> addressInsertionResult;
1704
1705 // test first that configured initial addresses per configured address space
1706 // are not same by inserting them to set container
1707 networkAddresses.insert(m_beamNetworkAddress.Get());
1708 addressInsertionResult = networkAddresses.insert(m_gwNetworkAddress.Get());
1709
1710 if (!addressInsertionResult.second)
1711 {
1712 NS_FATAL_ERROR("GW network address is invalid (same as Beam network address)");
1713 }
1714
1715 addressInsertionResult = networkAddresses.insert(m_utNetworkAddress.Get());
1716
1717 if (!addressInsertionResult.second)
1718 {
1719 NS_FATAL_ERROR("UT network address is invalid (same as Beam or GW network address)");
1720 }
1721
1722 // calculate values to check needed network and host address counts
1723 uint32_t utNetworkAddressCount = 0; // network addresses needed in UT network
1724 uint32_t utHostAddressCount = 0; // host addresses needed in UT network
1725 uint32_t beamHostAddressCount = 0; // host addresses needed in Beam network
1726 uint32_t gwNetworkAddressCount = 1; // network addresses needed in GW network. Initially one
1727 // network needed between GW users and Router needed
1728 std::set<uint32_t> gwIds; // to find out the additional network addresses needed in GW network
1729
1730 for (BeamUserInfoMap_t::const_iterator it = info.begin(); it != info.end(); it++)
1731 {
1732 uint32_t beamUtCount = it->second.GetUtCount();
1733 utNetworkAddressCount += beamUtCount;
1734
1735 if (beamUtCount > beamHostAddressCount)
1736 {
1737 beamHostAddressCount = beamUtCount;
1738 }
1739
1740 for (uint32_t i = 0; i < beamUtCount; i++)
1741 {
1742 if (it->second.GetUtUserCount(i) > utHostAddressCount)
1743 {
1744 utHostAddressCount = it->second.GetUtUserCount(i);
1745 }
1746 }
1747
1748 // try to add GW id to container, if not existing already in the container
1749 // increment GW network address count
1750 if (gwIds.insert(m_beamHelper->GetGwId(it->first.first, it->first.second)).second)
1751 {
1752 gwNetworkAddressCount++; // one network more needed between a GW and Router
1753 }
1754 }
1755
1756 // do final checking of the configured address spaces
1757 CheckNetwork("Beam",
1760 networkAddresses,
1761 info.size(),
1762 beamHostAddressCount);
1763 CheckNetwork("GW",
1766 networkAddresses,
1767 gwNetworkAddressCount,
1768 gwUsers);
1769 CheckNetwork("UT",
1772 networkAddresses,
1773 utNetworkAddressCount,
1774 utHostAddressCount);
1775
1776 // set base addresses of the sub-helpers
1780}
1781
1782void
1783SatHelper::CheckNetwork(std::string networkName,
1784 const Ipv4Address& firstNetwork,
1785 const Ipv4Mask& mask,
1786 const std::set<uint32_t>& networkAddresses,
1787 uint32_t networkCount,
1788 uint32_t hostCount) const
1789{
1790 NS_LOG_FUNCTION(this);
1791
1792 uint16_t addressPrefixLength = mask.GetPrefixLength();
1793
1794 // test that configured mask is valid (address prefix length is in valid range)
1795 if ((addressPrefixLength < MIN_ADDRESS_PREFIX_LENGTH) ||
1796 (addressPrefixLength > MAX_ADDRESS_PREFIX_LENGTH))
1797 {
1798 NS_FATAL_ERROR(networkName
1799 << " network mask value out of range (0xFFFFFF70 to 0x10000000).");
1800 }
1801
1802 // test that configured initial network number (prefix) is valid, consistent with mask
1803 if ((firstNetwork.Get() & mask.GetInverse()) != 0)
1804 {
1805 NS_FATAL_ERROR(networkName << " network address and mask inconsistent.");
1806 }
1807
1808 std::set<uint32_t>::const_iterator currentAddressIt = networkAddresses.find(firstNetwork.Get());
1809
1810 // test that network we are checking is in given container
1811 if (currentAddressIt != networkAddresses.end())
1812 {
1813 // calculate network and host count based on configured initial network address and
1814 // mask for the network space
1815 uint32_t hostAddressCount = std::pow(2, (32 - addressPrefixLength)) - 2;
1816 uint32_t firstAddressValue = firstNetwork.Get();
1817 uint32_t networkAddressCount =
1818 mask.Get() - firstAddressValue +
1819 1; // increase subtraction result by one, to include also first address
1820
1821 currentAddressIt++;
1822
1823 // test in the case that checked address space is not last ('highest') in the
1824 // given address container that the address space doesn't overlap with other configured
1825 // address spaces
1826 if ((currentAddressIt != networkAddresses.end()) &&
1827 (firstAddressValue + (networkCount << (32 - addressPrefixLength))) >= *currentAddressIt)
1828 {
1829 NS_FATAL_ERROR(networkName << " network's addresses overlaps with some other network)");
1830 }
1831
1832 // test that enough network addresses are available in address space
1833 if (networkCount > networkAddressCount)
1834 {
1835 NS_FATAL_ERROR("Not enough network addresses for '" << networkName << "' network");
1836 }
1837
1838 // test that enough host addresses are available in address space
1839 if (hostCount > hostAddressCount)
1840 {
1841 NS_FATAL_ERROR("Not enough host addresses for '" << networkName << "' network");
1842 }
1843 }
1844 else
1845 {
1846 NS_FATAL_ERROR(networkName
1847 << "network's initial address number not among of the given addresses");
1848 }
1849}
1850
1851void
1852SatHelper::ReadStandard(std::string pathName)
1853{
1854 NS_LOG_FUNCTION(this << pathName);
1855
1856 // READ FROM THE SPECIFIED INPUT FILE
1857 std::ifstream* ifs = new std::ifstream(pathName.c_str(), std::ifstream::in);
1858
1859 if (!ifs->is_open())
1860 {
1861 // script might be launched by test.py, try a different base path
1862 delete ifs;
1863 pathName = "../../" + pathName;
1864 ifs = new std::ifstream(pathName.c_str(), std::ifstream::in);
1865
1866 if (!ifs->is_open())
1867 {
1868 NS_FATAL_ERROR("The file " << pathName << " is not found.");
1869 }
1870 }
1871
1872 std::string standardString;
1873 *ifs >> standardString;
1874
1875 ifs->close();
1876 delete ifs;
1877
1878 if (standardString == "DVB")
1879 {
1881 }
1882 else if (standardString == "LORA")
1883 {
1885 }
1886 else
1887 {
1888 NS_FATAL_ERROR("Unknown standard: " << standardString << ". Must be DVB or LORA");
1889 }
1890
1891 Singleton<SatTopology>::Get()->SetStandard(m_standard);
1892}
1893
1894} // namespace ns3
GeoCoordinate class is used to store and operate with geodetic coordinates.
Class representing the MAC layer of a Class A LoRaWAN device.
void SetIslRoutes()
Set ISL routes.
SatChannel::CarrierFreqConverter CarrierFreqConverter
Define type CarrierFreqConverter.
Ptr< PropagationDelayModel > GetPropagationDelayModel(uint32_t satId, uint32_t beamId, SatEnums::ChannelType_t channelType)
Class that holds information for each beam regarding UTs and their users camped in each beam.
void AppendUt(uint32_t userCount)
Appends new UT to end of the list with given user count for the appended UT.
void SetUtUserCount(uint32_t utIndex, uint32_t userCount)
Sets user count for the UT with given uIndex.
double GetCarrierBandwidthHz(SatEnums::ChannelType_t chType, uint32_t carrierId, SatEnums::CarrierBandwidthType_t bandwidthType)
Convert carrier id and sequence id to to bandwidth value.
static const uint32_t GW_ID_INDEX
Definition for GW ID index (column) in m_conf.
static const uint32_t BEAM_ID_INDEX
Definition for beam ID index (column) in m_conf.
double GetCarrierFrequencyHz(SatEnums::ChannelType_t chType, uint32_t freqId, uint32_t carrierId)
Convert carrier id, sequency id and frequency id to real frequency value.
static const uint32_t U_FREQ_ID_INDEX
Definition for user frequency ID index (column) in m_conf.
static const uint32_t F_FREQ_ID_INDEX
Definition for feeder frequency ID index (column) in m_conf.
static Ptr< SatEnvVariables > GetInstance()
Build a satellite network set with needed objects and configuration.
Ptr< SatUserHelper > GetUserHelper() const
std::string m_waveformConfDirectoryName
virtual void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
void CreatePredefinedScenario(PreDefinedScenario_t scenario)
Create a pre-defined SatHelper to make life easier when creating Satellite topologies.
Ipv4Mask m_beamNetworkMask
Network mask number of satellite devices.
std::string m_utCreationFileName
File name for UT creation trace output.
SatHelper()
Default constructor.
static void CreationDetailsSink(Ptr< OutputStreamWrapper > stream, std::string context, std::string info)
Sink for creation details traces.
SatEnums::Standard_t m_standard
void LoadConstellationTopology(std::vector< std::string > &tles, std::vector< std::pair< uint32_t, uint32_t > > &isls)
Load a constellation topology.
std::multimap< uint32_t, uint32_t > m_mobileUtsUsersByBeam
List of users by mobile UT by beam ID.
Ptr< SatSpotBeamPositionAllocator > GetBeamAllocator(uint32_t beamId)
Create a SatSpotBeamPositionAllocator able to generate random position within the given beam.
Ipv4Address m_beamNetworkAddress
Initial network number of satellite devices, e.g., 10.1.1.0.
void CreateLargerScenario()
Creates satellite objects according to larger scenario.
bool m_handoversEnabled
Enable handovers for all UTs and GWs.
void SetGwMobility(NodeContainer gwNodes)
Sets mobilities to created GW nodes.
Ipv4Address m_gwNetworkAddress
Initial network number of GW, router, and GW users, e.g., 10.2.1.0.
Callback< uint32_t > GetNextUtUserCountCallback
Get number of Users for a UT.
void CheckNetwork(std::string networkName, const Ipv4Address &firstNetwork, const Ipv4Mask &mask, const std::set< uint32_t > &networkAddresses, uint32_t networkCount, uint32_t hostCount) const
Check validity of the configured network space.
Ipv4Mask m_utNetworkMask
Network mask number of UT and UT users.
void InstallMobilityObserver(uint32_t satId, NodeContainer nodes) const
Install Satellite Mobility Observer to nodes, if observer doesn't exist already in a node.
void ReadStandard(std::string pathName)
Read to standard use from file given in path.
static TypeId GetTypeId(void)
Get the type ID.
void SetGwAddressInUts()
Set the value of GW address for each UT.
std::string m_scenarioCreationFileName
File name for scenario creation trace output.
BeamUserInfoMap_t m_beamUserInfos
Info for beam creation in user defined scenario.
void DoCreateScenario(BeamUserInfoMap_t &info, uint32_t gwUsers)
Creates satellite objects according to given beam info.
uint32_t m_utsInBeam
Number of UTs created per Beam in full or user-defined scenario.
std::string m_scenarioPath
Scenario folder path.
std::string m_gwPosFileName
Ipv4Address GetUserAddress(Ptr< Node > node)
bool FindMatchingDevices(Ptr< Node > nodeA, Ptr< Node > nodeB, std::pair< Ptr< NetDevice >, Ptr< NetDevice > > &matchingDevices)
Find counterpart (device belonging to same network) devices from given nodes.
void SetCustomUtPositionAllocator(Ptr< SatListPositionAllocator > posAllocator)
Set custom position allocator.
void SetGroupHelper(Ptr< SatGroupHelper > groupHelper)
set the group helper.
std::string m_fwdConfFileName
bool m_creationTraces
flag to indicate if creation trace should be enabled for scenario creation.
void SetBeamRoutingConstellations()
Populate the routes, when using constellations.
SatBeamHelper::MulticastBeamInfo_t MulticastBeamInfo_t
static const uint16_t MAX_ADDRESS_PREFIX_LENGTH
Ptr< SatConf > m_satConf
Configuration for satellite network.
void SetAntennaGainPatterns(Ptr< SatAntennaGainPatternContainer > antennaGainPattern)
Set the antenna gain patterns.
Ptr< OutputStreamWrapper > m_creationTraceStream
Stream wrapper used for creation traces.
bool ConstructMulticastInfo(Ptr< Node > sourceUtNode, NodeContainer receivers, MulticastBeamInfo_t &beamInfo, Ptr< NetDevice > &routerUserOutputDev)
Construct multicast information from source UT node and group receivers.
std::string m_rtnConfFileName
Configuration file names as attributes of this class.
void LoadConstellationScenario(BeamUserInfoMap_t &info, GetNextUtUserCountCallback getNextUtUserCountCallback)
Load satellite objects according to constellation parameters.
bool m_packetTraces
flag to indicate if packet trace should be enabled after scenario creation.
void SetSatMobility(Ptr< Node > node)
Sets mobility to created Sat node.
PreDefinedScenario_t
Values for pre-defined scenarios to be used by helper when building satellite network topology base.
@ LARGER
LARGER Larger scenario used as base.
@ FULL
FULL Full scenario used as base.
@ SIMPLE
SIMPLE Simple scenario used as base.
Ptr< SatAntennaGainPatternContainer > GetAntennaGainPatterns()
TracedCallback< std::string > m_creationSummaryTrace
Trace callback for creation traces (summary).
void SetUtMobility(NodeContainer uts, uint32_t satId, uint32_t beamId)
Sets mobility to created UT nodes.
void EnableCreationTraces()
Enables creation traces to be written in given file.
bool m_detailedCreationTraces
flag to indicate if detailed creation trace should be enabled for scenario creation.
void CreationSummarySink(std::string title)
Sink for creation summary traces.
std::string CreateCreationSummary(std::string title)
Creates trace summary starting with give title.
Ptr< OutputStreamWrapper > m_utTraceStream
Stream wrapper used for UT position traces.
Ptr< SatUserHelper > m_userHelper
User helper.
void SetUtPositionAllocatorForBeam(uint32_t beamId, Ptr< SatListPositionAllocator > posAllocator)
Set custom position allocator for specific beam.
void SetUtMobilityFromPosition(NodeContainer uts, uint32_t satId, uint32_t beamId, std::vector< std::pair< GeoCoordinate, uint32_t > > positionsAndGroupId)
Sets mobility to created UT nodes when position is known.
void EnablePacketTrace()
Enable packet traces.
uint32_t GetBeamCount() const
Get count of the beams (configurations).
SatBeamHelper::MulticastBeamInfoItem_t MulticastBeamInfoItem_t
Ptr< SatAntennaGainPatternContainer > m_antennaGainPatterns
Antenna gain patterns for all spot-beams.
void CreateFullScenario()
Creates satellite objects according to full scenario.
std::map< uint32_t, NodeContainer > m_mobileUtsByBeam
List of mobile UTs by beam ID.
Ptr< SatGroupHelper > GetGroupHelper() const
void CreateSimpleScenario()
Creates satellite objects according to simple scenario.
bool m_scenarioCreated
flag to check if scenario is already created.
Ptr< SatGroupHelper > m_groupHelper
Group helper.
std::string m_satPosFileName
void SetNetworkAddresses(BeamUserInfoMap_t &info, uint32_t gwUsers) const
Set configured network addresses to user and beam helpers.
void CreateUserDefinedScenarioFromListPositions(uint32_t satId, BeamUserInfoMap_t &info, std::string inputFileUtListPositions, bool checkBeam)
Creates satellite objects according to user defined scenario.
void SetMulticastRouteToSourceNetwork(Ptr< Node > source, Ptr< Node > destination)
Set multicast traffic to source's nwtwork by finding source network utilizing given destination node.
void LoadMobileUTsFromFolder(const std::string &folderName, Ptr< RandomVariableStream > utUsers)
Load UTs with a SatTracedMobilityModel associated to them from the files found in the given folder.
Ipv4Address m_utNetworkAddress
Initial network number of UT and UT users, e.g., 10.3.1.0.
uint32_t m_utUsers
Number of users created in end user network (behind every UT) in full or user-defined scenario.
Ptr< NetDevice > FindMatchingDevice(Ptr< NetDevice > devA, Ptr< Node > nodeB)
Find given device's counterpart (device belonging to same network) device from given node.
TracedCallback< std::string > m_creationDetailsTrace
Trace callback for creation traces (details).
std::map< std::pair< uint32_t, uint32_t >, SatBeamUserInfo > BeamUserInfoMap_t
definition for beam map key is pair sat ID / beam ID and value is UT/user info.
static const uint16_t MIN_ADDRESS_PREFIX_LENGTH
std::map< uint32_t, Ptr< SatListPositionAllocator > > m_utPositionsByBeam
User defined UT positions by beam ID.
Ipv4Mask m_gwNetworkMask
Network mask number of GW, router, and GW users.
Ptr< SatBeamHelper > m_beamHelper
Beam helper.
void CreateUserDefinedScenario(BeamUserInfoMap_t &info)
Creates satellite objects according to user defined scenario.
Ptr< Node > LoadMobileUtFromFile(const std::string &filename)
Load an UT with a SatTracedMobilityModel associated to them from the given file.
void DoDispose()
Dispose of this class instance.
std::map< Ptr< NetDevice >, NetDeviceContainer > m_utsDistribution
Map indicating all UT NetDevices associated to each GW NetDevice.
std::map< uint32_t, uint32_t > m_gwSats
Map of closest satellite for each GW.
std::string m_utPosFileName
void SetMulticastGroupRoutes(Ptr< Node > source, NodeContainer receivers, Ipv4Address sourceAddress, Ipv4Address groupAddress)
Set multicast group to satellite network and IP router.
uint32_t m_gwUsers
Number of users created in public network (behind GWs) in full or user-defined scenario.
Ptr< SatBeamHelper > GetBeamHelper() const
bool m_satConstellationEnabled
Use a constellation of satellites.
void EnableDetailedCreationTraces()
Enables creation traces in sub-helpers.
Ptr< SatListPositionAllocator > m_utPositions
User defined UT positions from SatConf (or manually set).
@ LOG_WARNING
LOG_WARNING.
SatLorawanNetDevice to be utilized in the UT and GW nodes for IoT configuration.
Keep track of the current position and velocity of an object in satellite network.
Observes given mobilities and keeps track of certain wanted properties.
Ptr< SatMac > GetMac(void) const
Get a Mac pointer.
Keep track of the current position and velocity of satellite using SGP4 model.
void SetStartDate(std::string startStr)
Set the simulation absolute start time in string format.
void SetTleInfo(const std::string &tle)
Set satellite's TLE information required for its initialization.
Satellite mobility model for which the current position change based on values read from a file.
Callback< Ptr< PropagationDelayModel >, uint32_t, uint32_t, SatEnums::ChannelType_t > PropagationDelayCallback
void UpdateGwRoutes(Address ut, Address oldGateway, Address newGateway)
Update ARP cache and default route on the terrestrial network so packets are properly routed to the U...
void UpdateUtRoutes(Address ut, Address newGateway)
Update ARP cache and default route on an UT so packets are properly routed to the new GW as their nex...
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Ptr< SatMobilityModel > satMobility