Loading...
Searching...
No Matches
satellite-gw-helper-dvb.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013 Magister Solutions Ltd
4 * Copyright (c) 2018 CNES
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Author: Bastien Tauran <bastien.tauran@viveris.fr>
20 */
21
23
24#include "ns3/log.h"
25#include "ns3/pointer.h"
26#include "ns3/satellite-channel-estimation-error-container.h"
27#include "ns3/satellite-channel.h"
28#include "ns3/satellite-const-variables.h"
29#include "ns3/satellite-enums.h"
30#include "ns3/satellite-fwd-link-scheduler-default.h"
31#include "ns3/satellite-fwd-link-scheduler-time-slicing.h"
32#include "ns3/satellite-fwd-link-scheduler.h"
33#include "ns3/satellite-gw-llc.h"
34#include "ns3/satellite-gw-mac.h"
35#include "ns3/satellite-gw-phy.h"
36#include "ns3/satellite-id-mapper.h"
37#include "ns3/satellite-link-results.h"
38#include "ns3/satellite-lorawan-net-device.h"
39#include "ns3/satellite-lower-layer-service.h"
40#include "ns3/satellite-net-device.h"
41#include "ns3/satellite-node-info.h"
42#include "ns3/satellite-orbiter-net-device.h"
43#include "ns3/satellite-packet-classifier.h"
44#include "ns3/satellite-phy-rx-carrier-conf.h"
45#include "ns3/satellite-topology.h"
46#include "ns3/satellite-typedefs.h"
47#include "ns3/singleton.h"
48
49NS_LOG_COMPONENT_DEFINE("SatGwHelperDvb");
50
51namespace ns3
52{
53
54void
55logonCallbackHelper(Ptr<SatNcc> ncc,
56 Ptr<SatLowerLayerServiceConf> llsConf,
57 Address utId,
58 uint32_t satId,
59 uint32_t beamId,
60 Callback<void, uint32_t> setRaChannelCallback)
61{
62 ncc->AddUt(llsConf, utId, satId, beamId, setRaChannelCallback, true);
63}
64
65NS_OBJECT_ENSURE_REGISTERED(SatGwHelperDvb);
66
67TypeId
69{
70 static TypeId tid =
71 TypeId("ns3::SatGwHelperDvb").SetParent<SatGwHelper>().AddConstructor<SatGwHelperDvb>();
72 return tid;
73}
74
76{
77 // this default constructor should be never called
78 NS_FATAL_ERROR("Default constructor not supported!!!");
79}
80
82 uint32_t rtnLinkCarrierCount,
83 Ptr<SatSuperframeSeq> seq,
87 RandomAccessSettings_s randomAccessSettings)
88 : SatGwHelper(carrierBandwidthConverter,
89 rtnLinkCarrierCount,
90 seq,
91 readCb,
92 reserveCb,
93 sendCb,
94 randomAccessSettings)
95{
96 NS_LOG_FUNCTION(this << rtnLinkCarrierCount << seq);
97}
98
99Ptr<NetDevice>
101 uint32_t gwId,
102 uint32_t satId,
103 uint32_t beamId,
104 uint32_t feederSatId,
105 uint32_t feederBeamId,
106 Ptr<SatChannel> fCh,
107 Ptr<SatChannel> rCh,
109 Ptr<SatNcc> ncc,
110 Ptr<SatLowerLayerServiceConf> llsConf)
111{
112 NS_LOG_FUNCTION(this << n << gwId << satId << beamId << fCh << rCh << ncc << llsConf);
113
114 NetDeviceContainer container;
115
116 // Create SatNetDevice
117 Ptr<SatNetDevice> dev;
118 switch (Singleton<SatTopology>::Get()->GetStandard())
119 {
120 case SatEnums::DVB: {
121 m_deviceFactory.SetTypeId("ns3::SatNetDevice");
122 dev = m_deviceFactory.Create<SatNetDevice>();
123 break;
124 }
125 case SatEnums::LORA: {
126 m_deviceFactory.SetTypeId("ns3::SatLorawanNetDevice");
127 dev = m_deviceFactory.Create<SatLorawanNetDevice>();
128 break;
129 }
130 default:
131 NS_FATAL_ERROR("Incorrect standard chosen");
132 }
133
134 // Attach the SatNetDevices to nodes
135 n->AddDevice(dev);
136
138 params.m_satId = satId;
139 params.m_beamId = beamId;
140 params.m_device = dev;
141 params.m_txCh = fCh;
142 params.m_rxCh = rCh;
144
145 // Create a packet classifier
146 Ptr<SatPacketClassifier> classifier = Create<SatPacketClassifier>();
147
151 Ptr<SatChannelEstimationErrorContainer> cec;
152 // Not enabled, create only base class
154 {
155 cec = Create<SatSimpleChannelEstimationErrorContainer>();
156 }
157 // Create SatFwdLinkChannelEstimationErrorContainer
158 else
159 {
160 uint32_t minWfId = m_superframeSeq->GetWaveformConf()->GetMinWfId();
161 uint32_t maxWfId = m_superframeSeq->GetWaveformConf()->GetMaxWfId();
162 if (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
164 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() ==
166 {
167 cec = Create<SatRtnLinkChannelEstimationErrorContainer>(minWfId, maxWfId);
168 }
169 else
170 {
171 cec = Create<SatFwdLinkChannelEstimationErrorContainer>();
172 }
173 }
174
175 SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters =
176 SatPhyRxCarrierConf::RxCarrierCreateParams_s();
177 parameters.m_errorModel = m_errorModel;
178 parameters.m_daConstantErrorRate = m_daConstantErrorRate;
179 parameters.m_daIfModel = m_daInterferenceModel;
180 parameters.m_raIfModel = m_raSettings.m_raInterferenceModel;
181 parameters.m_raIfEliminateModel = m_raSettings.m_raInterferenceEliminationModel;
182 parameters.m_linkRegenerationMode =
183 Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode();
184 parameters.m_bwConverter = m_carrierBandwidthConverter;
185 parameters.m_carrierCount = m_rtnLinkCarrierCount;
186 parameters.m_cec = cec;
187 parameters.m_raCollisionModel = m_raSettings.m_raCollisionModel;
188 parameters.m_raConstantErrorRate = m_raSettings.m_raConstantErrorRate;
189 parameters.m_randomAccessModel = m_raSettings.m_randomAccessModel;
190
191 Ptr<SatGwPhy> phy = CreateObject<SatGwPhy>(
192 params,
194 parameters,
196 phy->SetChannelPairGetterCallback(cbChannel);
197
198 ncc->SetUseLogon(m_superframeSeq->GetSuperframeConf(SatConstVariables::SUPERFRAME_SEQUENCE)
199 ->IsLogonEnabled());
200
201 // Set fading
202 phy->SetTxFadingContainer(n->GetObject<SatBaseFading>());
203 phy->SetRxFadingContainer(n->GetObject<SatBaseFading>());
204
205 Ptr<SatGwMac> mac = CreateObject<SatGwMac>(n, satId, beamId, feederSatId, feederBeamId);
206
207 // Set the control message container callbacks
208 mac->SetReadCtrlCallback(m_readCtrlCb);
209 mac->SetReserveCtrlCallback(m_reserveCtrlCb);
210 mac->SetSendCtrlCallback(m_sendCtrlCb);
211
212 mac->SetCrReceiveCallback(MakeCallback(&SatNcc::UtCrReceived, ncc));
213
214 mac->SetHandoverCallback(MakeCallback(&SatNcc::MoveUtBetweenBeams, ncc));
215
216 // Attach the Mac layer receiver to Phy
217 SatPhy::ReceiveCallback recCb = MakeCallback(&SatGwMac::Receive, mac);
218
219 // Attach the NCC C/N0 update to Phy
220 SatPhy::CnoCallback cnoCb = MakeCallback(&SatNcc::UtCnoUpdated, ncc);
221
222 // Attach the NCC random access load update to Phy
223 SatPhy::AverageNormalizedOfferedLoadCallback avgNormalizedOfferedLoadCb =
225
226 phy->SetAttribute("ReceiveCb", CallbackValue(recCb));
227 phy->SetAttribute("CnoCb", CallbackValue(cnoCb));
228 phy->SetAttribute("AverageNormalizedOfferedLoadCallback",
229 CallbackValue(avgNormalizedOfferedLoadCb));
230
231 // Attach the PHY layer to SatNetDevice
232 dev->SetPhy(phy);
233
234 // Attach the Mac layer to SatNetDevice
235 dev->SetMac(mac);
236
237 // Create Logical Link Control (LLC) layer
238 Ptr<SatGwLlc> llc = CreateObject<SatGwLlc>();
239
240 // Set the control msg read callback to LLC due to ARQ ACKs
241 llc->SetReadCtrlCallback(m_readCtrlCb);
242
243 if (Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() != SatEnums::TRANSPARENT &&
244 Singleton<SatTopology>::Get()->GetForwardLinkRegenerationMode() !=
246 {
247 llc->SetAdditionalHeaderSize(SatAddressE2ETag::SIZE);
248 }
249
250 // Attach the LLC layer to SatNetDevice
251 dev->SetLlc(llc);
252
253 // Attach the packet classifier
254 dev->SetPacketClassifier(classifier);
255
256 // Attach the device receive callback to SatNetDevice
257 llc->SetReceiveCallback(MakeCallback(&SatNetDevice::Receive, dev));
258
259 // Attach the transmit callback to PHY
260 mac->SetTransmitCallback(MakeCallback(&SatPhy::SendPdu, phy));
261
262 // Attach the device receive callback to SatLlc
263 mac->SetReceiveCallback(MakeCallback(&SatLlc::Receive, llc));
264
265 // Attach the logon receive callback to SatNcc
266 mac->SetLogonCallback(MakeBoundCallback(&logonCallbackHelper, ncc, llsConf));
267
268 // Attach the beam handover callback to SatPhy
269 mac->SetBeamCallback(MakeCallback(&SatGwPhy::PerformHandover, phy));
270
271 // Attach the control burst receive callback to SatNcc
272 mac->SetControlMessageReceivedCallback(MakeCallback(&SatNcc::ReceiveControlBurst, ncc));
273
274 // Attach the remove UT to SatNcc
275 mac->SetRemoveUtCallback(MakeCallback(&SatNcc::RemoveUt, ncc));
276
277 // Set the device address and pass it to MAC as well
278 Mac48Address addr = Mac48Address::Allocate();
279 dev->SetAddress(addr);
280
281 Singleton<SatIdMapper>::Get()->AttachMacToTraceId(dev->GetAddress());
282 Singleton<SatIdMapper>::Get()->AttachMacToGwId(dev->GetAddress(), gwId);
283 Singleton<SatIdMapper>::Get()->AttachMacToBeamId(dev->GetAddress(), beamId);
284 Singleton<SatIdMapper>::Get()->AttachMacToSatId(dev->GetAddress(), satId + 1);
285
286 // Create an encapsulator for control messages.
287 // Source = GW address
288 // Destination = broadcast address
289 // Flow id = by default 0
290 Ptr<SatQueue> queue = CreateObject<SatQueue>(SatEnums::CONTROL_FID);
291 Ptr<SatBaseEncapsulator> gwEncap =
292 CreateObject<SatBaseEncapsulator>(addr,
293 Mac48Address::GetBroadcast(),
294 addr,
295 Mac48Address::GetBroadcast(),
297 gwEncap->SetQueue(queue);
298 llc->AddEncap(addr, Mac48Address::GetBroadcast(), SatEnums::CONTROL_FID, gwEncap);
299 llc->SetCtrlMsgCallback(MakeCallback(&SatNetDevice::SendControlMsg, dev));
300
301 phy->Initialize();
302
303 // Create a node info to all the protocol layers
304 Ptr<SatNodeInfo> nodeInfo = Create<SatNodeInfo>(SatEnums::NT_GW, n->GetId(), addr);
305 dev->SetNodeInfo(nodeInfo);
306 llc->SetNodeInfo(nodeInfo);
307 mac->SetNodeInfo(nodeInfo);
308 phy->SetNodeInfo(nodeInfo);
309
310 // Begin frame end scheduling for processes utilizing frame length as interval
311 // Node info needs to be set before the start in order to get the scheduling context correctly
312 // set
313 if (Singleton<SatTopology>::Get()->GetReturnLinkRegenerationMode() == SatEnums::TRANSPARENT)
314 {
315 phy->BeginEndScheduling();
316 }
317
318 // TODO: When multiple carriers are supported. Multiple scheduler are needed too.
319 double carrierBandwidth =
321
322 Ptr<SatFwdLinkScheduler> fwdLinkScheduler;
324 {
326 fwdLinkScheduler =
327 CreateObject<SatFwdLinkSchedulerDefault>(m_bbFrameConf, addr, carrierBandwidth);
328 break;
330 fwdLinkScheduler =
331 CreateObject<SatFwdLinkSchedulerTimeSlicing>(m_bbFrameConf, addr, carrierBandwidth);
332 break;
333 default:
334 NS_FATAL_ERROR("Forward scheduling algorithm is not implemented");
335 }
336
337 fwdLinkScheduler->SetSendControlMsgCallback(MakeCallback(&SatNetDevice::SendControlMsg, dev));
338
339 // Attach the LLC Tx opportunity and scheduling context getter callbacks to SatFwdLinkScheduler
340 fwdLinkScheduler->SetTxOpportunityCallback(MakeCallback(&SatGwLlc::NotifyTxOpportunity, llc));
341 fwdLinkScheduler->SetSchedContextCallback(MakeCallback(&SatLlc::GetSchedulingContexts, llc));
342
343 // set scheduler to Mac
344 mac->SetFwdScheduler(fwdLinkScheduler);
345
346 mac->SetClearQueuesCallback(MakeCallback(&SatGwLlc::ClearQueues, llc));
347 mac->StartPeriodicTransmissions();
348
349 Ptr<SatHandoverModule> handoverModule = n->GetObject<SatHandoverModule>();
350 if (handoverModule != nullptr)
351 {
352 handoverModule->SetHandoverRequestCallback(MakeCallback(&SatGwMac::ChangeBeam, mac));
353 mac->SetBeamSchedulerCallback(MakeCallback(&SatNcc::GetBeamScheduler, ncc));
354 mac->SetHandoverModule(handoverModule);
355 }
356
357 Singleton<SatTopology>::Get()
358 ->AddGwLayersDvb(n, feederSatId, feederBeamId, satId, beamId, dev, llc, mac, phy);
359
360 return dev;
361}
362
363} // namespace ns3
static const uint32_t SIZE
Base class for fading models such as Markov-based fading or fading trace.
virtual Ptr< NetDevice > Install(Ptr< Node > n, uint32_t gwId, uint32_t satId, uint32_t beamId, uint32_t feederSatId, uint32_t feederBeamId, Ptr< SatChannel > fCh, Ptr< SatChannel > rCh, SatPhy::ChannelPairGetterCallback cbChannel, Ptr< SatNcc > ncc, Ptr< SatLowerLayerServiceConf > llsConf)
SatGwHelperDvb()
Default constructor.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< SatSuperframeSeq > m_superframeSeq
SatPhy::ErrorModel m_errorModel
SatMac::SendCtrlMsgCallback m_sendCtrlCb
RandomAccessSettings_s m_raSettings
The used random access model settings.
SatEnums::FwdSchedulingAlgorithm_t m_fwdSchedulingAlgorithm
The forward link algorithm used.
bool m_enableChannelEstimationError
Enable channel estimation error modeling at forward link receiver (= UT).
SatMac::ReadCtrlMsgCallback m_readCtrlCb
ObjectFactory m_deviceFactory
Ptr< SatBbFrameConf > m_bbFrameConf
Ptr< SatLinkResults > m_linkResults
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.
virtual void ClearQueues()
Remove all packets from the queues.
void ChangeBeam(uint32_t satId, uint32_t beamId)
Method handling beam handover.
void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)
Receive packet from lower layer.
void PerformHandover(uint32_t satId, uint32_t beamId)
Change underlying SatChannel to send and receive data from a new satellite and beam.
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.
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 MoveUtBetweenBeams(Address utId, uint32_t srcSatId, uint32_t srcBeamId, uint32_t destSatId, uint32_t destBeamId)
Check if a terminal can be moved between two beams.
void UtCrReceived(uint32_t satId, uint32_t beamId, Address utId, Ptr< SatCrMessage > crMsg)
Capacity request receiver.
Ptr< SatBeamScheduler > GetBeamScheduler(uint32_t satId, uint32_t beamId) const
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 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
Callback< SatChannelPair::ChannelPair_t, uint32_t, uint32_t > ChannelPairGetterCallback
Callback for retrieving a pair of SatChannel associated to a beam.
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)
Creation parameters for base PHY object.
SatEnums::SatLoraNodeType_t m_standard