25 #include <ns3/config.h>
27 #include <ns3/internet-stack-helper.h>
28 #include <ns3/ipv4-interface.h>
29 #include <ns3/ipv4-static-routing-helper.h>
31 #include <ns3/mobility-helper.h>
32 #include <ns3/pointer.h>
33 #include <ns3/satellite-antenna-gain-pattern-container.h>
34 #include <ns3/satellite-arp-cache.h>
35 #include <ns3/satellite-bstp-controller.h>
36 #include <ns3/satellite-channel.h>
37 #include <ns3/satellite-const-variables.h>
38 #include <ns3/satellite-enums.h>
39 #include <ns3/satellite-fading-input-trace-container.h>
40 #include <ns3/satellite-fading-input-trace.h>
41 #include <ns3/satellite-geo-net-device.h>
42 #include <ns3/satellite-gw-llc.h>
43 #include <ns3/satellite-gw-mac.h>
44 #include <ns3/satellite-id-mapper.h>
45 #include <ns3/satellite-lorawan-net-device.h>
46 #include <ns3/satellite-mobility-model.h>
47 #include <ns3/satellite-packet-trace.h>
48 #include <ns3/satellite-phy-rx.h>
49 #include <ns3/satellite-phy-tx.h>
50 #include <ns3/satellite-phy.h>
51 #include <ns3/satellite-point-to-point-isl-helper.h>
52 #include <ns3/satellite-propagation-delay-model.h>
53 #include <ns3/satellite-sgp4-mobility-model.h>
54 #include <ns3/satellite-typedefs.h>
55 #include <ns3/satellite-ut-llc.h>
56 #include <ns3/satellite-ut-mac.h>
57 #include <ns3/satellite-utils.h>
58 #include <ns3/singleton.h>
59 #include <ns3/string.h>
60 #include <ns3/traffic-control-helper.h>
62 NS_LOG_COMPONENT_DEFINE(
"SatBeamHelper");
67 NS_OBJECT_ENSURE_REGISTERED(SatBeamHelper);
73 TypeId(
"ns3::SatBeamHelper")
75 .AddConstructor<SatBeamHelper>()
76 .AddAttribute(
"CarrierFrequencyConverter",
77 "Callback to convert carrier id to generate frequency.",
80 MakeCallbackChecker())
81 .AddAttribute(
"FadingModel",
91 .AddAttribute(
"RandomAccessModel",
92 "Random Access Model",
102 "RaRcs2Specification",
107 .AddAttribute(
"RaInterferenceModel",
108 "Interference model for random access",
119 .AddAttribute(
"RaInterferenceEliminationModel",
120 "Interference elimination model for random access",
129 "Collision model for random access",
133 "RaCollisionNotDefined",
135 "RaCollisionAlwaysDropCollidingPackets",
137 "RaCollisionCheckAgainstSinr",
139 "RaCollisionConstantErrorProbability"))
140 .AddAttribute(
"RaConstantErrorRate",
141 "Constant error rate for random access",
144 MakeDoubleChecker<double>())
145 .AddAttribute(
"PropagationDelayModel",
146 "Propagation delay model",
153 .AddAttribute(
"ConstantPropagationDelay",
154 "Constant propagation delay",
155 TimeValue(Seconds(0.13)),
159 "PrintDetailedInformationToCreationTraces",
160 "Print detailed information to creation traces",
163 MakeBooleanChecker())
164 .AddAttribute(
"CtrlMsgStoreTimeInFwdLink",
165 "Time to store a control message in container for forward link.",
166 TimeValue(MilliSeconds(10000)),
169 .AddAttribute(
"CtrlMsgStoreTimeInRtnLink",
170 "Time to store a control message in container for return link.",
171 TimeValue(MilliSeconds(10000)),
174 .AddAttribute(
"EnableFwdLinkBeamHopping",
175 "Enable beam hopping in forward link.",
178 MakeBooleanChecker())
179 .AddAttribute(
"EnableTracesOnUserReturnLink",
180 "Use traces files on the user return channel only",
183 MakeBooleanChecker())
184 .AddAttribute(
"DvbVersion",
185 "Indicates if using DVB-S2 or DVB-S2X",
189 .AddAttribute(
"ReturnLinkLinkResults",
190 "Protocol used for the return link link results.",
199 .AddTraceSource(
"Creation",
202 "ns3::SatTypedefs::CreationCallback");
209 NS_LOG_FUNCTION(
this);
215 : m_printDetailedInformationToCreationTraces(false),
217 m_propagationDelayModel(
SatEnums::PD_CONSTANT_SPEED),
218 m_constantPropagationDelay(Seconds(0.13)),
219 m_randomAccessModel(
SatEnums::RA_MODEL_OFF),
223 m_raConstantErrorRate(0.0),
224 m_enableFwdLinkBeamHopping(false),
226 m_forwardLinkRegenerationMode(
SatEnums::TRANSPARENT),
227 m_returnLinkRegenerationMode(
SatEnums::TRANSPARENT)
229 NS_LOG_FUNCTION(
this);
232 NS_FATAL_ERROR(
"SatBeamHelper::SatBeamHelper - Constructor not in use");
236 std::vector<std::pair<uint32_t, uint32_t>> isls,
238 uint32_t rtnLinkCarrierCount,
239 uint32_t fwdLinkCarrierCount,
240 Ptr<SatSuperframeSeq> seq,
243 : m_carrierBandwidthConverter(bandwidthConverterCb),
244 m_superframeSeq(seq),
245 m_printDetailedInformationToCreationTraces(false),
246 m_fadingModel(
SatEnums::FADING_MARKOV),
247 m_propagationDelayModel(
SatEnums::PD_CONSTANT_SPEED),
248 m_constantPropagationDelay(Seconds(0.13)),
249 m_randomAccessModel(
SatEnums::RA_MODEL_OFF),
253 m_raConstantErrorRate(0.0),
254 m_enableFwdLinkBeamHopping(false),
256 m_forwardLinkRegenerationMode(forwardLinkRegenerationMode),
257 m_returnLinkRegenerationMode(returnLinkRegenerationMode),
260 NS_LOG_FUNCTION(
this << rtnLinkCarrierCount << fwdLinkCarrierCount << seq);
264 ObjectBase::ConstructSelf(AttributeConstructionList());
273 Ptr<SatControlMsgContainer> rtnCtrlMsgContainer =
275 Ptr<SatControlMsgContainer> fwdCtrlMsgContainer =
318 Config::SetDefault(
"ns3::SatGeoHelper::DaRtnLinkInterferenceModel", StringValue(
"Trace"));
319 Config::SetDefault(
"ns3::SatGwHelper::DaRtnLinkInterferenceModel", StringValue(
"Trace"));
323 m_geoHelper = CreateObject<SatGeoHelper>(bandwidthConverterCb,
330 m_gwHelper = CreateObject<SatGwHelper>(bandwidthConverterCb,
337 m_utHelper = CreateObject<SatUtHelper>(bandwidthConverterCb,
356 Ptr<SatLinkResultsFwd> linkResultsFwd;
360 linkResultsFwd = CreateObject<SatLinkResultsDvbS2>();
363 linkResultsFwd = CreateObject<SatLinkResultsDvbS2X>();
366 NS_FATAL_ERROR(
"The DVB version does not exist");
369 Ptr<SatLinkResultsRtn> linkResultsReturnLink;
373 linkResultsReturnLink = CreateObject<SatLinkResultsDvbRcs2>();
377 linkResultsReturnLink = CreateObject<SatLinkResultsFSim>();
381 linkResultsReturnLink = CreateObject<SatLinkResultsLora>();
385 NS_FATAL_ERROR(
"Invalid address for multicast group");
390 linkResultsFwd->Initialize();
391 linkResultsReturnLink->Initialize();
402 m_geoHelper->Initialize(linkResultsFwd, linkResultsReturnLink);
404 m_superframeSeq->GetWaveformConf()->InitializeEbNoRequirements(linkResultsReturnLink);
409 m_ncc = CreateObject<SatNcc>();
413 PointerValue llsConf;
414 m_utHelper->GetAttribute(
"LowerLayerServiceConf", llsConf);
415 uint8_t allocationChannelCount =
419 for (uint8_t i = 0; i < allocationChannelCount; i++)
421 m_ncc->SetRandomAccessLowLoadBackoffProbability(
424 m_ncc->SetRandomAccessHighLoadBackoffProbability(
427 m_ncc->SetRandomAccessLowLoadBackoffTime(
430 m_ncc->SetRandomAccessHighLoadBackoffTime(
433 m_ncc->SetRandomAccessAverageNormalizedOfferedLoadThreshold(
464 NS_LOG_FUNCTION(
this);
482 NS_LOG_FUNCTION(
this);
499 NS_LOG_FUNCTION(
this << antennaPatterns);
507 NS_LOG_FUNCTION(
this << n1);
513 NS_LOG_FUNCTION(
this << n1);
521 NS_LOG_FUNCTION(
this << &cb);
523 m_ncc->SetUpdateRoutingCallback(cb);
526 std::pair<Ptr<NetDevice>, NetDeviceContainer>
532 uint32_t rtnUlFreqId,
533 uint32_t rtnFlFreqId,
534 uint32_t fwdUlFreqId,
535 uint32_t fwdFlFreqId,
538 NS_LOG_FUNCTION(
this << gwNode << gwId << satId << beamId << rtnUlFreqId << rtnFlFreqId
539 << fwdUlFreqId << fwdFlFreqId);
543 std::pair<std::map<std::pair<uint32_t, uint32_t>, uint32_t>::iterator,
bool> beam =
544 m_beam.insert(std::make_pair(std::make_pair(satId, beamId), gwId));
545 NS_ASSERT(beam.second ==
true);
562 NS_ASSERT(geoNode != NULL);
585 NS_ASSERT(gwMobility != NULL);
588 for (NodeContainer::Iterator i = ut.Begin(); i != ut.End(); i++)
593 NS_ASSERT(observer != NULL);
594 observer->ObserveTimingAdvance(userLink.second->GetPropagationDelayModel(),
595 feederLink.second->GetPropagationDelayModel(),
604 m_utNode.insert(std::make_pair(std::make_pair(satId, beamId), *i));
607 Ptr<NetDevice> gwNd =
InstallFeeder(DynamicCast<SatGeoNetDevice>(geoNode->GetDevice(0)),
617 NetDeviceContainer utNd;
626 utNd =
InstallUser(DynamicCast<SatGeoNetDevice>(geoNode->GetDevice(0)),
638 utNd =
InstallUser(DynamicCast<SatGeoNetDevice>(geoNode->GetDevice(0)),
654 m_bstpController->AddNetDeviceCallback(beamId, fwdUlFreqId, fwdFlFreqId, gwId, gwNdCb);
657 return std::make_pair(gwNd, utNd);
667 uint32_t rtnFlFreqId,
668 uint32_t fwdFlFreqId,
671 NS_LOG_FUNCTION(
this << gwNode << gwId << satId << beamId << rtnFlFreqId << fwdFlFreqId);
676 feederLink.second->SetAttribute(
"RxPowerCalculationMode",
691 PointerValue llsConf;
692 m_utHelper->GetAttribute(
"LowerLayerServiceConf", llsConf);
722 NS_FATAL_ERROR(
"Incorrect standard chosen");
726 Ptr<SatBbFrameConf> bbFrameConf =
m_gwHelper->GetBbFrameConf();
735 uint32_t maxBbFrameDataSizeInBytes =
736 (bbFrameConf->GetBbFramePayloadBits(bbFrameConf->GetMostRobustModcod(frameType),
739 bbFrameConf->GetBbFrameHeaderSizeInBytes();
749 DynamicCast<SatGwMac>(DynamicCast<SatNetDevice>(gwNd)->GetMac())),
751 maxBbFrameDataSizeInBytes,
755 m_ncc->AddBeam(satId,
758 DynamicCast<SatLorawanNetDevice>(gwNd)),
759 MakeNullCallback<void, Ptr<SatTbtpMessage>>(),
761 maxBbFrameDataSizeInBytes,
765 NS_FATAL_ERROR(
"Incorrect standard chosen");
772 Mac48Address satFeederAddress = geoNetDevice->GetSatelliteFeederAddress(beamId);
773 DynamicCast<SatGwMac>(DynamicCast<SatNetDevice>(gwNd)->GetMac())
774 ->SetSatelliteAddress(satFeederAddress);
780 Mac48Address satFeederAddress = geoNetDevice->GetSatelliteFeederAddress(beamId);
781 DynamicCast<SatGwLlc>(DynamicCast<SatNetDevice>(gwNd)->GetLlc())
782 ->SetSatelliteAddress(satFeederAddress);
795 uint32_t rtnUlFreqId,
796 uint32_t fwdUlFreqId,
799 NS_LOG_FUNCTION(
this << beamId << rtnUlFreqId << fwdUlFreqId);
804 userLink.second->SetAttribute(
"RxPowerCalculationMode",
808 Address satUserAddress = Address();
812 satUserAddress = geoNetDevice->GetUserMac(beamId)->GetAddress();
816 NetDeviceContainer utNd;
825 DynamicCast<SatNetDevice>(gwNd),
839 DynamicCast<SatNetDevice>(gwNd),
848 NS_FATAL_ERROR(
"Incorrect standard chosen");
855 for (NetDeviceContainer::Iterator i = utNd.Begin(); i != utNd.End(); i++)
857 DynamicCast<SatUtMac>(DynamicCast<SatNetDevice>(*i)->GetMac())
858 ->SetSatelliteAddress(satUserAddress);
865 for (NetDeviceContainer::Iterator i = utNd.Begin(); i != utNd.End(); i++)
867 DynamicCast<SatUtLlc>(DynamicCast<SatNetDevice>(*i)->GetLlc())
868 ->SetSatelliteAddress(Mac48Address::ConvertFrom(satUserAddress));
878 NS_LOG_FUNCTION(
this);
880 Ptr<PointToPointIslHelper> p2pIslHelper = CreateObject<PointToPointIslHelper>();
881 TrafficControlHelper tchIsl;
883 for (std::vector<std::pair<uint32_t, uint32_t>>::iterator it =
m_isls.begin();
891 NetDeviceContainer netDevices = p2pIslHelper->Install(sat1, sat2);
892 Ptr<PointToPointIslNetDevice> islNdSat1 =
893 DynamicCast<PointToPointIslNetDevice>(netDevices.Get(0));
894 Ptr<PointToPointIslNetDevice> islNdSat2 =
895 DynamicCast<PointToPointIslNetDevice>(netDevices.Get(1));
897 Ptr<SatGeoNetDevice> geoNdSat1 = DynamicCast<SatGeoNetDevice>(sat1->GetDevice(0));
898 Ptr<SatGeoNetDevice> geoNdSat2 = DynamicCast<SatGeoNetDevice>(sat2->GetDevice(0));
900 geoNdSat1->AddIslsNetDevice(islNdSat1);
901 geoNdSat2->AddIslsNetDevice(islNdSat2);
903 islNdSat1->SetGeoNetDevice(geoNdSat1);
904 islNdSat2->SetGeoNetDevice(geoNdSat2);
911 NS_LOG_FUNCTION(
this);
919 std::map<std::pair<uint32_t, uint32_t>, uint32_t>::const_iterator i =
920 m_beam.find(std::make_pair(satId, beamId));
935 NS_LOG_FUNCTION(
this << gwId);
937 std::map<uint32_t, Ptr<Node>>::const_iterator gwIterator =
m_gwNode.find(gwId);
938 Ptr<Node> node = NULL;
942 node = gwIterator->second;
951 NS_LOG_FUNCTION(
this);
958 NS_LOG_FUNCTION(
this);
965 NS_LOG_FUNCTION(
this);
972 NS_LOG_FUNCTION(
this);
979 NS_LOG_FUNCTION(
this);
981 NodeContainer gwNodes;
983 for (std::map<uint32_t, Ptr<Node>>::const_iterator i =
m_gwNode.begin(); i !=
m_gwNode.end();
986 gwNodes.Add(i->second);
995 NS_LOG_FUNCTION(
this);
997 NodeContainer utNodes;
999 for (std::multimap<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator i =
1004 utNodes.Add(i->second);
1013 NS_LOG_FUNCTION(
this << beamId);
1015 NodeContainer utNodes;
1018 std::pair<std::multimap<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator,
1019 std::multimap<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator>
1021 range =
m_utNode.equal_range(std::make_pair(satId, beamId));
1023 for (std::map<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator i = range.first;
1027 utNodes.Add(i->second);
1033 std::list<std::pair<uint32_t, uint32_t>>
1036 NS_LOG_FUNCTION(
this);
1038 std::list<std::pair<uint32_t, uint32_t>> ret;
1040 for (std::map<std::pair<uint32_t, uint32_t>, uint32_t>::const_iterator it =
m_beam.begin();
1044 ret.push_back(it->first);
1053 NS_LOG_FUNCTION(
this);
1061 NS_LOG_FUNCTION(
this);
1063 uint32_t beamId = 0;
1065 for (std::multimap<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator it =
1067 ((it !=
m_utNode.end()) && (beamId == 0));
1070 if (it->second == utNode)
1072 beamId = it->first.second;
1082 NS_LOG_FUNCTION(
this);
1089 Ptr<Node> sourceUtNode,
1090 Ipv4Address sourceAddress,
1091 Ipv4Address groupAddress,
1092 bool routeToGwUsers,
1093 Ptr<NetDevice>& gwOutputDev)
1095 NS_LOG_FUNCTION(
this);
1097 Mac48Address groupMacAddress;
1098 Ipv4StaticRoutingHelper multicast;
1099 NetDeviceContainer gwInputDevices;
1100 NetDeviceContainer routerGwOutputDevices;
1101 Ptr<NetDevice> routerDev = NULL;
1103 uint32_t sourceBeamId =
GetUtBeamId(sourceUtNode);
1107 if (groupAddress.IsMulticast())
1109 groupMacAddress = Mac48Address::GetMulticast(groupAddress);
1110 NS_LOG_INFO(
"IP address for multicast group: "
1111 << groupAddress <<
", MAC address for multicast group: " << groupMacAddress);
1115 NS_FATAL_ERROR(
"Invalid address for multicast group");
1121 for (NodeContainer::Iterator it = gwNodes.Begin(); it != gwNodes.End(); it++)
1123 bool routerGw =
false;
1124 NetDeviceContainer gwOutputDevices;
1125 Ptr<NetDevice> gwInputDev = NULL;
1128 for (uint32_t i = 1; i < (*it)->GetNDevices(); i++)
1130 Ptr<NetDevice> dev = (*it)->GetDevice(i);
1131 int32_t beamId = Singleton<SatIdMapper>::Get()->GetBeamIdWithMac(dev->GetAddress());
1132 MulticastBeamInfo_t::iterator beamIt = beamInfo.find(beamId);
1135 if (beamId == (int32_t)sourceBeamId)
1143 if (beamIt != beamInfo.end())
1146 if (dev->GetInstanceTypeId().GetName() ==
"ns3::SatNetDevice")
1150 gwOutputDevices.Add(dev);
1154 for (std::set<Ptr<Node>>::iterator utIt = beamIt->second.begin();
1155 utIt != beamIt->second.end();
1163 NS_FATAL_ERROR(
"Not a satellite net device!!!");
1166 else if (dev->GetInstanceTypeId().GetName() !=
"ns3::SatNetDevice")
1177 gwOutputDev = gwInputDev;
1182 routerGwOutputDevices = gwOutputDevices;
1184 else if (gwOutputDevices.GetN() >
1188 multicast.AddMulticastRoute(*it,
1195 gwInputDevices.Add(gwInputDev);
1201 if (sourceUtNode && ((gwInputDevices.GetN() > 0) || routeToGwUsers))
1205 NS_FATAL_ERROR(
"Router device shall exist!!!");
1208 routerGwOutputDevices.Add(gwOutputDev);
1218 if (routerDev && (routerGwOutputDevices.GetN() > 0))
1220 multicast.AddMulticastRoute(routerDev->GetNode(),
1224 routerGwOutputDevices);
1229 return gwInputDevices;
1235 NS_LOG_FUNCTION(
this);
1237 TraceConnect(
"Creation",
"SatBeamHelper", cb);
1239 m_gwHelper->EnableCreationTraces(stream, cb);
1240 m_utHelper->EnableCreationTraces(stream, cb);
1246 NS_LOG_FUNCTION(
this);
1248 double distanceMin = std::numeric_limits<double>::max();
1249 uint32_t indexDistanceMin = 0;
1251 for (uint32_t i = 0; i <
m_geoNodes.GetN(); i++)
1255 double distance = CalculateDistance(position.
ToVector(), satPos.
ToVector());
1256 if (distance < distanceMin)
1258 distanceMin = distance;
1259 indexDistanceMin = i;
1262 return indexDistanceMin;
1288 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/PacketTrace",
1290 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/SatPhy/PacketTrace",
1292 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/UserPhy/*/PacketTrace",
1294 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/FeederPhy/*/PacketTrace",
1296 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/SatMac/PacketTrace",
1301 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/UserMac/*/PacketTrace",
1303 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/FeederMac/*/PacketTrace",
1308 Config::ConnectWithoutContext(
"/NodeList/*/DeviceList/*/SatLlc/PacketTrace",
1316 NS_LOG_FUNCTION(
this);
1318 std::ostringstream oss;
1319 oss <<
"--- Beam Info, "
1320 <<
"number of created beams: " <<
m_beam.size() <<
" ---" << std::endl;
1333 NS_LOG_FUNCTION(
this);
1335 std::ostringstream oss;
1337 for (std::multimap<std::pair<uint32_t, uint32_t>, Ptr<Node>>::const_iterator i =
1346 Ptr<Ipv4> ipv4 = i->second->GetObject<Ipv4>();
1348 std::vector<Ipv4Address> IPAddressVector;
1349 std::vector<std::string> devNameVector;
1350 std::vector<Address> devAddressVector;
1352 for (uint32_t j = 0; j < i->second->GetNDevices(); j++)
1354 Ptr<NetDevice> device = i->second->GetDevice(j);
1356 if (device->GetInstanceTypeId().GetName() ==
"ns3::SatNetDevice")
1358 devAddress = device->GetAddress();
1360 IPAddressVector.push_back(
1361 ipv4->GetAddress(j, 0).GetLocal());
1362 devNameVector.push_back(device->GetInstanceTypeId().GetName());
1363 devAddressVector.push_back(device->GetAddress());
1368 oss << i->first.second <<
" "
1369 << Singleton<SatIdMapper>::Get()->GetUtIdWithMac(devAddress) <<
" "
1370 << pos.
GetLatitude() <<
" " << pos.GetLongitude() <<
" " << pos.GetAltitude()
1373 for (uint32_t j = 0; j < i->second->GetNDevices(); j++)
1375 oss << devNameVector[j] <<
" " << devAddressVector[j] <<
" " << IPAddressVector[j]
1383 oss << i->first.second <<
" "
1384 << Singleton<SatIdMapper>::Get()->GetUtIdWithMac(devAddress) <<
" "
1385 << pos.GetLatitude() <<
" " << pos.GetLongitude() <<
" " << pos.GetAltitude()
1396 NS_LOG_FUNCTION(
this);
1398 std::ostringstream oss;
1400 oss << std::endl <<
" -- Beam details --";
1402 for (std::map<std::pair<uint32_t, uint32_t>, uint32_t>::const_iterator i =
m_beam.begin();
1406 uint32_t satId = i->first.first;
1407 uint32_t beamId = i->first.second;
1409 oss << std::endl <<
"Sat ID: " << satId <<
" ";
1410 oss <<
"Beam ID: " << beamId <<
" ";
1412 std::map<std::pair<uint32_t, uint32_t>,
FrequencyPair_t>::const_iterator freqIds =
1417 oss <<
"user link frequency ID: " << (*freqIds).second.first <<
", ";
1418 oss <<
"feeder link frequency ID: " << (*freqIds).second.second;
1421 oss <<
", GW ID: " << (*i).second;
1424 oss << std::endl << std::endl <<
" -- GW details --" << std::endl;
1427 oss.setf(std::ios::fixed, std::ios::floatfield);
1429 for (std::map<uint32_t, Ptr<Node>>::const_iterator i =
m_gwNode.begin(); i !=
m_gwNode.end();
1436 Ptr<Ipv4> ipv4 = i->second->GetObject<Ipv4>();
1438 std::vector<Ipv4Address> IPAddressVector;
1439 std::vector<std::string> devNameVector;
1440 std::vector<Address> devAddressVector;
1442 for (uint32_t j = 0; j < i->second->GetNDevices(); j++)
1444 Ptr<NetDevice> device = i->second->GetDevice(j);
1446 if (device->GetInstanceTypeId().GetName() ==
"ns3::SatNetDevice")
1448 devAddress = device->GetAddress();
1451 IPAddressVector.push_back(
1452 ipv4->GetAddress(j, 0).GetLocal());
1453 devNameVector.push_back(device->GetInstanceTypeId().GetName());
1454 devAddressVector.push_back(device->GetAddress());
1459 oss <<
"GW=" << i->first <<
" "
1460 << Singleton<SatIdMapper>::Get()->GetUtIdWithMac(devAddress) <<
" "
1461 <<
" latitude=" << pos.
GetLatitude() <<
" longitude=" << pos.GetLongitude()
1462 <<
" altitude=" << pos.GetAltitude() <<
" ";
1464 for (uint32_t j = 0; j < i->second->GetNDevices(); j++)
1466 oss << devNameVector[j] <<
" " << devAddressVector[j] <<
" " << IPAddressVector[j]
1474 oss <<
"GW=" << i->first <<
" "
1475 << Singleton<SatIdMapper>::Get()->GetUtIdWithMac(devAddress) <<
" "
1476 <<
" latitude=" << pos.GetLatitude() <<
" longitude=" << pos.GetLongitude()
1477 <<
" altitude=" << pos.GetAltitude() << std::endl;
1481 oss << std::endl <<
" -- Geo Satellite position --" << std::endl;
1485 oss <<
"latitude=" << pos.
GetLatitude() <<
", longitude=" << pos.GetLongitude()
1486 <<
", altitude=" << pos.GetAltitude() << std::endl;
1494 uint32_t fwdFrequencyId,
1495 uint32_t rtnFrequencyId,
1498 NS_LOG_FUNCTION(
this << satId << beamId << fwdFrequencyId << rtnFrequencyId << isUserLink);
1502 bool hasFwdChannel = chPairs->HasFwdChannel(satId, fwdFrequencyId);
1503 bool hasRtnChannel = chPairs->HasRtnChannel(satId, rtnFrequencyId);
1505 if (hasFwdChannel && hasRtnChannel)
1507 chPairs->UpdateBeamsForFrequency(satId, beamId, fwdFrequencyId, rtnFrequencyId);
1511 Ptr<SatFreeSpaceLoss> pFsl;
1512 Ptr<PropagationDelayModel> pDelay;
1513 Ptr<SatChannel> forwardCh;
1514 Ptr<SatChannel> returnCh;
1518 forwardCh = chPairs->GetForwardChannel(satId, fwdFrequencyId);
1519 pDelay = forwardCh->GetPropagationDelayModel();
1520 pFsl = forwardCh->GetFreeSpaceLoss();
1522 else if (hasRtnChannel)
1524 returnCh = chPairs->GetReturnChannel(satId, rtnFrequencyId);
1525 pDelay = returnCh->GetPropagationDelayModel();
1526 pFsl = returnCh->GetFreeSpaceLoss();
1533 pDelay = CreateObject<ConstantSpeedPropagationDelayModel>();
1534 DynamicCast<ConstantSpeedPropagationDelayModel>(pDelay)->SetSpeed(
1539 pDelay = CreateObject<SatConstantPropagationDelayModel>();
1540 DynamicCast<SatConstantPropagationDelayModel>(pDelay)->SetDelay(
1545 NS_FATAL_ERROR(
"Unsupported propagation delay model!");
1548 pFsl = CreateObject<SatFreeSpaceLoss>();
1558 forwardCh->SetFrequencyId(fwdFrequencyId);
1559 forwardCh->SetPropagationDelayModel(pDelay);
1560 forwardCh->SetFreeSpaceLoss(pFsl);
1570 returnCh->SetFrequencyId(rtnFrequencyId);
1571 returnCh->SetPropagationDelayModel(pDelay);
1572 returnCh->SetFreeSpaceLoss(pFsl);
1576 ->StoreChannelPair(satId, beamId, fwdFrequencyId, forwardCh, rtnFrequencyId, returnCh);
1579 return chPairs->GetChannelPair(satId, beamId);
1585 NS_LOG_FUNCTION(
this <<
id << node);
1587 bool storingSuccess =
false;
1591 if (storedNode != NULL)
1593 if (storedNode == node)
1595 storingSuccess =
true;
1600 std::pair<std::map<uint32_t, Ptr<Node>>::iterator,
bool> result =
1601 m_gwNode.insert(std::make_pair(
id, node));
1602 storingSuccess = result.second;
1605 return storingSuccess;
1611 NS_LOG_FUNCTION(
this << node);
1613 Ptr<SatBaseFading> fadingContainer = node->GetObject<
SatBaseFading>();
1615 if (fadingContainer ==
nullptr)
1621 NS_ASSERT(observer != NULL);
1630 CreateObject<SatMarkovContainer>(
m_markovConf, elevationCb, velocityCb);
1631 node->AggregateObject(fadingContainer);
1638 CreateObject<SatFadingInputTrace>(Singleton<SatFadingInputTraceContainer>::Get());
1640 node->AggregateObject(fadingContainer);
1646 NS_FATAL_ERROR(
"SatBeamHelper::InstallFadingContainer - Incorrect fading model");
1651 return fadingContainer;
1656 Ipv4Address sourceAddress,
1657 Ipv4Address groupAddress,
1658 bool routeToSatellite)
1660 NS_LOG_FUNCTION(
this);
1662 Ptr<NetDevice> satDev = NULL;
1663 Ptr<NetDevice> publicDev = NULL;
1665 for (uint32_t i = 1; i < utNode->GetNDevices(); i++)
1667 Ptr<NetDevice> dev = utNode->GetDevice(i);
1670 if (dev->GetInstanceTypeId().GetName() ==
"ns3::SatNetDevice")
1681 if (satDev && publicDev)
1683 Ipv4StaticRoutingHelper multicast;
1685 if (routeToSatellite)
1687 multicast.AddMulticastRoute(utNode, sourceAddress, groupAddress, publicDev, satDev);
1691 multicast.AddMulticastRoute(utNode, sourceAddress, groupAddress, satDev, publicDev);
1698 NS_FATAL_ERROR(
"Input of output device not found in UT node!!!");
1702 Ptr<PropagationDelayModel>
1707 Ptr<SatChannel> channel = NULL;
1708 switch (channelType)
1711 channel =
m_flChannels->GetChannelPair(satId, beamId).first;
1715 channel =
m_ulChannels->GetChannelPair(satId, beamId).first;
1719 channel =
m_ulChannels->GetChannelPair(satId, beamId).second;
1723 channel =
m_flChannels->GetChannelPair(satId, beamId).second;
1731 return channel->GetPropagationDelayModel();
GeoCoordinate class is used to store and operate with geodetic coordinates.
double GetLatitude() const
Gets latitude value of coordinate.
Vector ToVector() const
Converts Geodetic coordinates to Cartesian 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.
void SetAntennaGainPatterns(Ptr< SatAntennaGainPatternContainer > antennaPatterns)
Set the antenna gain patterns to be used when configuring the beams to the GEO 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
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
The regeneration mode used in satellites for forward link.
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.
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)
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.
SatBeamHelper()
Default constructor for SatBeamHelper (should not be used).
SatEnums::LinkResults_t m_rlLinkResultsType
Type of Return channel link results.
std::string GetBeamInfo() const
Ptr< SatGeoHelper > GetGeoHelper() const
uint32_t GetUtBeamId(Ptr< Node > utNode) const
Get beam Id of the given UT.
NodeContainer GetGeoSatNodes() const
Gets Geo Satellite nodes.
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
void AddMulticastRouteToUt(Ptr< Node > utNode, Ipv4Address sourceAddress, Ipv4Address groupAddress, bool routeToSatellite)
Add multicast route to UT node.
static TypeId GetTypeId(void)
Get the type ID.
std::string GetUtInfo() const
std::string CreateBeamInfo() const
Creates info of the beam.
NodeContainer GetUtNodes() const
NodeContainer GetGwNodes() const
SatEnums::PropagationDelayModel_t m_propagationDelayModel
Propagation delay model.
SatEnums::RegenerationMode_t GetReturnLinkRegenerationMode() const
Get the regeneration mode used in satellites for return link.
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, SatUtMac::RoutingUpdateCallback routingCallback)
void SetStandard(SatEnums::Standard_t standard)
Set the standard to either DVB or Lora.
void EnablePacketTrace()
Enable packet traces.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
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.
NetDeviceContainer InstallUser(Ptr< SatGeoNetDevice > geoNetDevice, NodeContainer ut, Ptr< NetDevice > gwNd, uint32_t satId, uint32_t beamId, SatChannelPair::ChannelPair_t userLink, uint32_t rtnUlFreqId, uint32_t fwdUlFreqId, SatUtMac::RoutingUpdateCallback routingCallback)
Time m_ctrlMsgStoreTimeRtnLink
Control message store in container for return link.
uint32_t GetClosestSat(GeoCoordinate position)
Get closest satellite to a ground station.
Ptr< SatChannelPair > m_ulChannels
Ptr< NetDevice > InstallFeeder(Ptr< SatGeoNetDevice > geoNetDevice, Ptr< Node > gwNode, uint32_t gwId, uint32_t satId, uint32_t beamId, SatChannelPair::ChannelPair_t feederLink, uint32_t rtnFlFreqId, uint32_t fwdFlFreqId, SatUtMac::RoutingUpdateCallback routingCallback)
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
The regeneration mode used in satellites for return link.
Ptr< SatGwHelper > m_gwHelper
SatEnums::Standard_t m_standard
The global standard used.
Ptr< SatGeoHelper > m_geoHelper
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.
Standard_t
The global standard used.
@ 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
Keep track of the current position and velocity of satellite using SGP4 model.
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::RandomAccessCollisionModel m_raCollisionModel
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
SatPhyRxCarrierConf::InterferenceModel m_raRtnInterferenceModel
SatPhyRxCarrierConf::InterferenceModel m_raFwdInterferenceModel
SatEnums::RandomAccessModel_t m_randomAccessModel
Random access setting options.
SatPhyRxCarrierConf::InterferenceModel m_raInterferenceModel
double m_raConstantErrorRate
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
SatEnums::RandomAccessModel_t m_randomAccessModel
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
Define RandomAccessSettings as a struct.
SatEnums::RandomAccessModel_t m_randomAccessModel
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
SatPhyRxCarrierConf::InterferenceModel m_raInterferenceModel