33#include "ns3/config.h"
35#include "ns3/internet-stack-helper.h"
36#include "ns3/ipv4-interface.h"
37#include "ns3/ipv4-static-routing-helper.h"
39#include "ns3/mobility-helper.h"
40#include "ns3/pointer.h"
41#include "ns3/satellite-antenna-gain-pattern-container.h"
42#include "ns3/satellite-arp-cache.h"
43#include "ns3/satellite-bstp-controller.h"
44#include "ns3/satellite-channel.h"
45#include "ns3/satellite-const-variables.h"
46#include "ns3/satellite-enums.h"
47#include "ns3/satellite-fading-input-trace-container.h"
48#include "ns3/satellite-fading-input-trace.h"
49#include "ns3/satellite-gw-llc.h"
50#include "ns3/satellite-gw-mac.h"
51#include "ns3/satellite-id-mapper.h"
52#include "ns3/satellite-lorawan-net-device.h"
53#include "ns3/satellite-mobility-model.h"
54#include "ns3/satellite-orbiter-net-device.h"
55#include "ns3/satellite-packet-trace.h"
56#include "ns3/satellite-phy-rx.h"
57#include "ns3/satellite-phy-tx.h"
58#include "ns3/satellite-phy.h"
59#include "ns3/satellite-propagation-delay-model.h"
60#include "ns3/satellite-sgp4-mobility-model.h"
61#include "ns3/satellite-topology.h"
62#include "ns3/satellite-typedefs.h"
63#include "ns3/satellite-ut-llc.h"
64#include "ns3/satellite-ut-mac.h"
65#include "ns3/satellite-utils.h"
66#include "ns3/singleton.h"
67#include "ns3/string.h"
68#include "ns3/traffic-control-helper.h"
81NS_LOG_COMPONENT_DEFINE(
"SatBeamHelper");
92 TypeId(
"ns3::SatBeamHelper")
94 .AddConstructor<SatBeamHelper>()
95 .AddAttribute(
"CarrierFrequencyConverter",
96 "Callback to convert carrier id to generate frequency.",
99 MakeCallbackChecker())
100 .AddAttribute(
"FadingModel",
110 .AddAttribute(
"RandomAccessModel",
111 "Random Access Model",
113 MakeEnumAccessor<SatEnums::RandomAccessModel_t>(
122 "RaRcs2Specification",
127 .AddAttribute(
"RaInterferenceModel",
128 "Interference model for random access",
130 MakeEnumAccessor<SatPhyRxCarrierConf::InterferenceModel>(
140 .AddAttribute(
"RaInterferenceEliminationModel",
141 "Interference elimination model for random access",
143 MakeEnumAccessor<SatPhyRxCarrierConf::InterferenceEliminationModel>(
151 "Collision model for random access",
153 MakeEnumAccessor<SatPhyRxCarrierConf::RandomAccessCollisionModel>(
156 "RaCollisionNotDefined",
158 "RaCollisionAlwaysDropCollidingPackets",
160 "RaCollisionCheckAgainstSinr",
162 "RaCollisionConstantErrorProbability"))
163 .AddAttribute(
"RaConstantErrorRate",
164 "Constant error rate for random access",
167 MakeDoubleChecker<double>())
168 .AddAttribute(
"PropagationDelayModel",
169 "Propagation delay model",
171 MakeEnumAccessor<SatEnums::PropagationDelayModel_t>(
177 .AddAttribute(
"ConstantPropagationDelay",
178 "Constant propagation delay",
179 TimeValue(Seconds(0.13)),
183 "PrintDetailedInformationToCreationTraces",
184 "Print detailed information to creation traces",
187 MakeBooleanChecker())
188 .AddAttribute(
"CtrlMsgStoreTimeInFwdLink",
189 "Time to store a control message in container for forward link.",
190 TimeValue(MilliSeconds(10000)),
193 .AddAttribute(
"CtrlMsgStoreTimeInRtnLink",
194 "Time to store a control message in container for return link.",
195 TimeValue(MilliSeconds(10000)),
198 .AddAttribute(
"EnableFwdLinkBeamHopping",
199 "Enable beam hopping in forward link.",
202 MakeBooleanChecker())
203 .AddAttribute(
"EnableTracesOnUserReturnLink",
204 "Use traces files on the user return channel only",
207 MakeBooleanChecker())
208 .AddAttribute(
"DvbVersion",
209 "Indicates if using DVB-S2 or DVB-S2X",
214 "ReturnLinkLinkResults",
215 "Protocol used for the return link link results.",
224 .AddTraceSource(
"Creation",
227 "ns3::SatTypedefs::CreationCallback");
244 NS_LOG_FUNCTION(
this);
247 NS_FATAL_ERROR(
"SatBeamHelper::SatBeamHelper - Constructor not in use");
252 uint32_t rtnLinkCarrierCount,
253 uint32_t fwdLinkCarrierCount,
254 Ptr<SatSuperframeSeq> seq)
272 NS_LOG_FUNCTION(
this << rtnLinkCarrierCount << fwdLinkCarrierCount << seq);
278 NS_LOG_FUNCTION(
this);
280 Object::NotifyConstructionCompleted();
289 Ptr<SatControlMsgContainer> rtnCtrlMsgContainer =
291 Ptr<SatControlMsgContainer> fwdCtrlMsgContainer =
334 Config::SetDefault(
"ns3::SatOrbiterHelper::DaRtnLinkInterferenceModel",
335 StringValue(
"Trace"));
336 Config::SetDefault(
"ns3::SatGwHelper::DaRtnLinkInterferenceModel", StringValue(
"Trace"));
340 switch (Singleton<SatTopology>::Get()->GetStandard())
367 if (Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() ==
380 Config::SetDefault(
"ns3::SatGwMac::SendNcrBroadcast", BooleanValue(
false));
406 NS_FATAL_ERROR(
"Unknown standard");
420 Ptr<SatLinkResultsFwd> linkResultsFwd;
424 linkResultsFwd = CreateObject<SatLinkResultsDvbS2>();
427 linkResultsFwd = CreateObject<SatLinkResultsDvbS2X>();
430 NS_FATAL_ERROR(
"The DVB version does not exist");
433 Ptr<SatLinkResultsRtn> linkResultsReturnLink;
437 linkResultsReturnLink = CreateObject<SatLinkResultsDvbRcs2>();
441 linkResultsReturnLink = CreateObject<SatLinkResultsFSim>();
445 linkResultsReturnLink = CreateObject<SatLinkResultsLora>();
449 NS_FATAL_ERROR(
"Invalid address for multicast group");
454 linkResultsFwd->Initialize();
455 linkResultsReturnLink->Initialize();
457 bool useScpc = (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
459 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
470 m_superframeSeq->GetWaveformConf()->InitializeEbNoRequirements(linkResultsReturnLink);
474 m_ncc = CreateObject<SatNcc>();
476 if (Singleton<SatTopology>::Get()->GetStandard() ==
SatEnums::LORA)
478 m_ncc->SetUseLora(
true);
483 PointerValue llsConf;
484 m_utHelper->GetAttribute(
"LowerLayerServiceConf", llsConf);
485 uint8_t allocationChannelCount =
489 for (uint8_t i = 0; i < allocationChannelCount; i++)
491 m_ncc->SetRandomAccessLowLoadBackoffProbability(
494 m_ncc->SetRandomAccessHighLoadBackoffProbability(
497 m_ncc->SetRandomAccessLowLoadBackoffTime(
500 m_ncc->SetRandomAccessHighLoadBackoffTime(
503 m_ncc->SetRandomAccessAverageNormalizedOfferedLoadThreshold(
534 NS_LOG_FUNCTION(
this);
552 NS_LOG_FUNCTION(
this);
563 NS_LOG_FUNCTION(
this << antennaPatterns);
571 NS_LOG_FUNCTION(
this << n1);
577 NS_LOG_FUNCTION(
this << n1);
585 NS_LOG_FUNCTION(
this << &cb);
587 m_ncc->SetUpdateRoutingCallback(cb);
590std::pair<Ptr<NetDevice>, NetDeviceContainer>
596 uint32_t rtnUlFreqId,
597 uint32_t rtnFlFreqId,
598 uint32_t fwdUlFreqId,
599 uint32_t fwdFlFreqId,
602 NS_LOG_FUNCTION(
this << gwNode << gwId << satId << beamId << rtnUlFreqId << rtnFlFreqId
603 << fwdUlFreqId << fwdFlFreqId);
607 std::pair<std::map<std::pair<uint32_t, uint32_t>, uint32_t>::iterator,
bool> beam =
608 m_beam.insert(std::make_pair(std::make_pair(satId, beamId), gwId));
609 NS_ASSERT(beam.second ==
true);
624 Ptr<Node> satNode = Singleton<SatTopology>::Get()->GetOrbiterNode(satId);
626 NS_ASSERT(satNode !=
nullptr);
632 uint32_t feederSatId = Singleton<SatTopology>::Get()->GetClosestSat(gwPos);
634 if (feederBeamId == 0)
653 NS_ASSERT(gwMobility !=
nullptr);
656 for (NodeContainer::Iterator i = ut.Begin(); i != ut.End(); i++)
661 NS_ASSERT(observer !=
nullptr);
662 observer->ObserveTimingAdvance(userLink.second->GetPropagationDelayModel(),
663 feederLink.second->GetPropagationDelayModel(),
672 m_utNode.insert(std::make_pair(std::make_pair(satId, beamId), *i));
675 Ptr<NetDevice> gwNd =
InstallFeeder(DynamicCast<SatOrbiterNetDevice>(satNode->GetDevice(0)),
687 NetDeviceContainer utNd;
688 if (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
690 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
698 utNd =
InstallUser(DynamicCast<SatOrbiterNetDevice>(satNode->GetDevice(0)),
710 utNd =
InstallUser(DynamicCast<SatOrbiterNetDevice>(satNode->GetDevice(0)),
726 m_bstpController->AddNetDeviceCallback(beamId, fwdUlFreqId, fwdFlFreqId, gwId, gwNdCb);
729 return std::make_pair(gwNd, utNd);
738 uint32_t feederSatId,
739 uint32_t feederBeamId,
741 uint32_t rtnFlFreqId,
742 uint32_t fwdFlFreqId,
745 NS_LOG_FUNCTION(
this << gwNode << gwId << satId << beamId << rtnFlFreqId << fwdFlFreqId);
750 feederLink.second->SetAttribute(
"RxPowerCalculationMode",
765 PointerValue llsConf;
766 m_utHelper->GetAttribute(
"LowerLayerServiceConf", llsConf);
767 Ptr<NetDevice> gwNd =
781 Ptr<SatBbFrameConf> bbFrameConf =
m_gwHelper->GetBbFrameConf();
790 uint32_t maxBbFrameDataSizeInBytes =
791 (bbFrameConf->GetBbFramePayloadBits(bbFrameConf->GetMostRobustModcod(frameType),
794 bbFrameConf->GetBbFrameHeaderSizeInBytes();
796 Address satelliteUserAddress = Address();
797 if (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
799 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
802 satelliteUserAddress = orbiterNetDevice->GetSatelliteUserAddress(beamId);
805 switch (Singleton<SatTopology>::Get()->GetStandard())
811 DynamicCast<SatNetDevice>(gwNd),
815 DynamicCast<SatGwMac>(DynamicCast<SatNetDevice>(gwNd)->GetMac())),
817 maxBbFrameDataSizeInBytes,
818 satelliteUserAddress,
822 if (Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() ==
825 m_ncc->AddBeam(satId,
827 DynamicCast<SatNetDevice>(gwNd),
830 DynamicCast<SatLorawanNetDevice>(gwNd)),
831 MakeNullCallback<
void, Ptr<SatTbtpMessage>>(),
833 maxBbFrameDataSizeInBytes,
834 satelliteUserAddress,
842 DynamicCast<SatNetDevice>(gwNd),
846 DynamicCast<SatGwMac>(DynamicCast<SatNetDevice>(gwNd)->GetMac())),
848 maxBbFrameDataSizeInBytes,
849 satelliteUserAddress,
856 NS_FATAL_ERROR(
"Incorrect standard chosen");
860 if (Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() ==
862 Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() ==
865 Ptr<SatGwMac> gwMac = DynamicCast<SatGwMac>(DynamicCast<SatNetDevice>(gwNd)->GetMac());
866 Mac48Address satFeederAddress = orbiterNetDevice->GetSatelliteFeederAddress(beamId);
867 gwMac->SetSatelliteAddress(satFeederAddress);
871 if (Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() ==
874 Ptr<SatGwMac> gwMac = DynamicCast<SatGwMac>(DynamicCast<SatNetDevice>(gwNd)->GetMac());
875 Ptr<SatGwLlc> gwLlc = DynamicCast<SatGwLlc>(DynamicCast<SatNetDevice>(gwNd)->GetLlc());
876 Mac48Address satFeederAddress = orbiterNetDevice->GetSatelliteFeederAddress(beamId);
877 gwLlc->SetSatelliteAddress(satFeederAddress);
890 uint32_t rtnUlFreqId,
891 uint32_t fwdUlFreqId,
894 NS_LOG_FUNCTION(
this << beamId << rtnUlFreqId << fwdUlFreqId);
899 userLink.second->SetAttribute(
"RxPowerCalculationMode",
903 Address satUserAddress = Address();
904 if (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
906 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
909 satUserAddress = orbiterNetDevice->GetUserMac(beamId)->GetAddress();
913 NetDeviceContainer utNd =
919 DynamicCast<SatNetDevice>(gwNd),
926 if (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
928 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
931 for (NetDeviceContainer::Iterator i = utNd.Begin(); i != utNd.End(); i++)
933 Ptr<SatMac> mac = DynamicCast<SatNetDevice>(*i)->GetMac();
934 Ptr<SatUtMac> utMac = DynamicCast<SatUtMac>(mac);
935 if (utMac !=
nullptr)
937 utMac->SetSatelliteAddress(satUserAddress);
941 mac->SetSatelliteAddress(satUserAddress);
947 if (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
950 for (NetDeviceContainer::Iterator i = utNd.Begin(); i != utNd.End(); i++)
952 Ptr<SatUtLlc> utLlc = DynamicCast<SatUtLlc>(DynamicCast<SatNetDevice>(*i)->GetLlc());
953 if (utLlc !=
nullptr)
955 utLlc->SetSatelliteAddress(Mac48Address::ConvertFrom(satUserAddress));
966 NS_LOG_FUNCTION(
this);
968 Ptr<PointToPointIslHelper> p2pIslHelper = CreateObject<PointToPointIslHelper>();
969 TrafficControlHelper tchIsl;
971 for (std::vector<std::pair<uint32_t, uint32_t>>::iterator it =
m_isls.begin();
975 Ptr<Node> sat1 = Singleton<SatTopology>::Get()->GetOrbiterNode(it->first);
976 Ptr<Node> sat2 = Singleton<SatTopology>::Get()->GetOrbiterNode(it->second);
979 NetDeviceContainer netDevices = p2pIslHelper->Install(sat1, sat2);
980 Ptr<PointToPointIslNetDevice> islNdSat1 =
981 DynamicCast<PointToPointIslNetDevice>(netDevices.Get(0));
982 Ptr<PointToPointIslNetDevice> islNdSat2 =
983 DynamicCast<PointToPointIslNetDevice>(netDevices.Get(1));
985 Ptr<SatOrbiterNetDevice> satNdSat1 = DynamicCast<SatOrbiterNetDevice>(sat1->GetDevice(0));
986 Ptr<SatOrbiterNetDevice> satNdSat2 = DynamicCast<SatOrbiterNetDevice>(sat2->GetDevice(0));
988 satNdSat1->AddIslsNetDevice(islNdSat1);
989 satNdSat2->AddIslsNetDevice(islNdSat2);
991 islNdSat1->SetOrbiterNetDevice(satNdSat1);
992 islNdSat2->SetOrbiterNetDevice(satNdSat2);
999 NS_LOG_FUNCTION(
this);
1007 std::map<std::pair<uint32_t, uint32_t>, uint32_t>::const_iterator i =
1008 m_beam.find(std::make_pair(satId, beamId));
1023 NS_LOG_FUNCTION(
this << gwId);
1025 std::map<uint32_t, Ptr<Node>>::const_iterator gwIterator =
m_gwNode.find(gwId);
1026 Ptr<Node> node =
nullptr;
1030 node = gwIterator->second;
1039 NS_LOG_FUNCTION(
this);
1046 NS_LOG_FUNCTION(
this);
1050Ptr<SatOrbiterHelper>
1053 NS_LOG_FUNCTION(
this);
1060 NS_LOG_FUNCTION(
this << beamId);
1062 NodeContainer utNodes;
1065 std::pair<std::multimap<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator,
1066 std::multimap<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator>
1068 range =
m_utNode.equal_range(std::make_pair(satId, beamId));
1070 for (std::map<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator i = range.first;
1074 utNodes.Add(i->second);
1080std::list<std::pair<uint32_t, uint32_t>>
1083 NS_LOG_FUNCTION(
this);
1085 std::list<std::pair<uint32_t, uint32_t>> ret;
1087 for (std::map<std::pair<uint32_t, uint32_t>, uint32_t>::const_iterator it =
m_beam.begin();
1091 ret.push_back(it->first);
1100 NS_LOG_FUNCTION(
this);
1108 NS_LOG_FUNCTION(
this);
1110 uint32_t beamId = 0;
1112 for (std::multimap<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator it =
1114 ((it !=
m_utNode.end()) && (beamId == 0));
1117 if (it->second == utNode)
1119 beamId = it->first.second;
1128 Ptr<Node> sourceUtNode,
1129 Ipv4Address sourceAddress,
1130 Ipv4Address groupAddress,
1131 bool routeToGwUsers,
1132 Ptr<NetDevice>& gwOutputDev)
1134 NS_LOG_FUNCTION(
this);
1136 Mac48Address groupMacAddress;
1137 Ipv4StaticRoutingHelper multicast;
1138 NetDeviceContainer gwInputDevices;
1139 NetDeviceContainer routerGwOutputDevices;
1140 Ptr<NetDevice> routerDev =
nullptr;
1142 uint32_t sourceBeamId =
GetUtBeamId(sourceUtNode);
1143 gwOutputDev =
nullptr;
1146 if (groupAddress.IsMulticast())
1148 groupMacAddress = Mac48Address::GetMulticast(groupAddress);
1149 NS_LOG_INFO(
"IP address for multicast group: "
1150 << groupAddress <<
", MAC address for multicast group: " << groupMacAddress);
1154 NS_FATAL_ERROR(
"Invalid address for multicast group");
1157 NodeContainer gwNodes = Singleton<SatTopology>::Get()->GetGwNodes();
1160 for (NodeContainer::Iterator it = gwNodes.Begin(); it != gwNodes.End(); it++)
1162 bool routerGw =
false;
1163 NetDeviceContainer gwOutputDevices;
1164 Ptr<NetDevice> gwInputDev =
nullptr;
1167 for (uint32_t i = 1; i < (*it)->GetNDevices(); i++)
1169 Ptr<NetDevice> dev = (*it)->GetDevice(i);
1170 int32_t beamId = Singleton<SatIdMapper>::Get()->GetBeamIdWithMac(dev->GetAddress());
1171 MulticastBeamInfo_t::iterator beamIt = beamInfo.find(beamId);
1174 if (beamId == (int32_t)sourceBeamId)
1182 if (beamIt != beamInfo.end())
1185 if (dev->GetInstanceTypeId().GetName() ==
"ns3::SatNetDevice")
1189 gwOutputDevices.Add(dev);
1193 for (std::set<Ptr<Node>>::iterator utIt = beamIt->second.begin();
1194 utIt != beamIt->second.end();
1202 NS_FATAL_ERROR(
"Not a satellite net device!!!");
1205 else if (dev->GetInstanceTypeId().GetName() !=
"ns3::SatNetDevice")
1216 gwOutputDev = gwInputDev;
1221 routerGwOutputDevices = gwOutputDevices;
1223 else if (gwOutputDevices.GetN() >
1227 multicast.AddMulticastRoute(*it,
1234 gwInputDevices.Add(gwInputDev);
1240 if (sourceUtNode && ((gwInputDevices.GetN() > 0) || routeToGwUsers))
1244 NS_FATAL_ERROR(
"Router device shall exist!!!");
1247 routerGwOutputDevices.Add(gwOutputDev);
1251 gwOutputDev =
nullptr;
1257 if (routerDev && (routerGwOutputDevices.GetN() > 0))
1259 multicast.AddMulticastRoute(routerDev->GetNode(),
1263 routerGwOutputDevices);
1268 return gwInputDevices;
1274 NS_LOG_FUNCTION(
this);
1276 TraceConnect(
"Creation",
"SatBeamHelper", cb);
1278 m_gwHelper->EnableCreationTraces(stream, cb);
1279 m_utHelper->EnableCreationTraces(stream, cb);
1298 std::max(Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode(),
1299 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode());
1306 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/PacketTrace",
1308 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/SatPhy/PacketTrace",
1310 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/UserPhy/*/PacketTrace",
1312 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/FeederPhy/*/PacketTrace",
1314 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/SatMac/PacketTrace",
1319 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/UserMac/*/PacketTrace",
1322 for (std::pair<uint32_t, uint32_t> p :
GetBeams())
1324 Ptr<Node> orbiter = Singleton<SatTopology>::Get()->GetOrbiterNode(p.first);
1325 Ptr<SatOrbiterFeederMac> feederMac =
1326 Singleton<SatTopology>::Get()->GetOrbiterFeederMac(orbiter, p.second);
1327 feederMac->TraceConnectWithoutContext(
1332 if (Singleton<SatTopology>::Get()->GetStandard() ==
SatEnums::DVB)
1334 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/SatLlc/PacketTrace",
1342 NS_LOG_FUNCTION(
this);
1344 std::ostringstream oss;
1345 oss <<
"--- Beam Info, " <<
"number of created beams: " <<
m_beam.size() <<
" ---" << std::endl;
1358 NS_LOG_FUNCTION(
this);
1360 std::ostringstream oss;
1362 for (std::multimap<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator i =
1371 Ptr<Ipv4> ipv4 = i->second->GetObject<Ipv4>();
1373 std::vector<Ipv4Address> IPAddressVector;
1374 std::vector<std::string> devNameVector;
1375 std::vector<Address> devAddressVector;
1377 for (uint32_t j = 0; j < i->second->GetNDevices(); j++)
1379 Ptr<NetDevice> device = i->second->GetDevice(j);
1381 if (device->GetInstanceTypeId().GetName() ==
"ns3::SatNetDevice")
1383 devAddress = device->GetAddress();
1385 IPAddressVector.push_back(
1386 ipv4->GetAddress(j, 0).GetLocal());
1387 devNameVector.push_back(device->GetInstanceTypeId().GetName());
1388 devAddressVector.push_back(device->GetAddress());
1393 oss << i->first.second <<
" "
1394 << Singleton<SatIdMapper>::Get()->GetUtIdWithMac(devAddress) <<
" "
1395 << pos.GetLatitude() <<
" " << pos.GetLongitude() <<
" " << pos.GetAltitude()
1398 for (uint32_t j = 0; j < i->second->GetNDevices(); j++)
1400 oss << devNameVector[j] <<
" " << devAddressVector[j] <<
" " << IPAddressVector[j]
1408 oss << i->first.second <<
" "
1409 << Singleton<SatIdMapper>::Get()->GetUtIdWithMac(devAddress) <<
" "
1410 << pos.GetLatitude() <<
" " << pos.GetLongitude() <<
" " << pos.GetAltitude()
1421 NS_LOG_FUNCTION(
this);
1423 std::ostringstream oss;
1425 oss << std::endl <<
" -- Beam details --";
1427 for (std::map<std::pair<uint32_t, uint32_t>, uint32_t>::const_iterator i =
m_beam.begin();
1431 uint32_t satId = i->first.first;
1432 uint32_t beamId = i->first.second;
1434 oss << std::endl <<
"Sat ID: " << satId <<
" ";
1435 oss <<
"Beam ID: " << beamId <<
" ";
1437 std::map<std::pair<uint32_t, uint32_t>,
FrequencyPair_t>::const_iterator freqIds =
1442 oss <<
"user link frequency ID: " << (*freqIds).second.first <<
", ";
1443 oss <<
"feeder link frequency ID: " << (*freqIds).second.second;
1446 oss <<
", GW ID: " << (*i).second;
1449 oss << std::endl << std::endl <<
" -- GW details --" << std::endl;
1452 oss.setf(std::ios::fixed, std::ios::floatfield);
1454 for (std::map<uint32_t, Ptr<Node>>::const_iterator i =
m_gwNode.begin(); i !=
m_gwNode.end();
1461 Ptr<Ipv4> ipv4 = i->second->GetObject<Ipv4>();
1463 std::vector<Ipv4Address> IPAddressVector;
1464 std::vector<std::string> devNameVector;
1465 std::vector<Address> devAddressVector;
1467 for (uint32_t j = 0; j < i->second->GetNDevices(); j++)
1469 Ptr<NetDevice> device = i->second->GetDevice(j);
1471 if (device->GetInstanceTypeId().GetName() ==
"ns3::SatNetDevice")
1473 devAddress = device->GetAddress();
1476 IPAddressVector.push_back(
1477 ipv4->GetAddress(j, 0).GetLocal());
1478 devNameVector.push_back(device->GetInstanceTypeId().GetName());
1479 devAddressVector.push_back(device->GetAddress());
1484 oss <<
"GW=" << i->first <<
" "
1485 << Singleton<SatIdMapper>::Get()->GetUtIdWithMac(devAddress) <<
" "
1486 <<
" latitude=" << pos.GetLatitude() <<
" longitude=" << pos.GetLongitude()
1487 <<
" altitude=" << pos.GetAltitude() <<
" ";
1489 for (uint32_t j = 0; j < i->second->GetNDevices(); j++)
1491 oss << devNameVector[j] <<
" " << devAddressVector[j] <<
" " << IPAddressVector[j]
1499 oss <<
"GW=" << i->first <<
" "
1500 << Singleton<SatIdMapper>::Get()->GetUtIdWithMac(devAddress) <<
" "
1501 <<
" latitude=" << pos.GetLatitude() <<
" longitude=" << pos.GetLongitude()
1502 <<
" altitude=" << pos.GetAltitude() << std::endl;
1506 oss << std::endl <<
" -- Satellite positions --" << std::endl;
1508 NodeContainer orbiters = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1509 for (NodeContainer::Iterator it = orbiters.Begin(); it != orbiters.End(); it++)
1513 oss <<
"latitude=" << pos.GetLatitude() <<
", longitude=" << pos.GetLongitude()
1514 <<
", altitude=" << pos.GetAltitude() << std::endl;
1523 uint32_t fwdFrequencyId,
1524 uint32_t rtnFrequencyId,
1527 NS_LOG_FUNCTION(
this << satId << beamId << fwdFrequencyId << rtnFrequencyId << isUserLink);
1531 bool hasFwdChannel = chPairs->HasFwdChannel(satId, fwdFrequencyId);
1532 bool hasRtnChannel = chPairs->HasRtnChannel(satId, rtnFrequencyId);
1534 if (hasFwdChannel && hasRtnChannel)
1536 chPairs->UpdateBeamsForFrequency(satId, beamId, fwdFrequencyId, rtnFrequencyId);
1540 Ptr<SatFreeSpaceLoss> pFsl;
1541 Ptr<PropagationDelayModel> pDelay;
1542 Ptr<SatChannel> forwardCh;
1543 Ptr<SatChannel> returnCh;
1547 forwardCh = chPairs->GetForwardChannel(satId, fwdFrequencyId);
1548 pDelay = forwardCh->GetPropagationDelayModel();
1549 pFsl = forwardCh->GetFreeSpaceLoss();
1551 else if (hasRtnChannel)
1553 returnCh = chPairs->GetReturnChannel(satId, rtnFrequencyId);
1554 pDelay = returnCh->GetPropagationDelayModel();
1555 pFsl = returnCh->GetFreeSpaceLoss();
1562 pDelay = CreateObject<ConstantSpeedPropagationDelayModel>();
1563 DynamicCast<ConstantSpeedPropagationDelayModel>(pDelay)->SetSpeed(
1568 pDelay = CreateObject<SatConstantPropagationDelayModel>();
1569 DynamicCast<SatConstantPropagationDelayModel>(pDelay)->SetDelay(
1574 NS_FATAL_ERROR(
"Unsupported propagation delay model!");
1577 pFsl = CreateObject<SatFreeSpaceLoss>();
1587 forwardCh->SetFrequencyId(fwdFrequencyId);
1588 forwardCh->SetPropagationDelayModel(pDelay);
1589 forwardCh->SetFreeSpaceLoss(pFsl);
1599 returnCh->SetFrequencyId(rtnFrequencyId);
1600 returnCh->SetPropagationDelayModel(pDelay);
1601 returnCh->SetFreeSpaceLoss(pFsl);
1605 ->StoreChannelPair(satId, beamId, fwdFrequencyId, forwardCh, rtnFrequencyId, returnCh);
1608 return chPairs->GetChannelPair(satId, beamId);
1614 NS_LOG_FUNCTION(
this <<
id << node);
1616 bool storingSuccess =
false;
1620 if (storedNode !=
nullptr)
1622 if (storedNode == node)
1624 storingSuccess =
true;
1629 std::pair<std::map<uint32_t, Ptr<Node>>::iterator,
bool> result =
1630 m_gwNode.insert(std::make_pair(
id, node));
1631 storingSuccess = result.second;
1632 Singleton<SatTopology>::Get()->AddGwNode(
id, node);
1635 return storingSuccess;
1641 NS_LOG_FUNCTION(
this << node);
1643 Ptr<SatBaseFading> fadingContainer = node->GetObject<
SatBaseFading>();
1645 if (fadingContainer ==
nullptr)
1651 NS_ASSERT(observer !=
nullptr);
1660 CreateObject<SatMarkovContainer>(
m_markovConf, elevationCb, velocityCb);
1661 node->AggregateObject(fadingContainer);
1668 CreateObject<SatFadingInputTrace>(Singleton<SatFadingInputTraceContainer>::Get());
1670 node->AggregateObject(fadingContainer);
1676 NS_FATAL_ERROR(
"SatBeamHelper::InstallFadingContainer - Incorrect fading model");
1681 return fadingContainer;
1686 Ipv4Address sourceAddress,
1687 Ipv4Address groupAddress,
1688 bool routeToSatellite)
1690 NS_LOG_FUNCTION(
this);
1692 Ptr<NetDevice> satDev =
nullptr;
1693 Ptr<NetDevice> publicDev =
nullptr;
1695 for (uint32_t i = 1; i < utNode->GetNDevices(); i++)
1697 Ptr<NetDevice> dev = utNode->GetDevice(i);
1700 if (dev->GetInstanceTypeId().GetName() ==
"ns3::SatNetDevice")
1711 if (satDev && publicDev)
1713 Ipv4StaticRoutingHelper multicast;
1715 if (routeToSatellite)
1717 multicast.AddMulticastRoute(utNode, sourceAddress, groupAddress, publicDev, satDev);
1721 multicast.AddMulticastRoute(utNode, sourceAddress, groupAddress, satDev, publicDev);
1728 NS_FATAL_ERROR(
"Input of output device not found in UT node!!!");
1732Ptr<PropagationDelayModel>
1737 Ptr<SatChannel> channel =
nullptr;
1738 switch (channelType)
1741 channel =
m_flChannels->GetChannelPair(satId, beamId).first;
1745 channel =
m_ulChannels->GetChannelPair(satId, beamId).first;
1749 channel =
m_ulChannels->GetChannelPair(satId, beamId).second;
1753 channel =
m_flChannels->GetChannelPair(satId, beamId).second;
1761 return channel->GetPropagationDelayModel();
GeoCoordinate class is used to store and operate with geodetic coordinates.
Base class for fading models such as Markov-based fading or fading trace.
Callback< double > VelocityCallback
Gets velocity in m/s.
Callback< double > ElevationCallback
Gets elevation angle in degrees.
SatBeamHelper builds a set Satellite beams with needed objects and configuration.
void SetAntennaGainPatterns(Ptr< SatAntennaGainPatternContainer > antennaPatterns)
Set the antenna gain patterns to be used when configuring the beams to the satellite.
NetDeviceContainer AddMulticastGroupRoutes(MulticastBeamInfo_t beamInfo, Ptr< Node > sourceUtNode, Ipv4Address sourceAddress, Ipv4Address groupAddress, bool routeToGwUsers, Ptr< NetDevice > &gwOutputDev)
std::map< std::pair< uint32_t, uint32_t >, uint32_t > m_beam
SatEnums::DvbVersion_t m_dvbVersion
Indicates if using DVB-S2 or DVB-S2X.
Time m_constantPropagationDelay
Constant propagation delay.
bool m_printDetailedInformationToCreationTraces
Flag indicating whether to print detailed information to the creation traces.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
Ptr< SatChannelPair > m_flChannels
ObjectFactory m_channelFactory
virtual void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
void SetIslRoutes()
Set ISL routes.
Ptr< SatSuperframeSeq > m_superframeSeq
bool StoreGwNode(uint32_t id, Ptr< Node > node)
Creates GW node according to given id and stores GW to map.
Ptr< SatBstpController > m_bstpController
Beam Switching Time Plan controller, which is created if FWD link beam hopping is enabled (m_enableFw...
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void InstallIsls()
Create all the ISLs.
Ptr< SatGwHelper > GetGwHelper() const
SatEnums::PropagationDelayModel_t GetPropagationDelayModelEnum()
Ptr< SatAntennaGainPatternContainer > m_antennaGainPatterns
SatTypedefs::CarrierBandwidthConverter_t m_carrierBandwidthConverter
CarrierFreqConverter m_carrierFreqConverter
bool m_enableFwdLinkBeamHopping
Flag indicating whether beam hopping is enabled in FWD link.
uint32_t m_rtnLinkCarrierCount
Ptr< SatUtHelper > GetUtHelper() const
void EnableCreationTraces(Ptr< OutputStreamWrapper > stream, CallbackBase &cb)
Enables creation traces to be written in given file.
uint32_t GetGwId(uint32_t satId, uint32_t beamId) const
std::map< uint32_t, Ptr< NetDevice > > m_gwNdMap
Map used in regenerative mode to store GW Net device (we need only one per GW).
NodeContainer GetUtNodes(uint32_t satId, uint32_t beamId) const
virtual void DoDispose()
Dispose of this class instance.
Ptr< PropagationDelayModel > GetPropagationDelayModel(uint32_t satId, uint32_t beamId, SatEnums::ChannelType_t channelType)
TracedCallback< std::string > m_creationTrace
Trace callback for creation traces.
std::pair< Ptr< NetDevice >, NetDeviceContainer > Install(NodeContainer ut, Ptr< Node > gwNode, uint32_t gwId, uint32_t satId, uint32_t beamId, uint32_t rtnUlFreqId, uint32_t rtnFlFreqId, uint32_t fwdUlFreqId, uint32_t fwdFlFreqId, SatMac::RoutingUpdateCallback routingCallback)
NetDeviceContainer InstallUser(Ptr< SatOrbiterNetDevice > orbiterNetDevice, NodeContainer ut, Ptr< NetDevice > gwNd, uint32_t satId, uint32_t beamId, SatChannelPair::ChannelPair_t userLink, uint32_t rtnUlFreqId, uint32_t fwdUlFreqId, SatMac::RoutingUpdateCallback routingCallback)
SatBeamHelper()
Default constructor for SatBeamHelper (should not be used).
SatEnums::LinkResults_t m_rlLinkResultsType
Type of Return channel link results.
std::string GetBeamInfo() const
uint32_t GetUtBeamId(Ptr< Node > utNode) const
Get beam Id of the given UT.
Ptr< SatNcc > GetNcc() const
Ptr< SatBaseFading > InstallFadingContainer(Ptr< Node > node) const
Install fading model to node, if fading model doesn't exist already in node.
Time m_ctrlMsgStoreTimeFwdLink
Control message store time in container for forward link.
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
The used collision model for random access.
std::pair< uint32_t, uint32_t > FrequencyPair_t
std::map< std::pair< uint32_t, uint32_t >, FrequencyPair_t > m_beamFreqs
std::map< uint32_t, Ptr< Node > > m_gwNode
std::list< std::pair< uint32_t, uint32_t > > GetBeams() const
Ptr< SatMarkovConf > m_markovConf
Common configuration for Markov model.
Ptr< SatUtHelper > m_utHelper
uint32_t m_fwdLinkCarrierCount
void AddMulticastRouteToUt(Ptr< Node > utNode, Ipv4Address sourceAddress, Ipv4Address groupAddress, bool routeToSatellite)
Add multicast route to UT node.
Ptr< SatOrbiterHelper > GetOrbiterHelper() const
Ptr< NetDevice > InstallFeeder(Ptr< SatOrbiterNetDevice > orbiterNetDevice, Ptr< Node > gwNode, uint32_t gwId, uint32_t satId, uint32_t beamId, uint32_t feederSatId, uint32_t feederBeamId, SatChannelPair::ChannelPair_t feederLink, uint32_t rtnFlFreqId, uint32_t fwdFlFreqId, SatMac::RoutingUpdateCallback routingCallback)
Ptr< SatOrbiterHelper > m_orbiterHelper
static TypeId GetTypeId(void)
Get the type ID.
std::string GetUtInfo() const
std::string CreateBeamInfo() const
Creates info of the beam.
SatEnums::PropagationDelayModel_t m_propagationDelayModel
Propagation delay model.
void EnablePacketTrace()
Enable packet traces.
void Init()
Init method is called after all the initial configurations have been done by the SatHelper and SatBea...
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
The used interference model for random access.
Ptr< SatPacketTrace > m_packetTrace
Packet trace.
SatEnums::FadingModel_t m_fadingModel
Configured fading model.
Ptr< Node > GetGwNode(uint32_t gwId) const
Gets GW node according to given id.
SatChannelPair::ChannelPair_t GetChannelPair(uint32_t satId, uint32_t beamId, uint32_t fwdFrequencyId, uint32_t rtnFrequencyId, bool isUserLink)
Gets satellite channel pair from requested map.
std::vector< std::pair< uint32_t, uint32_t > > m_isls
Vector constaining all the ISLs of the topology.
SatEnums::RandomAccessModel_t m_randomAccessModel
The used random access model.
Time m_ctrlMsgStoreTimeRtnLink
Control message store in container for return link.
Ptr< SatChannelPair > m_ulChannels
Ptr< SatGwHelper > m_gwHelper
std::map< uint32_t, std::set< Ptr< Node > > > MulticastBeamInfo_t
SatPhyRxCarrierConf::InterferenceModel m_raInterferenceModel
The used interference model for random access.
double m_raConstantErrorRate
Constant error rate for random access.
void SetNccRoutingCallback(SatNcc::UpdateRoutingCallback cb)
Attach an update routing callback to the NCC of this simulation.
std::multimap< std::pair< uint32_t, uint32_t >, Ptr< Node > > m_utNode
bool m_enableTracesOnReturnLink
Helper flag to activate packet traces on the return link only.
Callback< void, bool > ToggleCallback
Callback to fetch queue statistics.
Satellite channel implementation.
virtual void SetChannelType(SatEnums::ChannelType_t chType)
Set the type of the channel.
std::pair< Ptr< SatChannel >, Ptr< SatChannel > > ChannelPair_t
ChannelPair_t GetChannelPair(uint32_t satId, uint32_t beamId) const
Retrieve the channel pair associated to a beam.
Ptr< SatControlMessage > Read(uint32_t recvId)
Read a control message.
uint32_t Send(uint32_t sendId)
Add a control message.
uint32_t ReserveIdAndStore(Ptr< SatControlMessage > controlMsg)
Reserve an id and store a control message.
SatEnums class is for simplifying the use of enumerators in the satellite module.
SatBbFrameType_t
BB frame type used in DVB-S2 FWD link.
ChannelType_t
Types of channel.
PropagationDelayModel_t
Propagation delay model.
@ SHORT_FRAMES
SHORT_FRAMES.
@ RA_MODEL_RCS2_SPECIFICATION
RegenerationMode_t
The regeneration mode used in satellites.
void TbtpSent(Ptr< SatTbtpMessage > tbtp)
Function called when a TBTP has been sent by the SatBeamScheduler.
bool SendControlMsg(Ptr< SatControlMessage > msg, const Address &dest)
The SatLowerLayerServiceConf class holds information of all configures lower layer service entries.
uint16_t GetRaHighLoadBackOffProbability(uint8_t index) const
Get high load back off probability.
uint16_t GetRaHighLoadBackOffTimeInMilliSeconds(uint8_t index) const
Get high load back off time in milliseconds.
double GetRaAverageNormalizedOfferedLoadThreshold(uint8_t index) const
Get average normalized offeredLoad Threshold.
uint16_t GetRaBackOffProbability(uint8_t index) const
Get back off probability.
uint16_t GetRaBackOffTimeInMilliSeconds(uint8_t index) const
Get back off time in milliseconds.
Callback< uint32_t, Ptr< SatControlMessage > > ReserveCtrlMsgCallback
Callback to reserve an id and initially store the control message.
Callback< void, Address, Address > RoutingUpdateCallback
Callback to update routing and ARP tables after handover.
Callback< uint32_t, uint32_t > SendCtrlMsgCallback
Callback to send a control message and allocate a recv ID for it.
Callback< Ptr< SatControlMessage >, uint32_t > ReadCtrlMsgCallback
Callback to read control messages from container storing control messages.
Keep track of the current position and velocity of an object in satellite network.
Observes given mobilities and keeps track of certain wanted properties.
double GetVelocity(void)
Get velocity of own movement (speed).
double GetElevationAngle(void)
Get elevation angle.
Callback< void, Address, Address, Address > UpdateRoutingCallback
Update routes and ARP tables on gateways after a terminal handover.
void ToggleState(bool enabled)
Toggle the state of the device.
bool SendControlMsg(Ptr< SatControlMessage > msg, const Address &dest)
void AddTraceEntry(Time now, SatEnums::SatPacketEvent_t packetEvent, SatEnums::SatNodeType_t nodeType, uint32_t nodeId, Mac48Address macAddress, SatEnums::SatLogLevel_t logLevel, SatEnums::SatLinkDir_t linkDir, std::string packetInfo)
Add a packet trace entry to the log.
Information of beam users liken UTs and their users.
@ RA_CONSTANT_COLLISION_PROBABILITY
@ RA_COLLISION_CHECK_AGAINST_SINR
@ RA_COLLISION_NOT_DEFINED
@ RA_COLLISION_ALWAYS_DROP_ALL_COLLIDING_PACKETS
Callback< double, SatEnums::ChannelType_t, uint32_t, SatEnums::CarrierBandwidthType_t > CarrierBandwidthConverter_t
Callback for carrier bandwidths.
constexpr double SPEED_OF_LIGHT
Constant definition for the speed of light in m/s.
constexpr uint32_t BITS_PER_BYTE
Number of bits in a byte.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Random access setting options.
SatPhyRxCarrierConf::InterferenceModel m_raInterferenceModel
double m_raConstantErrorRate
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
SatEnums::RandomAccessModel_t m_randomAccessModel
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
Random access setting options.
SatPhyRxCarrierConf::InterferenceModel m_raFwdInterferenceModel
SatPhyRxCarrierConf::InterferenceModel m_raRtnInterferenceModel
SatEnums::RandomAccessModel_t m_randomAccessModel
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
Define RandomAccessSettings as a struct.
SatEnums::RandomAccessModel_t m_randomAccessModel
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
SatPhyRxCarrierConf::InterferenceModel m_raInterferenceModel