simulation-helper.h
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  */
22 
23 #ifndef SIMULATION_HELPER_H
24 #define SIMULATION_HELPER_H
25 
26 #include "satellite-cno-helper.h"
27 #include "satellite-group-helper.h"
28 #include "satellite-helper.h"
30 
31 #include <ns3/command-line.h>
32 #include <ns3/random-variable-stream.h>
33 #include <ns3/satellite-enums.h>
34 #include <ns3/satellite-stats-helper-container.h>
35 
36 #include <map>
37 #include <set>
38 #include <stdint.h>
39 #include <string>
40 
41 namespace ns3
42 {
43 
64 class SimulationHelper : public Object
65 {
66  public:
71 
76  SimulationHelper(std::string simulationName);
77 
81  virtual ~SimulationHelper();
82 
86  void DoDispose(void);
87 
91  static TypeId GetTypeId(void);
92 
96  TypeId GetInstanceTypeId(void) const;
97 
102  void SetDefaultValues();
103 
110  void SetBeams(const std::string& beamList);
111 
118  void SetBeamSet(std::set<uint32_t> beamSet);
119 
120  inline std::set<uint32_t> GetBeamSet(void) const
121  {
122  return m_enabledBeams;
123  }
124 
129  const std::set<uint32_t>& GetBeams();
130 
135  void SetUtCountPerBeam(uint32_t count);
136 
141  void SetUtCountPerBeam(Ptr<RandomVariableStream> rs);
142 
147  void SetUtCountPerBeam(uint32_t beamId, uint32_t count);
148 
153  void SetUtCountPerBeam(uint32_t beamId, Ptr<RandomVariableStream> rs);
154 
159  void SetUserCountPerUt(uint32_t count);
160 
165  void SetUserCountPerUt(Ptr<RandomVariableStream> rs);
166 
171  void SetUserCountPerMobileUt(uint32_t count);
172 
177  void SetUserCountPerMobileUt(Ptr<RandomVariableStream> rs);
178 
184  void SetGwUserCount(uint32_t gwUserCount);
185 
190  void SetSimulationTime(double seconds);
191 
196  inline void SetSimulationTime(Time time)
197  {
198  m_simTime = time;
199  }
200 
205 
211 
217 
222 
228  void EnableOnlyConstantRate(uint32_t rcIndex, double rateKbps);
229 
234  void EnableOnlyRbdc(uint32_t rcIndex);
235 
240  void EnableOnlyVbdc(uint32_t rcIndex);
241 
245  void EnableFca();
246 
250  void DisableFca();
251 
255  void EnablePeriodicalControlSlots(Time periodicity);
256 
261 
265  void DisableRandomAccess();
266 
270  void EnableSlottedAloha();
271 
275  void EnableCrdsa();
276 
286  void ConfigureFrame(uint32_t superFrameId,
287  double bw,
288  double carrierBw,
289  double rollOff,
290  double carrierSpacing,
291  bool isRandomAccess = false);
292 
298 
306 
311 
315  void EnableOutputTraces();
316 
320  void ConfigureLinkBudget();
321 
327  void SetErrorModel(SatPhyRxCarrierConf::ErrorModel em, double errorRate = 0.0);
328 
337  double constantIf = 0.0);
338 
344  void EnableProgressLogs();
345 
349  void DisableProgressLogs();
350 
356  void AddDefaultUiArguments(CommandLine& cmd);
357 
364  void AddDefaultUiArguments(CommandLine& cmd, std::string& xmlInputFile);
365 
369  void RunSimulation();
370 
376  void LoadScenario(std::string name);
377 
381  void ParseScenarioFolder();
382 
390  const std::string& mobileUtsFolder = "");
391 
396  void CreateDefaultStats();
397 
403 
409 
415  void SetOutputTag(std::string tag);
416 
422  void SetOutputPath(std::string path);
423 
430  void ConfigureAttributesFromFile(std::string filePath, bool overrideManualConfiguration = true);
431 
436  void ReadInputAttributesFromFile(std::string filePath);
437 
445  std::string StoreAttributesToFile(std::string fileName, bool outputAttributes = false);
446 
452  inline Time& GetSimTime()
453  {
454  return m_simTime;
455  }
456 
464  void SetCommonUtPositionAllocator(Ptr<SatListPositionAllocator> posAllocator);
465 
473  void SetUtPositionAllocatorForBeam(uint32_t beamId, Ptr<SatListPositionAllocator> posAllocator);
474 
480  void EnableUtListPositionsFromInputFile(std::string inputFile, bool checkBeams = true);
481 
486  inline Ptr<SatHelper> GetSatelliteHelper()
487  {
488  NS_ASSERT_MSG(m_satHelper != nullptr,
489  "CreateSatScenario not called before calling GetSatelliteHelper");
490  return m_satHelper;
491  }
492 
497  Ptr<SatStatsHelperContainer> GetStatisticsContainer();
498 
503  Ptr<SatTrafficHelper> GetTrafficHelper();
504 
509  Ptr<SatGroupHelper> GetGroupHelper();
510 
515  Ptr<SatCnoHelper> GetCnoHelper();
516 
517  typedef enum
518  {
523  } CrTxConf_t;
524 
525  void SetCrTxConf(CrTxConf_t crTxConf);
526 
527  protected:
531  void EnableRandomAccess();
532 
536  void ProgressCb();
537 
541  bool IsBeamEnabled(uint32_t beamId) const;
542 
546  uint32_t GetNextUtCount(uint32_t beamId = 0) const;
547 
551  inline uint32_t GetNextUtUserCount() const
552  {
553  NS_ASSERT_MSG(m_utUserCount != nullptr, "User count per UT not set");
554  return m_utUserCount->GetInteger();
555  }
556 
560  bool HasSinkInstalled(Ptr<Node> node, uint16_t port);
561 
566  void SetupOutputPath();
567 
568  private:
569  Ptr<SatHelper> m_satHelper;
570  Ptr<SatStatsHelperContainer> m_statContainer;
571  Ptr<SatTrafficHelper> m_trafficHelper;
572  Ptr<SatGroupHelper> m_groupHelper;
573  Ptr<SatCnoHelper> m_cnoHelper;
574  Ptr<SatListPositionAllocator> m_commonUtPositions;
575  std::map<uint32_t, Ptr<SatListPositionAllocator>> m_utPositionsByBeam;
576 
577  std::string m_scenarioPath;
578  std::string m_simulationName;
579  std::string m_simulationTag;
580  std::string m_enabledBeamsStr;
581  std::set<uint32_t> m_enabledBeams;
582  std::string m_outputPath;
583 
584  std::map<uint32_t, Ptr<RandomVariableStream>> m_utCount;
585 
586  Ptr<RandomVariableStream> m_utUserCount;
587  Ptr<RandomVariableStream> m_utMobileUserCount;
588  Time m_simTime;
593 
597 };
598 
599 class SimulationHelperConf : public Object
600 {
601  public:
606 
610  virtual ~SimulationHelperConf();
611 
615  static TypeId GetTypeId(void);
616 
620  TypeId GetInstanceTypeId(void) const;
621 
622  Time m_simTime;
623  std::string m_enabledBeams;
624  Ptr<RandomVariableStream> m_utCount;
625  Ptr<RandomVariableStream> m_utUserCount;
626  Ptr<RandomVariableStream> m_utMobileUserCount;
630  std::string m_mobileUtsFolder;
631 };
632 
633 } // namespace ns3
634 
635 #endif /* TEST_SCRIPT_INPUT_HELPER_H */
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.
@ NONE
NONE Not used.
InterferenceModel
Interference model enum.
Ptr< RandomVariableStream > m_utCount
Ptr< RandomVariableStream > m_utUserCount
Ptr< RandomVariableStream > m_utMobileUserCount
SimulationHelper::CrTxConf_t m_crTxConf
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 SetSimulationTime(Time time)
Set simulation time.
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.
std::set< uint32_t > GetBeamSet(void) const
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.