simulation-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 Magister Solutions
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: Lauri Sormunen <lauri.sormunen@magister.fi>
20  * Author: Mathias Ettinger <mettinger@viveris.toulouse.fr>
21  * Modified by: Patrice Raveneau <patrice.raveneau@cnes.fr>
22  *
23  */
24 
25 #include "simulation-helper.h"
26 
28 
29 #include <ns3/address.h>
30 #include <ns3/cbr-helper.h>
31 #include <ns3/config-store.h>
32 #include <ns3/config.h>
33 #include <ns3/enum.h>
34 #include <ns3/log.h>
35 #include <ns3/nrtv-helper.h>
36 #include <ns3/packet-sink-helper.h>
37 #include <ns3/packet-sink.h>
38 #include <ns3/pointer.h>
39 #include <ns3/random-variable-stream.h>
40 #include <ns3/satellite-env-variables.h>
41 #include <ns3/satellite-topology.h>
42 #include <ns3/singleton.h>
43 #include <ns3/string.h>
44 #include <ns3/three-gpp-http-satellite-helper.h>
45 #include <ns3/uinteger.h>
46 
47 #include <iostream>
48 #include <map>
49 #include <set>
50 #include <sstream>
51 #include <string>
52 #include <utility>
53 #include <vector>
54 
55 NS_LOG_COMPONENT_DEFINE("SimulationHelper");
56 
57 namespace ns3
58 {
59 
60 NS_OBJECT_ENSURE_REGISTERED(SimulationHelperConf);
61 
62 TypeId
64 {
65  static TypeId tid =
66  TypeId("ns3::SimulationHelperConf")
67  .SetParent<Object>()
68  .AddConstructor<SimulationHelperConf>()
69  .AddAttribute("SimTime",
70  "Simulation time",
71  TimeValue(Seconds(100)),
72  MakeTimeAccessor(&SimulationHelperConf::m_simTime),
73  MakeTimeChecker(Seconds(1)))
74  .AddAttribute("BeamsIDs",
75  "Enabled Beams IDs",
76  StringValue("10 11 12 23 24 25"),
77  MakeStringAccessor(&SimulationHelperConf::m_enabledBeams),
78  MakeStringChecker())
79  .AddAttribute("UserCountPerUt",
80  "Amount of user per User Terminal",
81  StringValue("ns3::ConstantRandomVariable[Constant=1]"),
82  MakePointerAccessor(&SimulationHelperConf::m_utUserCount),
83  MakePointerChecker<RandomVariableStream>())
84  .AddAttribute("UserCountPerMobileUt",
85  "Amount of user per mobile User Terminal",
86  StringValue("ns3::ConstantRandomVariable[Constant=1]"),
87  MakePointerAccessor(&SimulationHelperConf::m_utMobileUserCount),
88  MakePointerChecker<RandomVariableStream>())
89  .AddAttribute("UtCountPerBeam",
90  "Amount of User Terminal associated to each Beam",
91  StringValue("ns3::ConstantRandomVariable[Constant=1]"),
92  MakePointerAccessor(&SimulationHelperConf::m_utCount),
93  MakePointerChecker<RandomVariableStream>())
94  .AddAttribute("ActivateStatistics",
95  "Enable outputing values from stats helpers",
96  BooleanValue(true),
97  MakeBooleanAccessor(&SimulationHelperConf::m_activateStatistics),
98  MakeBooleanChecker())
99  .AddAttribute("ActivateProgressLogs",
100  "Enable outputing progress of the simulation",
101  BooleanValue(true),
103  MakeBooleanChecker())
104  .AddAttribute("MobileUtsFolder",
105  "Select the folder where mobile UTs traces should be found",
106  StringValue(Singleton<SatEnvVariables>::Get()->LocateDataDirectory() +
107  "/utpositions/mobiles/"),
108  MakeStringAccessor(&SimulationHelperConf::m_mobileUtsFolder),
109  MakeStringChecker());
110 
111  return tid;
112 }
113 
114 TypeId
116 {
117  NS_LOG_FUNCTION(this);
118 
119  return GetTypeId();
120 }
121 
123  : m_simTime(0),
124  m_enabledBeams(""),
125  m_utCount(0),
126  m_utUserCount(0),
127  m_utMobileUserCount(0),
128  m_activateStatistics(false),
129  m_activateProgressLogging(false)
130 {
131  NS_LOG_FUNCTION(this);
132 }
133 
135 {
136  NS_LOG_FUNCTION(this);
137 }
138 
139 NS_OBJECT_ENSURE_REGISTERED(SimulationHelper);
140 
141 TypeId
143 {
144  static TypeId tid =
145  TypeId("ns3::SimulationHelper").SetParent<Object>().AddConstructor<SimulationHelper>();
146  return tid;
147 }
148 
149 TypeId
151 {
152  NS_LOG_FUNCTION(this);
153 
154  return GetTypeId();
155 }
156 
158  : m_satHelper(nullptr),
159  m_statContainer(nullptr),
160  m_commonUtPositions(),
161  m_utPositionsByBeam(),
162  m_scenarioPath(""),
163  m_simulationName(""),
164  m_enabledBeamsStr(""),
165  m_enabledBeams(),
166  m_outputPath(""),
167  m_utCount(),
168  m_utUserCount(0),
169  m_utMobileUserCount(0),
170  m_simTime(0),
171  m_numberOfConfiguredFrames(0),
172  m_randomAccessConfigured(false),
173  m_inputFileUtListPositions(""),
174  m_inputFileUtPositionsCheckBeams(true),
175  m_progressLoggingEnabled(false),
176  m_progressUpdateInterval(Seconds(0.5))
177 {
178  NS_FATAL_ERROR(
179  "SimulationHelper: Default constructor not in use. Please create with simulation name. ");
180 }
181 
182 SimulationHelper::SimulationHelper(std::string simulationName)
183  : m_satHelper(nullptr),
184  m_statContainer(nullptr),
185  m_commonUtPositions(),
186  m_utPositionsByBeam(),
187  m_simulationName(""),
188  m_enabledBeamsStr(""),
189  m_enabledBeams(),
190  m_outputPath(""),
191  m_utCount(),
192  m_utUserCount(0),
193  m_utMobileUserCount(0),
194  m_simTime(0),
195  m_numberOfConfiguredFrames(0),
196  m_randomAccessConfigured(false),
197  m_inputFileUtListPositions(""),
198  m_inputFileUtPositionsCheckBeams(true),
199  m_progressLoggingEnabled(false),
200  m_progressUpdateInterval(Seconds(0.5))
201 {
202  NS_LOG_FUNCTION(this);
203 
204  ObjectBase::ConstructSelf(AttributeConstructionList());
205 
206  m_simulationName = simulationName;
207  Config::SetDefault("ns3::SatEnvVariables::SimulationCampaignName",
208  StringValue(m_simulationName));
209  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
210 
211  // NCC configuration
212  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_2"));
213  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
214 
215  // RBDC
216  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
217  BooleanValue(false));
218  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed", BooleanValue(true));
219  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_MinimumServiceRate",
220  UintegerValue(16));
221  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
222  BooleanValue(false));
223 }
224 
226 {
227  NS_LOG_FUNCTION(this);
228 }
229 
230 void
232 {
233  NS_LOG_FUNCTION(this);
234 
235  m_commonUtPositions = nullptr;
236  m_utPositionsByBeam.clear();
237 }
238 
239 void
241 {
242  NS_LOG_FUNCTION(this << count);
243 
244  Ptr<RandomVariableStream> utCount = CreateObject<ConstantRandomVariable>();
245  utCount->SetAttribute("Constant", DoubleValue(count));
246 
247  m_utCount.insert(std::make_pair(0, utCount));
248 }
249 
250 void
251 SimulationHelper::SetUtCountPerBeam(Ptr<RandomVariableStream> rs)
252 {
253  NS_LOG_FUNCTION(this << &rs);
254 
255  m_utCount.insert(std::make_pair(0, rs));
256 }
257 
258 void
259 SimulationHelper::SetUtCountPerBeam(uint32_t beamId, uint32_t count)
260 {
261  NS_LOG_FUNCTION(this << beamId << count);
262 
263  Ptr<RandomVariableStream> utCount = CreateObject<ConstantRandomVariable>();
264  utCount->SetAttribute("Constant", DoubleValue(count));
265 
266  m_utCount.insert(std::make_pair(beamId, utCount));
267 }
268 
269 void
270 SimulationHelper::SetUtCountPerBeam(uint32_t beamId, Ptr<RandomVariableStream> rs)
271 {
272  NS_LOG_FUNCTION(this << &rs);
273 
274  m_utCount.insert(std::make_pair(beamId, rs));
275 }
276 
277 void
279 {
280  NS_LOG_FUNCTION(this << count);
281 
282  m_utUserCount = CreateObject<ConstantRandomVariable>();
283  m_utUserCount->SetAttribute("Constant", DoubleValue(count));
284 }
285 
286 void
287 SimulationHelper::SetUserCountPerUt(Ptr<RandomVariableStream> rs)
288 {
289  NS_LOG_FUNCTION(this << &rs);
290 
291  m_utUserCount = rs;
292 }
293 
294 void
296 {
297  NS_LOG_FUNCTION(this << count);
298 
299  m_utMobileUserCount = CreateObject<ConstantRandomVariable>();
300  m_utMobileUserCount->SetAttribute("Constant", DoubleValue(count));
301 }
302 
303 void
304 SimulationHelper::SetUserCountPerMobileUt(Ptr<RandomVariableStream> rs)
305 {
306  NS_LOG_FUNCTION(this << &rs);
307 
308  m_utMobileUserCount = rs;
309 }
310 
311 void
312 SimulationHelper::SetGwUserCount(uint32_t gwUserCount)
313 {
314  NS_LOG_FUNCTION(this << gwUserCount);
315 
316  Config::SetDefault("ns3::SatHelper::GwUsers", UintegerValue(gwUserCount));
317 }
318 
319 void
321 {
322  NS_LOG_FUNCTION(this << seconds);
323 
324  m_simTime = Seconds(seconds);
325 }
326 
327 void
329 {
330  NS_LOG_FUNCTION(this << tag);
331 
332  // Set simulation output details
333  m_simulationTag = tag;
334 }
335 
336 void
338 {
339  NS_LOG_FUNCTION(this << path);
340 
341  // Set simulation output details
342  m_outputPath = path;
343 }
344 
345 void
346 SimulationHelper::AddDefaultUiArguments(CommandLine& cmd, std::string& xmlInputFile)
347 {
348  NS_LOG_FUNCTION(this);
349 
351  cmd.AddValue("InputXml", "Input attributes in XML file", xmlInputFile);
352 }
353 
354 void
356 {
357  NS_LOG_FUNCTION(this);
358 
359  // Create a customizable output path
360  cmd.AddValue("OutputPath", "Output path for storing the simulation statistics", m_outputPath);
361 }
362 
363 void
365 {
366  NS_LOG_FUNCTION(this);
367 
369  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_OFF));
370 
371  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0", StringValue("Configuration_0"));
372  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_2"));
373  Config::SetDefault("ns3::SatSuperframeSeq::TargetDuration", TimeValue(MilliSeconds(100)));
374 
375  Config::SetDefault("ns3::SatRequestManager::EvaluationInterval", TimeValue(MilliSeconds(100)));
376  Config::SetDefault("ns3::SatRequestManager::EnableOnDemandEvaluation", BooleanValue(false));
377 
378  Config::SetDefault("ns3::SatBbFrameConf::BBFrameUsageMode", StringValue("NormalFrames"));
379 
381  ConfigureFrame(0, 20e5, 5e5, 0.2, 0.3, false);
382 
385 
386  // ACM enabled
389 
391  EnableOnlyVbdc(3);
392 
393  EnablePeriodicalControlSlots(MilliSeconds(100));
394 
395  Config::SetDefault("ns3::SatUtHelper::EnableChannelEstimationError", BooleanValue(true));
396  Config::SetDefault("ns3::SatGwHelper::EnableChannelEstimationError", BooleanValue(true));
397 
398  Config::SetDefault("ns3::SatFwdLinkScheduler::DummyFrameSendingEnabled", BooleanValue(false));
399 
400  Config::SetDefault("ns3::SatQueue::MaxPackets", UintegerValue(10000));
401 }
402 
403 void
405 {
406  NS_LOG_FUNCTION(this);
407 
408  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaServiceCount", UintegerValue(4));
409  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
410  BooleanValue(false));
411  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
412  BooleanValue(false));
413  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
414  BooleanValue(false));
415  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
416  BooleanValue(false));
417  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
418  BooleanValue(false));
419  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
420  BooleanValue(false));
421  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
422  BooleanValue(false));
423  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
424  BooleanValue(false));
425  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
426  BooleanValue(false));
427  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
428  BooleanValue(false));
429  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
430  BooleanValue(false));
431  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
432  BooleanValue(false));
433 }
434 
435 void
436 SimulationHelper::EnableOnlyConstantRate(uint32_t rcIndex, double rateKbps)
437 {
438  NS_LOG_FUNCTION(this << rcIndex << rateKbps);
439 
440  std::stringstream ss;
441  ss << rcIndex;
442  std::string attributeDefault("ns3::SatLowerLayerServiceConf::DaService" + ss.str());
443 
444  Config::SetDefault(attributeDefault + "_ConstantAssignmentProvided", BooleanValue(true));
445  Config::SetDefault(attributeDefault + "_RbdcAllowed", BooleanValue(false));
446  Config::SetDefault(attributeDefault + "_VolumeAllowed", BooleanValue(false));
447 }
448 
449 void
451 {
452  NS_LOG_FUNCTION(this << rcIndex);
453 
454  std::stringstream ss;
455  ss << rcIndex;
456  std::string attributeDefault("ns3::SatLowerLayerServiceConf::DaService" + ss.str());
457 
458  Config::SetDefault(attributeDefault + "_ConstantAssignmentProvided", BooleanValue(false));
459  Config::SetDefault(attributeDefault + "_RbdcAllowed", BooleanValue(true));
460  Config::SetDefault(attributeDefault + "_VolumeAllowed", BooleanValue(false));
461 
462  Config::SetDefault("ns3::SatLowerLayerServiceConf::DynamicRatePersistence", UintegerValue(10));
463 }
464 
465 void
467 {
468  NS_LOG_FUNCTION(this << rcIndex);
469 
470  std::stringstream ss;
471  ss << rcIndex;
472  std::string attributeDefault("ns3::SatLowerLayerServiceConf::DaService" + ss.str());
473 
474  Config::SetDefault(attributeDefault + "_ConstantAssignmentProvided", BooleanValue(false));
475  Config::SetDefault(attributeDefault + "_RbdcAllowed", BooleanValue(false));
476  Config::SetDefault(attributeDefault + "_VolumeAllowed", BooleanValue(true));
477 
478  Config::SetDefault("ns3::SatLowerLayerServiceConf::VolumeBacklogPersistence",
479  UintegerValue(10));
480 }
481 
482 void
484 {
485  NS_LOG_FUNCTION(this);
486 
487  Config::SetDefault("ns3::SatSuperframeAllocator::FcaEnabled", BooleanValue(true));
488 }
489 
490 void
492 {
493  NS_LOG_FUNCTION(this);
494 
495  Config::SetDefault("ns3::SatSuperframeAllocator::FcaEnabled", BooleanValue(false));
496 }
497 
498 void
500 {
501  NS_LOG_FUNCTION(this << periodicity.GetSeconds());
502 
503  // Controls slots
504  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
505  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotInterval", TimeValue(periodicity));
506 }
507 
508 void
510 {
511  NS_LOG_FUNCTION(this << dir);
512 
513  switch (dir)
514  {
515  case SatEnums::LD_FORWARD: {
516  Config::SetDefault("ns3::SatLlc::FwdLinkArqEnabled", BooleanValue(true));
517 
518  Config::SetDefault("ns3::SatGenericStreamEncapsulatorArq::MaxNoOfRetransmissions",
519  UintegerValue(2));
520  Config::SetDefault("ns3::SatGenericStreamEncapsulatorArq::RetransmissionTimer",
521  TimeValue(MilliSeconds(600)));
522  Config::SetDefault("ns3::SatGenericStreamEncapsulatorArq::WindowSize", UintegerValue(10));
523  Config::SetDefault("ns3::SatGenericStreamEncapsulatorArq::ArqHeaderSize", UintegerValue(1));
524  Config::SetDefault("ns3::SatGenericStreamEncapsulatorArq::RxWaitingTime",
525  TimeValue(Seconds(1.8)));
526  break;
527  }
528  case SatEnums::LD_RETURN: {
529  Config::SetDefault("ns3::SatLlc::RtnLinkArqEnabled", BooleanValue(true));
530 
531  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::MaxRtnArqSegmentSize",
532  UintegerValue(38));
533  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::MaxNoOfRetransmissions",
534  UintegerValue(2));
535  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::RetransmissionTimer",
536  TimeValue(MilliSeconds(600)));
537  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::WindowSize", UintegerValue(10));
538  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::ArqHeaderSize", UintegerValue(1));
539  Config::SetDefault("ns3::SatReturnLinkEncapsulatorArq::RxWaitingTime",
540  TimeValue(Seconds(1.8)));
541  break;
542  }
543  default: {
544  NS_FATAL_ERROR("Unsupported SatLinkDir_t!");
545  break;
546  }
547  }
548 }
549 
550 void
552 {
553  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_OFF));
554  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
556  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
558  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
560  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
561  BooleanValue(false));
562 }
563 
564 void
566 {
567  NS_LOG_FUNCTION(this);
568 
569  if (m_randomAccessConfigured == true)
570  {
571  NS_FATAL_ERROR("Random access already configured!");
572  }
573 
574  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
575  UintegerValue(1));
577 }
578 
579 void
581 {
582  NS_LOG_FUNCTION(this);
583 
584  if (m_randomAccessConfigured == true)
585  {
586  NS_FATAL_ERROR("Random access already configured!");
587  }
588 
589  Config::SetDefault("ns3::SatUtHelper::UseCrdsaOnlyForControlPackets", BooleanValue(false));
590  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
591  UintegerValue(3));
593 }
594 
595 void
597 {
598  NS_LOG_FUNCTION(this);
599 
600  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
601 
602  Config::SetDefault("ns3::SatLowerLayerServiceConf::DefaultControlRandomizationInterval",
603  TimeValue(MilliSeconds(100)));
604  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaServiceCount", UintegerValue(1));
605  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
607  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
609  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
611  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
613  Config::SetDefault("ns3::SatBeamHelper::RaConstantErrorRate", DoubleValue(0.0));
614 
615  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
616  BooleanValue(false));
617  Config::SetDefault(
618  "ns3::SatPhyRxCarrierConf::RandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize",
619  UintegerValue(10));
620 
621  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
622  UintegerValue(3));
623  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
624  UintegerValue(6));
625  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
626  UintegerValue(2));
627  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
628  UintegerValue(50));
629  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
630  UintegerValue(1));
631  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
632  UintegerValue(1));
633  Config::SetDefault(
634  "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
635  DoubleValue(0.99));
636 
638 
639  ConfigureFrame(0, 1.25e6, 1.25e6, 0.2, 0.3, true);
640 }
641 
642 void
644 {
645  NS_LOG_FUNCTION(this);
646 
647  Config::SetDefault("ns3::SatChannel::EnableExternalFadingInputTrace", BooleanValue(false));
648  Config::SetDefault("ns3::SatChannel::ForwardingMode", StringValue("OnlyDestNode"));
649  Config::SetDefault("ns3::SatChannel::RxPowerCalculationMode",
650  StringValue("RxPowerCalculation"));
651  Config::SetDefault("ns3::SatBeamHelper::FadingModel", StringValue("FadingOff"));
652  Config::SetDefault("ns3::SatUtHelper::EnableChannelEstimationError", BooleanValue(false));
653  Config::SetDefault("ns3::SatGwHelper::EnableChannelEstimationError", BooleanValue(false));
654  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel", StringValue("Constant"));
655  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
656  StringValue("Perfect"));
657  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
658  StringValue("RaCollisionNotDefined"));
659 
662 }
663 
664 void
666 {
667  NS_LOG_FUNCTION(this << dir);
668 
669  switch (dir)
670  {
671  case SatEnums::LD_FORWARD: {
672  Config::SetDefault("ns3::SatBbFrameConf::AcmEnabled", BooleanValue(true));
673  Config::SetDefault("ns3::SatBbFrameConf::DefaultModCod", StringValue("QPSK_1_TO_2"));
674  Config::SetDefault("ns3::SatRequestManager::CnoReportInterval", TimeValue(Seconds(0.1)));
675  Config::SetDefault("ns3::SatFwdLinkScheduler::CnoEstimationMode",
676  StringValue("AverageValueInWindow"));
677  Config::SetDefault("ns3::SatFwdLinkScheduler::CnoEstimationWindow", TimeValue(Seconds(2)));
678  break;
679  }
680  case SatEnums::LD_RETURN: {
681  Config::SetDefault("ns3::SatBeamScheduler::CnoEstimationMode",
682  StringValue("MinimumValueInWindow"));
683  Config::SetDefault("ns3::SatBeamScheduler::CnoEstimationWindow", TimeValue(Seconds(2)));
684  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
685  break;
686  }
687  default: {
688  NS_FATAL_ERROR("Unsupported SatLinkDir_t!");
689  break;
690  }
691  }
692 }
693 
694 void
696 {
697  NS_LOG_FUNCTION(this << dir);
698 
699  switch (dir)
700  {
701  case SatEnums::LD_FORWARD: {
702  Config::SetDefault("ns3::SatBbFrameConf::AcmEnabled", BooleanValue(false));
703  Config::SetDefault("ns3::SatBbFrameConf::DefaultModCod", StringValue("QPSK_1_TO_2"));
704  Config::SetDefault("ns3::SatRequestManager::CnoReportInterval", TimeValue(Seconds(100)));
705  break;
706  }
707  case SatEnums::LD_RETURN: {
708  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(false));
709  break;
710  }
711  default: {
712  NS_FATAL_ERROR("Unsupported SatLinkDir_t!");
713  break;
714  }
715  }
716 }
717 
718 void
720 {
721  std::cout << "Progress: " << Simulator::Now().GetSeconds() << "/" << GetSimTime().GetSeconds()
722  << std::endl;
724  Simulator::Schedule(m_progressUpdateInterval, &SimulationHelper::ProgressCb, this);
725 }
726 
727 void
729 {
730  NS_ASSERT_MSG(m_satHelper != nullptr, "Satellite scenario not created yet!");
731 
732  if (!m_statContainer)
733  {
734  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite",
735  BooleanValue(true));
736  m_statContainer = CreateObject<SatStatsHelperContainer>(m_satHelper);
737  }
738 
741 }
742 
743 void
745 {
746  NS_LOG_FUNCTION(this);
747 
748  if (!m_statContainer)
749  {
750  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite",
751  BooleanValue(true));
752  m_statContainer = CreateObject<SatStatsHelperContainer>(m_satHelper);
753  }
754 
755  // Throughput
756  m_statContainer->AddAverageUtUserFwdAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
757  m_statContainer->AddAverageUtFwdUserPhyThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
758  m_statContainer->AddAverageBeamFwdAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
759 
760  m_statContainer->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
761  m_statContainer->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
762  m_statContainer->AddGlobalFwdFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
763  m_statContainer->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
764  m_statContainer->AddGlobalFwdFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
765  m_statContainer->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
766  m_statContainer->AddGlobalFwdFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
767  m_statContainer->AddGlobalFwdUserPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
768  m_statContainer->AddGlobalFwdFeederPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
769  m_statContainer->AddGlobalFwdUserPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
770 
771  m_statContainer->AddPerBeamFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
772  m_statContainer->AddPerBeamFwdFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
773  m_statContainer->AddPerBeamFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
774  m_statContainer->AddPerBeamFwdFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
775  m_statContainer->AddPerBeamFwdUserPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
776  Config::SetDefault("ns3::SatStatsThroughputHelper::AveragingMode", BooleanValue(true));
777  m_statContainer->AddPerBeamFwdAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
778  m_statContainer->AddPerBeamFwdFeederMacThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
779  m_statContainer->AddPerBeamFwdUserMacThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
780  m_statContainer->AddPerBeamFwdFeederPhyThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
781  m_statContainer->AddPerBeamFwdUserPhyThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
782 
783  // SINR
784  m_statContainer->AddGlobalFwdCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
785  m_statContainer->AddGlobalFwdCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
786 
787  // Delay
789  m_statContainer->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
790 
791  // Packet error
792  m_statContainer->AddGlobalFwdUserDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
793  m_statContainer->AddPerBeamFwdUserDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
794  m_statContainer->AddPerBeamRtnFeederDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
795  m_statContainer->AddPerBeamFeederCrdsaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
796  m_statContainer->AddPerBeamFeederCrdsaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
797  m_statContainer->AddPerBeamFeederSlottedAlohaPacketCollision(
799  m_statContainer->AddPerBeamFeederSlottedAlohaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
800 
801  // Marsala
802  m_statContainer->AddPerBeamMarsalaCorrelation(SatStatsHelper::OUTPUT_SCALAR_FILE);
803  m_statContainer->AddPerBeamMarsalaCorrelation(SatStatsHelper::OUTPUT_SCATTER_FILE);
804 
805  // Frame type usage
806  Config::SetDefault("ns3::SatStatsFrameTypeUsageHelper::Percentage", BooleanValue(true));
807  m_statContainer->AddGlobalFrameTypeUsage(SatStatsHelper::OUTPUT_SCALAR_FILE);
808  m_statContainer->AddPerGwFrameTypeUsage(SatStatsHelper::OUTPUT_SCALAR_FILE);
809  m_statContainer->AddPerBeamFrameTypeUsage(SatStatsHelper::OUTPUT_SCALAR_FILE);
810 
811  // Beam service time
812  m_statContainer->AddPerBeamBeamServiceTime(SatStatsHelper::OUTPUT_SCALAR_FILE);
813 }
814 
815 void
817 {
818  NS_LOG_FUNCTION(this);
819 
820  if (!m_statContainer)
821  {
822  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite",
823  BooleanValue(true));
824  m_statContainer = CreateObject<SatStatsHelperContainer>(m_satHelper);
825  }
826 
827  // Throughput
828  m_statContainer->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
829  m_statContainer->AddAverageUtRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
830  m_statContainer->AddAverageBeamRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
831  m_statContainer->AddPerUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
832 
833  m_statContainer->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
834  m_statContainer->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
835  m_statContainer->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
836  m_statContainer->AddGlobalRtnUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
837  m_statContainer->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
838  m_statContainer->AddGlobalRtnUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
839  m_statContainer->AddGlobalRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
840  m_statContainer->AddGlobalRtnUserPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
841  m_statContainer->AddGlobalRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
842  m_statContainer->AddGlobalRtnUserPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
843 
844  m_statContainer->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
845  m_statContainer->AddPerBeamRtnFeederDevThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
846  m_statContainer->AddPerBeamRtnUserDevThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
847  m_statContainer->AddPerBeamRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
848  m_statContainer->AddPerBeamRtnUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
849  m_statContainer->AddPerBeamRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
850  m_statContainer->AddPerBeamRtnUserPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
851 
852  // Granted resources
853  m_statContainer->AddGlobalResourcesGranted(SatStatsHelper::OUTPUT_SCATTER_FILE);
854  m_statContainer->AddGlobalResourcesGranted(SatStatsHelper::OUTPUT_SCALAR_FILE);
855  m_statContainer->AddGlobalResourcesGranted(SatStatsHelper::OUTPUT_CDF_FILE);
856  m_statContainer->AddPerBeamResourcesGranted(SatStatsHelper::OUTPUT_CDF_FILE);
857  m_statContainer->AddPerBeamResourcesGranted(SatStatsHelper::OUTPUT_CDF_PLOT);
858  m_statContainer->AddPerUtResourcesGranted(SatStatsHelper::OUTPUT_SCATTER_FILE);
859 
860  // Frame load
861  m_statContainer->AddGlobalFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
862  m_statContainer->AddPerBeamFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
863 
864  m_statContainer->AddGlobalRtnFeederLinkSinr(SatStatsHelper::OUTPUT_CDF_FILE);
865  m_statContainer->AddGlobalRtnUserLinkSinr(SatStatsHelper::OUTPUT_CDF_FILE);
866 
867  // SINR
868  m_statContainer->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
869  m_statContainer->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
870  m_statContainer->AddPerBeamRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
871  m_statContainer->AddPerBeamRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_PLOT);
872 
873  // Delay
875  m_statContainer->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
876 
877  m_statContainer->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
878  m_statContainer->AddPerBeamRtnDevDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
879  m_statContainer->AddPerBeamRtnPhyDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
880  m_statContainer->AddPerBeamRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
881 
882  m_statContainer->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
883  m_statContainer->AddPerBeamRtnDevDelay(SatStatsHelper::OUTPUT_CDF_FILE);
884  m_statContainer->AddPerBeamRtnPhyDelay(SatStatsHelper::OUTPUT_CDF_FILE);
885  m_statContainer->AddPerBeamRtnMacDelay(SatStatsHelper::OUTPUT_CDF_FILE);
886 
887  // Packet error
888  m_statContainer->AddGlobalRtnFeederDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
889  m_statContainer->AddPerBeamRtnFeederDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
890  m_statContainer->AddPerBeamFeederCrdsaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
891  m_statContainer->AddPerBeamFeederCrdsaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
892  m_statContainer->AddPerBeamFeederSlottedAlohaPacketCollision(
894  m_statContainer->AddPerBeamFeederSlottedAlohaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
895 
896  // Waveform
897  m_statContainer->AddPerBeamWaveformUsage(SatStatsHelper::OUTPUT_SCALAR_FILE);
898  m_statContainer->AddPerBeamFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
899 
900  // Capacity request
901  m_statContainer->AddPerUtCapacityRequest(SatStatsHelper::OUTPUT_SCATTER_FILE);
902  m_statContainer->AddPerBeamCapacityRequest(SatStatsHelper::OUTPUT_SCATTER_FILE);
903 }
904 
905 void
907 {
908  NS_LOG_FUNCTION(this << em << errorRate);
909 
910  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
911  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
912 
914  {
915  Config::SetDefault("ns3::SatGwHelper::RtnLinkConstantErrorRate", DoubleValue(errorRate));
916  Config::SetDefault("ns3::SatUtHelper::FwdLinkConstantErrorRate", DoubleValue(errorRate));
917  }
918 }
919 
920 void
922  double constantIf)
923 {
924  NS_LOG_FUNCTION(this << ifModel << constantIf);
925 
926  Config::SetDefault("ns3::SatUtHelper::DaFwdLinkInterferenceModel", EnumValue(ifModel));
927  Config::SetDefault("ns3::SatGwHelper::DaRtnLinkInterferenceModel", EnumValue(ifModel));
928 
929  if (ifModel == SatPhyRxCarrierConf::IF_CONSTANT)
930  {
931  Config::SetDefault("ns3::SatConstantInterference::ConstantInterferencePower",
932  DoubleValue(constantIf));
933  }
934 }
935 
936 void
937 SimulationHelper::ConfigureFrame(uint32_t superFrameId,
938  double bw,
939  double carrierBw,
940  double rollOff,
941  double carrierSpacing,
942  bool isRandomAccess)
943 {
944  NS_LOG_FUNCTION(this << bw << carrierBw << rollOff << carrierSpacing << isRandomAccess);
945 
946  std::stringstream sfId, fId;
947  sfId << superFrameId;
949  std::string attributeDefault("ns3::SatSuperframeConf" + sfId.str() + "::Frame" + fId.str());
950 
951  Config::SetDefault(attributeDefault + "_AllocatedBandwidthHz", DoubleValue(bw));
952  Config::SetDefault(attributeDefault + "_CarrierAllocatedBandwidthHz", DoubleValue(carrierBw));
953  Config::SetDefault(attributeDefault + "_CarrierRollOff", DoubleValue(rollOff));
954  Config::SetDefault(attributeDefault + "_CarrierSpacing", DoubleValue(carrierSpacing));
955  Config::SetDefault(attributeDefault + "_RandomAccessFrame", BooleanValue(isRandomAccess));
956 
958 
959  Config::SetDefault("ns3::SatSuperframeConf" + sfId.str() + "::FrameCount",
960  UintegerValue(m_numberOfConfiguredFrames));
961 }
962 
963 void
965 {
966  NS_LOG_FUNCTION(this);
967 
968  Config::SetDefault("ns3::SatConf::FwdFeederLinkBandwidth", DoubleValue(2e+09));
969  Config::SetDefault("ns3::SatConf::FwdFeederLinkBaseFrequency", DoubleValue(2.75e+10));
970  Config::SetDefault("ns3::SatConf::FwdUserLinkBandwidth", DoubleValue(5e+08));
971  Config::SetDefault("ns3::SatConf::FwdUserLinkBaseFrequency", DoubleValue(1.97e+10));
972 
973  Config::SetDefault("ns3::SatConf::RtnFeederLinkBandwidth", DoubleValue(2e+09));
974  Config::SetDefault("ns3::SatConf::RtnFeederLinkBaseFrequency", DoubleValue(1.77e+10));
975  Config::SetDefault("ns3::SatConf::RtnUserLinkBandwidth", DoubleValue(5e+08));
976  Config::SetDefault("ns3::SatConf::RtnUserLinkBaseFrequency", DoubleValue(2.95e+10));
977 
978  Config::SetDefault("ns3::SatConf::FwdUserLinkChannels", UintegerValue(4));
979  Config::SetDefault("ns3::SatConf::FwdFeederLinkChannels", UintegerValue(16));
980  Config::SetDefault("ns3::SatConf::RtnUserLinkChannels", UintegerValue(4));
981  Config::SetDefault("ns3::SatConf::RtnFeederLinkChannels", UintegerValue(16));
982 
983  Config::SetDefault("ns3::SatConf::FwdCarrierAllocatedBandwidth", DoubleValue(1.25e+08));
984  Config::SetDefault("ns3::SatConf::FwdCarrierRollOff", DoubleValue(0.2));
985  Config::SetDefault("ns3::SatConf::FwdCarrierSpacing", DoubleValue(0.0));
986 }
987 
988 void
990 {
991  NS_LOG_FUNCTION(this);
992 
993  // Enable flag
994  Config::SetDefault("ns3::SatBeamHelper::EnableFwdLinkBeamHopping", BooleanValue(true));
995 
996  Config::SetDefault("ns3::SatBstpController::BeamHoppingMode",
997  EnumValue(SatBstpController::BH_STATIC));
998  Config::SetDefault("ns3::SatBstpController::StaticBeamHoppingConfigFileName",
999  StringValue(m_scenarioPath + "/beamhopping/SatBstpConf_GW1.txt"));
1000  Config::SetDefault("ns3::SatBstpController::SuperframeDuration", TimeValue(MilliSeconds(1)));
1001 
1002  // Frequency configuration for 500 MHz user link bandwidth
1003  Config::SetDefault("ns3::SatConf::FwdFeederLinkBandwidth", DoubleValue(2e+09));
1004  Config::SetDefault("ns3::SatConf::FwdFeederLinkBaseFrequency", DoubleValue(2.75e+10));
1005  Config::SetDefault("ns3::SatConf::FwdUserLinkBandwidth", DoubleValue(5e+08));
1006  Config::SetDefault("ns3::SatConf::FwdUserLinkBaseFrequency", DoubleValue(1.97e+10));
1007 
1008  Config::SetDefault("ns3::SatConf::FwdUserLinkChannels", UintegerValue(1));
1009  Config::SetDefault("ns3::SatConf::FwdFeederLinkChannels", UintegerValue(4));
1010 
1011  Config::SetDefault("ns3::SatConf::FwdCarrierAllocatedBandwidth", DoubleValue(5e+08));
1012  Config::SetDefault("ns3::SatConf::FwdCarrierRollOff", DoubleValue(0.2));
1013  Config::SetDefault("ns3::SatConf::FwdCarrierSpacing", DoubleValue(0.0));
1014 }
1015 
1016 void
1018 {
1019  NS_LOG_FUNCTION(this);
1020 
1021  Config::SetDefault("ns3::SatPhyRxCarrier::EnableCompositeSinrOutputTrace", BooleanValue(true));
1022  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableIntfOutputTrace", BooleanValue(true));
1023  Config::SetDefault("ns3::SatChannel::EnableRxPowerOutputTrace", BooleanValue(true));
1024  Config::SetDefault("ns3::SatChannel::EnableFadingOutputTrace", BooleanValue(true));
1025 }
1026 
1027 void
1029 {
1030  NS_LOG_FUNCTION(this);
1031 
1032  Config::SetDefault("ns3::SatOrbiterFeederPhy::RxTemperatureDbk", DoubleValue(28.4));
1033  Config::SetDefault("ns3::SatOrbiterFeederPhy::RxMaxAntennaGainDb", DoubleValue(54));
1034  Config::SetDefault("ns3::SatOrbiterFeederPhy::TxMaxAntennaGainDb", DoubleValue(54));
1035  Config::SetDefault("ns3::SatOrbiterFeederPhy::TxMaxPowerDbw", DoubleValue(-4.38));
1036  Config::SetDefault("ns3::SatOrbiterFeederPhy::TxOutputLossDb", DoubleValue(1.75));
1037  Config::SetDefault("ns3::SatOrbiterFeederPhy::TxPointingLossDb", DoubleValue(0));
1038  Config::SetDefault("ns3::SatOrbiterFeederPhy::TxOboLossDb", DoubleValue(4));
1039  Config::SetDefault("ns3::SatOrbiterFeederPhy::TxAntennaLossDb", DoubleValue(1));
1040  Config::SetDefault("ns3::SatOrbiterFeederPhy::RxAntennaLossDb", DoubleValue(1));
1041  Config::SetDefault("ns3::SatOrbiterFeederPhy::DefaultFadingValue", DoubleValue(1));
1042  Config::SetDefault("ns3::SatOrbiterFeederPhy::ExtNoisePowerDensityDbwhz", DoubleValue(-207));
1043  Config::SetDefault("ns3::SatOrbiterFeederPhy::ImIfCOverIDb", DoubleValue(27));
1044  Config::SetDefault("ns3::SatOrbiterFeederPhy::FixedAmplificationGainDb", DoubleValue(82));
1045  Config::SetDefault("ns3::SatOrbiterUserPhy::RxTemperatureDbk", DoubleValue(28.4));
1046  Config::SetDefault("ns3::SatOrbiterUserPhy::RxMaxAntennaGainDb", DoubleValue(54));
1047  Config::SetDefault("ns3::SatOrbiterUserPhy::TxMaxAntennaGainDb", DoubleValue(54));
1048  Config::SetDefault("ns3::SatOrbiterUserPhy::TxMaxPowerDbw", DoubleValue(15));
1049  Config::SetDefault("ns3::SatOrbiterUserPhy::TxOutputLossDb", DoubleValue(2.85));
1050  Config::SetDefault("ns3::SatOrbiterUserPhy::TxPointingLossDb", DoubleValue(0));
1051  Config::SetDefault("ns3::SatOrbiterUserPhy::TxOboLossDb", DoubleValue(0));
1052  Config::SetDefault("ns3::SatOrbiterUserPhy::TxAntennaLossDb", DoubleValue(1));
1053  Config::SetDefault("ns3::SatOrbiterUserPhy::RxAntennaLossDb", DoubleValue(1));
1054  Config::SetDefault("ns3::SatOrbiterUserPhy::DefaultFadingValue", DoubleValue(1));
1055  Config::SetDefault("ns3::SatOrbiterUserPhy::OtherSysIfCOverIDb", DoubleValue(27.5));
1056  Config::SetDefault("ns3::SatOrbiterUserPhy::AciIfCOverIDb", DoubleValue(17));
1057  Config::SetDefault("ns3::SatGwPhy::RxTemperatureDbk", DoubleValue(24.62));
1058  Config::SetDefault("ns3::SatGwPhy::RxMaxAntennaGainDb", DoubleValue(61.5));
1059  Config::SetDefault("ns3::SatGwPhy::TxMaxAntennaGainDb", DoubleValue(65.2));
1060  Config::SetDefault("ns3::SatGwPhy::TxMaxPowerDbw", DoubleValue(8.97));
1061  Config::SetDefault("ns3::SatGwPhy::TxOutputLossDb", DoubleValue(2));
1062  Config::SetDefault("ns3::SatGwPhy::TxPointingLossDb", DoubleValue(1.1));
1063  Config::SetDefault("ns3::SatGwPhy::TxOboLossDb", DoubleValue(6));
1064  Config::SetDefault("ns3::SatGwPhy::TxAntennaLossDb", DoubleValue(0));
1065  Config::SetDefault("ns3::SatGwPhy::RxAntennaLossDb", DoubleValue(0));
1066  Config::SetDefault("ns3::SatGwPhy::DefaultFadingValue", DoubleValue(1));
1067  Config::SetDefault("ns3::SatGwPhy::ImIfCOverIDb", DoubleValue(22));
1068  Config::SetDefault("ns3::SatGwPhy::AciIfWrtNoisePercent", DoubleValue(10));
1069  Config::SetDefault("ns3::SatUtPhy::RxTemperatureDbk", DoubleValue(24.6));
1070  Config::SetDefault("ns3::SatUtPhy::RxMaxAntennaGainDb", DoubleValue(44.6));
1071  Config::SetDefault("ns3::SatUtPhy::TxMaxAntennaGainDb", DoubleValue(45.2));
1072  Config::SetDefault("ns3::SatUtPhy::TxMaxPowerDbw", DoubleValue(4));
1073  Config::SetDefault("ns3::SatUtPhy::TxOutputLossDb", DoubleValue(0.5));
1074  Config::SetDefault("ns3::SatUtPhy::TxPointingLossDb", DoubleValue(1));
1075  Config::SetDefault("ns3::SatUtPhy::TxOboLossDb", DoubleValue(0.5));
1076  Config::SetDefault("ns3::SatUtPhy::TxAntennaLossDb", DoubleValue(1));
1077  Config::SetDefault("ns3::SatUtPhy::RxAntennaLossDb", DoubleValue(0));
1078  Config::SetDefault("ns3::SatUtPhy::DefaultFadingValue", DoubleValue(1));
1079  Config::SetDefault("ns3::SatUtPhy::OtherSysIfCOverIDb", DoubleValue(24.7));
1080 }
1081 
1082 void
1084 {
1085  NS_LOG_FUNCTION(this);
1086 
1087  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_OFF));
1088 
1089  // Set index files defining external tracing input files for UTs
1090  // Given index files must locate in /satellite/data/ext-fadingtraces/input folder
1091  Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtRtnUpIndexFileName",
1092  StringValue("BeamId-1_256_UT_fading_rtnup_trace_index.txt"));
1093  Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtFwdDownIndexFileName",
1094  StringValue("BeamId-1_256_UT_fading_fwddwn_trace_index.txt"));
1095 
1096  // Set external fading input trace container mode as list mode
1097  // Now external fading input file used for UT1 is input file defined in row one in set index
1098  // file, for UT2 second input file defined in row two in set index file etc. Position info in
1099  // index file is ignored by list mode
1100  Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtInputMode",
1101  StringValue("ListMode"));
1102 
1103  // enable/disable external fading input on SatChannel as user requests
1104  Config::SetDefault("ns3::SatChannel::EnableExternalFadingInputTrace", BooleanValue(true));
1105 }
1106 
1107 void
1108 SimulationHelper::SetCommonUtPositionAllocator(Ptr<SatListPositionAllocator> posAllocator)
1109 {
1110  NS_LOG_FUNCTION(this);
1111  m_commonUtPositions = posAllocator;
1112 }
1113 
1114 void
1116  Ptr<SatListPositionAllocator> posAllocator)
1117 {
1118  NS_LOG_FUNCTION(this << beamId);
1119  m_utPositionsByBeam[beamId] = posAllocator;
1120 }
1121 
1122 void
1123 SimulationHelper::EnableUtListPositionsFromInputFile(std::string inputFile, bool checkBeams)
1124 {
1125  NS_LOG_FUNCTION(this << inputFile);
1126 
1127  m_inputFileUtListPositions = inputFile;
1128  m_inputFileUtPositionsCheckBeams = checkBeams;
1129 }
1130 
1131 Ptr<SatStatsHelperContainer>
1133 {
1134  NS_LOG_FUNCTION(this);
1135 
1136  if (!m_statContainer)
1137  {
1138  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite",
1139  BooleanValue(true));
1140  m_statContainer = CreateObject<SatStatsHelperContainer>(m_satHelper);
1141  }
1142 
1143  return m_statContainer;
1144 }
1145 
1146 Ptr<SatTrafficHelper>
1148 {
1149  NS_LOG_FUNCTION(this);
1150 
1151  if (!m_trafficHelper)
1152  {
1153  m_trafficHelper =
1154  CreateObject<SatTrafficHelper>(GetSatelliteHelper(), GetStatisticsContainer());
1155  }
1156 
1157  return m_trafficHelper;
1158 }
1159 
1160 Ptr<SatGroupHelper>
1162 {
1163  NS_LOG_FUNCTION(this);
1164 
1165  if (!m_groupHelper)
1166  {
1167  m_groupHelper = CreateObject<SatGroupHelper>();
1168  }
1169 
1170  return m_groupHelper;
1171 }
1172 
1173 Ptr<SatCnoHelper>
1175 {
1176  NS_LOG_FUNCTION(this);
1177 
1178  if (!m_cnoHelper)
1179  {
1180  m_cnoHelper = CreateObject<SatCnoHelper>(m_satHelper);
1181  }
1182 
1183  return m_cnoHelper;
1184 }
1185 
1186 void
1188 {
1189  NS_LOG_FUNCTION(this);
1190  if (m_outputPath == "")
1191  {
1192  m_outputPath = Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/sims/" +
1193  m_simulationName + "/";
1194  // Create the simulation campaign output directory in data/sims/
1195  if (!Singleton<SatEnvVariables>::Get()->IsValidDirectory(m_outputPath))
1196  {
1197  Singleton<SatEnvVariables>::Get()->CreateDirectory(m_outputPath);
1198  }
1199  if (m_simulationTag != "")
1200  {
1201  m_outputPath += m_simulationTag + "/";
1202  Config::SetDefault("ns3::SatEnvVariables::SimulationTag", StringValue(m_simulationTag));
1203 
1204  // Create the simulation output directory by tag name in
1205  // data/sims/simulation-campaign-directory/
1206  if (!Singleton<SatEnvVariables>::Get()->IsValidDirectory(m_outputPath))
1207  {
1208  Singleton<SatEnvVariables>::Get()->CreateDirectory(m_outputPath);
1209  }
1210  }
1211  }
1212  Singleton<SatEnvVariables>::Get()->SetOutputPath(m_outputPath);
1213 }
1214 
1215 Ptr<SatHelper>
1217  const std::string& mobileUtsFolder)
1218 {
1219  NS_LOG_FUNCTION(this);
1220 
1221  std::stringstream ss;
1222  ss << "Created scenario: " << std::endl;
1223 
1224  // Set final output path
1225  SetupOutputPath();
1226 
1227  if (m_scenarioPath == "")
1228  {
1229  NS_FATAL_ERROR("Must specify a scenario folder name from data submodule");
1230  }
1231 
1232  if (Singleton<SatEnvVariables>::Get()->IsValidDirectory(m_scenarioPath + "/beamhopping"))
1233  {
1235  }
1236 
1237  m_satHelper = CreateObject<SatHelper>(m_scenarioPath);
1238 
1240 
1241  m_satHelper->SetGroupHelper(
1242  GetGroupHelper()); // If not done in user scenario, group helper is created here
1243  Ptr<SatAntennaGainPatternContainer> antennaGainPatterns = m_satHelper->GetAntennaGainPatterns();
1244  m_satHelper->GetBeamHelper()->SetAntennaGainPatterns(antennaGainPatterns);
1245 
1246  // Set UT position allocators, if any
1247  if (m_inputFileUtListPositions == "" && !m_satHelper->IsSatConstellationEnabled())
1248  {
1249  if (m_commonUtPositions)
1250  {
1251  m_satHelper->SetCustomUtPositionAllocator(m_commonUtPositions);
1252  }
1253  for (auto it : m_utPositionsByBeam)
1254  {
1255  m_satHelper->SetUtPositionAllocatorForBeam(it.first, it.second);
1256  }
1257  }
1258 
1259  // Determine scenario
1260  if (m_satHelper->IsSatConstellationEnabled())
1261  {
1263  switch (scenario)
1264  {
1265  case SatHelper::NONE: {
1266  for (uint32_t satId = 0; satId < Singleton<SatTopology>::Get()->GetNOrbiterNodes();
1267  satId++)
1268  {
1269  // Set beamInfo to indicate enabled beams
1270  for (uint32_t i = 1; i <= m_satHelper->GetBeamCount(); i++)
1271  {
1272  if (IsBeamEnabled(i))
1273  {
1274  SatBeamUserInfo info;
1275  beamInfo.insert(std::make_pair(std::make_pair(satId, i), info));
1276  }
1277  }
1278  }
1279  break;
1280  }
1281  case SatHelper::FULL: {
1282  for (uint32_t satId = 0; satId < Singleton<SatTopology>::Get()->GetNOrbiterNodes();
1283  satId++)
1284  {
1285  // Set beamInfo to indicate enabled beams
1286  for (uint32_t i = 1; i <= m_satHelper->GetBeamCount(); i++)
1287  {
1288  SatBeamUserInfo info;
1289  beamInfo.insert(std::make_pair(std::make_pair(satId, i), info));
1290  }
1291  }
1292  break;
1293  }
1294  case SatHelper::SIMPLE:
1295  case SatHelper::LARGER:
1296  default: {
1297  NS_FATAL_ERROR("Incorrect scenario chosen with a constellation");
1298  }
1299  }
1300 
1301  m_satHelper->LoadConstellationScenario(
1302  beamInfo,
1303  MakeCallback(&SimulationHelper::GetNextUtUserCount, this));
1304 
1305  std::vector<std::pair<GeoCoordinate, uint32_t>> additionalNodesVector =
1306  m_groupHelper->GetAdditionalNodesPerBeam();
1307  std::map<uint32_t, std::vector<std::pair<GeoCoordinate, uint32_t>>> additionalNodes;
1308  for (std::vector<std::pair<GeoCoordinate, uint32_t>>::iterator it =
1309  additionalNodesVector.begin();
1310  it != additionalNodesVector.end();
1311  it++)
1312  {
1313  uint32_t bestBeamId = antennaGainPatterns->GetBestBeamId(0, it->first, false);
1314  additionalNodes[bestBeamId].push_back(*it);
1315  }
1316 
1317  for (std::map<uint32_t, std::vector<std::pair<GeoCoordinate, uint32_t>>>::iterator it =
1318  additionalNodes.begin();
1319  it != additionalNodes.end();
1320  it++)
1321  {
1322  if (!IsBeamEnabled(it->first))
1323  {
1324  NS_LOG_WARN("Beam ID " << it->first << " is not enabled, cannot add "
1325  << it->second.size() << " UTs from SatGroupHelper");
1326  std::cout << "Beam ID " << it->first << " is not enabled, cannot add "
1327  << it->second.size() << " UTs from SatGroupHelper" << std::endl;
1328  continue;
1329  }
1330  beamInfo[std::make_pair(0, it->first)].SetPositions(it->second);
1331  for (uint32_t i = 0; i < it->second.size(); i++)
1332  {
1333  beamInfo[std::make_pair(0, it->first)].AppendUt(GetNextUtUserCount());
1334  }
1335  }
1336 
1337  if (mobileUtsFolder != "")
1338  {
1339  m_satHelper->LoadMobileUTsFromFolder(mobileUtsFolder, m_utMobileUserCount);
1340  }
1341 
1342  // Now, create either a scenario based on list positions in input file
1343  // or create a generic scenario with UT positions configured by other ways..
1344  if (m_inputFileUtListPositions != "")
1345  {
1346  m_satHelper->CreateUserDefinedScenarioFromListPositions(
1347  0,
1348  beamInfo,
1351  }
1352  else
1353  {
1354  m_satHelper->CreateUserDefinedScenario(beamInfo);
1355  }
1356  }
1357  else if (scenario == SatHelper::NONE)
1358  {
1359  // Create beam scenario
1361 
1362  for (uint32_t i = 1; i <= m_satHelper->GetBeamCount(); i++)
1363  {
1364  if (IsBeamEnabled(i))
1365  {
1366  SatBeamUserInfo info;
1367 
1368  uint32_t utCount;
1369  std::map<uint32_t, Ptr<RandomVariableStream>>::iterator iti = m_utCount.find(i);
1370  std::map<uint32_t, Ptr<RandomVariableStream>>::iterator it0 = m_utCount.find(0);
1371  if (iti == m_utCount.end() && it0 == m_utCount.end())
1372  {
1373  NS_LOG_WARN("No UT count per beam set. Must be set for GEO scenarios");
1374  utCount = 0;
1375  }
1376  else
1377  {
1378  utCount = GetNextUtCount(i);
1379  }
1380 
1381  ss << " Beam " << i << ": UT count= " << utCount;
1382 
1383  for (uint32_t j = 1; j < utCount + 1; j++)
1384  {
1385  uint32_t utUserCount = GetNextUtUserCount();
1386  info.AppendUt(utUserCount);
1387  ss << ", " << j << ". UT user count= " << utUserCount;
1388  }
1389 
1390  beamInfo.insert(std::make_pair(std::make_pair(0, i), info));
1391 
1392  ss << std::endl;
1393  }
1394  }
1395 
1396  std::vector<std::pair<GeoCoordinate, uint32_t>> additionalNodesVector =
1397  m_groupHelper->GetAdditionalNodesPerBeam();
1398  std::map<uint32_t, std::vector<std::pair<GeoCoordinate, uint32_t>>> additionalNodes;
1399  for (std::vector<std::pair<GeoCoordinate, uint32_t>>::iterator it =
1400  additionalNodesVector.begin();
1401  it != additionalNodesVector.end();
1402  it++)
1403  {
1404  uint32_t bestBeamId = antennaGainPatterns->GetBestBeamId(0, it->first, false);
1405  additionalNodes[bestBeamId].push_back(*it);
1406  }
1407 
1408  for (std::map<uint32_t, std::vector<std::pair<GeoCoordinate, uint32_t>>>::iterator it =
1409  additionalNodes.begin();
1410  it != additionalNodes.end();
1411  it++)
1412  {
1413  if (!IsBeamEnabled(it->first))
1414  {
1415  NS_LOG_WARN("Beam ID " << it->first << " is not enabled, cannot add "
1416  << it->second.size() << " UTs from SatGroupHelper");
1417  std::cout << "Beam ID " << it->first << " is not enabled, cannot add "
1418  << it->second.size() << " UTs from SatGroupHelper" << std::endl;
1419  continue;
1420  }
1421  beamInfo[std::make_pair(0, it->first)].SetPositions(it->second);
1422  for (uint32_t i = 0; i < it->second.size(); i++)
1423  {
1424  beamInfo[std::make_pair(0, it->first)].AppendUt(GetNextUtUserCount());
1425  }
1426  }
1427 
1428  if (mobileUtsFolder != "")
1429  {
1430  m_satHelper->LoadMobileUTsFromFolder(mobileUtsFolder, m_utMobileUserCount);
1431  }
1432 
1433  // Now, create either a scenario based on list positions in input file
1434  // or create a generic scenario with UT positions configured by other ways..
1435  if (m_inputFileUtListPositions != "")
1436  {
1437  m_satHelper->CreateUserDefinedScenarioFromListPositions(
1438  0,
1439  beamInfo,
1442  }
1443  else
1444  {
1445  m_satHelper->CreateUserDefinedScenario(beamInfo);
1446  }
1447  }
1448  else
1449  {
1450  m_satHelper->CreatePredefinedScenario(scenario);
1451  }
1452 
1453  NS_LOG_INFO(ss.str());
1454 
1455  m_groupHelper->Init();
1456 
1457  return m_satHelper;
1458 }
1459 
1460 bool
1461 SimulationHelper::HasSinkInstalled(Ptr<Node> node, uint16_t port)
1462 {
1463  NS_LOG_FUNCTION(this << node->GetId() << port);
1464 
1465  for (uint32_t i = 0; i < node->GetNApplications(); i++)
1466  {
1467  auto sink = DynamicCast<PacketSink>(node->GetApplication(i));
1468  if (sink != nullptr)
1469  {
1470  AddressValue av;
1471  sink->GetAttribute("Local", av);
1472  if (InetSocketAddress::ConvertFrom(av.Get()).GetPort() == port)
1473  {
1474  return true;
1475  }
1476  }
1477  }
1478  return false;
1479 }
1480 
1481 void
1483 {
1484  switch (crTxConf)
1485  {
1486  case CR_PERIODIC_CONTROL: {
1487  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
1488  EnumValue(SatEnums::RA_MODEL_OFF));
1489  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
1490  break;
1491  }
1492  case CR_SLOTTED_ALOHA: {
1493  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
1495  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
1496  break;
1497  }
1498  case CR_CRDSA_LOOSE_RC_0: {
1499  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
1500  EnumValue(SatEnums::RA_MODEL_CRDSA));
1501  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
1502  Config::SetDefault("ns3::SatUtHelper::UseCrdsaOnlyForControlPackets", BooleanValue(false));
1503  break;
1504  }
1505  default: {
1506  NS_FATAL_ERROR("Unsupported crTxConf: " << crTxConf);
1507  break;
1508  }
1509  }
1510 }
1511 
1512 void
1513 SimulationHelper::SetBeams(const std::string& enabledBeams)
1514 {
1515  NS_LOG_FUNCTION(this << enabledBeams);
1516 
1517  m_enabledBeamsStr = enabledBeams;
1518  m_enabledBeams.clear();
1519  std::stringstream bss(enabledBeams);
1520 
1521  while (!bss.eof())
1522  {
1523  uint32_t beamId;
1524  bss >> beamId;
1525  if (bss.fail())
1526  {
1527  bss.clear();
1528  std::string garbage;
1529  bss >> garbage;
1530  }
1531  else
1532  {
1533  m_enabledBeams.insert(beamId);
1534  }
1535  }
1536 }
1537 
1538 void
1539 SimulationHelper::SetBeamSet(std::set<uint32_t> beamSet)
1540 {
1541  NS_LOG_FUNCTION(this);
1542 
1543  m_enabledBeams = beamSet;
1544  std::stringstream bss;
1545  for (auto beamId : beamSet)
1546  {
1547  bss << beamId << " ";
1548  }
1549  m_enabledBeamsStr = bss.str();
1550 }
1551 
1552 const std::set<uint32_t>&
1554 {
1555  NS_LOG_FUNCTION(this);
1556 
1557  return m_enabledBeams;
1558 }
1559 
1560 bool
1561 SimulationHelper::IsBeamEnabled(uint32_t beamId) const
1562 {
1563  NS_LOG_FUNCTION(this << beamId);
1564 
1565  bool beamEnabled = false;
1566 
1567  if (m_enabledBeams.find(beamId) != m_enabledBeams.end())
1568  {
1569  beamEnabled = true;
1570  }
1571 
1572  return beamEnabled;
1573 }
1574 
1575 uint32_t
1576 SimulationHelper::GetNextUtCount(uint32_t beamId) const
1577 {
1578  NS_LOG_FUNCTION(this << beamId);
1579 
1580  auto iter = m_utCount.find(beamId);
1581  if (iter != m_utCount.end())
1582  {
1583  return m_utCount.at(beamId)->GetInteger();
1584  }
1585 
1586  return m_utCount.at(0)->GetInteger();
1587 }
1588 
1589 void
1591 {
1592  NS_LOG_FUNCTION(this);
1593 
1594  NS_LOG_INFO("--- " << m_simulationName << "---");
1595  NS_LOG_INFO(" Simulation length: " << m_simTime.GetSeconds());
1596  NS_LOG_INFO(" Enabled beams: " << m_enabledBeamsStr);
1597  NS_LOG_INFO(" Number of UTs: " << Singleton<SatTopology>::Get()->GetNGwUserNodes());
1598  NS_LOG_INFO(" Number of end users: " << Singleton<SatTopology>::Get()->GetNUtUserNodes());
1599 
1600  Simulator::Stop(m_simTime);
1601  Simulator::Run();
1602 
1603  Simulator::Destroy();
1604 }
1605 
1606 void
1608 {
1609  NS_LOG_FUNCTION(this);
1610 
1612  {
1613  if (GetSimTime().GetSeconds() > 20)
1614  {
1615  m_progressUpdateInterval = Seconds(GetSimTime().GetSeconds() / 100);
1616  }
1617  else
1618  {
1619  m_progressUpdateInterval = Seconds(0.2);
1620  }
1622  Simulator::Schedule(m_progressUpdateInterval, &SimulationHelper::ProgressCb, this);
1623  m_progressLoggingEnabled = true;
1624  }
1625 }
1626 
1627 void
1629 {
1630  NS_LOG_FUNCTION(this);
1631 
1632  m_progressLoggingEnabled = false;
1633  m_progressReportEvent.Cancel();
1634 }
1635 
1636 void
1638 {
1639  NS_LOG_FUNCTION(this << name);
1640 
1641  std::string path =
1642  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/" + name;
1643 
1644  if (!Singleton<SatEnvVariables>::Get()->IsValidFile(path))
1645  {
1646  NS_FATAL_ERROR("Scenario in " << path << " does not exist");
1647  }
1648 
1649  m_scenarioPath = path;
1650 }
1651 
1652 void
1654 {
1655  NS_LOG_FUNCTION(this);
1656 }
1657 
1658 void
1660  bool overrideManualConfiguration)
1661 {
1662  ReadInputAttributesFromFile(filePath);
1663  Ptr<SimulationHelperConf> simulationConf = CreateObject<SimulationHelperConf>();
1664 
1665  if (overrideManualConfiguration)
1666  {
1667  SetBeams(simulationConf->m_enabledBeams);
1668  SetUtCountPerBeam(simulationConf->m_utCount);
1669  SetUserCountPerUt(simulationConf->m_utUserCount);
1670  SetUserCountPerMobileUt(simulationConf->m_utMobileUserCount);
1671  SetSimulationTime(simulationConf->m_simTime);
1672  }
1673 
1674  CreateSatScenario(SatHelper::NONE, simulationConf->m_mobileUtsFolder);
1675  if (simulationConf->m_activateProgressLogging)
1676  {
1678  }
1679 
1680  Ptr<SatTrafficHelperConf> satTrafficHelperConf =
1681  CreateObject<SatTrafficHelperConf>(GetTrafficHelper(), m_simTime);
1682  satTrafficHelperConf->InstallTrafficModels();
1683 
1684  if (simulationConf->m_activateStatistics)
1685  {
1687  }
1688 }
1689 
1690 void
1692 {
1693  NS_LOG_FUNCTION(this << filePath);
1694 
1695  // To read attributes from file
1696  Config::SetDefault("ns3::ConfigStore::Filename", StringValue(filePath));
1697  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Load"));
1698  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
1699  ConfigStore inputConfig;
1700  inputConfig.ConfigureDefaults();
1701 }
1702 
1703 std::string
1704 SimulationHelper::StoreAttributesToFile(std::string fileName, bool outputAttributes)
1705 {
1706  NS_LOG_FUNCTION(this);
1707 
1708  std::string outputPath;
1709  outputPath = Singleton<SatEnvVariables>::Get()->GetOutputPath();
1710 
1711  // Store set attribute values to XML output file
1712  Config::SetDefault("ns3::ConfigStore::Filename", StringValue(outputPath + "/" + fileName));
1713  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
1714  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
1715  ConfigStore outputConfig;
1716  outputConfig.ConfigureDefaults();
1717 
1718  if (outputAttributes)
1719  {
1720  outputConfig.ConfigureAttributes();
1721  }
1722 
1723  return outputPath;
1724 }
1725 
1726 } // namespace ns3
Class that holds information for each beam regarding UTs and their users camped in each beam.
void AppendUt(uint32_t userCount)
Appends new UT to end of the list with given user count for the appended UT.
SatLinkDir_t
Link direction used for packet tracing.
PreDefinedScenario_t
Values for pre-defined scenarios to be used by helper when building satellite network topology base.
@ LARGER
LARGER Larger scenario used as base.
@ NONE
NONE Not used.
@ FULL
FULL Full scenario used as base.
@ SIMPLE
SIMPLE Simple scenario used as base.
std::map< std::pair< uint32_t, uint32_t >, SatBeamUserInfo > BeamUserInfoMap_t
definition for beam map key is pair sat ID / beam ID and value is UT/user info.
InterferenceModel
Interference model enum.
Ptr< RandomVariableStream > m_utCount
Ptr< RandomVariableStream > m_utUserCount
Ptr< RandomVariableStream > m_utMobileUserCount
TypeId GetInstanceTypeId(void) const
Derived from Object.
SimulationHelperConf()
Default constructor.
static TypeId GetTypeId(void)
Derived from Object.
virtual ~SimulationHelperConf()
Destructor.
A helper to make it easier to create example simulation cases.
uint32_t GetNextUtCount(uint32_t beamId=0) const
Get next UT count from internal random variable stream.
void EnableCrdsa()
Enable CRDSA random access.
Ptr< SatCnoHelper > m_cnoHelper
void ProgressCb()
Callback that prints simulation progress to stdout.
void SetErrorModel(SatPhyRxCarrierConf::ErrorModel em, double errorRate=0.0)
Set simulation error model.
Ptr< SatTrafficHelper > m_trafficHelper
void SetupOutputPath()
Check if output path has been set.
void SetUserCountPerMobileUt(uint32_t count)
Set user count per mobile UT.
void EnableAcm(SatEnums::SatLinkDir_t dir)
Enable ACM for a simulation direction.
Time & GetSimTime()
Get simulation time.
void DoDispose(void)
Disposing.
void ParseScenarioFolder()
parse scenario folder to load all variables that can be
SimulationHelper()
Default constructor, which is not used.
void ConfigureFrequencyBands()
Configure the default setting for the forward and return link frequencies.
std::string m_inputFileUtListPositions
virtual ~SimulationHelper()
Destructor.
void DisableAcm(SatEnums::SatLinkDir_t dir)
Disable ACM for a simulation direction.
void ConfigureAttributesFromFile(std::string filePath, bool overrideManualConfiguration=true)
Configure this instance after reading input attributes from XML file.
std::map< uint32_t, Ptr< RandomVariableStream > > m_utCount
Ptr< SatCnoHelper > GetCnoHelper()
Get the C/N0 helper to customize C/N0 on some nodes.
void DisableProgressLogs()
Disables simulation progress logs.
void SetIdealPhyParameterization()
Set ideal channel/physical layer parameterization.
void DisableFca()
Disable free capacity allocation.
Ptr< SatHelper > m_satHelper
Ptr< SatHelper > CreateSatScenario(SatHelper::PreDefinedScenario_t scenario=SatHelper::NONE, const std::string &mobileUtsFolder="")
Create the satellite scenario.
void CreateDefaultRtnLinkStats()
Create stats collectors if needed and set default statistics settings for both RTN link.
Ptr< SatGroupHelper > m_groupHelper
Ptr< SatListPositionAllocator > m_commonUtPositions
void RunSimulation()
Run the simulation.
void SetSimulationTime(double seconds)
Set simulation time in seconds.
void EnableFca()
Enable free capacity allocation.
std::string StoreAttributesToFile(std::string fileName, bool outputAttributes=false)
Store all used attributes.
void SetCrTxConf(CrTxConf_t crTxConf)
void SetGwUserCount(uint32_t gwUserCount)
Set the number of GW users in the scenario.
void EnableOnlyConstantRate(uint32_t rcIndex, double rateKbps)
Enable only CRA for a given RC index.
void EnableExternalFadingInputTrace()
Enable external fading input.
void EnableOutputTraces()
Enable all output traces.
void ConfigureLinkBudget()
Configure all link budget related attributes.
void EnableSlottedAloha()
Enable slotted ALOHA random access.
void DisableAllCapacityAssignmentCategories()
Disable all capacity allocation categories: CRA/VBDC/RBDC.
void EnableArq(SatEnums::SatLinkDir_t dir)
Enable ARQ.
void ConfigureFrame(uint32_t superFrameId, double bw, double carrierBw, double rollOff, double carrierSpacing, bool isRandomAccess=false)
Configure a frame for a certain superframe id.
void EnableOnlyRbdc(uint32_t rcIndex)
Enable only RBDC for a given RC index.
void EnableOnlyVbdc(uint32_t rcIndex)
Enable only VBDC for a given RC index.
void SetUtPositionAllocatorForBeam(uint32_t beamId, Ptr< SatListPositionAllocator > posAllocator)
Set a list position allocator for UTs of a specific beam.
void SetUtCountPerBeam(uint32_t count)
Set UT count per beam.
Ptr< SatHelper > GetSatelliteHelper()
If lower layer API access is required, use this to access SatHelper.
Ptr< SatTrafficHelper > GetTrafficHelper()
Get the traffic helper to create more complex traffics.
TypeId GetInstanceTypeId(void) const
Derived from Object.
void ReadInputAttributesFromFile(std::string filePath)
Read input attributes from XML file.
void CreateDefaultFwdLinkStats()
Create stats collectors if needed and set default statistics settings for both FWD link.
void DisableRandomAccess()
Disable random access.
void EnablePeriodicalControlSlots(Time periodicity)
Enable periodical control slots.
Ptr< SatStatsHelperContainer > GetStatisticsContainer()
Get the statistics container of this helper.
void EnableRandomAccess()
Enable random access.
void EnableUtListPositionsFromInputFile(std::string inputFile, bool checkBeams=true)
Enable reading UT list positions from input file.
std::set< uint32_t > m_enabledBeams
void SetUserCountPerUt(uint32_t count)
Set user count per UT.
void CreateDefaultStats()
Create stats collectors and set default statistics settings for both FWD and RTN links.
void SetOutputPath(std::string path)
Force a output file path to this simulation instead of default satellite/data/sims/.
uint32_t GetNextUtUserCount() const
Get next UT user count from internal random variable stream.
Ptr< SatGroupHelper > GetGroupHelper()
Get the group helper.
void SetInterferenceModel(SatPhyRxCarrierConf::InterferenceModel ifModel, double constantIf=0.0)
Set simulation interference model.
void LoadScenario(std::string name)
Load a scenario from data submodule.
void SetBeams(const std::string &beamList)
Ptr< RandomVariableStream > m_utMobileUserCount
const std::set< uint32_t > & GetBeams()
Get enabled beams in integer format.
bool HasSinkInstalled(Ptr< Node > node, uint16_t port)
Check if node has a PacketSink installed at certain port.
std::map< uint32_t, Ptr< SatListPositionAllocator > > m_utPositionsByBeam
void EnableProgressLogs()
Enables simulation progress logging.
bool IsBeamEnabled(uint32_t beamId) const
Check if a beam is enabled.
void SetCommonUtPositionAllocator(Ptr< SatListPositionAllocator > posAllocator)
Set common UT position allocator for all beams.
void ConfigureFwdLinkBeamHopping()
Configure the beam hopping functionality for the FWD link.
void AddDefaultUiArguments(CommandLine &cmd)
Add default command line arguments for the simulation.
Ptr< SatStatsHelperContainer > m_statContainer
void SetOutputTag(std::string tag)
Set simulation output tag, which is the basename of the directory where output files are stored.
Ptr< RandomVariableStream > m_utUserCount
static TypeId GetTypeId(void)
Derived from Object.
void SetDefaultValues()
Set default values shared by all examples using SimulationHelper.
void SetBeamSet(std::set< uint32_t > beamSet)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.