23#include "ns3/double.h"
26#include "ns3/satellite-const-variables.h"
27#include "ns3/satellite-env-variables.h"
28#include "ns3/satellite-topology.h"
29#include "ns3/satellite-wave-form-conf.h"
30#include "ns3/simulator.h"
31#include "ns3/singleton.h"
32#include "ns3/string.h"
40NS_LOG_COMPONENT_DEFINE(
"SatConf");
45NS_OBJECT_ENSURE_REGISTERED(
SatConf);
51 TypeId(
"ns3::SatConf")
53 .AddConstructor<SatConf>()
54 .AddAttribute(
"FwdFeederLinkBandwidth",
55 "Bandwidth of the forward link.",
58 MakeDoubleChecker<double>())
59 .AddAttribute(
"FwdFeederLinkBaseFrequency",
60 "Base frequency of the forward feeder link band.",
63 MakeDoubleChecker<double>())
64 .AddAttribute(
"RtnFeederLinkBandwidth",
65 "Bandwidth of the return feeder link band.",
68 MakeDoubleChecker<double>())
69 .AddAttribute(
"RtnFeederLinkBaseFrequency",
70 "Base frequency of the return feeder link band.",
73 MakeDoubleChecker<double>())
74 .AddAttribute(
"FwdUserLinkBandwidth",
75 "Bandwidth of the forward user link band.",
78 MakeDoubleChecker<double>())
79 .AddAttribute(
"FwdUserLinkBaseFrequency",
80 "Base frequency of the forward user link band.",
83 MakeDoubleChecker<double>())
84 .AddAttribute(
"RtnUserLinkBandwidth",
85 "Bandwidth of the return user link band.",
88 MakeDoubleChecker<double>())
89 .AddAttribute(
"RtnUserLinkBaseFrequency",
90 "Base frequency of the return user link band.",
93 MakeDoubleChecker<double>())
94 .AddAttribute(
"FwdUserLinkChannels",
95 "The number of channels in forward user link",
98 MakeUintegerChecker<uint32_t>(1))
99 .AddAttribute(
"RtnUserLinkChannels",
100 "The number of channels in return user link",
103 MakeUintegerChecker<uint32_t>(1))
104 .AddAttribute(
"FwdFeederLinkChannels",
105 "The number of channels in forward feeder link",
108 MakeUintegerChecker<uint32_t>(1))
109 .AddAttribute(
"RtnFeederLinkChannels",
110 "The number of channels in return feeder link",
113 MakeUintegerChecker<uint32_t>(1))
114 .AddAttribute(
"SuperFrameConfForSeq0",
115 "Super frame configuration used for super frame sequence 0.",
117 MakeEnumAccessor<SatSuperframeConf::SuperFrameConfiguration_t>(
129 .AddAttribute(
"FwdCarrierAllocatedBandwidth",
130 "The allocated carrier bandwidth for forward link carriers [Hz].",
131 DoubleValue(0.125e9),
133 MakeDoubleChecker<double>())
134 .AddAttribute(
"FwdCarrierRollOff",
135 "The roll-off factor for forward link carriers.",
138 MakeDoubleChecker<double>(0.00, 1.00))
139 .AddAttribute(
"FwdCarrierSpacing",
140 "The carrier spacing factor for forward link carriers.",
143 MakeDoubleChecker<double>(0.00, 1.00))
144 .AddAttribute(
"RtnScpcCarrierAllocatedBandwidth",
145 "The allocated carrier bandwidth for SCPC link carriers [Hz].",
146 DoubleValue(0.125e9),
148 MakeDoubleChecker<double>())
149 .AddAttribute(
"RtnScpcCarrierRollOff",
150 "The roll-off factor for SCPC link carriers.",
153 MakeDoubleChecker<double>(0.00, 1.00))
154 .AddAttribute(
"RtnScpcCarrierSpacing",
155 "The carrier spacing factor for SCPC link carriers.",
158 MakeDoubleChecker<double>(0.00, 1.00))
159 .AddAttribute(
"ForwardLinkRegenerationMode",
160 "The regeneration mode used in satellites for forward link.",
162 MakeEnumAccessor<SatEnums::RegenerationMode_t>(
169 "REGENERATION_NETWORK"))
170 .AddAttribute(
"ReturnLinkRegenerationMode",
171 "The regeneration mode used in satellites for return link.",
173 MakeEnumAccessor<SatEnums::RegenerationMode_t>(
182 "REGENERATION_NETWORK"))
212 NS_LOG_FUNCTION(
this);
224 bool isConstellation)
226 NS_LOG_FUNCTION(
this << rtnConf << fwdConf << gwPos << satPos << utPos << wfConf
247 if (!isConstellation)
260 for (uint32_t i = 0; i <
m_fwdConf.size(); i++)
274 NS_LOG_FUNCTION(
this);
279 double fwdFeederLinkChannelBandwidthHz =
285 if ((fwdFeederLinkChannelBandwidthHz != fwdUserLinkChannelBandwidthHz) &&
289 NS_FATAL_ERROR(
"Channel bandwidths for forward feeder and user links are not equal!!!");
294 NS_FATAL_ERROR(
"Fwd Link carrier bandwidth exceeds channel bandwidth!!!");
299 Ptr<SatFwdCarrierConf> fwdCarrierConf =
307 Ptr<SatFwdCarrierConf> rtnCarrierConf =
320 if ((rtnFeederLinkBandwidthHz != rtnUserLinkBandwidthHz) &&
324 NS_FATAL_ERROR(
"Bandwidths of return feeder and user links are not equal!!!");
331 Ptr<SatWaveformConf> waveFormConf = CreateObject<SatWaveformConf>(wfConf);
334 Ptr<SatSuperframeConf> superFrameConf =
337 superFrameConf->Configure(rtnUserLinkBandwidthHz,
346 NS_LOG_FUNCTION(
this << chType << freqId << carrierId);
348 double centerFrequencyHz = 0.0;
349 double baseFreqHz = 0.0;
350 double channelBandwidthHz = 0.0;
351 double carrierBandwidthHz = 0.0;
358 NS_FATAL_ERROR(
"Fwd Carrier id out of the range!!");
365 baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
371 NS_FATAL_ERROR(
"Fwd Carrier id out of the range!!");
378 baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
384 centerFrequencyHz = baseFreqHz +
m_superframeSeq->GetCarrierFrequencyHz(carrierId);
390 centerFrequencyHz = baseFreqHz +
m_superframeSeq->GetCarrierFrequencyHz(carrierId);
398 return centerFrequencyHz;
406 NS_LOG_FUNCTION(
this << chType << carrierId << bandwidthType);
408 double carrierBandwidthHz = 0.0;
421 carrierBandwidthHz =
m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
430 carrierBandwidthHz =
m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
438 return carrierBandwidthHz;
444 NS_LOG_FUNCTION(
this << filePathName);
447 std::ifstream* ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
453 filePathName =
"../../" + filePathName;
454 ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
458 NS_FATAL_ERROR(
"The file " << filePathName <<
" is not found.");
464std::vector<std::vector<uint32_t>>
467 NS_LOG_FUNCTION(
this << filePathName);
469 std::vector<std::vector<uint32_t>> conf;
472 std::ifstream* ifs =
OpenFile(filePathName);
474 uint32_t beamId, userChannelId, gwId, feederChannelId;
475 *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
479 NS_LOG_DEBUG(
this <<
" beamId = " << beamId <<
", userChannelId = " << userChannelId
480 <<
", gwId = " << gwId <<
", feederChannelId = " << feederChannelId);
483 std::vector<uint32_t> beamConf;
485 beamConf.push_back(beamId);
486 beamConf.push_back(userChannelId);
487 beamConf.push_back(gwId);
488 beamConf.push_back(feederChannelId);
490 conf.push_back(beamConf);
493 *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
505 NS_LOG_FUNCTION(
this << inputFileUtListPositions);
514 NS_LOG_FUNCTION(
this << filePathName);
517 std::ifstream* ifs =
OpenFile(filePathName);
519 double lat, lon, alt;
520 *ifs >> lat >> lon >> alt;
524 NS_LOG_DEBUG(
this <<
" latitude [deg] = " << lat <<
", longitude [deg] = " << lon
525 <<
", altitude [m] = ");
529 container.push_back(coord);
532 *ifs >> lat >> lon >> alt;
539std::vector<std::string>
542 NS_LOG_FUNCTION(
this << filePathName);
545 std::ifstream* ifs =
OpenFile(startDatePathName);
552 std::vector<std::string> tles;
558 std::string firstLine;
559 std::getline(*ifs, firstLine);
560 std::istringstream iss(firstLine);
565 while (ifs->good() && i < size)
572 std::getline(*ifs, name);
573 std::getline(*ifs, line1);
574 std::getline(*ifs, line2);
576 tle = line1 +
'\n' + line2;
592std::vector<std::pair<uint32_t, uint32_t>>
595 NS_LOG_FUNCTION(
this << filePathName);
597 std::vector<std::pair<uint32_t, uint32_t>> isls;
600 std::ifstream* ifs =
OpenFile(filePathName);
604 std::string firstLine;
605 std::getline(*ifs, firstLine);
606 std::istringstream iss(firstLine);
611 while (ifs->good() && i < size)
617 std::getline(*ifs, line);
619 std::stringstream ss(line);
623 isls.push_back(std::make_pair(std::stoi(sat1), std::stoi(sat2)));
637 NS_LOG_FUNCTION(
this);
645 NS_LOG_FUNCTION(
this);
653 NS_LOG_FUNCTION(
this);
661 NS_LOG_FUNCTION(
this);
676 NS_LOG_FUNCTION(
this);
677 NS_ASSERT((beamId > 0) && (beamId <=
m_beamCount));
685 NS_LOG_FUNCTION(
this);
693 NS_LOG_FUNCTION(
this);
702 NS_LOG_FUNCTION(
this);
704 double bandwidtHz = 0.0;
708 NS_FATAL_ERROR(
"Fwd Carrier id out of the range!!");
711 switch (bandwidthType)
726 NS_FATAL_ERROR(
"Invalid bandwidth type");
737 NS_LOG_FUNCTION(
this);
739 double bandwidtHz = 0.0;
743 NS_FATAL_ERROR(
"Rtn Carrier id out of the range!!");
746 switch (bandwidthType)
761 NS_FATAL_ERROR(
"Invalid bandwidth type");
771 NS_LOG_FUNCTION(
this);
780 NS_LOG_FUNCTION(
this);
789 NS_LOG_FUNCTION(
this);
798 NS_LOG_FUNCTION(
this);
GeoCoordinate class is used to store and operate with geodetic coordinates.
A configuration class for the satellite reference system.
uint32_t m_beamCount
Beam count.
double GetCarrierBandwidthHz(SatEnums::ChannelType_t chType, uint32_t carrierId, SatEnums::CarrierBandwidthType_t bandwidthType)
Convert carrier id and sequence id to to bandwidth value.
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.
double m_rtnUserLinkBandwidthHz
Bandwidth of return user link.
uint32_t m_rtnFeederLinkChannelCount
uint32_t GetSatCount() const
Get count of the SATs (positions).
void Initialize(std::string rtnConf, std::string fwdConf, std::string gwPos, std::string satPos, std::string utPos, std::string wfConf, bool isConstellation=false)
Initialize the configuration.
double m_fwdCarrierAllocatedBandwidthHz
The configured allocated bandwidth for forward link carriers.
SatConf()
Default constructor.
uint32_t m_rtnUserLinkChannelCount
std::string GetStartTimeStr() const
Get the simulation start time for scenarios using SGP4 model.
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.
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.
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::string m_startTimeStr
Start time of simulation, on format "YYYY-MM-DD hh:mm:ss".
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.
GeoCoordinate GetSatPosition() const
Get the position of the Satellite.
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.
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
PositionContainer_t m_satPosition
Geodetic positions of the Satellite.
std::vector< std::string > LoadTles(std::string filePathName, std::string startDatePathName)
Load a vector of TLE information from a file.
double m_fwdCarrierSpacingFactor
The configured carrier spacing factor for forward link carriers.
void SetUtPositionsPath(std::string inputFileUtListPositions)
Update the list of positions.
bool m_isConstellation
Indicates with this is a constellation of satellites.
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.
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.