satellite-gw-helper.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: Sami Rantanen <sami.rantanen@magister.fi>
20  * Author: Mathias Ettinger <mettinger@viveris.toulouse.fr>
21  */
22 
23 #include "ns3/satellite-gw-helper.h"
24 
25 #include <ns3/config.h>
26 #include <ns3/double.h>
27 #include <ns3/enum.h>
28 #include <ns3/log.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>
59 
60 NS_LOG_COMPONENT_DEFINE("SatGwHelper");
61 
62 namespace ns3
63 {
64 
65 void
66 logonCallbackHelper(Ptr<SatNcc> ncc,
67  Ptr<SatLowerLayerServiceConf> llsConf,
68  Address utId,
69  uint32_t satId,
70  uint32_t beamId,
71  Callback<void, uint32_t> setRaChannelCallback)
72 {
73  ncc->AddUt(llsConf, utId, satId, beamId, setRaChannelCallback, true);
74 }
75 
76 NS_OBJECT_ENSURE_REGISTERED(SatGwHelper);
77 
78 TypeId
80 {
81  static TypeId tid =
82  TypeId("ns3::SatGwHelper")
83  .SetParent<Object>()
84  .AddConstructor<SatGwHelper>()
85  .AddAttribute("DaRtnLinkInterferenceModel",
86  "Return link interference model for dedicated access",
88  MakeEnumAccessor(&SatGwHelper::m_daInterferenceModel),
89  MakeEnumChecker(SatPhyRxCarrierConf::IF_CONSTANT,
90  "Constant",
92  "Trace",
94  "PerPacket",
96  "PerFragment"))
97  .AddAttribute("RtnLinkErrorModel",
98  "Return link error model for",
99  EnumValue(SatPhyRxCarrierConf::EM_AVI),
100  MakeEnumAccessor(&SatGwHelper::m_errorModel),
101  MakeEnumChecker(SatPhyRxCarrierConf::EM_NONE,
102  "None",
104  "Constant",
106  "AVI"))
107  .AddAttribute("FwdSchedulingAlgorithm",
108  "The scheduling algorithm used to fill the BBFrames",
109  EnumValue(SatEnums::NO_TIME_SLICING),
110  MakeEnumAccessor(&SatGwHelper::m_fwdSchedulingAlgorithm),
111  MakeEnumChecker(SatEnums::NO_TIME_SLICING,
112  "NoTimeSlicing",
114  "TimeSlicing"))
115  .AddAttribute("RtnLinkConstantErrorRate",
116  "Constant error rate",
117  DoubleValue(0.01),
118  MakeDoubleAccessor(&SatGwHelper::m_daConstantErrorRate),
119  MakeDoubleChecker<double>())
120  .AddAttribute("EnableChannelEstimationError",
121  "Enable channel estimation error in return link receiver at GW.",
122  BooleanValue(true),
123  MakeBooleanAccessor(&SatGwHelper::m_enableChannelEstimationError),
124  MakeBooleanChecker())
125  .AddTraceSource("Creation",
126  "Creation traces",
127  MakeTraceSourceAccessor(&SatGwHelper::m_creationTrace),
128  "ns3::SatTypedefs::CreationCallback");
129  return tid;
130 }
131 
132 TypeId
134 {
135  return GetTypeId();
136 }
137 
139  : m_rtnLinkCarrierCount(0),
140  m_daInterferenceModel(SatPhyRxCarrierConf::IF_CONSTANT),
141  m_errorModel(SatPhyRxCarrierConf::EM_AVI),
142  m_daConstantErrorRate(0.0),
143  m_symbolRate(0.0),
144  m_enableChannelEstimationError(false),
145  m_raSettings()
146 {
147  // this default constructor should be never called
148  NS_FATAL_ERROR("Default constructor not supported!!!");
149 }
150 
152  uint32_t rtnLinkCarrierCount,
153  Ptr<SatSuperframeSeq> seq,
157  RandomAccessSettings_s randomAccessSettings)
158  : m_carrierBandwidthConverter(carrierBandwidthConverter),
159  m_rtnLinkCarrierCount(rtnLinkCarrierCount),
160  m_superframeSeq(seq),
161  m_readCtrlCb(readCb),
162  m_reserveCtrlCb(reserveCb),
163  m_sendCtrlCb(sendCb),
164  m_daInterferenceModel(SatPhyRxCarrierConf::IF_CONSTANT),
165  m_errorModel(SatPhyRxCarrierConf::EM_AVI),
166  m_daConstantErrorRate(0.0),
167  m_symbolRate(0.0),
168  m_enableChannelEstimationError(false),
169  m_raSettings(randomAccessSettings)
170 {
171  NS_LOG_FUNCTION(this << rtnLinkCarrierCount);
172 
173  m_deviceFactory.SetTypeId("ns3::SatNetDevice");
174  m_channelFactory.SetTypeId("ns3::SatChannel");
175 
176  // LogComponentEnable ("SatGwHelper", LOG_LEVEL_INFO);
177 }
178 
179 void
180 SatGwHelper::Initialize(Ptr<SatLinkResultsRtn> lrRcs2,
181  Ptr<SatLinkResultsFwd> lrFwd,
182  SatEnums::DvbVersion_t dvbVersion,
183  bool useScpc)
184 {
185  NS_LOG_FUNCTION(this);
186 
187  switch (m_fwdSchedulingAlgorithm)
188  {
190  Config::SetDefault("ns3::SatBbFrameConf::PlHeaderInSlots", UintegerValue(1));
191  break;
193  Config::SetDefault("ns3::SatBbFrameConf::PlHeaderInSlots", UintegerValue(2));
194  break;
195  default:
196  NS_FATAL_ERROR("Forward scheduling algorithm is not implemented");
197  }
198 
199  // TODO: Usage of multiple carriers needed to take into account, now only one carrier assumed to
200  // be used.
201  // TODO: Symbol rate needed to check.
202  m_symbolRate =
204 
205  /*
206  * Return channel link results (DVB-RCS2) are created for GWs.
207  */
208  if (lrRcs2 && m_errorModel == SatPhyRxCarrierConf::EM_AVI)
209  {
210  m_linkResults = lrRcs2;
211  }
212  if (useScpc)
213  {
214  m_linkResults = lrFwd;
215  }
216 
217  m_bbFrameConf = CreateObject<SatBbFrameConf>(m_symbolRate, dvbVersion);
218  m_bbFrameConf->InitializeCNoRequirements(lrFwd);
219 
220  // m_bbFrameConf->DumpWaveforms ();
221 }
222 
223 Ptr<SatBbFrameConf>
225 {
226  NS_LOG_FUNCTION(this);
227 
228  return m_bbFrameConf;
229 }
230 
231 void
232 SatGwHelper::SetDeviceAttribute(std::string n1, const AttributeValue& v1)
233 {
234  NS_LOG_FUNCTION(this << n1);
235 
236  m_deviceFactory.Set(n1, v1);
237 }
238 
239 void
240 SatGwHelper::SetChannelAttribute(std::string n1, const AttributeValue& v1)
241 {
242  NS_LOG_FUNCTION(this << n1);
243 
244  m_channelFactory.Set(n1, v1);
245 }
246 
247 void
248 SatGwHelper::SetPhyAttribute(std::string n1, const AttributeValue& v1)
249 {
250  NS_LOG_FUNCTION(this << n1);
251 
252  Config::SetDefault("ns3::SatGwPhy::" + n1, v1);
253 }
254 
255 NetDeviceContainer
256 SatGwHelper::InstallDvb(NodeContainer c,
257  uint32_t gwId,
258  uint32_t satId,
259  uint32_t beamId,
260  Ptr<SatChannel> fCh,
261  Ptr<SatChannel> rCh,
262  Ptr<SatNcc> ncc,
263  Ptr<SatLowerLayerServiceConf> llsConf,
264  SatEnums::RegenerationMode_t forwardLinkRegenerationMode,
265  SatEnums::RegenerationMode_t returnLinkRegenerationMode)
266 {
267  NS_LOG_FUNCTION(this << satId << beamId << fCh << rCh);
268 
269  NetDeviceContainer devs;
270 
271  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
272  {
273  devs.Add(InstallDvb(*i,
274  gwId,
275  satId,
276  beamId,
277  fCh,
278  rCh,
279  ncc,
280  llsConf,
281  forwardLinkRegenerationMode,
282  returnLinkRegenerationMode));
283  }
284 
285  return devs;
286 }
287 
288 Ptr<NetDevice>
290  uint32_t gwId,
291  uint32_t satId,
292  uint32_t beamId,
293  Ptr<SatChannel> fCh,
294  Ptr<SatChannel> rCh,
295  Ptr<SatNcc> ncc,
296  Ptr<SatLowerLayerServiceConf> llsConf,
297  SatEnums::RegenerationMode_t forwardLinkRegenerationMode,
298  SatEnums::RegenerationMode_t returnLinkRegenerationMode)
299 {
300  NS_LOG_FUNCTION(this << n << satId << beamId << fCh << rCh);
301 
302  NetDeviceContainer container;
303 
304  // Create SatNetDevice
305  m_deviceFactory.SetTypeId("ns3::SatNetDevice");
306  Ptr<SatNetDevice> dev = m_deviceFactory.Create<SatNetDevice>();
307 
308  // Attach the SatNetDevices to nodes
309  n->AddDevice(dev);
310 
311  SatPhy::CreateParam_t params;
312  params.m_satId = satId;
313  params.m_beamId = beamId;
314  params.m_device = dev;
315  params.m_txCh = fCh;
316  params.m_rxCh = rCh;
317  params.m_standard = SatEnums::DVB_GW;
318 
319  // Create a packet classifier
320  Ptr<SatPacketClassifier> classifier = Create<SatPacketClassifier>();
321 
325  Ptr<SatChannelEstimationErrorContainer> cec;
326  // Not enabled, create only base class
328  {
329  cec = Create<SatSimpleChannelEstimationErrorContainer>();
330  }
331  // Create SatFwdLinkChannelEstimationErrorContainer
332  else
333  {
334  uint32_t minWfId = m_superframeSeq->GetWaveformConf()->GetMinWfId();
335  uint32_t maxWfId = m_superframeSeq->GetWaveformConf()->GetMaxWfId();
336  if (returnLinkRegenerationMode == SatEnums::TRANSPARENT ||
337  returnLinkRegenerationMode == SatEnums::REGENERATION_PHY)
338  {
339  cec = Create<SatRtnLinkChannelEstimationErrorContainer>(minWfId, maxWfId);
340  }
341  else
342  {
343  cec = Create<SatFwdLinkChannelEstimationErrorContainer>();
344  }
345  }
346 
347  SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters =
348  SatPhyRxCarrierConf::RxCarrierCreateParams_s();
349  parameters.m_errorModel = m_errorModel;
350  parameters.m_daConstantErrorRate = m_daConstantErrorRate;
351  parameters.m_daIfModel = m_daInterferenceModel;
352  parameters.m_raIfModel = m_raSettings.m_raInterferenceModel;
353  parameters.m_raIfEliminateModel = m_raSettings.m_raInterferenceEliminationModel;
354  parameters.m_linkRegenerationMode = returnLinkRegenerationMode;
355  parameters.m_bwConverter = m_carrierBandwidthConverter;
356  parameters.m_carrierCount = m_rtnLinkCarrierCount;
357  parameters.m_cec = cec;
358  parameters.m_raCollisionModel = m_raSettings.m_raCollisionModel;
359  parameters.m_raConstantErrorRate = m_raSettings.m_raConstantErrorRate;
360  parameters.m_randomAccessModel = m_raSettings.m_randomAccessModel;
361 
362  Ptr<SatGwPhy> phy = CreateObject<SatGwPhy>(
363  params,
365  parameters,
367  returnLinkRegenerationMode);
368 
369  ncc->SetUseLogon(m_superframeSeq->GetSuperframeConf(SatConstVariables::SUPERFRAME_SEQUENCE)
370  ->IsLogonEnabled());
371 
372  // Set fading
373  phy->SetTxFadingContainer(n->GetObject<SatBaseFading>());
374  phy->SetRxFadingContainer(n->GetObject<SatBaseFading>());
375 
376  Ptr<SatGwMac> mac = CreateObject<SatGwMac>(satId,
377  beamId,
378  forwardLinkRegenerationMode,
379  returnLinkRegenerationMode);
380 
381  // Set the control message container callbacks
382  mac->SetReadCtrlCallback(m_readCtrlCb);
383  mac->SetReserveCtrlCallback(m_reserveCtrlCb);
384  mac->SetSendCtrlCallback(m_sendCtrlCb);
385 
386  mac->SetCrReceiveCallback(MakeCallback(&SatNcc::UtCrReceived, ncc));
387 
388  mac->SetHandoverCallback(MakeCallback(&SatNcc::MoveUtBetweenBeams, ncc));
389 
390  // Attach the Mac layer receiver to Phy
391  SatPhy::ReceiveCallback recCb = MakeCallback(&SatGwMac::Receive, mac);
392 
393  // Attach the NCC C/N0 update to Phy
394  SatPhy::CnoCallback cnoCb = MakeCallback(&SatNcc::UtCnoUpdated, ncc);
395 
396  // Attach the NCC random access load update to Phy
397  SatPhy::AverageNormalizedOfferedLoadCallback avgNormalizedOfferedLoadCb =
398  MakeCallback(&SatNcc::DoRandomAccessDynamicLoadControl, ncc);
399 
400  phy->SetAttribute("ReceiveCb", CallbackValue(recCb));
401  phy->SetAttribute("CnoCb", CallbackValue(cnoCb));
402  phy->SetAttribute("AverageNormalizedOfferedLoadCallback",
403  CallbackValue(avgNormalizedOfferedLoadCb));
404 
405  // Attach the PHY layer to SatNetDevice
406  dev->SetPhy(phy);
407 
408  // Attach the Mac layer to SatNetDevice
409  dev->SetMac(mac);
410 
411  // Create Logical Link Control (LLC) layer
412  Ptr<SatGwLlc> llc =
413  CreateObject<SatGwLlc>(forwardLinkRegenerationMode, returnLinkRegenerationMode);
414 
415  // Set the control msg read callback to LLC due to ARQ ACKs
416  llc->SetReadCtrlCallback(m_readCtrlCb);
417 
418  if (forwardLinkRegenerationMode != SatEnums::TRANSPARENT &&
419  forwardLinkRegenerationMode != SatEnums::REGENERATION_PHY)
420  {
421  llc->SetAdditionalHeaderSize(SatAddressE2ETag::SIZE);
422  }
423 
424  // Attach the LLC layer to SatNetDevice
425  dev->SetLlc(llc);
426 
427  // Attach the packet classifier
428  dev->SetPacketClassifier(classifier);
429 
430  // Attach the device receive callback to SatNetDevice
431  llc->SetReceiveCallback(MakeCallback(&SatNetDevice::Receive, dev));
432 
433  // Attach the transmit callback to PHY
434  mac->SetTransmitCallback(MakeCallback(&SatPhy::SendPdu, phy));
435 
436  // Attach the device receive callback to SatLlc
437  mac->SetReceiveCallback(MakeCallback(&SatLlc::Receive, llc));
438 
439  // Attach the logon receive callback to SatNcc
440  mac->SetLogonCallback(MakeBoundCallback(&logonCallbackHelper, ncc, llsConf));
441 
442  // Attach the control burst receive callback to SatNcc
443  mac->SetControlMessageReceivedCallback(MakeCallback(&SatNcc::ReceiveControlBurst, ncc));
444 
445  // Attach the remove UT to SatNcc
446  mac->SetRemoveUtCallback(MakeCallback(&SatNcc::RemoveUt, ncc));
447 
448  // Set the device address and pass it to MAC as well
449  Mac48Address addr = Mac48Address::Allocate();
450  dev->SetAddress(addr);
451 
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);
456 
457  // Create an encapsulator for control messages.
458  // Source = GW address
459  // Destination = broadcast address
460  // Flow id = by default 0
461  Ptr<SatQueue> queue = CreateObject<SatQueue>(SatEnums::CONTROL_FID);
462  Ptr<SatBaseEncapsulator> gwEncap =
463  CreateObject<SatBaseEncapsulator>(addr,
464  Mac48Address::GetBroadcast(),
465  addr,
466  Mac48Address::GetBroadcast(),
468  gwEncap->SetQueue(queue);
469  llc->AddEncap(addr, Mac48Address::GetBroadcast(), SatEnums::CONTROL_FID, gwEncap);
470  llc->SetCtrlMsgCallback(MakeCallback(&SatNetDevice::SendControlMsg, dev));
471 
472  phy->Initialize();
473 
474  // Create a node info to all the protocol layers
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);
480 
481  // Begin frame end scheduling for processes utilizing frame length as interval
482  // Node info needs to be set before the start in order to get the scheduling context correctly
483  // set
484  if (returnLinkRegenerationMode == SatEnums::TRANSPARENT)
485  {
486  phy->BeginEndScheduling();
487  }
488 
489  // TODO: When multiple carriers are supported. Multiple scheduler are needed too.
490  double carrierBandwidth =
492 
493  Ptr<SatFwdLinkScheduler> fwdLinkScheduler;
494  switch (m_fwdSchedulingAlgorithm)
495  {
497  fwdLinkScheduler =
498  CreateObject<SatFwdLinkSchedulerDefault>(m_bbFrameConf, addr, carrierBandwidth);
499  break;
501  fwdLinkScheduler =
502  CreateObject<SatFwdLinkSchedulerTimeSlicing>(m_bbFrameConf, addr, carrierBandwidth);
503  break;
504  default:
505  NS_FATAL_ERROR("Forward scheduling algorithm is not implemented");
506  }
507 
508  fwdLinkScheduler->SetSendControlMsgCallback(MakeCallback(&SatNetDevice::SendControlMsg, dev));
509 
510  // Attach the LLC Tx opportunity and scheduling context getter callbacks to SatFwdLinkScheduler
511  fwdLinkScheduler->SetTxOpportunityCallback(MakeCallback(&SatGwLlc::NotifyTxOpportunity, llc));
512  fwdLinkScheduler->SetSchedContextCallback(MakeCallback(&SatLlc::GetSchedulingContexts, llc));
513 
514  // set scheduler to Mac
515  mac->SetFwdScheduler(fwdLinkScheduler);
516 
517  mac->StartPeriodicTransmissions();
518 
519  return dev;
520 }
521 
522 NetDeviceContainer
523 SatGwHelper::InstallLora(NodeContainer c,
524  uint32_t gwId,
525  uint32_t satId,
526  uint32_t beamId,
527  Ptr<SatChannel> fCh,
528  Ptr<SatChannel> rCh,
529  Ptr<SatNcc> ncc,
530  Ptr<SatLowerLayerServiceConf> llsConf,
531  SatEnums::RegenerationMode_t forwardLinkRegenerationMode,
532  SatEnums::RegenerationMode_t returnLinkRegenerationMode)
533 {
534  NS_LOG_FUNCTION(this << satId << beamId << fCh << rCh);
535 
536  NetDeviceContainer devs;
537 
538  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
539  {
540  devs.Add(InstallLora(*i,
541  gwId,
542  satId,
543  beamId,
544  fCh,
545  rCh,
546  ncc,
547  llsConf,
548  forwardLinkRegenerationMode,
549  returnLinkRegenerationMode));
550  }
551 
552  return devs;
553 }
554 
555 Ptr<NetDevice>
557  uint32_t gwId,
558  uint32_t satId,
559  uint32_t beamId,
560  Ptr<SatChannel> fCh,
561  Ptr<SatChannel> rCh,
562  Ptr<SatNcc> ncc,
563  Ptr<SatLowerLayerServiceConf> llsConf,
564  SatEnums::RegenerationMode_t forwardLinkRegenerationMode,
565  SatEnums::RegenerationMode_t returnLinkRegenerationMode)
566 {
567  NS_LOG_FUNCTION(this << n << satId << beamId << fCh << rCh);
568 
569  NetDeviceContainer container;
570 
571  // Create SatNetDevice
572  m_deviceFactory.SetTypeId("ns3::SatLorawanNetDevice");
573  Ptr<SatLorawanNetDevice> dev = m_deviceFactory.Create<SatLorawanNetDevice>();
574 
575  // Attach the SatNetDevices to nodes
576  n->AddDevice(dev);
577 
578  SatPhy::CreateParam_t params;
579  params.m_satId = satId;
580  params.m_beamId = beamId;
581  params.m_device = dev;
582  params.m_txCh = fCh;
583  params.m_rxCh = rCh;
584  params.m_standard = SatEnums::LORA_GW;
585 
589  Ptr<SatChannelEstimationErrorContainer> cec;
590  // Not enabled, create only base class
592  {
593  cec = Create<SatSimpleChannelEstimationErrorContainer>();
594  }
595  // Create SatFwdLinkChannelEstimationErrorContainer
596  else
597  {
598  uint32_t minWfId = m_superframeSeq->GetWaveformConf()->GetMinWfId();
599  uint32_t maxWfId = m_superframeSeq->GetWaveformConf()->GetMaxWfId();
600  if (returnLinkRegenerationMode == SatEnums::TRANSPARENT ||
601  returnLinkRegenerationMode == SatEnums::REGENERATION_PHY)
602  {
603  cec = Create<SatRtnLinkChannelEstimationErrorContainer>(minWfId, maxWfId);
604  }
605  else
606  {
607  cec = Create<SatFwdLinkChannelEstimationErrorContainer>();
608  }
609  }
610 
611  SatPhyRxCarrierConf::RxCarrierCreateParams_s parameters =
612  SatPhyRxCarrierConf::RxCarrierCreateParams_s();
613  parameters.m_errorModel = m_errorModel;
614  parameters.m_daConstantErrorRate = m_daConstantErrorRate;
615  parameters.m_daIfModel = m_daInterferenceModel;
616  parameters.m_raIfModel = m_raSettings.m_raInterferenceModel;
617  parameters.m_raIfEliminateModel = m_raSettings.m_raInterferenceEliminationModel;
618  parameters.m_linkRegenerationMode = returnLinkRegenerationMode;
619  parameters.m_bwConverter = m_carrierBandwidthConverter;
620  parameters.m_carrierCount = m_rtnLinkCarrierCount;
621  parameters.m_cec = cec;
622  parameters.m_raCollisionModel = m_raSettings.m_raCollisionModel;
623  parameters.m_raConstantErrorRate = m_raSettings.m_raConstantErrorRate;
624  parameters.m_randomAccessModel = m_raSettings.m_randomAccessModel;
625 
626  Ptr<SatGwPhy> phy = CreateObject<SatGwPhy>(
627  params,
629  parameters,
631  returnLinkRegenerationMode);
632 
633  ncc->SetUseLora(true);
634 
635  // Set fading
636  phy->SetTxFadingContainer(n->GetObject<SatBaseFading>());
637  phy->SetRxFadingContainer(n->GetObject<SatBaseFading>());
638 
639  Ptr<LorawanMacGateway> mac = CreateObject<LorawanMacGateway>(satId, beamId);
640 
641  SatLoraConf satLoraConf;
642  satLoraConf.SetConf(mac);
643 
644  // Attach the Mac layer receiver to Phy
645  SatPhy::ReceiveCallback recCb = MakeCallback(&LorawanMac::Receive, mac);
646 
647  // Attach the NCC C/N0 update to Phy
648  SatPhy::CnoCallback cnoCb = MakeCallback(&SatNcc::UtCnoUpdated, ncc);
649 
650  // Attach the NCC random access load update to Phy
651  SatPhy::AverageNormalizedOfferedLoadCallback avgNormalizedOfferedLoadCb =
652  MakeCallback(&SatNcc::DoRandomAccessDynamicLoadControl, ncc);
653 
654  phy->SetAttribute("ReceiveCb", CallbackValue(recCb));
655  phy->SetAttribute("CnoCb", CallbackValue(cnoCb));
656  phy->SetAttribute("AverageNormalizedOfferedLoadCallback",
657  CallbackValue(avgNormalizedOfferedLoadCb));
658 
659  // Attach the PHY layer to SatNetDevice
660  dev->SetPhy(phy);
661 
662  // Attach the Mac layer to SatNetDevice
663  dev->SetLorawanMac(mac);
664  mac->SetDevice(dev);
665 
666  mac->SetPhy(phy);
667 
668  // Set the device address and pass it to MAC as well
669  Mac48Address addr = Mac48Address::Allocate();
670  dev->SetAddress(addr);
671 
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);
676 
677  phy->Initialize();
678 
679  // Create a node info to all the protocol layers
680  Ptr<SatNodeInfo> nodeInfo = Create<SatNodeInfo>(SatEnums::NT_GW, n->GetId(), addr);
681  dev->SetNodeInfo(nodeInfo);
682  mac->SetNodeInfo(nodeInfo);
683  phy->SetNodeInfo(nodeInfo);
684 
685  // Begin frame end scheduling for processes utilizing frame length as interval
686  // Node info needs to be set before the start in order to get the scheduling context correctly
687  // set
688  if (returnLinkRegenerationMode == SatEnums::TRANSPARENT)
689  {
690  phy->BeginEndScheduling();
691  }
692 
693  return dev;
694 }
695 
696 void
697 SatGwHelper::EnableCreationTraces(Ptr<OutputStreamWrapper> stream, CallbackBase& cb)
698 {
699  NS_LOG_FUNCTION(this);
700 
701  TraceConnect("Creation", "SatGwHelper", cb);
702 }
703 
704 } // namespace ns3
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.
bool m_enableChannelEstimationError
Enable channel estimation error modeling at forward link receiver (= UT).
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
Definition: satellite-phy.h:93
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
Definition: satellite-phy.h:84
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)
SatPhyRxCarrierConf::InterferenceModel m_raInterferenceModel
SatPhyRxCarrierConf::InterferenceEliminationModel m_raInterferenceEliminationModel
SatEnums::RandomAccessModel_t m_randomAccessModel
SatPhyRxCarrierConf::RandomAccessCollisionModel m_raCollisionModel
Creation parameters for base PHY object.
Ptr< SatChannel > m_rxCh
Ptr< NetDevice > m_device
Ptr< SatChannel > m_txCh
SatEnums::SatLoraNodeType_t m_standard