Loading...
Searching...
No Matches
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
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
41namespace ns3
42{
43
64class 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
97 void SetDefaultValues();
98
105 void SetBeams(const std::string& beamList);
106
113 void SetBeamSet(std::set<uint32_t> beamSet);
114
115 inline std::set<uint32_t> GetBeamSet(void) const
116 {
117 return m_enabledBeams;
118 }
119
124 const std::set<uint32_t>& GetBeams();
125
130 void SetUtCountPerBeam(uint32_t count);
131
136 void SetUtCountPerBeam(Ptr<RandomVariableStream> rs);
137
142 void SetUtCountPerBeam(uint32_t beamId, uint32_t count);
143
148 void SetUtCountPerBeam(uint32_t beamId, Ptr<RandomVariableStream> rs);
149
154 void SetUserCountPerUt(uint32_t count);
155
160 void SetUserCountPerUt(Ptr<RandomVariableStream> rs);
161
166 void SetUserCountPerMobileUt(uint32_t count);
167
172 void SetUserCountPerMobileUt(Ptr<RandomVariableStream> rs);
173
179 void SetGwUserCount(uint32_t gwUserCount);
180
185 void SetSimulationTime(double seconds);
186
191 inline void SetSimulationTime(Time time)
192 {
193 m_simTime = time;
194 }
195
200
206
212
217
223 void EnableOnlyConstantRate(uint32_t rcIndex, double rateKbps);
224
229 void EnableOnlyRbdc(uint32_t rcIndex);
230
235 void EnableOnlyVbdc(uint32_t rcIndex);
236
240 void EnableFca();
241
245 void DisableFca();
246
250 void EnablePeriodicalControlSlots(Time periodicity);
251
256
260 void DisableRandomAccess();
261
265 void EnableSlottedAloha();
266
270 void EnableCrdsa();
271
281 void ConfigureFrame(uint32_t superFrameId,
282 double bw,
283 double carrierBw,
284 double rollOff,
285 double carrierSpacing,
286 bool isRandomAccess = false);
287
293
301
306
310 void EnableOutputTraces();
311
315 void ConfigureLinkBudget();
316
322 void SetErrorModel(SatPhyRxCarrierConf::ErrorModel em, double errorRate = 0.0);
323
332 double constantIf = 0.0);
333
339 void EnableProgressLogs();
340
344 void DisableProgressLogs();
345
351 void AddDefaultUiArguments(CommandLine& cmd);
352
359 void AddDefaultUiArguments(CommandLine& cmd, std::string& xmlInputFile);
360
364 void RunSimulation();
365
371 void LoadScenario(std::string name);
372
376 void ParseScenarioFolder();
377
385 const std::string& mobileUtsFolder = "");
386
391 void CreateDefaultStats();
392
398
404
410 void SetOutputTag(std::string tag);
411
417 void SetOutputPath(std::string path);
418
425 void ConfigureAttributesFromFile(std::string filePath, bool overrideManualConfiguration = true);
426
431 void ReadInputAttributesFromFile(std::string filePath);
432
440 std::string StoreAttributesToFile(std::string fileName, bool outputAttributes = false);
441
446
447 inline Time& GetSimTime()
448 {
449 return m_simTime;
450 }
451
459 void SetCommonUtPositionAllocator(Ptr<SatListPositionAllocator> posAllocator);
460
468 void SetUtPositionAllocatorForBeam(uint32_t beamId, Ptr<SatListPositionAllocator> posAllocator);
469
475 void EnableUtListPositionsFromInputFile(std::string inputFile, bool checkBeams = true);
476
481 inline Ptr<SatHelper> GetSatelliteHelper()
482 {
483 NS_ASSERT_MSG(m_satHelper != nullptr,
484 "CreateSatScenario not called before calling GetSatelliteHelper");
485 return m_satHelper;
486 }
487
492 Ptr<SatStatsHelperContainer> GetStatisticsContainer();
493
498 Ptr<SatTrafficHelper> GetTrafficHelper();
499
504 Ptr<SatGroupHelper> GetGroupHelper();
505
510 Ptr<SatCnoHelper> GetCnoHelper();
511
519
520 void SetCrTxConf(CrTxConf_t crTxConf);
521
522 protected:
526 void EnableRandomAccess();
527
531 void ProgressCb();
532
536 bool IsBeamEnabled(uint32_t beamId) const;
537
541 uint32_t GetNextUtCount(uint32_t beamId = 0) const;
542
546 inline uint32_t GetNextUtUserCount() const
547 {
548 NS_ASSERT_MSG(m_utUserCount != nullptr, "User count per UT not set");
549 return m_utUserCount->GetInteger();
550 }
551
555 bool HasSinkInstalled(Ptr<Node> node, uint16_t port);
556
561 void SetupOutputPath();
562
563 private:
564 Ptr<SatHelper> m_satHelper;
565 Ptr<SatStatsHelperContainer> m_statContainer;
566 Ptr<SatTrafficHelper> m_trafficHelper;
567 Ptr<SatGroupHelper> m_groupHelper;
568 Ptr<SatCnoHelper> m_cnoHelper;
569 Ptr<SatListPositionAllocator> m_commonUtPositions;
570 std::map<uint32_t, Ptr<SatListPositionAllocator>> m_utPositionsByBeam;
571
572 std::string m_scenarioPath;
573 std::string m_simulationName;
574 std::string m_simulationTag;
575 std::string m_enabledBeamsStr;
576 std::set<uint32_t> m_enabledBeams;
577 std::string m_outputPath;
578
579 std::map<uint32_t, Ptr<RandomVariableStream>> m_utCount;
580
581 Ptr<RandomVariableStream> m_utUserCount;
582 Ptr<RandomVariableStream> m_utMobileUserCount;
588
592};
593
594class SimulationHelperConf : public Object
595{
596 public:
601
605 virtual ~SimulationHelperConf();
606
610 static TypeId GetTypeId(void);
611
613 std::string m_enabledBeams;
614 Ptr<RandomVariableStream> m_utCount;
615 Ptr<RandomVariableStream> m_utUserCount;
616 Ptr<RandomVariableStream> m_utMobileUserCount;
620 std::string m_mobileUtsFolder;
621};
622
623} // namespace ns3
624
625#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
SimulationHelperConf()
Default constructor.
static TypeId GetTypeId(void)
Derived from Object.
virtual ~SimulationHelperConf()
Destructor.
uint32_t GetNextUtCount(uint32_t beamId=0) const
Get next UT count from internal random variable stream.
Time & GetSimTime()
Get simulation time.
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.
Ptr< SatHelper > GetSatelliteHelper()
If lower layer API access is required, use this to access SatHelper.
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< SatTrafficHelper > GetTrafficHelper()
Get the traffic helper to create more complex traffics.
std::set< uint32_t > GetBeamSet(void) const
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.