23 #include "ns3/double.h"
26 #include "ns3/satellite-const-variables.h"
27 #include "ns3/satellite-env-variables.h"
28 #include "ns3/satellite-wave-form-conf.h"
29 #include "ns3/simulator.h"
30 #include "ns3/singleton.h"
31 #include "ns3/string.h"
33 NS_LOG_COMPONENT_DEFINE(
"SatConf");
38 NS_OBJECT_ENSURE_REGISTERED(SatConf);
44 TypeId(
"ns3::SatConf")
46 .AddConstructor<SatConf>()
47 .AddAttribute(
"FwdFeederLinkBandwidth",
48 "Bandwidth of the forward link.",
51 MakeDoubleChecker<double>())
52 .AddAttribute(
"FwdFeederLinkBaseFrequency",
53 "Base frequency of the forward feeder link band.",
56 MakeDoubleChecker<double>())
57 .AddAttribute(
"RtnFeederLinkBandwidth",
58 "Bandwidth of the return feeder link band.",
61 MakeDoubleChecker<double>())
62 .AddAttribute(
"RtnFeederLinkBaseFrequency",
63 "Base frequency of the return feeder link band.",
66 MakeDoubleChecker<double>())
67 .AddAttribute(
"FwdUserLinkBandwidth",
68 "Bandwidth of the forward user link band.",
71 MakeDoubleChecker<double>())
72 .AddAttribute(
"FwdUserLinkBaseFrequency",
73 "Base frequency of the forward user link band.",
76 MakeDoubleChecker<double>())
77 .AddAttribute(
"RtnUserLinkBandwidth",
78 "Bandwidth of the return user link band.",
81 MakeDoubleChecker<double>())
82 .AddAttribute(
"RtnUserLinkBaseFrequency",
83 "Base frequency of the return user link band.",
86 MakeDoubleChecker<double>())
87 .AddAttribute(
"FwdUserLinkChannels",
88 "The number of channels in forward user link",
91 MakeUintegerChecker<uint32_t>(1))
92 .AddAttribute(
"RtnUserLinkChannels",
93 "The number of channels in return user link",
96 MakeUintegerChecker<uint32_t>(1))
97 .AddAttribute(
"FwdFeederLinkChannels",
98 "The number of channels in forward feeder link",
101 MakeUintegerChecker<uint32_t>(1))
102 .AddAttribute(
"RtnFeederLinkChannels",
103 "The number of channels in return feeder link",
106 MakeUintegerChecker<uint32_t>(1))
107 .AddAttribute(
"SuperFrameConfForSeq0",
108 "Super frame configuration used for super frame sequence 0.",
121 .AddAttribute(
"FwdCarrierAllocatedBandwidth",
122 "The allocated carrier bandwidth for forward link carriers [Hz].",
123 DoubleValue(0.125e9),
125 MakeDoubleChecker<double>())
126 .AddAttribute(
"FwdCarrierRollOff",
127 "The roll-off factor for forward link carriers.",
130 MakeDoubleChecker<double>(0.00, 1.00))
131 .AddAttribute(
"FwdCarrierSpacing",
132 "The carrier spacing factor for forward link carriers.",
135 MakeDoubleChecker<double>(0.00, 1.00))
136 .AddAttribute(
"RtnScpcCarrierAllocatedBandwidth",
137 "The allocated carrier bandwidth for SCPC link carriers [Hz].",
138 DoubleValue(0.125e9),
140 MakeDoubleChecker<double>())
141 .AddAttribute(
"RtnScpcCarrierRollOff",
142 "The roll-off factor for SCPC link carriers.",
145 MakeDoubleChecker<double>(0.00, 1.00))
146 .AddAttribute(
"RtnScpcCarrierSpacing",
147 "The carrier spacing factor for SCPC link carriers.",
150 MakeDoubleChecker<double>(0.00, 1.00))
151 .AddAttribute(
"UtPositionInputFileName",
152 "File defining user defined UT positions for user defined scenarios.",
153 StringValue(
"UtPos.txt"),
156 .AddAttribute(
"ForwardLinkRegenerationMode",
157 "The regeneration mode used in satellites for forward link.",
165 "REGENERATION_NETWORK"))
166 .AddAttribute(
"ReturnLinkRegenerationMode",
167 "The regeneration mode used in satellites for return link.",
177 "REGENERATION_NETWORK"))
186 NS_LOG_FUNCTION(
this);
193 m_fwdFeederLinkFreqHz(0.0),
194 m_fwdFeederLinkBandwidthHz(0.0),
195 m_fwdUserLinkFreqHz(0.0),
196 m_fwdUserLinkBandwidthHz(0.0),
197 m_rtnFeederLinkFreqHz(0.0),
198 m_rtnFeederLinkBandwidthHz(0.0),
199 m_rtnUserLinkFreqHz(0.0),
200 m_rtnUserLinkBandwidthHz(0.0),
201 m_fwdUserLinkChannelCount(0),
202 m_rtnUserLinkChannelCount(0),
203 m_fwdFeederLinkChannelCount(0),
204 m_rtnFeederLinkChannelCount(0),
206 m_fwdCarrierAllocatedBandwidthHz(0.0),
207 m_fwdCarrierRollOffFactor(0.0),
208 m_fwdCarrierSpacingFactor(0.0),
209 m_rtnCarrierAllocatedBandwidthHz(0.0),
210 m_rtnCarrierRollOffFactor(0.0),
211 m_rtnCarrierSpacingFactor(0.0),
212 m_forwardLinkRegenerationMode(
SatEnums::TRANSPARENT),
213 m_returnLinkRegenerationMode(
SatEnums::TRANSPARENT)
215 NS_LOG_FUNCTION(
this);
227 bool isConstellation)
229 NS_LOG_FUNCTION(
this);
233 std::string dataPath = Singleton<SatEnvVariables>::Get()->LocateDataDirectory() +
"/";
234 std::string dataPathTle = Singleton<SatEnvVariables>::Get()->LocateDataDirectory() +
"/tle/";
262 for (uint32_t i = 0; i <
m_fwdConf.size(); i++)
276 NS_LOG_FUNCTION(
this);
281 double fwdFeederLinkChannelBandwidthHz =
287 if ((fwdFeederLinkChannelBandwidthHz != fwdUserLinkChannelBandwidthHz) &&
291 NS_FATAL_ERROR(
"Channel bandwidths for forward feeder and user links are not equal!!!");
296 NS_FATAL_ERROR(
"Fwd Link carrier bandwidth exceeds channel bandwidth!!!");
301 Ptr<SatFwdCarrierConf> fwdCarrierConf =
309 Ptr<SatFwdCarrierConf> rtnCarrierConf =
322 if ((rtnFeederLinkBandwidthHz != rtnUserLinkBandwidthHz) &&
326 NS_FATAL_ERROR(
"Bandwidths of return feeder and user links are not equal!!!");
333 Ptr<SatWaveformConf> waveFormConf = CreateObject<SatWaveformConf>(wfConf);
336 Ptr<SatSuperframeConf> superFrameConf =
339 superFrameConf->Configure(rtnUserLinkBandwidthHz,
348 NS_LOG_FUNCTION(
this << chType << freqId << carrierId);
350 double centerFrequencyHz = 0.0;
351 double baseFreqHz = 0.0;
352 double channelBandwidthHz = 0.0;
353 double carrierBandwidthHz = 0.0;
360 NS_FATAL_ERROR(
"Fwd Carrier id out of the range!!");
367 baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
373 NS_FATAL_ERROR(
"Fwd Carrier id out of the range!!");
380 baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
386 centerFrequencyHz = baseFreqHz +
m_superframeSeq->GetCarrierFrequencyHz(carrierId);
392 centerFrequencyHz = baseFreqHz +
m_superframeSeq->GetCarrierFrequencyHz(carrierId);
400 return centerFrequencyHz;
408 NS_LOG_FUNCTION(
this << chType << carrierId << bandwidthType);
410 double carrierBandwidthHz = 0.0;
423 carrierBandwidthHz =
m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
432 carrierBandwidthHz =
m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
440 return carrierBandwidthHz;
446 NS_LOG_FUNCTION(
this << filePathName);
449 std::ifstream* ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
455 filePathName =
"../../" + filePathName;
456 ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
460 NS_FATAL_ERROR(
"The file " << filePathName <<
" is not found.");
466 std::vector<std::vector<uint32_t>>
469 NS_LOG_FUNCTION(
this << filePathName);
471 std::vector<std::vector<uint32_t>> conf;
474 std::ifstream* ifs =
OpenFile(filePathName);
476 uint32_t beamId, userChannelId, gwId, feederChannelId;
477 *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
481 NS_LOG_DEBUG(
this <<
" beamId = " << beamId <<
", userChannelId = " << userChannelId
482 <<
", gwId = " << gwId <<
", feederChannelId = " << feederChannelId);
485 std::vector<uint32_t> beamConf;
487 beamConf.push_back(beamId);
488 beamConf.push_back(userChannelId);
489 beamConf.push_back(gwId);
490 beamConf.push_back(feederChannelId);
492 conf.push_back(beamConf);
495 *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
507 NS_LOG_FUNCTION(
this << filePathName);
510 std::ifstream* ifs =
OpenFile(filePathName);
512 double lat, lon, alt;
513 *ifs >> lat >> lon >> alt;
517 NS_LOG_DEBUG(
this <<
" latitude [deg] = " << lat <<
", longitude [deg] = " << lon
518 <<
", altitude [m] = ");
522 container.push_back(coord);
525 *ifs >> lat >> lon >> alt;
535 NS_LOG_FUNCTION(
this << filePathName);
538 std::ifstream* ifs =
OpenFile(filePathName);
540 std::stringstream buffer;
541 buffer << ifs->rdbuf();
542 tleInfo = buffer.str();
548 std::vector<std::string>
551 NS_LOG_FUNCTION(
this << filePathName);
553 std::vector<std::string> tles;
556 std::ifstream* ifs =
OpenFile(filePathName);
560 std::string firstLine;
561 std::getline(*ifs, firstLine);
562 std::istringstream iss(firstLine);
567 while (ifs->good() && i < size)
574 std::getline(*ifs, name);
575 std::getline(*ifs, line1);
576 std::getline(*ifs, line2);
578 tle = line1 +
'\n' + line2;
594 std::vector<std::pair<uint32_t, uint32_t>>
597 NS_LOG_FUNCTION(
this << filePathName);
599 std::vector<std::pair<uint32_t, uint32_t>> isls;
602 std::ifstream* ifs =
OpenFile(filePathName);
606 std::string firstLine;
607 std::getline(*ifs, firstLine);
608 std::istringstream iss(firstLine);
613 while (ifs->good() && i < size)
619 std::getline(*ifs, line);
621 std::stringstream ss(line);
625 isls.push_back(std::make_pair(std::stoi(sat1), std::stoi(sat2)));
639 NS_LOG_FUNCTION(
this);
647 NS_LOG_FUNCTION(
this);
655 NS_LOG_FUNCTION(
this);
663 NS_LOG_FUNCTION(
this);
675 std::vector<uint32_t>
678 NS_LOG_FUNCTION(
this);
679 NS_ASSERT((beamId > 0) && (beamId <=
m_beamCount));
687 NS_LOG_FUNCTION(
this);
695 NS_LOG_FUNCTION(
this);
703 NS_LOG_FUNCTION(
this);
711 NS_LOG_FUNCTION(
this);
720 NS_LOG_FUNCTION(
this);
722 double bandwidtHz = 0.0;
726 NS_FATAL_ERROR(
"Fwd Carrier id out of the range!!");
729 switch (bandwidthType)
744 NS_FATAL_ERROR(
"Invalid bandwidth type");
755 NS_LOG_FUNCTION(
this);
757 double bandwidtHz = 0.0;
761 NS_FATAL_ERROR(
"Rtn Carrier id out of the range!!");
764 switch (bandwidthType)
779 NS_FATAL_ERROR(
"Invalid bandwidth type");
789 NS_LOG_FUNCTION(
this);
798 NS_LOG_FUNCTION(
this);
807 NS_LOG_FUNCTION(
this);
816 NS_LOG_FUNCTION(
this);
GeoCoordinate class is used to store and operate with geodetic coordinates.
uint32_t m_beamCount
Beam count.
std::string m_utPositionInputFileName
File to use when loading UT specific position (for user defined positions)
double GetCarrierBandwidthHz(SatEnums::ChannelType_t chType, uint32_t carrierId, SatEnums::CarrierBandwidthType_t bandwidthType)
Convert carrier id and sequence id to to bandwidth value.
std::string m_tleSat
TLE information of the Satellite.
std::vector< uint32_t > GetBeamConfiguration(uint32_t beamId, SatEnums::SatLinkDir_t dir) const
Get the configuration vector for a given satellite beam id.
uint32_t m_fwdFeederLinkChannelCount
GeoCoordinate GetUtPosition(uint32_t utId) const
Get the position of the GW for a given UT id.
TypeId GetInstanceTypeId(void) const
std::string GetSatTle() const
Get the TLE of the Satellite.
double m_rtnUserLinkBandwidthHz
Bandwidth of return user link.
uint32_t m_rtnFeederLinkChannelCount
uint32_t GetSatCount() const
Get count of the SATs (positions).
double m_fwdCarrierAllocatedBandwidthHz
The configured allocated bandwidth for forward link carriers.
void Initialize(std::string rtnConf, std::string fwdConf, std::string gwPos, std::string satPos, std::string wfConf, std::string tle, bool isConstellation=false)
Initialize the configuration.
SatConf()
Default constructor.
uint32_t m_rtnUserLinkChannelCount
PositionContainer_t m_utPositions
Geodetic positions of the UTs.
static const uint32_t GW_ID_INDEX
Definition for GW ID index (column) in m_conf.
double GetRtnLinkCarrierBandwidthHz(uint32_t carrierId, SatEnums::CarrierBandwidthType_t bandwidthType) const
Get bandwidth of the return link carrier.
uint32_t GetRtnLinkCarrierCount() const
std::vector< std::pair< uint32_t, uint32_t > > LoadIsls(std::string filePathName)
Load a vector of ISLs from a file.
double m_rtnCarrierSpacingFactor
The configured carrier spacing factor for return link carriers.
GeoCoordinate GetGeoSatPosition() const
Get the position of the Geo Satellite.
SatSuperframeConf::SuperFrameConfiguration_t m_SuperFrameConfForSeq0
The super frame configuration used for sequence 0.
double m_fwdFeederLinkFreqHz
Base frequency of forward feeder link.
std::vector< std::string > m_tles
TLE information for a satellite constellation.
std::vector< Ptr< SatFwdCarrierConf > > m_returnLinkCarrierConf
Return link carrier configuration for SCPC.
double m_fwdCarrierRollOffFactor
The configured carrier roll-off factor for forward link carriers.
std::ifstream * OpenFile(std::string filePathName) const
Try to open a file from a given path.
SatEnums::RegenerationMode_t GetForwardLinkRegenerationMode() const
Get the regeneration mode used in satellites for forward link.
PositionContainer_t m_geoSatPosition
Geodetic positions of the Geo Satellite.
double m_rtnFeederLinkFreqHz
Base frequency of return feeder link.
uint32_t GetBeamCount() const
Get count of the beams (configurations).
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
The regeneration mode used in satellites for return link.
uint32_t GetGwCount() const
Get count of the GWs (positions).
double m_rtnCarrierAllocatedBandwidthHz
The configured allocated bandwidth for return link carriers.
double m_rtnCarrierRollOffFactor
The configured carrier roll-off factor for return link carriers.
std::vector< std::string > LoadTles(std::string filePathName)
Load a vector of TLE information from a file.
void Configure(std::string wfConf)
Configures itself with default values.
double m_rtnFeederLinkBandwidthHz
Bandwidth of return feeder link.
GeoCoordinate GetGwPosition(uint32_t gwId) const
Get the position of the GW for a given GW id.
double GetCarrierFrequencyHz(SatEnums::ChannelType_t chType, uint32_t freqId, uint32_t carrierId)
Convert carrier id, sequency id and frequency id to real frequency value.
double m_rtnUserLinkFreqHz
Base frequency of return user link.
double GetFwdLinkCarrierBandwidthHz(uint32_t carrierId, SatEnums::CarrierBandwidthType_t bandwidthType) const
Get bandwidth of the forward link carrier.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
The regeneration mode used in satellites for forward link.
static TypeId GetTypeId(void)
Get the type ID.
double m_fwdUserLinkBandwidthHz
Bandwidth of forward user link.
std::vector< std::vector< uint32_t > > m_fwdConf
double m_fwdFeederLinkBandwidthHz
Bandwidth of forward feeder link.
PositionContainer_t m_gwPositions
Geodetic positions of the GWs.
std::vector< std::vector< uint32_t > > LoadSatConf(std::string filePathName) const
Load satellite configuration from a file.
double m_fwdUserLinkFreqHz
Base frequency of forward user link.
uint32_t GetFwdLinkCarrierCount() const
Ptr< SatSuperframeSeq > m_superframeSeq
Superframe sequence configuration.
void LoadTle(std::string filePathName, std::string &tleInfo)
Load TLE information from a file.
std::vector< GeoCoordinate > PositionContainer_t
void LoadPositions(std::string filePathName, PositionContainer_t &container)
Load node positions from a file.
std::vector< std::vector< uint32_t > > m_rtnConf
SatEnums::RegenerationMode_t GetReturnLinkRegenerationMode() const
Get the regeneration mode used in satellites for return link.
double m_fwdCarrierSpacingFactor
The configured carrier spacing factor for forward link carriers.
bool m_isConstellation
Indicates with this is a constellation of satellites.
void SetUtPositionInputFileName(std::string utPositionInputFileName)
Set the UT positions file name.
uint32_t GetUtCount() const
Get count of the UTs (positions).
std::vector< Ptr< SatFwdCarrierConf > > m_forwardLinkCarrierConf
Forward link carrier configuration.
uint32_t m_fwdUserLinkChannelCount
The number of the channels in different satellite links: forward user, return user,...
SatEnums class is for simplifying the use of enumerators in the satellite module.
SatLinkDir_t
Link direction used for packet tracing.
ChannelType_t
Types of channel.
CarrierBandwidthType_t
Types of bandwidth.
RegenerationMode_t
The regeneration mode used in satellites.
This abstract class defines and implements interface of configuration for super frames.
@ SUPER_FRAME_CONFIG_0
SUPER_FRAME_CONFIG_0.
@ SUPER_FRAME_CONFIG_3
SUPER_FRAME_CONFIG_3.
@ SUPER_FRAME_CONFIG_4
SUPER_FRAME_CONFIG_4.
@ SUPER_FRAME_CONFIG_1
SUPER_FRAME_CONFIG_1.
@ SUPER_FRAME_CONFIG_2
SUPER_FRAME_CONFIG_2.
static Ptr< SatSuperframeConf > CreateSuperframeConf(SuperFrameConfiguration_t conf)
Create pre-configured super frame configuration-.
constexpr uint32_t MAX_BEAMS_PER_SATELLITE
Maximum number of beams per satellite.
constexpr uint32_t MAX_SATELLITES
Maximum number of satellites in constellation.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.