23 #include "ns3/satellite-gw-helper.h"
25 #include <ns3/config.h>
26 #include <ns3/double.h>
29 #include <ns3/lorawan-mac-gateway.h>
30 #include <ns3/names.h>
31 #include <ns3/pointer.h>
32 #include <ns3/satellite-channel-estimation-error-container.h>
33 #include <ns3/satellite-channel.h>
34 #include <ns3/satellite-const-variables.h>
35 #include <ns3/satellite-enums.h>
36 #include <ns3/satellite-fwd-link-scheduler-default.h>
37 #include <ns3/satellite-fwd-link-scheduler-time-slicing.h>
38 #include <ns3/satellite-fwd-link-scheduler.h>
39 #include <ns3/satellite-geo-net-device.h>
40 #include <ns3/satellite-gw-llc.h>
41 #include <ns3/satellite-gw-mac.h>
42 #include <ns3/satellite-gw-phy.h>
43 #include <ns3/satellite-id-mapper.h>
44 #include <ns3/satellite-link-results.h>
45 #include <ns3/satellite-lora-conf.h>
46 #include <ns3/satellite-lorawan-net-device.h>
47 #include <ns3/satellite-lower-layer-service.h>
48 #include <ns3/satellite-mac-tag.h>
49 #include <ns3/satellite-net-device.h>
50 #include <ns3/satellite-node-info.h>
51 #include <ns3/satellite-packet-classifier.h>
52 #include <ns3/satellite-phy-rx-carrier-conf.h>
53 #include <ns3/satellite-phy-rx.h>
54 #include <ns3/satellite-phy-tx.h>
55 #include <ns3/satellite-typedefs.h>
56 #include <ns3/satellite-utils.h>
57 #include <ns3/singleton.h>
58 #include <ns3/uinteger.h>
60 NS_LOG_COMPONENT_DEFINE(
"SatGwHelper");
67 Ptr<SatLowerLayerServiceConf> llsConf,
71 Callback<void, uint32_t> setRaChannelCallback)
73 ncc->AddUt(llsConf, utId, satId, beamId, setRaChannelCallback,
true);
76 NS_OBJECT_ENSURE_REGISTERED(SatGwHelper);
82 TypeId(
"ns3::SatGwHelper")
84 .AddConstructor<SatGwHelper>()
85 .AddAttribute(
"DaRtnLinkInterferenceModel",
86 "Return link interference model for dedicated access",
97 .AddAttribute(
"RtnLinkErrorModel",
98 "Return link error model for",
107 .AddAttribute(
"FwdSchedulingAlgorithm",
108 "The scheduling algorithm used to fill the BBFrames",
115 .AddAttribute(
"RtnLinkConstantErrorRate",
116 "Constant error rate",
119 MakeDoubleChecker<double>())
120 .AddAttribute(
"EnableChannelEstimationError",
121 "Enable channel estimation error in return link receiver at GW.",
124 MakeBooleanChecker())
125 .AddTraceSource(
"Creation",
128 "ns3::SatTypedefs::CreationCallback");
139 : m_rtnLinkCarrierCount(0),
142 m_daConstantErrorRate(0.0),
144 m_enableChannelEstimationError(false),
148 NS_FATAL_ERROR(
"Default constructor not supported!!!");
152 uint32_t rtnLinkCarrierCount,
153 Ptr<SatSuperframeSeq> seq,
158 : m_carrierBandwidthConverter(carrierBandwidthConverter),
159 m_rtnLinkCarrierCount(rtnLinkCarrierCount),
160 m_superframeSeq(seq),
161 m_readCtrlCb(readCb),
162 m_reserveCtrlCb(reserveCb),
163 m_sendCtrlCb(sendCb),
166 m_daConstantErrorRate(0.0),
168 m_enableChannelEstimationError(false),
169 m_raSettings(randomAccessSettings)
171 NS_LOG_FUNCTION(
this << rtnLinkCarrierCount);
181 Ptr<SatLinkResultsFwd> lrFwd,
185 NS_LOG_FUNCTION(
this);
190 Config::SetDefault(
"ns3::SatBbFrameConf::PlHeaderInSlots", UintegerValue(1));
193 Config::SetDefault(
"ns3::SatBbFrameConf::PlHeaderInSlots", UintegerValue(2));
196 NS_FATAL_ERROR(
"Forward scheduling algorithm is not implemented");
226 NS_LOG_FUNCTION(
this);
234 NS_LOG_FUNCTION(
this << n1);
242 NS_LOG_FUNCTION(
this << n1);
250 NS_LOG_FUNCTION(
this << n1);
252 Config::SetDefault(
"ns3::SatGwPhy::" + n1, v1);
263 Ptr<SatLowerLayerServiceConf> llsConf,
267 NS_LOG_FUNCTION(
this << satId << beamId << fCh << rCh);
269 NetDeviceContainer devs;
271 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
281 forwardLinkRegenerationMode,
282 returnLinkRegenerationMode));
296 Ptr<SatLowerLayerServiceConf> llsConf,
300 NS_LOG_FUNCTION(
this << n << satId << beamId << fCh << rCh);
302 NetDeviceContainer container;
320 Ptr<SatPacketClassifier> classifier = Create<SatPacketClassifier>();
325 Ptr<SatChannelEstimationErrorContainer> cec;
329 cec = Create<SatSimpleChannelEstimationErrorContainer>();
339 cec = Create<SatRtnLinkChannelEstimationErrorContainer>(minWfId, maxWfId);
343 cec = Create<SatFwdLinkChannelEstimationErrorContainer>();
347 SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters =
348 SatPhyRxCarrierConf::RxCarrierCreateParams_s();
354 parameters.m_linkRegenerationMode = returnLinkRegenerationMode;
357 parameters.m_cec = cec;
362 Ptr<SatGwPhy> phy = CreateObject<SatGwPhy>(
367 returnLinkRegenerationMode);
376 Ptr<SatGwMac> mac = CreateObject<SatGwMac>(satId,
378 forwardLinkRegenerationMode,
379 returnLinkRegenerationMode);
400 phy->SetAttribute(
"ReceiveCb", CallbackValue(recCb));
401 phy->SetAttribute(
"CnoCb", CallbackValue(cnoCb));
402 phy->SetAttribute(
"AverageNormalizedOfferedLoadCallback",
403 CallbackValue(avgNormalizedOfferedLoadCb));
413 CreateObject<SatGwLlc>(forwardLinkRegenerationMode, returnLinkRegenerationMode);
428 dev->SetPacketClassifier(classifier);
449 Mac48Address addr = Mac48Address::Allocate();
450 dev->SetAddress(addr);
452 Singleton<SatIdMapper>::Get()->AttachMacToTraceId(dev->GetAddress());
453 Singleton<SatIdMapper>::Get()->AttachMacToGwId(dev->GetAddress(), gwId);
454 Singleton<SatIdMapper>::Get()->AttachMacToBeamId(dev->GetAddress(), beamId);
455 Singleton<SatIdMapper>::Get()->AttachMacToSatId(dev->GetAddress(), satId + 1);
462 Ptr<SatBaseEncapsulator> gwEncap =
463 CreateObject<SatBaseEncapsulator>(addr,
464 Mac48Address::GetBroadcast(),
466 Mac48Address::GetBroadcast(),
468 gwEncap->SetQueue(queue);
475 Ptr<SatNodeInfo> nodeInfo = Create<SatNodeInfo>(
SatEnums::NT_GW, n->GetId(), addr);
476 dev->SetNodeInfo(nodeInfo);
477 llc->SetNodeInfo(nodeInfo);
478 mac->SetNodeInfo(nodeInfo);
479 phy->SetNodeInfo(nodeInfo);
486 phy->BeginEndScheduling();
490 double carrierBandwidth =
493 Ptr<SatFwdLinkScheduler> fwdLinkScheduler;
498 CreateObject<SatFwdLinkSchedulerDefault>(
m_bbFrameConf, addr, carrierBandwidth);
502 CreateObject<SatFwdLinkSchedulerTimeSlicing>(
m_bbFrameConf, addr, carrierBandwidth);
505 NS_FATAL_ERROR(
"Forward scheduling algorithm is not implemented");
515 mac->SetFwdScheduler(fwdLinkScheduler);
517 mac->StartPeriodicTransmissions();
530 Ptr<SatLowerLayerServiceConf> llsConf,
534 NS_LOG_FUNCTION(
this << satId << beamId << fCh << rCh);
536 NetDeviceContainer devs;
538 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
548 forwardLinkRegenerationMode,
549 returnLinkRegenerationMode));
563 Ptr<SatLowerLayerServiceConf> llsConf,
567 NS_LOG_FUNCTION(
this << n << satId << beamId << fCh << rCh);
569 NetDeviceContainer container;
589 Ptr<SatChannelEstimationErrorContainer> cec;
593 cec = Create<SatSimpleChannelEstimationErrorContainer>();
603 cec = Create<SatRtnLinkChannelEstimationErrorContainer>(minWfId, maxWfId);
607 cec = Create<SatFwdLinkChannelEstimationErrorContainer>();
611 SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters =
612 SatPhyRxCarrierConf::RxCarrierCreateParams_s();
618 parameters.m_linkRegenerationMode = returnLinkRegenerationMode;
621 parameters.m_cec = cec;
626 Ptr<SatGwPhy> phy = CreateObject<SatGwPhy>(
631 returnLinkRegenerationMode);
633 ncc->SetUseLora(
true);
639 Ptr<LorawanMacGateway> mac = CreateObject<LorawanMacGateway>(satId, beamId);
654 phy->SetAttribute(
"ReceiveCb", CallbackValue(recCb));
655 phy->SetAttribute(
"CnoCb", CallbackValue(cnoCb));
656 phy->SetAttribute(
"AverageNormalizedOfferedLoadCallback",
657 CallbackValue(avgNormalizedOfferedLoadCb));
663 dev->SetLorawanMac(mac);
669 Mac48Address addr = Mac48Address::Allocate();
670 dev->SetAddress(addr);
672 Singleton<SatIdMapper>::Get()->AttachMacToTraceId(dev->GetAddress());
673 Singleton<SatIdMapper>::Get()->AttachMacToGwId(dev->GetAddress(), gwId);
674 Singleton<SatIdMapper>::Get()->AttachMacToBeamId(dev->GetAddress(), beamId);
675 Singleton<SatIdMapper>::Get()->AttachMacToSatId(dev->GetAddress(), satId + 1);
680 Ptr<SatNodeInfo> nodeInfo = Create<SatNodeInfo>(
SatEnums::NT_GW, n->GetId(), addr);
681 dev->SetNodeInfo(nodeInfo);
682 mac->SetNodeInfo(nodeInfo);
683 phy->SetNodeInfo(nodeInfo);
690 phy->BeginEndScheduling();
699 NS_LOG_FUNCTION(
this);
701 TraceConnect(
"Creation",
"SatGwHelper", cb);
virtual void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)=0
Receive a packet from the lower layer.
static const uint32_t SIZE
Base class for fading models such as Markov-based fading or fading trace.
RegenerationMode_t
The regeneration mode used in satellites.
DvbVersion_t
The scheduling algorithm used to fill the BBFrames.
Ptr< SatSuperframeSeq > m_superframeSeq
SatPhy::ErrorModel m_errorModel
ObjectFactory m_channelFactory
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
void Initialize(Ptr< SatLinkResultsRtn > lrRcs2, Ptr< SatLinkResultsFwd > lrFwd, SatEnums::DvbVersion_t dvbVersion, bool useScpc)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetPhyAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Phy created by the helper.
static TypeId GetTypeId(void)
Get the type ID.
SatMac::SendCtrlMsgCallback m_sendCtrlCb
RandomAccessSettings_s m_raSettings
The used random access model settings.
TracedCallback< std::string > m_creationTrace
Trace callback for creation traces.
NetDeviceContainer InstallDvb(NodeContainer c, uint32_t gwId, uint32_t satId, uint32_t beamId, Ptr< SatChannel > fCh, Ptr< SatChannel > rCh, Ptr< SatNcc > ncc, Ptr< SatLowerLayerServiceConf > llsConf, SatEnums::RegenerationMode_t forwardLinkRegenerationMode, SatEnums::RegenerationMode_t returnLinkRegenerationMode)
void EnableCreationTraces(Ptr< OutputStreamWrapper > stream, CallbackBase &cb)
Enables creation traces to be written in given file.
SatEnums::FwdSchedulingAlgorithm_t m_fwdSchedulingAlgorithm
The forward link algorithm used.
uint32_t m_rtnLinkCarrierCount
bool m_enableChannelEstimationError
Enable channel estimation error modeling at forward link receiver (= UT).
double m_daConstantErrorRate
Ptr< SatBbFrameConf > GetBbFrameConf() const
Get BB frame configuration.
SatMac::ReadCtrlMsgCallback m_readCtrlCb
ObjectFactory m_deviceFactory
Ptr< SatBbFrameConf > m_bbFrameConf
Ptr< SatLinkResults > m_linkResults
TypeId GetInstanceTypeId(void) const
NetDeviceContainer InstallLora(NodeContainer c, uint32_t gwId, uint32_t satId, uint32_t beamId, Ptr< SatChannel > fCh, Ptr< SatChannel > rCh, Ptr< SatNcc > ncc, Ptr< SatLowerLayerServiceConf > llsConf, SatEnums::RegenerationMode_t forwardLinkRegenerationMode, SatEnums::RegenerationMode_t returnLinkRegenerationMode)
SatMac::ReserveCtrlMsgCallback m_reserveCtrlCb
SatGwHelper()
Default constructor.
SatPhy::InterferenceModel m_daInterferenceModel
SatTypedefs::CarrierBandwidthConverter_t m_carrierBandwidthConverter
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 Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)
Receive packet from lower layer.
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.
A configuration class for the GEO satellite reference system.
void SetConf(Ptr< LorawanMacGateway > gatewayMac)
SatLorawanNetDevice to be utilized in the UT and GW nodes for IoT configuration.
Callback< uint32_t, Ptr< SatControlMessage > > ReserveCtrlMsgCallback
Callback to reserve an id and initially store the control message.
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.
void ReceiveControlBurst(Address utId, uint32_t satId, uint32_t beamId)
Function to call when a control burst has been received.
void RemoveUt(Address utId, uint32_t satId, uint32_t beamId)
Remove a UT.
void UtCrReceived(uint32_t satId, uint32_t beamId, Address utId, Ptr< SatCrMessage > crMsg)
Capacity request receiver.
void DoRandomAccessDynamicLoadControl(uint32_t satId, uint32_t beamId, uint32_t carrierId, uint8_t allocationChannelId, double averageNormalizedOfferedLoad)
Function for adjusting the random access allocation channel specific load.
void MoveUtBetweenBeams(Address utId, uint32_t satId, uint32_t srcBeamId, uint32_t destBeamId)
Check if a terminal can be moved between two beams.
void UtCnoUpdated(uint32_t satId, uint32_t beamId, Address sourceMac, Address gwId, double cno, bool isSatelliteMac)
Update UT specific C/N0 information.
SatNetDevice to be utilized in the UT and GW nodes.
virtual void Receive(Ptr< const Packet > packet)
bool SendControlMsg(Ptr< SatControlMessage > msg, const Address &dest)
Callback< void, uint32_t, uint32_t, Address, Address, double, bool > CnoCallback
virtual void SendPdu(PacketContainer_t, uint32_t carrierId, Time duration, SatSignalParameters::txInfo_s txInfo)
Send Pdu to the PHY tx module (for initial transmissions from either UT or GW)
Callback< void, uint32_t, uint32_t, uint32_t, uint8_t, double > AverageNormalizedOfferedLoadCallback
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.
void logonCallbackHelper(Ptr< SatNcc > ncc, Ptr< SatLowerLayerServiceConf > llsConf, Address utId, uint32_t satId, uint32_t beamId, Callback< void, uint32_t > setRaChannelCallback)
Random access setting options.
SatPhyRxCarrierConf::InterferenceModel m_raInterferenceModel
double m_raConstantErrorRate
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
SatEnums::RandomAccessModel_t m_randomAccessModel
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
Creation parameters for base PHY object.
Ptr< NetDevice > m_device
SatEnums::SatLoraNodeType_t m_standard