28 #include "ns3/config.h"
29 #include "ns3/double.h"
32 #include "ns3/names.h"
33 #include "ns3/packet.h"
34 #include "ns3/pointer.h"
35 #include "ns3/satellite-channel-estimation-error-container.h"
36 #include "ns3/satellite-const-variables.h"
37 #include "ns3/satellite-id-mapper.h"
38 #include "ns3/satellite-orbiter-feeder-llc.h"
39 #include "ns3/satellite-orbiter-feeder-mac.h"
40 #include "ns3/satellite-orbiter-feeder-phy.h"
41 #include "ns3/satellite-orbiter-user-llc.h"
42 #include "ns3/satellite-orbiter-user-mac.h"
43 #include "ns3/satellite-orbiter-user-phy.h"
44 #include "ns3/satellite-phy-rx-carrier-conf.h"
45 #include "ns3/satellite-phy-rx.h"
46 #include "ns3/satellite-phy-tx.h"
47 #include "ns3/satellite-topology.h"
48 #include "ns3/satellite-typedefs.h"
49 #include "ns3/satellite-utils.h"
50 #include "ns3/singleton.h"
51 #include "ns3/uinteger.h"
58 NS_LOG_COMPONENT_DEFINE(
"SatOrbiterHelper");
63 NS_OBJECT_ENSURE_REGISTERED(SatOrbiterHelper);
69 TypeId(
"ns3::SatOrbiterHelper")
71 .AddAttribute(
"DaFwdLinkInterferenceModel",
72 "Forward link interference model for dedicated access",
74 MakeEnumAccessor<SatPhyRxCarrierConf::InterferenceModel>(
84 .AddAttribute(
"DaRtnLinkInterferenceModel",
85 "Return link interference model for dedicated access",
87 MakeEnumAccessor<SatPhyRxCarrierConf::InterferenceModel>(
97 .AddAttribute(
"FwdLinkErrorModel",
98 "Forward feeder link error model",
100 MakeEnumAccessor<SatPhyRxCarrierConf::ErrorModel>(
108 .AddAttribute(
"FwdLinkConstantErrorRate",
109 "Constant error rate on forward feeder link",
112 MakeDoubleChecker<double>())
113 .AddAttribute(
"RtnLinkErrorModel",
114 "Return user link error model",
116 MakeEnumAccessor<SatPhyRxCarrierConf::ErrorModel>(
124 .AddAttribute(
"RtnLinkConstantErrorRate",
125 "Constant error rate on return user link",
128 MakeDoubleChecker<double>())
131 "Arbiter in use to route packets on ISLs",
135 .AddTraceSource(
"Creation",
138 "ns3::SatTypedefs::CreationCallback");
145 NS_LOG_FUNCTION(
this);
151 : m_carrierBandwidthConverter(),
152 m_fwdLinkCarrierCount(),
153 m_rtnLinkCarrierCount(),
161 m_islArbiterType(
SatEnums::UNICAST),
165 NS_LOG_FUNCTION(
this);
172 uint32_t rtnLinkCarrierCount,
173 uint32_t fwdLinkCarrierCount,
174 Ptr<SatSuperframeSeq> seq,
178 : m_carrierBandwidthConverter(bandwidthConverterCb),
179 m_fwdLinkCarrierCount(fwdLinkCarrierCount),
180 m_rtnLinkCarrierCount(rtnLinkCarrierCount),
185 m_superframeSeq(seq),
186 m_raSettings(randomAccessSettings),
189 m_fwdReadCtrlCb(fwdReadCb),
190 m_rtnReadCtrlCb(rtnReadCb)
192 NS_LOG_FUNCTION(
this << rtnLinkCarrierCount << fwdLinkCarrierCount);
198 NS_LOG_FUNCTION(
this);
234 NS_LOG_FUNCTION(
this << n1);
242 NS_LOG_FUNCTION(
this << n1);
244 Config::SetDefault(
"ns3::SatOrbiterUserPhy::" + n1, v1);
250 NS_LOG_FUNCTION(
this << n1);
252 Config::SetDefault(
"ns3::SatOrbiterFeederPhy::" + n1, v1);
258 NS_LOG_FUNCTION(
this);
260 NodeContainer c = Singleton<SatTopology>::Get()->GetOrbiterNodes();
261 NetDeviceContainer devs;
263 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
274 NS_LOG_FUNCTION(
this << n);
281 satDev->SetAddress(Mac48Address::Allocate());
282 n->AddDevice(satDev);
286 Singleton<SatIdMapper>::Get()->AttachMacToTraceId(satDev->GetAddress());
287 Singleton<SatIdMapper>::Get()->AttachMacToSatId(satDev->GetAddress(),
m_nodeIds.size());
295 NS_LOG_FUNCTION(
this << aName);
297 Ptr<Node> n = Names::Find<Node>(aName);
308 Ptr<SatAntennaGainPattern> userAgp,
309 Ptr<SatAntennaGainPattern> feederAgp,
315 NS_LOG_FUNCTION(
this << d << ff << fr << uf << ur << userAgp << feederAgp << satId << gwId
318 Ptr<SatOrbiterNetDevice> dev = DynamicCast<SatOrbiterNetDevice>(d);
320 dev->SetForwardLinkRegenerationMode(
321 Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode());
322 dev->SetReturnLinkRegenerationMode(
323 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode());
324 dev->SetNodeId(satId);
334 Ptr<SatAntennaGainPattern> feederAgp,
340 NS_LOG_FUNCTION(
this << dev << ff << fr << feederAgp << satId << gwId << userBeamId);
351 Ptr<SatChannelEstimationErrorContainer> cec =
352 Create<SatSimpleChannelEstimationErrorContainer>();
354 SatPhyRxCarrierConf::RxCarrierCreateParams_s parametersFeeder =
355 SatPhyRxCarrierConf::RxCarrierCreateParams_s();
361 parametersFeeder.m_linkRegenerationMode =
362 Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode();
365 parametersFeeder.m_cec = cec;
372 Ptr<SatOrbiterFeederPhy> fPhy = CreateObject<SatOrbiterFeederPhy>(
381 fPhy->SetTxAntennaGainPattern(feederAgp, dev->GetNode()->GetObject<
SatMobilityModel>());
382 fPhy->SetRxAntennaGainPattern(feederAgp, dev->GetNode()->GetObject<
SatMobilityModel>());
384 dev->AddFeederPhy(fPhy, userBeamId);
388 Ptr<SatOrbiterFeederMac> fMac;
389 Ptr<SatOrbiterFeederLlc> fLlc;
390 bool startScheduler =
false;
393 fMac = CreateObject<SatOrbiterFeederMac>(satId, userBeamId);
395 Mac48Address feederAddress;
398 switch (std::max(Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode(),
399 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode()))
404 Ptr<SatNodeInfo> niPhyFeeder =
407 Mac48Address::ConvertFrom(dev->GetAddress()));
408 fPhy->SetNodeInfo(niPhyFeeder);
409 fMac->SetNodeInfo(niPhyFeeder);
415 fLlc = CreateObject<SatOrbiterFeederLlc>();
417 if (
m_gwMacMap.count(std::make_pair(satId, gwId)))
420 dev->AddFeederMac(fMac,
m_gwMacMap[std::make_pair(satId, gwId)], userBeamId);
421 Singleton<SatTopology>::Get()->AddOrbiterFeederMacPair(
428 dev->AddFeederMac(fMac, fMac, userBeamId);
429 Singleton<SatTopology>::Get()->AddOrbiterFeederMacPair(fMac, fMac);
430 m_gwMacMap[std::make_pair(satId, gwId)] = fMac;
431 startScheduler =
true;
438 feederAddress = Mac48Address::Allocate();
439 Ptr<SatNodeInfo> niFeeder =
441 fPhy->SetNodeInfo(niFeeder);
442 fMac->SetNodeInfo(niFeeder);
443 fLlc->SetNodeInfo(niFeeder);
445 dev->AddFeederPair(userBeamId, feederAddress);
451 fLlc = CreateObject<SatOrbiterFeederLlc>();
453 if (
m_gwMacMap.count(std::make_pair(satId, gwId)))
456 dev->AddFeederMac(fMac,
m_gwMacMap[std::make_pair(satId, gwId)], userBeamId);
457 Singleton<SatTopology>::Get()->AddOrbiterFeederMacPair(
464 dev->AddFeederMac(fMac, fMac, userBeamId);
465 Singleton<SatTopology>::Get()->AddOrbiterFeederMacPair(fMac, fMac);
466 m_gwMacMap[std::make_pair(satId, gwId)] = fMac;
467 startScheduler =
true;
474 feederAddress = Mac48Address::Allocate();
475 Ptr<SatNodeInfo> niFeeder =
477 fPhy->SetNodeInfo(niFeeder);
478 fMac->SetNodeInfo(niFeeder);
479 fLlc->SetNodeInfo(niFeeder);
481 dev->AddFeederPair(userBeamId, feederAddress);
486 NS_FATAL_ERROR(
"Forward or return link regeneration mode unknown");
490 switch (Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode())
495 fPhy->SetAttribute(
"ReceiveCb", CallbackValue(fCb));
503 fPhy->SetAttribute(
"ReceiveCb", CallbackValue(fCb));
507 fLlc->SetReceiveSatelliteCallback(
513 NS_FATAL_ERROR(
"Forward link regeneration mode unknown");
517 switch (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode())
531 Ptr<SatScpcScheduler> scpcScheduler =
532 CreateObject<SatScpcScheduler>(
m_bbFrameConfRtn, feederAddress, carrierBandwidth);
533 fMac->SetFwdScheduler(scpcScheduler);
537 fMac->StartPeriodicTransmissions();
542 scpcScheduler->SetTxOpportunityCallback(
549 NS_FATAL_ERROR(
"Return link regeneration mode unknown");
552 Singleton<SatTopology>::Get()->AddOrbiterFeederLayers(dev->GetNode(),
553 dev->GetNode()->GetId(),
564 NS_LOG_FUNCTION(
this);
566 TraceConnect(
"Creation",
"SatOrbiterHelper", cb);
572 NS_LOG_FUNCTION(
this);
577 Ptr<SatIslArbiterUnicastHelper> satIslArbiterHelper =
578 CreateObject<SatIslArbiterUnicastHelper>(isls);
579 satIslArbiterHelper->InstallArbiters();
583 NS_FATAL_ERROR(
"ISL Arbiter ECMP not implemented yet");
586 NS_FATAL_ERROR(
"Unknown ISL arbiter");
SatEnums class is for simplifying the use of enumerators in the satellite module.
virtual void GetSchedulingContexts(std::vector< Ptr< SatSchedulingObject >> &output) const =0
Create and fill the scheduling objects based on LLC layer information.
virtual void Receive(Ptr< Packet > packet, Mac48Address source, Mac48Address dest)
Receive user data packet from lower layer.
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.
void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters > rxParams)
Receive packet from lower layer.
virtual void SendPduWithParams(Ptr< SatSignalParameters > rxParams)
Send Pdu to the PHY tx module (for satellite switch packet forwarding)
Ptr< SatLinkResults > m_rtnLinkResults
Return channel link results (DVB-RCS2) are created if ErrorModel is configured to be AVI.
SatPhy::InterferenceModel m_daFwdLinkInterferenceModel
SatMac::ReadCtrlMsgCallback m_fwdReadCtrlCb
Control forward link messages callback.
SatEnums::IslArbiterType_t m_islArbiterType
Arbiter in use to route packets on ISLs.
virtual void AttachChannelsUser(Ptr< SatOrbiterNetDevice > dev, Ptr< SatChannel > uf, Ptr< SatChannel > ur, Ptr< SatAntennaGainPattern > userAgp, Ptr< SatNcc > ncc, uint32_t satId, uint32_t userBeamId)=0
void Initialize(Ptr< SatLinkResultsFwd > lrFwd, Ptr< SatLinkResultsRtn > lrRcs2)
std::map< std::pair< uint32_t, uint32_t >, Ptr< SatOrbiterFeederMac > > m_gwMacMap
Map used in regenerative mode to store if MAC already created for a given pair SAT ID / GW ID.
void SetFeederPhyAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Feeder Phy created by the helper.
double m_fwdDaConstantErrorRate
void SetUserPhyAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each User Phy created by the helper.
TypeId GetInstanceTypeId(void) const
RandomAccessSettings_s m_raSettings
The used random access model settings.
ObjectFactory m_deviceFactory
std::vector< uint32_t > m_nodeIds
Satellites node id.
double m_rtnDaConstantErrorRate
SatPhy::ErrorModel m_rtnErrorModel
NetDeviceContainer InstallAllOrbiters()
This method creates a ns3::SatOrbiterNetDevices with the requested attributes and associate the resul...
Ptr< SatBbFrameConf > m_bbFrameConfFwd
void AttachChannelsFeeder(Ptr< SatOrbiterNetDevice > dev, Ptr< SatChannel > ff, Ptr< SatChannel > fr, Ptr< SatAntennaGainPattern > feederAgp, Ptr< SatNcc > ncc, uint32_t satId, uint32_t gwId, uint32_t userBeamId)
TracedCallback< std::string > m_creationTrace
Trace callback for creation traces.
Ptr< SatLinkResults > m_fwdLinkResults
Forward channel link results (DVB-S2) are created if ErrorModel is configured to be AVI.
Ptr< SatSuperframeSeq > m_superframeSeq
Superframe sequence.
SatPhy::InterferenceModel m_daRtnLinkInterferenceModel
virtual Ptr< SatOrbiterNetDevice > CreateOrbiterNetDevice()=0
Create a SatOrbiterNetDevice instance, with correct type infered from child classes.
SatPhy::ErrorModel m_fwdErrorModel
void AttachChannels(Ptr< NetDevice > dev, Ptr< SatChannel > ff, Ptr< SatChannel > fr, Ptr< SatChannel > uf, Ptr< SatChannel > ur, Ptr< SatAntennaGainPattern > userAgp, Ptr< SatAntennaGainPattern > feederAgp, Ptr< SatNcc > ncc, uint32_t satId, uint32_t gwId, uint32_t userBeamId)
uint32_t m_fwdLinkCarrierCount
SatTypedefs::CarrierBandwidthConverter_t m_carrierBandwidthConverter
void SetIslRoutes(std::vector< std::pair< uint32_t, uint32_t >> isls)
Set ISL routes.
void EnableCreationTraces(Ptr< OutputStreamWrapper > stream, CallbackBase &cb)
Enables creation traces to be written in given file.
Ptr< SatBbFrameConf > m_bbFrameConfRtn
SatOrbiterHelper()
Default constructor.
Ptr< NetDevice > Install(Ptr< Node > n)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
static TypeId GetTypeId(void)
Get the type ID.
std::map< uint32_t, uint16_t > m_deviceCount
virtual Ptr< Packet > NotifyTxOpportunity(uint32_t bytes, Mac48Address utAddr, uint8_t flowId, uint32_t &bytesLeft, uint32_t &nextMinTxO)
Called from lower layer (MAC) to inform a Tx opportunity of certain amount of bytes.
void ReceiveFeeder(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters > rxParams)
Receive the packet from the lower layers.
virtual void ReceivePacketFeeder(Ptr< Packet > packet, const Address &feederAddress)=0
Receive the packet from the lower layers, in network regeneration on forward link.
Callback< void, PacketContainer_t, Ptr< SatSignalParameters > > ReceiveCallback
Information of beam users liken UTs and their users.
Callback< double, SatEnums::ChannelType_t, uint32_t, SatEnums::CarrierBandwidthType_t > CarrierBandwidthConverter_t
Callback for carrier bandwidths.
constexpr uint8_t SUPERFRAME_SEQUENCE
Used superframe sequence in the RTN link.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Random access setting options.
SatPhyRxCarrierConf::InterferenceModel m_raFwdInterferenceModel
SatEnums::RandomAccessModel_t m_randomAccessModel
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
Creation parameters for base PHY object.
Ptr< NetDevice > m_device
SatEnums::SatLoraNodeType_t m_standard