25 #include <ns3/callback.h>
26 #include <ns3/config.h>
27 #include <ns3/double.h>
30 #include <ns3/lorawan-mac-end-device-class-a.h>
31 #include <ns3/names.h>
32 #include <ns3/nstime.h>
33 #include <ns3/pointer.h>
34 #include <ns3/satellite-base-encapsulator.h>
35 #include <ns3/satellite-channel-estimation-error-container.h>
36 #include <ns3/satellite-channel.h>
37 #include <ns3/satellite-const-variables.h>
38 #include <ns3/satellite-enums.h>
39 #include <ns3/satellite-generic-stream-encapsulator-arq.h>
40 #include <ns3/satellite-generic-stream-encapsulator.h>
41 #include <ns3/satellite-gw-llc.h>
42 #include <ns3/satellite-id-mapper.h>
43 #include <ns3/satellite-lora-conf.h>
44 #include <ns3/satellite-lorawan-net-device.h>
45 #include <ns3/satellite-mac-tag.h>
46 #include <ns3/satellite-mobility-observer.h>
47 #include <ns3/satellite-net-device.h>
48 #include <ns3/satellite-node-info.h>
49 #include <ns3/satellite-packet-classifier.h>
50 #include <ns3/satellite-phy-rx-carrier-conf.h>
51 #include <ns3/satellite-phy-rx.h>
52 #include <ns3/satellite-phy-tx.h>
53 #include <ns3/satellite-queue.h>
54 #include <ns3/satellite-request-manager.h>
55 #include <ns3/satellite-return-link-encapsulator-arq.h>
56 #include <ns3/satellite-return-link-encapsulator.h>
57 #include <ns3/satellite-typedefs.h>
58 #include <ns3/satellite-ut-handover-module.h>
59 #include <ns3/satellite-ut-llc.h>
60 #include <ns3/satellite-ut-mac.h>
61 #include <ns3/satellite-ut-phy.h>
62 #include <ns3/satellite-ut-scheduler.h>
63 #include <ns3/satellite-utils.h>
64 #include <ns3/singleton.h>
65 #include <ns3/string.h>
66 #include <ns3/uinteger.h>
68 NS_LOG_COMPONENT_DEFINE(
"SatUtHelper");
73 NS_OBJECT_ENSURE_REGISTERED(SatUtHelper);
79 TypeId(
"ns3::SatUtHelper")
81 .AddConstructor<SatUtHelper>()
82 .AddAttribute(
"DaFwdLinkInterferenceModel",
83 "Forward link interference model for dedicated access",
94 .AddAttribute(
"FwdLinkErrorModel",
95 "Forward link error model",
104 .AddAttribute(
"FwdLinkConstantErrorRate",
105 "Constant error rate",
108 MakeDoubleChecker<double>())
109 .AddAttribute(
"LowerLayerServiceConf",
110 "Pointer to lower layer service configuration.",
113 MakePointerChecker<SatLowerLayerServiceConf>())
114 .AddAttribute(
"EnableChannelEstimationError",
115 "Enable channel estimation error in forward link receiver at UT.",
118 MakeBooleanChecker())
119 .AddAttribute(
"UseCrdsaOnlyForControlPackets",
120 "CRDSA utilized only for control packets or also for user data.",
123 MakeBooleanChecker())
124 .AddAttribute(
"AsynchronousReturnAccess",
125 "Use asynchronous access methods on the return channel.",
128 MakeBooleanChecker())
129 .AddTraceSource(
"Creation",
132 "ns3::SatTypedefs::CreationCallback");
139 NS_LOG_FUNCTION(
this);
145 : m_carrierBandwidthConverter(),
146 m_fwdLinkCarrierCount(),
150 m_daConstantErrorRate(0.0),
153 m_enableChannelEstimationError(false),
154 m_crdsaOnlyForControl(false),
155 m_asyncAccess(false),
158 NS_LOG_FUNCTION(
this);
161 NS_FATAL_ERROR(
"SatUtHelper::SatUtHelper - Constructor not in use");
165 uint32_t fwdLinkCarrierCount,
166 Ptr<SatSuperframeSeq> seq,
171 : m_carrierBandwidthConverter(carrierBandwidthConverter),
172 m_fwdLinkCarrierCount(fwdLinkCarrierCount),
173 m_superframeSeq(seq),
174 m_readCtrlCb(readCb),
175 m_reserveCtrlCb(reserveCb),
176 m_sendCtrlCb(sendCb),
179 m_daConstantErrorRate(0.0),
182 m_enableChannelEstimationError(false),
183 m_crdsaOnlyForControl(false),
184 m_raSettings(randomAccessSettings)
186 NS_LOG_FUNCTION(
this << fwdLinkCarrierCount << seq);
190 m_llsConf = CreateObject<SatLowerLayerServiceConf>();
196 NS_LOG_FUNCTION(
this);
209 NS_LOG_FUNCTION(
this << n1);
217 NS_LOG_FUNCTION(
this << n1);
225 NS_LOG_FUNCTION(
this << n1);
227 Config::SetDefault(
"ns3::SatUtPhy::" + n1, v1);
236 Ptr<SatNetDevice> gwNd,
238 Address satUserAddress,
244 NS_LOG_FUNCTION(
this << beamId << fCh << rCh);
246 NetDeviceContainer devs;
248 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
260 forwardLinkRegenerationMode,
261 returnLinkRegenerationMode));
273 Ptr<SatNetDevice> gwNd,
275 Address satUserAddress,
281 NS_LOG_FUNCTION(
this << n << beamId << fCh << rCh);
283 NetDeviceContainer container;
301 Ptr<SatPacketClassifier> classifier = Create<SatPacketClassifier>();
306 Ptr<SatChannelEstimationErrorContainer> cec;
310 cec = Create<SatSimpleChannelEstimationErrorContainer>();
315 cec = Create<SatFwdLinkChannelEstimationErrorContainer>();
318 SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters =
319 SatPhyRxCarrierConf::RxCarrierCreateParams_s();
325 parameters.m_linkRegenerationMode = forwardLinkRegenerationMode;
328 parameters.m_cec = cec;
332 Ptr<SatUtPhy> phy = CreateObject<SatUtPhy>(
337 forwardLinkRegenerationMode);
338 phy->SetChannelPairGetterCallback(cbChannel);
344 Ptr<SatUtMac> mac = CreateObject<SatUtMac>(satId,
347 forwardLinkRegenerationMode,
348 returnLinkRegenerationMode,
360 NS_ASSERT(observer != NULL);
364 mac->SetTimingAdvanceCallback(timingCb);
370 phy->SetAttribute(
"ReceiveCb", CallbackValue(recCb));
378 CreateObject<SatUtLlc>(forwardLinkRegenerationMode, returnLinkRegenerationMode);
384 Ptr<SatRequestManager> rm = CreateObject<SatRequestManager>();
385 llc->SetRequestManager(rm);
417 dev->SetPacketClassifier(classifier);
421 phy->SetAttribute(
"CnoCb", CallbackValue(cnoCb));
424 Mac48Address addr = Mac48Address::Allocate();
425 dev->SetAddress(addr);
427 Singleton<SatIdMapper>::Get()->AttachMacToTraceId(dev->GetAddress());
428 Singleton<SatIdMapper>::Get()->AttachMacToUtId(dev->GetAddress());
429 Singleton<SatIdMapper>::Get()->AttachMacToBeamId(dev->GetAddress(), beamId);
430 Singleton<SatIdMapper>::Get()->AttachMacToSatId(dev->GetAddress(), satId + 1);
433 Mac48Address gwAddr = Mac48Address::ConvertFrom(gwNd->GetAddress());
439 Ptr<SatBaseEncapsulator> utEncap;
442 utEncap = CreateObject<SatBaseEncapsulator>(addr,
443 Mac48Address::ConvertFrom(satUserAddress),
469 queue->AddLogonCallback(logonCb);
470 queue->AddQueueEventCallback(macCb);
471 queue->AddQueueEventCallback(rmCb);
472 utEncap->SetQueue(queue);
476 Mac48Address::ConvertFrom(satUserAddress),
489 llc->SetMacQueueEventCallback(macCb);
492 mac->SetRoutingUpdateCallback(cbRouting);
494 mac->SetGwAddress(gwAddr);
507 Ptr<SatSuperframeConf> superFrameConf =
509 bool enableLogon = superFrameConf->IsLogonEnabled();
510 uint32_t logonChannelId = superFrameConf->GetLogonChannelIndex();
515 ncc->ReserveLogonChannel(logonChannelId);
529 Ptr<SatUtScheduler> utScheduler = CreateObject<SatUtScheduler>(
m_llsConf);
532 mac->SetAttribute(
"Scheduler", PointerValue(utScheduler));
535 Ptr<SatNodeInfo> nodeInfo = Create<SatNodeInfo>(
SatEnums::NT_UT, n->GetId(), addr);
536 dev->SetNodeInfo(nodeInfo);
537 llc->SetNodeInfo(nodeInfo);
538 mac->SetNodeInfo(nodeInfo);
539 phy->SetNodeInfo(nodeInfo);
545 Ptr<SatRandomAccessConf> randomAccessConf =
549 Ptr<SatRandomAccess> randomAccess =
555 randomAccess->SetAreBuffersEmptyCallback(
564 mac->SetRandomAccess(randomAccess);
567 mac->SetLogonChannel(logonChannelId);
571 else if (enableLogon)
573 NS_FATAL_ERROR(
"Cannot simulate logon without a RA frame");
577 if (utHandoverModule != NULL)
581 mac->SetBeamCheckerCallback(
583 mac->SetAskedBeamCallback(
598 Ptr<SatNetDevice> gwNd,
600 Address satUserAddress,
606 NS_LOG_FUNCTION(
this << beamId << fCh << rCh);
608 NetDeviceContainer devs;
610 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
622 forwardLinkRegenerationMode,
623 returnLinkRegenerationMode));
635 Ptr<SatNetDevice> gwNd,
637 Address satUserAddress,
643 NS_LOG_FUNCTION(
this << n << beamId << fCh << rCh);
645 NetDeviceContainer container;
665 Ptr<SatChannelEstimationErrorContainer> cec;
669 cec = Create<SatSimpleChannelEstimationErrorContainer>();
674 cec = Create<SatFwdLinkChannelEstimationErrorContainer>();
677 SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters =
678 SatPhyRxCarrierConf::RxCarrierCreateParams_s();
684 parameters.m_linkRegenerationMode = forwardLinkRegenerationMode;
687 parameters.m_cec = cec;
691 Ptr<SatUtPhy> phy = CreateObject<SatUtPhy>(
696 forwardLinkRegenerationMode);
697 phy->SetChannelPairGetterCallback(cbChannel);
703 Ptr<LorawanMacEndDeviceClassA> mac =
704 CreateObject<LorawanMacEndDeviceClassA>(satId, beamId,
m_superframeSeq);
707 mac->SetTxDbmForTxPower(std::vector<double>{16, 14, 12, 10, 8, 6, 4, 2});
715 phy->SetAttribute(
"ReceiveCb", CallbackValue(recCb));
721 dev->SetLorawanMac(mac);
725 mac->SetPhyRx(DynamicCast<SatLoraPhyRx>(phy->GetPhyRx()));
729 Mac48Address addr = Mac48Address::Allocate();
730 dev->SetAddress(addr);
732 Singleton<SatIdMapper>::Get()->AttachMacToTraceId(dev->GetAddress());
733 Singleton<SatIdMapper>::Get()->AttachMacToUtId(dev->GetAddress());
734 Singleton<SatIdMapper>::Get()->AttachMacToBeamId(dev->GetAddress(), beamId);
735 Singleton<SatIdMapper>::Get()->AttachMacToSatId(dev->GetAddress(), satId + 1);
738 Mac48Address gwAddr = Mac48Address::ConvertFrom(gwNd->GetAddress());
741 mac->SetRoutingUpdateCallback(cbRouting);
742 mac->SetGwAddress(gwAddr);
754 Ptr<SatNodeInfo> nodeInfo = Create<SatNodeInfo>(
SatEnums::NT_UT, n->GetId(), addr);
755 dev->SetNodeInfo(nodeInfo);
756 mac->SetNodeInfo(nodeInfo);
757 phy->SetNodeInfo(nodeInfo);
765 NS_LOG_FUNCTION(
this);
767 TraceConnect(
"Creation",
"SatUtHelper", cb);
void SetRaChannel(uint32_t raChannel)
Set RA channel assigned for this UT.
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.
virtual bool BuffersEmpty() const
Are buffers empty?
virtual void GetSchedulingContexts(std::vector< Ptr< SatSchedulingObject >> &output) const =0
Create and fill the scheduling objects based on LLC layer information.
virtual bool ControlBuffersEmpty() const
Are buffers empty?
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< 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.
Observes given mobilities and keeps track of certain wanted properties.
Time GetTimingAdvance(void)
Get timing advance.
Ptr< SatBeamScheduler > GetBeamScheduler(uint32_t satId, uint32_t beamId) const
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, PacketContainer_t, Ptr< SatSignalParameters > > ReceiveCallback
Callback< SatChannelPair::ChannelPair_t, uint32_t, uint32_t > ChannelPairGetterCallback
Callback for retrieving a pair of SatChannel associated to a beam.
Information of beam users liken UTs and their users.
Callback< void, SatQueue::QueueEvent_t, uint8_t > QueueEventCallback
Callback to indicate queue related event.
Callback< void, Ptr< Packet > > LogonCallback
logon msg sending callback
QueueStats_t GetQueueStatistics(bool reset)
GetQueueStatistics returns a struct of KPIs.
void AssignedDaResources(uint8_t rcIndex, uint32_t bytes)
Sat UT MAC informs that certain amount of resources have been received in TBTP.
void SendLogonMessage()
Send a logon message to the gateway.
void ReceiveQueueEvent(SatQueue::QueueEvent_t event, uint8_t rcIndex)
Receive a queue event.
void SendHandoverRecommendation(uint32_t beamId)
Send a handover recommendation message to the gateway.
void SetGwAddress(Mac48Address address)
Set the GW address needed for CR transmission.
void CnoUpdated(uint32_t satId, uint32_t beamId, Address sourceMac, Address gwId, double cno, bool isSatelliteMac)
Update C/N0 information from lower layer.
Callback< double, SatEnums::ChannelType_t, uint32_t, SatEnums::CarrierBandwidthType_t > CarrierBandwidthConverter_t
Callback for carrier bandwidths.
void SetHandoverRequestCallback(SatUtHandoverModule::HandoverRequestCallback cb)
Set the handover recommendation message sending callback.
bool CheckForHandoverRecommendation(uint32_t satId, uint32_t beamId)
Inspect whether or not the given beam is still suitable for the underlying mobility model.
uint32_t GetAskedBeamId()
Get the best beam ID.
NetDeviceContainer InstallLora(NodeContainer c, uint32_t satId, uint32_t beamId, Ptr< SatChannel > fCh, Ptr< SatChannel > rCh, Ptr< SatNetDevice > gwNd, Ptr< SatNcc > ncc, Address satUserAddress, SatPhy::ChannelPairGetterCallback cbChannel, SatMac::RoutingUpdateCallback cbRouting, SatEnums::RegenerationMode_t forwardLinkRegenerationMode, SatEnums::RegenerationMode_t returnLinkRegenerationMode)
void EnableCreationTraces(Ptr< OutputStreamWrapper > stream, CallbackBase &cb)
Enables creation traces to be written in given file.
SatPhy::ErrorModel m_errorModel
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
SatPhy::InterferenceModel m_daInterferenceModel
uint32_t m_fwdLinkCarrierCount
RandomAccessSettings_s m_raSettings
The used random access model settings.
bool m_enableChannelEstimationError
Enable channel estimation error modeling at forward link receiver (= UT).
SatMac::ReadCtrlMsgCallback m_readCtrlCb
TracedCallback< std::string > m_creationTrace
Trace callback for creation traces.
void SetPhyAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Phy created by the helper.
void Initialize(Ptr< SatLinkResultsFwd > lrFwd)
ObjectFactory m_channelFactory
double m_daConstantErrorRate
Ptr< SatLinkResults > m_linkResults
Ptr< SatLowerLayerServiceConf > m_llsConf
Configured lower layer service configuration.
NetDeviceContainer InstallDvb(NodeContainer c, uint32_t satId, uint32_t beamId, Ptr< SatChannel > fCh, Ptr< SatChannel > rCh, Ptr< SatNetDevice > gwNd, Ptr< SatNcc > ncc, Address satUserAddress, SatPhy::ChannelPairGetterCallback cbChannel, SatMac::RoutingUpdateCallback cbRouting, SatEnums::RegenerationMode_t forwardLinkRegenerationMode, SatEnums::RegenerationMode_t returnLinkRegenerationMode)
SatUtHelper()
Default constructor.
SatTypedefs::CarrierBandwidthConverter_t m_carrierBandwidthConverter
ObjectFactory m_deviceFactory
bool m_crdsaOnlyForControl
Planned CRDSA usage:
SatMac::SendCtrlMsgCallback m_sendCtrlCb
Ptr< SatSuperframeSeq > m_superframeSeq
SatMac::ReserveCtrlMsgCallback m_reserveCtrlCb
static TypeId GetTypeId(void)
Derived from Object.
TypeId GetInstanceTypeId(void) const
Derived from Object.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetGwAddress(Mac48Address address)
Set the GW address.
virtual Ptr< Packet > NotifyTxOpportunity(uint32_t bytes, Mac48Address utAddr, uint8_t rcIndex, uint32_t &bytesLeft, uint32_t &nextMinTxO)
Called from lower layer (MAC) to inform a Tx opportunity of certain amount of bytes.
virtual void ReceiveQueueEventEssa(SatQueue::QueueEvent_t event, uint8_t rcIndex)
Receive a queue event:
virtual void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)
Receive packet from lower layer.
void SendLogon(Ptr< Packet > packet)
Receive a logon message to transmit /param packet The logon packet to send.
virtual void ReceiveQueueEvent(SatQueue::QueueEvent_t event, uint8_t rcIndex)
Receive a queue event:
Callback< Time > TimingAdvanceCallback
void SetRaChannel(uint32_t raChannel)
Set RA channel assigned for this UT.
bool ControlMsgTransmissionPossible() const
Method to check whether a transmission of a control msg is somewhat possible.
bool LogonMsgTransmissionPossible() const
Method to check whether a transmission of a logon msg is somewhat possible.
void PerformHandover(uint32_t beamId)
Change underlying SatChannel to send and receive data from a new beam.
bool IsTxPossible(void) const
Inform whether or not the underlying Tx channel is properly configured for transmission.
void UpdateSliceSubscription(uint8_t slice)
Updates the slices subscription list.
constexpr uint8_t SUPERFRAME_SEQUENCE
Used superframe sequence in the RTN link.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Creation parameters for base PHY object.
Ptr< NetDevice > m_device
SatEnums::SatLoraNodeType_t m_standard
Define RandomAccessSettings as a struct.
SatEnums::RandomAccessModel_t m_randomAccessModel
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
SatPhyRxCarrierConf::InterferenceModel m_raInterferenceModel