Loading...
Searching...
No Matches
satellite-topology.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: Bastien Tauran <bastien.tauran@viveris.fr>
19 */
20
21#include "satellite-topology.h"
22
23#include "ns3/log.h"
24
25#include <iostream>
26#include <limits>
27#include <map>
28#include <ostream>
29#include <set>
30#include <utility>
31
32NS_LOG_COMPONENT_DEFINE("SatTopology");
33
34namespace ns3
35{
36
37NS_OBJECT_ENSURE_REGISTERED(SatTopology);
38
39TypeId
41{
42 static TypeId tid =
43 TypeId("ns3::SatTopology").SetParent<Object>().AddConstructor<SatTopology>();
44 return tid;
45}
46
48 : m_enableMapPrint(false)
49{
50 NS_LOG_FUNCTION(this);
51}
52
54{
55 NS_LOG_FUNCTION(this);
56
57 Reset();
58}
59
60void
62{
63 NS_LOG_FUNCTION(this);
64
65 Reset();
66
67 Object::DoDispose();
68}
69
70void
72{
73 NS_LOG_FUNCTION(this);
74
75 m_gws = NodeContainer();
76 m_gwIds.clear();
77 m_uts = NodeContainer();
78 m_orbiters = NodeContainer();
79 m_gwUsers = NodeContainer();
80 m_utUsers = NodeContainer();
81 m_utToGwMap.clear();
82 m_beamToGwMap.clear();
84
85 m_enableMapPrint = false;
86}
87
88void
90{
91 NS_LOG_FUNCTION(this << standard);
92
93 m_standard = standard;
94}
95
98{
99 NS_LOG_FUNCTION(this);
100
101 return m_standard;
102}
103
104void
106 SatEnums::RegenerationMode_t forwardLinkRegenerationMode)
107{
108 NS_LOG_FUNCTION(this << forwardLinkRegenerationMode);
109
110 m_forwardLinkRegenerationMode = forwardLinkRegenerationMode;
111}
112
115{
116 NS_LOG_FUNCTION(this);
117
119}
120
121void
123{
124 NS_LOG_FUNCTION(this << returnLinkRegenerationMode);
125
126 m_returnLinkRegenerationMode = returnLinkRegenerationMode;
127}
128
131{
132 NS_LOG_FUNCTION(this);
133
135}
136
137void
138SatTopology::AddGwNode(uint32_t gwId, Ptr<Node> gw)
139{
140 NS_LOG_FUNCTION(this << gw);
141
142 m_gwIds.insert(std::make_pair(gwId, gw));
143
144 m_gws = NodeContainer();
145 for (std::map<uint32_t, Ptr<Node>>::const_iterator i = m_gwIds.begin(); i != m_gwIds.end(); i++)
146 {
147 m_gws.Add(i->second);
148 }
149}
150
151void
153{
154 NS_LOG_FUNCTION(this << ut);
155
156 m_uts.Add(ut);
157}
158
159void
161{
162 NS_LOG_FUNCTION(this << orbiter);
163
164 m_orbiters.Add(orbiter);
165}
166
167void
169{
170 NS_LOG_FUNCTION(this << gwUser);
171
172 m_gwUsers.Add(gwUser);
173}
174
175void
176SatTopology::AddUtUserNode(Ptr<Node> utUser, Ptr<Node> ut)
177{
178 NS_LOG_FUNCTION(this << utUser);
179
180 if (m_detailledUtUsers.find(ut) == m_detailledUtUsers.end())
181 {
182 m_detailledUtUsers[ut] = NodeContainer();
183 }
184 m_detailledUtUsers[ut].Add(utUser);
185 m_utUsers.Add(utUser);
186}
187
188void
189SatTopology::ConnectGwToUt(Ptr<Node> ut, Ptr<Node> gw)
190{
191 NS_LOG_FUNCTION(this << ut << gw);
192
193 if (m_utToGwMap.count(ut) > 0)
194 {
195 NS_FATAL_ERROR("UT " << ut << " already in GW to UT map. Connected to GW "
196 << m_utToGwMap[ut]);
197 }
198
199 m_utToGwMap[ut] = gw;
200}
201
202void
203SatTopology::UpdateGwConnectedToUt(Ptr<Node> ut, Ptr<Node> gw)
204{
205 NS_LOG_FUNCTION(this << ut << gw);
206
207 if (m_utToGwMap.count(ut) == 0)
208 {
209 NS_FATAL_ERROR("UT " << ut << " not in GW to UT map.");
210 }
211
212 m_utToGwMap[ut] = gw;
213}
214
215void
217{
218 NS_LOG_FUNCTION(this << ut);
219
220 const std::map<Ptr<Node>, Ptr<Node>>::iterator it = m_utToGwMap.find(ut);
221 if (it == m_utToGwMap.end())
222 {
223 NS_FATAL_ERROR("UT " << ut << " not in GW to UT map.");
224 }
225 else
226 {
227 m_utToGwMap.erase(it);
228 }
229}
230
231Ptr<Node>
232SatTopology::GetGwFromUt(Ptr<Node> ut) const
233{
234 NS_LOG_FUNCTION(this << ut);
235
236 const std::map<Ptr<Node>, Ptr<Node>>::const_iterator it = m_utToGwMap.find(ut);
237 if (it == m_utToGwMap.end())
238 {
239 NS_FATAL_ERROR("UT " << ut << " not in GW to UT map.");
240 }
241 return it->second;
242}
243
244void
245SatTopology::ConnectGwToBeam(uint32_t beamId, Ptr<Node> gw)
246{
247 NS_LOG_FUNCTION(this << beamId << gw);
248
249 if (m_beamToGwMap.count(beamId) > 0)
250 {
251 NS_FATAL_ERROR("Beam " << beamId << " already in GW to beam map. Connected to GW "
252 << m_beamToGwMap[beamId]);
253 }
254
255 m_beamToGwMap[beamId] = gw;
256}
257
258Ptr<Node>
259SatTopology::GetGwFromBeam(uint32_t beamId) const
260{
261 NS_LOG_FUNCTION(this << beamId);
262
263 const std::map<uint32_t, Ptr<Node>>::const_iterator it = m_beamToGwMap.find(beamId);
264 if (it == m_beamToGwMap.end())
265 {
266 NS_FATAL_ERROR("Beam " << beamId << " not in GW to beam map.");
267 }
268 return it->second;
269}
270
271void
272SatTopology::AddOrbiterFeederMacPair(Ptr<SatOrbiterFeederMac> mac, Ptr<SatOrbiterFeederMac> usedMac)
273{
274 NS_LOG_FUNCTION(this << mac << usedMac);
275
276 if (m_orbiterFeederMacMap.count(mac) > 0)
277 {
278 NS_FATAL_ERROR("Feeder MAC " << mac << " already associated to "
279 << m_orbiterFeederMacMap[mac]);
280 }
281
282 m_orbiterFeederMacMap[mac] = usedMac;
283}
284
285Ptr<SatOrbiterFeederMac>
286SatTopology::GetOrbiterFeederMacUsed(Ptr<SatOrbiterFeederMac> mac) const
287{
288 NS_LOG_FUNCTION(this << mac);
289
290 const std::map<Ptr<SatOrbiterFeederMac>, Ptr<SatOrbiterFeederMac>>::const_iterator it =
291 m_orbiterFeederMacMap.find(mac);
292 if (it == m_orbiterFeederMacMap.end())
293 {
294 NS_FATAL_ERROR("Feeder MAC " << mac << " not found");
295 }
296
297 return it->second;
298}
299
300Mac48Address
302{
303 NS_LOG_FUNCTION(this << utId);
304
305 Ptr<Node> utNode = GetNodeFromId(utId);
306 uint32_t utBeamId = GetUtBeamId(utNode);
307 Ptr<Node> gwNode = GetGwFromBeam(utBeamId);
308
309 uint32_t gwSatId =
310 GetClosestSat(GeoCoordinate(gwNode->GetObject<SatMobilityModel>()->GetPosition()));
311 Ptr<Node> gwOrbiter = m_orbiters.Get(gwSatId);
312
313 Ptr<SatOrbiterFeederMac> mac = GetOrbiterFeederMac(gwOrbiter, utBeamId);
314 uint32_t usedBeamId = GetOrbiterFeederMacUsed(mac)->GetBeamId();
315
316 Ptr<SatGwMac> gwMac = GetDvbGwMac(gwNode, gwSatId, usedBeamId);
317
318 NS_ASSERT_MSG(gwMac != nullptr, "Got a null SatGwMac");
319
320 return Mac48Address::ConvertFrom(gwMac->GetAddress());
321}
322
323NodeContainer
325{
326 NS_LOG_FUNCTION(this);
327
328 return m_gws;
329}
330
331NodeContainer
333{
334 NS_LOG_FUNCTION(this);
335
336 return m_uts;
337}
338
339NodeContainer
341{
342 NS_LOG_FUNCTION(this);
343
344 return m_orbiters;
345}
346
347NodeContainer
349{
350 NS_LOG_FUNCTION(this);
351
352 return m_gwUsers;
353}
354
355NodeContainer
357{
358 NS_LOG_FUNCTION(this);
359
360 return m_utUsers;
361}
362
363NodeContainer
364SatTopology::GetUtUserNodes(NodeContainer uts) const
365{
366 NS_LOG_FUNCTION(this);
367
368 NodeContainer total;
369 for (NodeContainer::Iterator i = uts.Begin(); i != uts.End(); i++)
370 {
371 total.Add(GetUtUserNodes(*i));
372 }
373 return total;
374}
375
376NodeContainer
378{
379 NS_LOG_FUNCTION(this << ut);
380
381 std::map<Ptr<Node>, NodeContainer>::const_iterator it = m_detailledUtUsers.find(ut);
382
383 if (it == m_detailledUtUsers.end())
384 {
385 NS_FATAL_ERROR("UT which users are requested in not installed!!!");
386 }
387
388 return it->second;
389}
390
391Ptr<Node>
392SatTopology::GetUtNode(Ptr<Node> utUser) const
393{
394 for (std::map<Ptr<Node>, NodeContainer>::const_iterator it = m_detailledUtUsers.begin();
395 it != m_detailledUtUsers.end();
396 it++)
397 {
398 for (NodeContainer::Iterator it2 = it->second.Begin(); it2 != it->second.End(); it2++)
399 {
400 if (*it2 == utUser)
401 {
402 return it->first;
403 }
404 }
405 }
406
407 return nullptr;
408}
409
410uint32_t
412{
413 NS_LOG_FUNCTION(this);
414
415 return m_gws.GetN();
416}
417
418uint32_t
420{
421 NS_LOG_FUNCTION(this);
422
423 return m_uts.GetN();
424}
425
426uint32_t
428{
429 NS_LOG_FUNCTION(this);
430
431 return m_orbiters.GetN();
432}
433
434uint32_t
436{
437 NS_LOG_FUNCTION(this);
438
439 return m_gwUsers.GetN();
440}
441
442uint32_t
444{
445 NS_LOG_FUNCTION(this);
446
447 return m_utUsers.GetN();
448}
449
450Ptr<Node>
451SatTopology::GetGwNode(uint32_t nodeId) const
452{
453 NS_LOG_FUNCTION(this << nodeId);
454
455 return m_gws.Get(nodeId);
456}
457
458Ptr<Node>
459SatTopology::GetUtNode(uint32_t nodeId) const
460{
461 NS_LOG_FUNCTION(this << nodeId);
462
463 return m_uts.Get(nodeId);
464}
465
466Ptr<Node>
467SatTopology::GetOrbiterNode(uint32_t nodeId) const
468{
469 NS_LOG_FUNCTION(this << nodeId);
470
471 return m_orbiters.Get(nodeId);
472}
473
474Ptr<Node>
475SatTopology::GetGwUserNode(uint32_t nodeId) const
476{
477 NS_LOG_FUNCTION(this << nodeId);
478
479 return m_gwUsers.Get(nodeId);
480}
481
482Ptr<Node>
483SatTopology::GetUtUserNode(uint32_t nodeId) const
484{
485 NS_LOG_FUNCTION(this << nodeId);
486
487 return m_utUsers.Get(nodeId);
488}
489
490Ptr<Node>
491SatTopology::GetNodeFromId(uint32_t nodeId) const
492{
493 NS_LOG_FUNCTION(this << nodeId);
494
495 NodeContainer::Iterator it;
496 for (it = m_gws.Begin(); it != m_gws.End(); it++)
497 {
498 if ((*it)->GetId() == nodeId)
499 {
500 return *it;
501 }
502 }
503
504 for (it = m_uts.Begin(); it != m_uts.End(); it++)
505 {
506 if ((*it)->GetId() == nodeId)
507 {
508 return *it;
509 }
510 }
511
512 for (it = m_orbiters.Begin(); it != m_orbiters.End(); it++)
513 {
514 if ((*it)->GetId() == nodeId)
515 {
516 return *it;
517 }
518 }
519
520 for (it = m_gwUsers.Begin(); it != m_gwUsers.End(); it++)
521 {
522 if ((*it)->GetId() == nodeId)
523 {
524 return *it;
525 }
526 }
527
528 for (it = m_utUsers.Begin(); it != m_utUsers.End(); it++)
529 {
530 if ((*it)->GetId() == nodeId)
531 {
532 return *it;
533 }
534 }
535
536 NS_FATAL_ERROR("Node " << nodeId << " not found");
537
538 return nullptr;
539}
540
541void
543 uint32_t gwSatId,
544 uint32_t gwBeamId,
545 uint32_t utSatId,
546 uint32_t utBeamId,
547 Ptr<SatNetDevice> netDevice,
548 Ptr<SatGwLlc> llc,
549 Ptr<SatGwMac> mac,
550 Ptr<SatGwPhy> phy)
551{
552 NS_LOG_FUNCTION(this << gw << gwSatId << gwBeamId << utSatId << utBeamId << netDevice << llc
553 << mac << phy);
554
555 std::map<Ptr<Node>, GwLayers_s>::iterator it = m_gwLayers.find(gw);
556 GwLayers_s layers;
557 if (it != m_gwLayers.end())
558 {
559 layers = it->second;
560 NS_ASSERT_MSG(
561 layers.m_satId == gwSatId,
562 "Gw has already a different GW satellite ID that the one in argument of this method");
563 NS_ASSERT_MSG(
564 layers.m_beamId == gwBeamId,
565 "Gw has already a different GW beam ID that the one in argument of this method");
566 NS_ASSERT_MSG(layers.m_netDevice.find(std::make_pair(utSatId, utBeamId)) ==
567 layers.m_netDevice.end(),
568 "Net device already stored for this GW + UT satellite and beam");
569 NS_ASSERT_MSG(layers.m_llc.find(std::make_pair(utSatId, utBeamId)) == layers.m_llc.end(),
570 "LLC already stored for this GW + UT satellite and beam");
571 NS_ASSERT_MSG(layers.m_dvbMac.find(std::make_pair(utSatId, utBeamId)) ==
572 layers.m_dvbMac.end(),
573 "MAC already stored for this GW + UT satellite and beam");
574 NS_ASSERT_MSG(layers.m_phy.find(std::make_pair(utSatId, utBeamId)) == layers.m_phy.end(),
575 "Physical layer already stored for this GW + UT satellite and beam");
576 }
577 else
578 {
579 layers.m_satId = gwSatId;
580 layers.m_beamId = gwBeamId;
581 }
582
583 layers.m_netDevice.insert(std::make_pair(std::make_pair(utSatId, utBeamId), netDevice));
584 layers.m_llc.insert(std::make_pair(std::make_pair(utSatId, utBeamId), llc));
585 layers.m_dvbMac.insert(std::make_pair(std::make_pair(utSatId, utBeamId), mac));
586 layers.m_phy.insert(std::make_pair(std::make_pair(utSatId, utBeamId), phy));
587
588 m_gwLayers[gw] = layers;
589}
590
591void
593 uint32_t gwSatId,
594 uint32_t gwBeamId,
595 uint32_t utSatId,
596 uint32_t utBeamId,
597 Ptr<SatNetDevice> netDevice,
598 Ptr<LorawanGroundMacGateway> mac,
599 Ptr<SatGwPhy> phy)
600{
601 NS_LOG_FUNCTION(this << gw << gwSatId << gwBeamId << utSatId << utBeamId << netDevice << mac
602 << phy);
603
604 std::map<Ptr<Node>, GwLayers_s>::iterator it = m_gwLayers.find(gw);
605 GwLayers_s layers;
606 if (it != m_gwLayers.end())
607 {
608 layers = it->second;
609 NS_ASSERT_MSG(
610 layers.m_satId == gwSatId,
611 "Gw has already a different GW satellite ID that the one in argument of this method");
612 NS_ASSERT_MSG(
613 layers.m_beamId == gwBeamId,
614 "Gw has already a different GW beam ID that the one in argument of this method");
615 NS_ASSERT_MSG(layers.m_netDevice.find(std::make_pair(utSatId, utBeamId)) ==
616 layers.m_netDevice.end(),
617 "Net device already stored for this GW + UT satellite and beam");
618 NS_ASSERT_MSG(layers.m_loraMac.find(std::make_pair(utSatId, utBeamId)) ==
619 layers.m_loraMac.end(),
620 "MAC already stored for this GW + UT satellite and beam");
621 NS_ASSERT_MSG(layers.m_phy.find(std::make_pair(utSatId, utBeamId)) == layers.m_phy.end(),
622 "Physical layer already stored for this GW + UT satellite and beam");
623 }
624 else
625 {
626 layers.m_satId = gwSatId;
627 layers.m_beamId = gwBeamId;
628 }
629
630 layers.m_netDevice.insert(std::make_pair(std::make_pair(utSatId, utBeamId), netDevice));
631 layers.m_loraMac.insert(std::make_pair(std::make_pair(utSatId, utBeamId), mac));
632 layers.m_phy.insert(std::make_pair(std::make_pair(utSatId, utBeamId), phy));
633
634 m_gwLayers[gw] = layers;
635}
636
637void
638SatTopology::UpdateGwSatAndBeam(Ptr<Node> gw, uint32_t satId, uint32_t beamId)
639{
640 NS_LOG_FUNCTION(this << gw << satId << beamId);
641
642 NS_ASSERT_MSG(m_gwLayers.find(gw) != m_gwLayers.end(), "Layers do not exist for this GW");
643
644 m_gwLayers[gw].m_satId = satId;
645 m_gwLayers[gw].m_beamId = beamId;
646}
647
648uint32_t
649SatTopology::GetGwSatId(Ptr<Node> gw) const
650{
651 NS_LOG_FUNCTION(this << gw);
652
653 NS_ASSERT_MSG(m_gwLayers.find(gw) != m_gwLayers.end(), "Layers do not exist for this GW");
654
655 return m_gwLayers.at(gw).m_satId;
656}
657
658uint32_t
659SatTopology::GetGwBeamId(Ptr<Node> gw) const
660{
661 NS_LOG_FUNCTION(this << gw);
662
663 NS_ASSERT_MSG(m_gwLayers.find(gw) != m_gwLayers.end(), "Layers do not exist for this GW");
664
665 return m_gwLayers.at(gw).m_beamId;
666}
667
668Ptr<SatNetDevice>
669SatTopology::GetGwNetDevice(Ptr<Node> gw, uint32_t utSatId, uint32_t utBeamId) const
670{
671 NS_LOG_FUNCTION(this << gw << utSatId << utBeamId);
672
673 std::map<Ptr<Node>, GwLayers_s>::const_iterator it = m_gwLayers.find(gw);
674 NS_ASSERT_MSG(it != m_gwLayers.end(),
675 "Layers do not exist for this GW and pair UT satellite+beam");
676
677 GwLayers_s layers = it->second;
678 NS_ASSERT_MSG(layers.m_netDevice.find(std::make_pair(utSatId, utBeamId)) !=
679 layers.m_netDevice.end(),
680 "Net device not stored for this GW + UT satellite and beam");
681
682 return layers.m_netDevice.at(std::make_pair(utSatId, utBeamId));
683}
684
685Ptr<SatGwLlc>
686SatTopology::GetGwLlc(Ptr<Node> gw, uint32_t utSatId, uint32_t utBeamId) const
687{
688 NS_LOG_FUNCTION(this << gw << utSatId << utBeamId);
689
690 std::map<Ptr<Node>, GwLayers_s>::const_iterator it = m_gwLayers.find(gw);
691 NS_ASSERT_MSG(it != m_gwLayers.end(),
692 "Layers do not exist for this GW and pair UT satellite+beam");
693
694 GwLayers_s layers = it->second;
695 NS_ASSERT_MSG(layers.m_llc.find(std::make_pair(utSatId, utBeamId)) != layers.m_llc.end(),
696 "LLC not stored for this GW + UT satellite and beam");
697
698 return layers.m_llc.at(std::make_pair(utSatId, utBeamId));
699}
700
701Ptr<SatGwMac>
702SatTopology::GetDvbGwMac(Ptr<Node> gw, uint32_t utSatId, uint32_t utBeamId) const
703{
704 NS_LOG_FUNCTION(this << gw << utSatId << utBeamId);
705
706 std::map<Ptr<Node>, GwLayers_s>::const_iterator it = m_gwLayers.find(gw);
707 NS_ASSERT_MSG(it != m_gwLayers.end(),
708 "Layers do not exist for this GW and pair UT satellite+beam");
709
710 GwLayers_s layers = it->second;
711 NS_ASSERT_MSG(layers.m_dvbMac.find(std::make_pair(utSatId, utBeamId)) != layers.m_dvbMac.end(),
712 "MAC not stored for this GW + UT satellite and beam");
713
714 return layers.m_dvbMac.at(std::make_pair(utSatId, utBeamId));
715}
716
717Ptr<LorawanGroundMacGateway>
718SatTopology::GetLoraGwMac(Ptr<Node> gw, uint32_t utSatId, uint32_t utBeamId) const
719{
720 NS_LOG_FUNCTION(this << gw << utSatId << utBeamId);
721
722 std::map<Ptr<Node>, GwLayers_s>::const_iterator it = m_gwLayers.find(gw);
723 NS_ASSERT_MSG(it != m_gwLayers.end(),
724 "Layers do not exist for this GW and pair UT satellite+beam");
725
726 GwLayers_s layers = it->second;
727 NS_ASSERT_MSG(layers.m_loraMac.find(std::make_pair(utSatId, utBeamId)) !=
728 layers.m_loraMac.end(),
729 "MAC not stored for this GW + UT satellite and beam");
730
731 return layers.m_loraMac.at(std::make_pair(utSatId, utBeamId));
732}
733
734Ptr<SatGwPhy>
735SatTopology::GetGwPhy(Ptr<Node> gw, uint32_t utSatId, uint32_t utBeamId) const
736{
737 NS_LOG_FUNCTION(this << gw << utSatId << utBeamId);
738
739 std::map<Ptr<Node>, GwLayers_s>::const_iterator it = m_gwLayers.find(gw);
740 NS_ASSERT_MSG(it != m_gwLayers.end(),
741 "Layers do not exist for this GW and pair UT satellite+beam");
742
743 GwLayers_s layers = it->second;
744 NS_ASSERT_MSG(layers.m_phy.find(std::make_pair(utSatId, utBeamId)) != layers.m_phy.end(),
745 "Physical layer not stored for this GW + UT satellite and beam");
746
747 return layers.m_phy.at(std::make_pair(utSatId, utBeamId));
748}
749
750void
752 uint32_t satId,
753 uint32_t beamId,
754 uint32_t groupId,
755 Ptr<SatNetDevice> netDevice,
756 Ptr<SatUtLlc> llc,
757 Ptr<SatUtMac> mac,
758 Ptr<SatUtPhy> phy)
759{
760 NS_LOG_FUNCTION(this << ut << satId << beamId << groupId << netDevice << llc << mac << phy);
761
762 NS_ASSERT_MSG(m_utLayers.find(ut) == m_utLayers.end(), "Layers already added to this UT node");
763
764 UtLayers_s layers;
765 layers.m_satId = satId;
766 layers.m_beamId = beamId;
767 layers.m_groupId = groupId;
768 layers.m_netDevice = netDevice;
769 layers.m_llc = llc;
770 layers.m_dvbMac = mac;
771 layers.m_phy = phy;
772
773 m_utLayers.insert(std::make_pair(ut, layers));
774}
775
776void
778 uint32_t satId,
779 uint32_t beamId,
780 uint32_t groupId,
781 Ptr<SatNetDevice> netDevice,
782 Ptr<LorawanMacEndDevice> mac,
783 Ptr<SatUtPhy> phy)
784{
785 NS_LOG_FUNCTION(this << ut << satId << beamId << groupId << netDevice << mac << phy);
786
787 NS_ASSERT_MSG(m_utLayers.find(ut) == m_utLayers.end(), "Layers already added to this UT node");
788
789 UtLayers_s layers;
790 layers.m_satId = satId;
791 layers.m_beamId = beamId;
792 layers.m_groupId = groupId;
793 layers.m_netDevice = netDevice;
794 layers.m_loraMac = mac;
795 layers.m_phy = phy;
796
797 m_utLayers.insert(std::make_pair(ut, layers));
798}
799
800void
801SatTopology::UpdateUtSatAndBeam(Ptr<Node> ut, uint32_t satId, uint32_t beamId)
802{
803 NS_LOG_FUNCTION(this << ut << satId << beamId);
804
805 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
806
807 m_utLayers[ut].m_satId = satId;
808 m_utLayers[ut].m_beamId = beamId;
809}
810
811void
812SatTopology::UpdateUtGroup(Ptr<Node> ut, uint32_t groupId)
813{
814 NS_LOG_FUNCTION(this << ut << groupId);
815
816 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
817
818 m_utLayers[ut].m_groupId = groupId;
819}
820
821uint32_t
822SatTopology::GetUtSatId(Ptr<Node> ut) const
823{
824 NS_LOG_FUNCTION(this << ut);
825
826 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
827
828 return m_utLayers.at(ut).m_satId;
829}
830
831uint32_t
832SatTopology::GetUtBeamId(Ptr<Node> ut) const
833{
834 NS_LOG_FUNCTION(this << ut);
835
836 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
837
838 return m_utLayers.at(ut).m_beamId;
839}
840
841uint32_t
842SatTopology::GetUtGroupId(Ptr<Node> ut) const
843{
844 NS_LOG_FUNCTION(this << ut);
845
846 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
847
848 return m_utLayers.at(ut).m_groupId;
849}
850
851Ptr<SatNetDevice>
853{
854 NS_LOG_FUNCTION(this << ut);
855
856 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
857
858 return m_utLayers.at(ut).m_netDevice;
859}
860
861Ptr<SatUtLlc>
862SatTopology::GetUtLlc(Ptr<Node> ut) const
863{
864 NS_LOG_FUNCTION(this << ut);
865
866 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
867
868 return m_utLayers.at(ut).m_llc;
869}
870
871Ptr<SatUtMac>
872SatTopology::GetDvbUtMac(Ptr<Node> ut) const
873{
874 NS_LOG_FUNCTION(this << ut);
875
876 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
877
878 return m_utLayers.at(ut).m_dvbMac;
879}
880
881Ptr<LorawanMacEndDevice>
882SatTopology::GetLoraUtMac(Ptr<Node> ut) const
883{
884 NS_LOG_FUNCTION(this << ut);
885
886 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
887
888 return m_utLayers.at(ut).m_loraMac;
889}
890
891Ptr<SatUtPhy>
892SatTopology::GetUtPhy(Ptr<Node> ut) const
893{
894 NS_LOG_FUNCTION(this << ut);
895
896 NS_ASSERT_MSG(m_utLayers.find(ut) != m_utLayers.end(), "Layers do not exist for this UT");
897
898 return m_utLayers.at(ut).m_phy;
899}
900
901void
903 uint32_t satId,
904 uint32_t utBeamId,
905 Ptr<SatOrbiterNetDevice> netDevice,
906 Ptr<SatOrbiterFeederLlc> llc,
907 Ptr<SatOrbiterFeederMac> mac,
908 Ptr<SatOrbiterFeederPhy> phy)
909{
910 NS_LOG_FUNCTION(this << orbiter << satId << utBeamId << netDevice << llc << mac << phy);
911
912 std::map<Ptr<Node>, OrbiterLayers_s>::iterator it = m_orbiterLayers.find(orbiter);
913 OrbiterLayers_s layers;
914 if (it != m_orbiterLayers.end())
915 {
916 layers = it->second;
917 NS_ASSERT_MSG(
918 layers.m_satId == satId,
919 "Orbiter has already a different satellite ID that the one in argument of this method");
920 NS_ASSERT_MSG(layers.m_netDevice == netDevice,
921 "Orbiter has already a different SatOrbiterNetDevice that the one in "
922 "argument of this method");
923 NS_ASSERT_MSG(layers.m_feederLlc.find(utBeamId) == layers.m_feederLlc.end(),
924 "Feeder LLC already stored for this pair orbiter/beam");
925 NS_ASSERT_MSG(layers.m_feederMac.find(utBeamId) == layers.m_feederMac.end(),
926 "Feeder MAC already stored for this pair orbiter/beam");
927 NS_ASSERT_MSG(layers.m_feederPhy.find(utBeamId) == layers.m_feederPhy.end(),
928 "Feeder physical layer already stored for this pair orbiter/beam");
929 }
930 else
931 {
932 layers.m_satId = satId;
933 layers.m_netDevice = netDevice;
934 }
935
936 layers.m_feederLlc.insert(std::make_pair(utBeamId, llc));
937 layers.m_feederMac.insert(std::make_pair(utBeamId, mac));
938 layers.m_feederPhy.insert(std::make_pair(utBeamId, phy));
939
940 m_orbiterLayers[orbiter] = layers;
941}
942
943void
945 uint32_t satId,
946 uint32_t beamId,
947 Ptr<SatOrbiterNetDevice> netDevice,
948 Ptr<SatOrbiterUserLlc> llc,
949 Ptr<SatOrbiterUserMac> mac,
950 Ptr<SatOrbiterUserPhy> phy)
951{
952 NS_LOG_FUNCTION(this << orbiter << satId << beamId << netDevice << llc << mac << phy);
953
954 std::map<Ptr<Node>, OrbiterLayers_s>::iterator it = m_orbiterLayers.find(orbiter);
955 OrbiterLayers_s layers;
956 if (it != m_orbiterLayers.end())
957 {
958 layers = it->second;
959 NS_ASSERT_MSG(
960 layers.m_satId == satId,
961 "Orbiter has already a different satellite ID that the one in argument of this method");
962 NS_ASSERT_MSG(layers.m_netDevice == netDevice,
963 "Orbiter has already a different SatOrbiterNetDevice that the one in "
964 "argument of this method");
965 NS_ASSERT_MSG(layers.m_userLlc.find(beamId) == layers.m_userLlc.end(),
966 "User LLC already stored for this pair orbiter/beam");
967 NS_ASSERT_MSG(layers.m_dvbUserMac.find(beamId) == layers.m_dvbUserMac.end(),
968 "User MAC already stored for this pair orbiter/beam");
969 NS_ASSERT_MSG(layers.m_userPhy.find(beamId) == layers.m_userPhy.end(),
970 "User physical layer already stored for this pair orbiter/beam");
971 }
972 else
973 {
974 layers.m_satId = satId;
975 layers.m_netDevice = netDevice;
976 }
977
978 layers.m_userLlc.insert(std::make_pair(beamId, llc));
979 layers.m_dvbUserMac.insert(std::make_pair(beamId, mac));
980 layers.m_userPhy.insert(std::make_pair(beamId, phy));
981
982 m_orbiterLayers[orbiter] = layers;
983}
984
985void
987 uint32_t satId,
988 uint32_t beamId,
989 Ptr<SatOrbiterNetDevice> netDevice,
990 Ptr<LorawanOrbiterMacGateway> mac,
991 Ptr<SatOrbiterUserPhy> phy)
992{
993 NS_LOG_FUNCTION(this << orbiter << satId << beamId << netDevice << mac << phy);
994
995 std::map<Ptr<Node>, OrbiterLayers_s>::iterator it = m_orbiterLayers.find(orbiter);
996 OrbiterLayers_s layers;
997 if (it != m_orbiterLayers.end())
998 {
999 layers = it->second;
1000 NS_ASSERT_MSG(
1001 layers.m_satId == satId,
1002 "Orbiter has already a different satellite ID that the one in argument of this method");
1003 NS_ASSERT_MSG(layers.m_netDevice == netDevice,
1004 "Orbiter has already a different SatOrbiterNetDevice that the one in "
1005 "argument of this method");
1006 NS_ASSERT_MSG(layers.m_loraUserMac.find(beamId) == layers.m_loraUserMac.end(),
1007 "User MAC already stored for this pair orbiter/beam");
1008 NS_ASSERT_MSG(layers.m_userPhy.find(beamId) == layers.m_userPhy.end(),
1009 "User physical layer already stored for this pair orbiter/beam");
1010 }
1011 else
1012 {
1013 layers.m_satId = satId;
1014 layers.m_netDevice = netDevice;
1015 }
1016
1017 layers.m_loraUserMac.insert(std::make_pair(beamId, mac));
1018 layers.m_userPhy.insert(std::make_pair(beamId, phy));
1019
1020 m_orbiterLayers[orbiter] = layers;
1021}
1022
1023uint32_t
1024SatTopology::GetOrbiterSatId(Ptr<Node> orbiter) const
1025{
1026 NS_LOG_FUNCTION(this << orbiter);
1027
1028 NS_ASSERT_MSG(m_orbiterLayers.find(orbiter) != m_orbiterLayers.end(),
1029 "Layers do not exist for this UT");
1030
1031 return m_orbiterLayers.at(orbiter).m_satId;
1032}
1033
1034Ptr<SatOrbiterNetDevice>
1035SatTopology::GetOrbiterNetDevice(Ptr<Node> orbiter) const
1036{
1037 NS_LOG_FUNCTION(this << orbiter);
1038
1039 NS_ASSERT_MSG(m_orbiterLayers.find(orbiter) != m_orbiterLayers.end(),
1040 "Layers do not exist for this UT");
1041
1042 return m_orbiterLayers.at(orbiter).m_netDevice;
1043}
1044
1045Ptr<SatOrbiterFeederLlc>
1046SatTopology::GetOrbiterFeederLlc(Ptr<Node> orbiter, uint32_t utBeamId) const
1047{
1048 NS_LOG_FUNCTION(this << orbiter << utBeamId);
1049
1050 std::map<Ptr<Node>, OrbiterLayers_s>::const_iterator it = m_orbiterLayers.find(orbiter);
1051 NS_ASSERT_MSG(it != m_orbiterLayers.end(), "Layers do not exist for this UT");
1052
1053 OrbiterLayers_s layers = it->second;
1054 NS_ASSERT_MSG(layers.m_feederLlc.find(utBeamId) != layers.m_feederLlc.end(),
1055 "Feeder LLC not stored for this pair orbiter/beam");
1056
1057 return layers.m_feederLlc.at(utBeamId);
1058}
1059
1060Ptr<SatOrbiterUserLlc>
1061SatTopology::GetOrbiterUserLlc(Ptr<Node> orbiter, uint32_t beamId) const
1062{
1063 NS_LOG_FUNCTION(this << orbiter << beamId);
1064
1065 std::map<Ptr<Node>, OrbiterLayers_s>::const_iterator it = m_orbiterLayers.find(orbiter);
1066 NS_ASSERT_MSG(it != m_orbiterLayers.end(), "Layers do not exist for this UT");
1067
1068 OrbiterLayers_s layers = it->second;
1069 NS_ASSERT_MSG(layers.m_userLlc.find(beamId) != layers.m_userLlc.end(),
1070 "Feeder LLC not stored for this pair orbiter/beam");
1071
1072 return layers.m_userLlc.at(beamId);
1073}
1074
1075Ptr<SatOrbiterFeederMac>
1076SatTopology::GetOrbiterFeederMac(Ptr<Node> orbiter, uint32_t utBeamId) const
1077{
1078 NS_LOG_FUNCTION(this << orbiter << utBeamId);
1079
1080 std::map<Ptr<Node>, OrbiterLayers_s>::const_iterator it = m_orbiterLayers.find(orbiter);
1081 NS_ASSERT_MSG(it != m_orbiterLayers.end(), "Layers do not exist for this UT");
1082
1083 OrbiterLayers_s layers = it->second;
1084
1085 NS_ASSERT_MSG(layers.m_feederMac.find(utBeamId) != layers.m_feederMac.end(),
1086 "Feeder MAC not stored for this pair orbiter/beam");
1087
1088 return layers.m_feederMac.at(utBeamId);
1089}
1090
1091Ptr<SatOrbiterUserMac>
1092SatTopology::GetDvbOrbiterUserMac(Ptr<Node> orbiter, uint32_t beamId) const
1093{
1094 NS_LOG_FUNCTION(this << orbiter << beamId);
1095
1096 std::map<Ptr<Node>, OrbiterLayers_s>::const_iterator it = m_orbiterLayers.find(orbiter);
1097 NS_ASSERT_MSG(it != m_orbiterLayers.end(), "Layers do not exist for this UT");
1098
1099 OrbiterLayers_s layers = it->second;
1100 NS_ASSERT_MSG(layers.m_dvbUserMac.find(beamId) != layers.m_dvbUserMac.end(),
1101 "Feeder MAC not stored for this pair orbiter/beam");
1102
1103 return layers.m_dvbUserMac.at(beamId);
1104}
1105
1106Ptr<LorawanOrbiterMacGateway>
1107SatTopology::GetLoraOrbiterUserMac(Ptr<Node> orbiter, uint32_t beamId) const
1108{
1109 NS_LOG_FUNCTION(this << orbiter << beamId);
1110
1111 std::map<Ptr<Node>, OrbiterLayers_s>::const_iterator it = m_orbiterLayers.find(orbiter);
1112 NS_ASSERT_MSG(it != m_orbiterLayers.end(), "Layers do not exist for this UT");
1113
1114 OrbiterLayers_s layers = it->second;
1115 NS_ASSERT_MSG(layers.m_loraUserMac.find(beamId) != layers.m_loraUserMac.end(),
1116 "Feeder MAC not stored for this pair orbiter/beam");
1117
1118 return layers.m_loraUserMac.at(beamId);
1119}
1120
1121Ptr<SatOrbiterFeederPhy>
1122SatTopology::GetOrbiterFeederPhy(Ptr<Node> orbiter, uint32_t utBeamId) const
1123{
1124 NS_LOG_FUNCTION(this << orbiter << utBeamId);
1125
1126 std::map<Ptr<Node>, OrbiterLayers_s>::const_iterator it = m_orbiterLayers.find(orbiter);
1127 NS_ASSERT_MSG(it != m_orbiterLayers.end(), "Layers do not exist for this UT");
1128
1129 OrbiterLayers_s layers = it->second;
1130 NS_ASSERT_MSG(layers.m_feederPhy.find(utBeamId) != layers.m_feederPhy.end(),
1131 "Feeder PHY not stored for this pair orbiter/beam");
1132
1133 return layers.m_feederPhy.at(utBeamId);
1134}
1135
1136Ptr<SatOrbiterUserPhy>
1137SatTopology::GetOrbiterUserPhy(Ptr<Node> orbiter, uint32_t beamId) const
1138{
1139 NS_LOG_FUNCTION(this << orbiter << beamId);
1140
1141 std::map<Ptr<Node>, OrbiterLayers_s>::const_iterator it = m_orbiterLayers.find(orbiter);
1142 NS_ASSERT_MSG(it != m_orbiterLayers.end(), "Layers do not exist for this UT");
1143
1144 OrbiterLayers_s layers = it->second;
1145 NS_ASSERT_MSG(layers.m_userPhy.find(beamId) != layers.m_userPhy.end(),
1146 "Feeder PHY not stored for this pair orbiter/beam");
1147
1148 return layers.m_userPhy.at(beamId);
1149}
1150
1151void
1152SatTopology::PrintTopology(std::ostream& os) const
1153{
1154 NS_LOG_FUNCTION(this);
1155
1156 os << "Satellite topology" << std::endl;
1157 os << "==================" << std::endl;
1158
1159 os << "Satellites" << std::endl;
1160 Ptr<Node> orbiter;
1161 for (NodeContainer::Iterator itOrbiter = m_orbiters.Begin(); itOrbiter != m_orbiters.End();
1162 itOrbiter++)
1163 {
1164 orbiter = *itOrbiter;
1165 const OrbiterLayers_s layers = m_orbiterLayers.at(orbiter);
1166
1167 os << " SAT: ID = " << layers.m_satId;
1168 os << ", at " << GeoCoordinate(orbiter->GetObject<SatMobilityModel>()->GetPosition())
1169 << std::endl;
1170 os << " Devices to ground stations " << std::endl;
1171
1172 os << " " << layers.m_netDevice->GetAddress() << std::endl;
1173 for (std::pair<uint32_t, Ptr<SatOrbiterFeederMac>> feederMac : layers.m_feederMac)
1174 {
1175 os << " Feeder at " << feederMac.second->GetAddress() << ", beam "
1176 << feederMac.first << std::endl;
1177 }
1178
1179 os << " Feeder connected to" << std::endl;
1180 std::set<Mac48Address> gwConnected = layers.m_netDevice->GetGwConnected();
1181 for (std::set<Mac48Address>::iterator it = gwConnected.begin(); it != gwConnected.end();
1182 it++)
1183 {
1184 os << " " << *it << std::endl;
1185 }
1186
1187 if (m_standard == SatEnums::LORA &&
1189 {
1190 for (std::pair<uint32_t, Ptr<LorawanOrbiterMacGateway>> userMac : layers.m_loraUserMac)
1191 {
1192 os << " User at " << userMac.second->GetAddress() << ", beam "
1193 << userMac.first << std::endl;
1194 }
1195 }
1196 else
1197 {
1198 for (std::pair<uint32_t, Ptr<SatOrbiterUserMac>> userMac : layers.m_dvbUserMac)
1199 {
1200 os << " User at " << userMac.second->GetAddress() << ", beam "
1201 << userMac.first << std::endl;
1202 }
1203 }
1204
1205 os << " User connected to" << std::endl;
1206 std::set<Mac48Address> utConnected = layers.m_netDevice->GetUtConnected();
1207 for (std::set<Mac48Address>::iterator it = utConnected.begin(); it != utConnected.end();
1208 it++)
1209 {
1210 os << " " << *it << std::endl;
1211 }
1212
1213 os << " ISLs " << std::endl;
1214 for (uint32_t j = 0; j < orbiter->GetNDevices(); j++)
1215 {
1216 Ptr<PointToPointIslNetDevice> islNetDevice =
1217 DynamicCast<PointToPointIslNetDevice>(orbiter->GetDevice(j));
1218 if (islNetDevice)
1219 {
1220 os << " " << islNetDevice->GetAddress() << " to SAT "
1221 << islNetDevice->GetDestinationNode()->GetId() << std::endl;
1222 }
1223 }
1224 }
1225
1226 os << "GWs" << std::endl;
1227 Ptr<Node> gwNode;
1228 for (NodeContainer::Iterator itGw = m_gws.Begin(); itGw != m_gws.End(); itGw++)
1229 {
1230 gwNode = *itGw;
1231 const GwLayers_s layers = m_gwLayers.at(gwNode);
1232 os << " GW: ID = " << gwNode->GetId();
1233 os << ", at " << GeoCoordinate(gwNode->GetObject<SatMobilityModel>()->GetPosition())
1234 << std::endl;
1235 os << " Devices " << std::endl;
1236
1238 {
1239 for (std::pair<std::pair<uint32_t, uint32_t>, Ptr<LorawanGroundMacGateway>> mac :
1240 layers.m_loraMac)
1241 {
1242 uint32_t satId = mac.first.first;
1243 uint32_t beamId = mac.first.second;
1244 os << " " << mac.second->GetAddress() << ", sat: " << satId
1245 << ", beam: " << beamId << std::endl;
1246 }
1247 }
1248 else
1249 {
1250 for (std::pair<std::pair<uint32_t, uint32_t>, Ptr<SatGwMac>> mac : layers.m_dvbMac)
1251 {
1252 uint32_t satId = mac.first.first;
1253 uint32_t beamId = mac.first.second;
1254 os << " " << mac.second->GetAddress() << ", sat: " << satId
1255 << ", beam: " << beamId << std::endl;
1256 }
1257 }
1258 }
1259
1260 os << "UTs" << std::endl;
1261 Ptr<Node> utNode;
1262 for (NodeContainer::Iterator itUt = m_uts.Begin(); itUt != m_uts.End(); itUt++)
1263 {
1264 utNode = *itUt;
1265 const UtLayers_s utLayers = m_utLayers.at(utNode);
1266 os << " UT: ID = " << utNode->GetId();
1267 os << ", at " << GeoCoordinate(utNode->GetObject<SatMobilityModel>()->GetPosition())
1268 << std::endl;
1269 os << " Devices " << std::endl;
1270 const GwLayers_s gwLayers = m_gwLayers.at(m_utToGwMap.at(utNode));
1271 uint32_t utSatId = utLayers.m_satId;
1272 uint32_t utBeamId = utLayers.m_beamId;
1273 uint32_t gwSatId = gwLayers.m_satId;
1274
1276 {
1277 os << " " << utLayers.m_dvbMac->GetAddress() << ", sat: " << utSatId
1278 << ", beam: " << utBeamId;
1279 os << ". Linked to GW "
1280 << gwLayers.m_dvbMac.at(std::make_pair(gwSatId, utBeamId))->GetAddress()
1281 << std::endl;
1282 }
1283 else
1284 {
1285 os << " " << utLayers.m_loraMac->GetAddress() << ", sat: " << utSatId
1286 << ", beam: " << utBeamId;
1288 {
1289 os << ". Linked to GW "
1290 << gwLayers.m_loraMac.at(std::make_pair(gwSatId, utBeamId))->GetAddress()
1291 << std::endl;
1292 }
1293 else
1294 {
1295 os << ". Linked to GW "
1296 << gwLayers.m_dvbMac.at(std::make_pair(gwSatId, utBeamId))->GetAddress()
1297 << std::endl;
1298 }
1299 }
1300 }
1301
1302 os << "GW users" << std::endl;
1303 for (NodeContainer::Iterator it = m_gwUsers.Begin(); it != m_gwUsers.End(); it++)
1304 {
1305 Ptr<Node> gwUserNode = *it;
1306 os << " GW user: ID = " << gwUserNode->GetId() << std::endl;
1307 }
1308
1309 os << "UT users" << std::endl;
1310 for (NodeContainer::Iterator it = m_utUsers.Begin(); it != m_utUsers.End(); it++)
1311 {
1312 Ptr<Node> utUserNode = *it;
1313 os << " GW user: ID = " << utUserNode->GetId() << std::endl;
1314 }
1315
1316 os << "==================" << std::endl;
1317 os << std::endl;
1318}
1319
1320uint32_t
1322{
1323 NS_LOG_FUNCTION(this << position);
1324
1325 double distanceMin = std::numeric_limits<double>::max();
1326 uint32_t indexDistanceMin = 0;
1327
1328 for (uint32_t i = 0; i < m_orbiters.GetN(); i++)
1329 {
1330 GeoCoordinate satPos = m_orbiters.Get(i)->GetObject<SatMobilityModel>()->GetGeoPosition();
1331 double distance = CalculateDistance(position.ToVector(), satPos.ToVector());
1332 if (distance < distanceMin)
1333 {
1334 distanceMin = distance;
1335 indexDistanceMin = i;
1336 }
1337 }
1338 return indexDistanceMin;
1339}
1340
1341} // namespace ns3
GeoCoordinate class is used to store and operate with geodetic coordinates.
Vector ToVector() const
Converts Geodetic coordinates to Cartesian coordinates.
Standard_t
The global standard used.
RegenerationMode_t
The regeneration mode used in satellites.
Keep track of the current position and velocity of an object in satellite network.
Class to store topology of the whole system.
void AddGwNode(uint32_t gwId, Ptr< Node > gw)
Add a GW node to the topology.
void UpdateUtSatAndBeam(Ptr< Node > ut, uint32_t satId, uint32_t beamId)
Update satellite and beam associated to a UT.
Ptr< SatOrbiterFeederLlc > GetOrbiterFeederLlc(Ptr< Node > orbiter, uint32_t utBeamId) const
Get SatOrbiterFeederLlc instance of an orbiter serving wanted beam ID.
void AddGwLayersLora(Ptr< Node > gw, uint32_t gwSatId, uint32_t gwBeamId, uint32_t utSatId, uint32_t utBeamId, Ptr< SatNetDevice > netDevice, Ptr< LorawanGroundMacGateway > mac, Ptr< SatGwPhy > phy)
Add LORA GW layers for given node, associated to chosen satellite and beam.
Ptr< Node > GetGwNode(uint32_t nodeId) const
Get the wanted GW node.
void AddOrbiterFeederLayers(Ptr< Node > orbiter, uint32_t satId, uint32_t utBeamId, Ptr< SatOrbiterNetDevice > netDevice, Ptr< SatOrbiterFeederLlc > llc, Ptr< SatOrbiterFeederMac > mac, Ptr< SatOrbiterFeederPhy > phy)
Add orbiter feeder layers for given satellite and beam ID.
void SetStandard(SatEnums::Standard_t standard)
Set standard used (DVB or LORA).
Ptr< SatUtPhy > GetUtPhy(Ptr< Node > ut) const
Get SatUtPhy instance of a UT.
NodeContainer GetUtNodes() const
Get the list of UT nodes.
Ptr< SatUtMac > GetDvbUtMac(Ptr< Node > ut) const
Get SatUtMac instance of a DVB UT.
void Reset()
Function for resetting the variables.
NodeContainer GetUtUserNodes() const
Get the list of UT user nodes.
uint32_t GetOrbiterSatId(Ptr< Node > orbiter) const
Get ID of a given orbiter.
std::map< Ptr< Node >, GwLayers_s > m_gwLayers
std::map< Ptr< Node >, Ptr< Node > > m_utToGwMap
Ptr< LorawanOrbiterMacGateway > GetLoraOrbiterUserMac(Ptr< Node > orbiter, uint32_t beamId) const
Get LorawanOrbiterMacGateway instance of a LORA orbiter serving wanted beam ID.
Ptr< SatGwPhy > GetGwPhy(Ptr< Node > gw, uint32_t utSatId, uint32_t utBeamId) const
Get SatGwPhy instance of a GW.
void AddUtUserNode(Ptr< Node > utUser, Ptr< Node > ut)
Add a UT user node to the topology.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
uint32_t GetGwBeamId(Ptr< Node > gw) const
Get ID of beam linked to a GW.
Ptr< Node > GetGwFromUt(Ptr< Node > ut) const
Get GW connected to a given UT.
SatEnums::Standard_t GetStandard()
Get standard used (DVB or LORA).
uint32_t GetUtGroupId(Ptr< Node > ut) const
Get ID of group linked to a UT.
Ptr< SatOrbiterUserPhy > GetOrbiterUserPhy(Ptr< Node > orbiter, uint32_t beamId) const
Get SatOrbiterUserPhy instance of an orbiter serving wanted beam ID.
Ptr< Node > GetNodeFromId(uint32_t nodeId) const
Get the wanted node from its node ID.
Ptr< SatNetDevice > GetGwNetDevice(Ptr< Node > gw, uint32_t utSatId, uint32_t utBeamId) const
Get SatNetDevice instance of a GW.
void AddUtLayersLora(Ptr< Node > ut, uint32_t satId, uint32_t beamId, uint32_t groupId, Ptr< SatNetDevice > netDevice, Ptr< LorawanMacEndDevice > mac, Ptr< SatUtPhy > phy)
Add LORA UT layers for given node, associated to chosen satellite and beam.
Ptr< Node > GetOrbiterNode(uint32_t nodeId) const
Get the wanted orbiter node.
NodeContainer m_utUsers
void PrintTopology(std::ostream &os) const
Print all the satellite topology.
uint32_t GetClosestSat(GeoCoordinate position)
Get closest satellite to a ground station.
std::map< Ptr< Node >, OrbiterLayers_s > m_orbiterLayers
uint32_t GetNUtUserNodes() const
Get the number of UT user nodes.
void DoDispose()
Do needed dispose actions.
std::map< uint32_t, Ptr< Node > > m_gwIds
NodeContainer GetGwUserNodes() const
Get the list of GW user nodes.
SatEnums::RegenerationMode_t GetForwardLinkRegenerationMode()
Get forward link regeneration mode.
Ptr< LorawanGroundMacGateway > GetLoraGwMac(Ptr< Node > gw, uint32_t utSatId, uint32_t utBeamId) const
Get SatGwMac instance of a LORA GW.
Ptr< SatOrbiterUserMac > GetDvbOrbiterUserMac(Ptr< Node > orbiter, uint32_t beamId) const
Get SatOrbiterUserMac instance of a DVB orbiter serving wanted beam ID.
void ConnectGwToUt(Ptr< Node > ut, Ptr< Node > gw)
Connect a GW to a UT.
void UpdateGwConnectedToUt(Ptr< Node > ut, Ptr< Node > gw)
Connect a new GW to a UT.
std::map< Ptr< SatOrbiterFeederMac >, Ptr< SatOrbiterFeederMac > > m_orbiterFeederMacMap
SatEnums::RegenerationMode_t GetReturnLinkRegenerationMode()
Get return link regeneration mode.
void AddUtLayersDvb(Ptr< Node > ut, uint32_t satId, uint32_t beamId, uint32_t groupId, Ptr< SatNetDevice > netDevice, Ptr< SatUtLlc > llc, Ptr< SatUtMac > mac, Ptr< SatUtPhy > phy)
Add DVB UT layers for given node, associated to chosen satellite and beam.
Ptr< SatOrbiterFeederPhy > GetOrbiterFeederPhy(Ptr< Node > orbiter, uint32_t utBeamId) const
Get SatOrbiterFeederPhy instance of an orbiter serving wanted beam ID.
Ptr< SatGwMac > GetDvbGwMac(Ptr< Node > gw, uint32_t utSatId, uint32_t utBeamId) const
Get SatGwMac instance of a DVB GW.
SatEnums::Standard_t m_standard
Ptr< SatOrbiterFeederMac > GetOrbiterFeederMac(Ptr< Node > orbiter, uint32_t utBeamId) const
Get SatOrbiterFeederMac instance of an orbiter serving wanted beam ID.
Ptr< Node > GetGwUserNode(uint32_t nodeId) const
Get the wanted GW user node.
uint32_t GetNOrbiterNodes() const
Get the number of orbiter nodes.
void SetForwardLinkRegenerationMode(SatEnums::RegenerationMode_t forwardLinkRegenerationMode)
Set forward link regeneration mode.
Ptr< SatUtLlc > GetUtLlc(Ptr< Node > ut) const
Get SatUtLlc instance of a UT.
NodeContainer GetOrbiterNodes() const
Get the list of orbiter nodes.
Ptr< Node > GetUtUserNode(uint32_t nodeId) const
Get the wanted UT user node.
uint32_t GetUtBeamId(Ptr< Node > ut) const
Get ID of beam linked to a UT.
std::map< Ptr< Node >, NodeContainer > m_detailledUtUsers
void AddOrbiterFeederMacPair(Ptr< SatOrbiterFeederMac > mac, Ptr< SatOrbiterFeederMac > usedMac)
Create an association between a feeder MAC layer, and the entity really used.
NodeContainer GetGwNodes() const
Get the list of GW nodes.
Ptr< SatOrbiterNetDevice > GetOrbiterNetDevice(Ptr< Node > orbiter) const
Get SatOrbiterNetDevice instance of an orbiter.
void SetReturnLinkRegenerationMode(SatEnums::RegenerationMode_t returnLinkRegenerationMode)
Set return link regeneration mode.
void AddUtNode(Ptr< Node > ut)
Add a UT node to the topology.
Ptr< SatOrbiterFeederMac > GetOrbiterFeederMacUsed(Ptr< SatOrbiterFeederMac > mac) const
Get feeder MAC really used to connect to a GW.
void AddGwLayersDvb(Ptr< Node > gw, uint32_t gwSatId, uint32_t gwBeamId, uint32_t utSatId, uint32_t utBeamId, Ptr< SatNetDevice > netDevice, Ptr< SatGwLlc > llc, Ptr< SatGwMac > mac, Ptr< SatGwPhy > phy)
Add DVB GW layers for given node, associated to chosen satellite and beam.
void ConnectGwToBeam(uint32_t beamId, Ptr< Node > gw)
Connect a GW to a Beam.
uint32_t GetNGwNodes() const
Get the number of GW nodes.
void UpdateGwSatAndBeam(Ptr< Node > gw, uint32_t satId, uint32_t beamId)
Update satellite and beam associated to a GW.
uint32_t GetNGwUserNodes() const
Get the number of GW user nodes.
SatTopology()
Constructor.
static TypeId GetTypeId(void)
NS-3 type id function.
Ptr< SatNetDevice > GetUtNetDevice(Ptr< Node > ut) const
Get SatNetDevice instance of a UT.
NodeContainer m_orbiters
void AddGwUserNode(Ptr< Node > gwUser)
Add a GW user node to the topology.
Ptr< Node > GetGwFromBeam(uint32_t beamId) const
Get GW connected to a given beam ID.
~SatTopology()
Destructor.
uint32_t GetUtSatId(Ptr< Node > ut) const
Get ID of satellite linked to a UT.
NodeContainer m_gwUsers
Ptr< SatGwLlc > GetGwLlc(Ptr< Node > gw, uint32_t utSatId, uint32_t utBeamId) const
Get SatGwLlc instance of a GW.
void UpdateUtGroup(Ptr< Node > ut, uint32_t groupId)
Update satellite and beam associated to a UT.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
void AddOrbiterNode(Ptr< Node > orbiter)
Add an orbiter node to the topology.
void AddOrbiterUserLayersDvb(Ptr< Node > orbiter, uint32_t satId, uint32_t beamId, Ptr< SatOrbiterNetDevice > netDevice, Ptr< SatOrbiterUserLlc > llc, Ptr< SatOrbiterUserMac > mac, Ptr< SatOrbiterUserPhy > phy)
Add DVB orbiter user layers for given satellite and beam ID.
void AddOrbiterUserLayersLora(Ptr< Node > orbiter, uint32_t satId, uint32_t beamId, Ptr< SatOrbiterNetDevice > netDevice, Ptr< LorawanOrbiterMacGateway > mac, Ptr< SatOrbiterUserPhy > phy)
Add LORA orbiter user layers for given satellite and beam ID.
Ptr< Node > GetUtNode(Ptr< Node > utUser) const
Get UT node linked to some UT user.
void DisconnectGwFromUt(Ptr< Node > ut)
Disconnect a GW from a UT.
Ptr< SatOrbiterUserLlc > GetOrbiterUserLlc(Ptr< Node > orbiter, uint32_t beamId) const
Get SatOrbiterUserLlc instance of an orbiter serving wanted beam ID.
std::map< uint32_t, Ptr< Node > > m_beamToGwMap
Mac48Address GetGwAddressInUt(uint32_t utId)
Set the value of GW address for a UT.
Ptr< LorawanMacEndDevice > GetLoraUtMac(Ptr< Node > ut) const
Get SatUtMac instance of a LORA UT.
std::map< Ptr< Node >, UtLayers_s > m_utLayers
uint32_t GetNUtNodes() const
Get the number of UT nodes.
uint32_t GetGwSatId(Ptr< Node > gw) const
Get ID of satellite linked to a GW.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
std::map< std::pair< uint32_t, uint32_t >, Ptr< SatGwLlc > > m_llc
std::map< std::pair< uint32_t, uint32_t >, Ptr< SatGwPhy > > m_phy
std::map< std::pair< uint32_t, uint32_t >, Ptr< SatNetDevice > > m_netDevice
std::map< std::pair< uint32_t, uint32_t >, Ptr< LorawanGroundMacGateway > > m_loraMac
std::map< std::pair< uint32_t, uint32_t >, Ptr< SatGwMac > > m_dvbMac
std::map< uint32_t, Ptr< SatOrbiterUserPhy > > m_userPhy
std::map< uint32_t, Ptr< SatOrbiterUserLlc > > m_userLlc
Ptr< SatOrbiterNetDevice > m_netDevice
std::map< uint32_t, Ptr< SatOrbiterFeederLlc > > m_feederLlc
std::map< uint32_t, Ptr< SatOrbiterFeederPhy > > m_feederPhy
std::map< uint32_t, Ptr< SatOrbiterFeederMac > > m_feederMac
std::map< uint32_t, Ptr< SatOrbiterUserMac > > m_dvbUserMac
std::map< uint32_t, Ptr< LorawanOrbiterMacGateway > > m_loraUserMac
Ptr< LorawanMacEndDevice > m_loraMac