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"
40 NS_LOG_COMPONENT_DEFINE(
"SatConf");
45 NS_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"))
191 NS_LOG_FUNCTION(
this);
198 m_fwdFeederLinkFreqHz(0.0),
199 m_fwdFeederLinkBandwidthHz(0.0),
200 m_fwdUserLinkFreqHz(0.0),
201 m_fwdUserLinkBandwidthHz(0.0),
202 m_rtnFeederLinkFreqHz(0.0),
203 m_rtnFeederLinkBandwidthHz(0.0),
204 m_rtnUserLinkFreqHz(0.0),
205 m_rtnUserLinkBandwidthHz(0.0),
206 m_fwdUserLinkChannelCount(0),
207 m_rtnUserLinkChannelCount(0),
208 m_fwdFeederLinkChannelCount(0),
209 m_rtnFeederLinkChannelCount(0),
211 m_fwdCarrierAllocatedBandwidthHz(0.0),
212 m_fwdCarrierRollOffFactor(0.0),
213 m_fwdCarrierSpacingFactor(0.0),
214 m_rtnCarrierAllocatedBandwidthHz(0.0),
215 m_rtnCarrierRollOffFactor(0.0),
216 m_rtnCarrierSpacingFactor(0.0),
217 m_forwardLinkRegenerationMode(
SatEnums::TRANSPARENT),
218 m_returnLinkRegenerationMode(
SatEnums::TRANSPARENT)
220 NS_LOG_FUNCTION(
this);
232 bool isConstellation)
234 NS_LOG_FUNCTION(
this << rtnConf << fwdConf << gwPos << satPos << utPos << wfConf
255 if (!isConstellation)
268 for (uint32_t i = 0; i <
m_fwdConf.size(); i++)
282 NS_LOG_FUNCTION(
this);
287 double fwdFeederLinkChannelBandwidthHz =
293 if ((fwdFeederLinkChannelBandwidthHz != fwdUserLinkChannelBandwidthHz) &&
297 NS_FATAL_ERROR(
"Channel bandwidths for forward feeder and user links are not equal!!!");
302 NS_FATAL_ERROR(
"Fwd Link carrier bandwidth exceeds channel bandwidth!!!");
307 Ptr<SatFwdCarrierConf> fwdCarrierConf =
315 Ptr<SatFwdCarrierConf> rtnCarrierConf =
328 if ((rtnFeederLinkBandwidthHz != rtnUserLinkBandwidthHz) &&
332 NS_FATAL_ERROR(
"Bandwidths of return feeder and user links are not equal!!!");
339 Ptr<SatWaveformConf> waveFormConf = CreateObject<SatWaveformConf>(wfConf);
342 Ptr<SatSuperframeConf> superFrameConf =
345 superFrameConf->Configure(rtnUserLinkBandwidthHz,
354 NS_LOG_FUNCTION(
this << chType << freqId << carrierId);
356 double centerFrequencyHz = 0.0;
357 double baseFreqHz = 0.0;
358 double channelBandwidthHz = 0.0;
359 double carrierBandwidthHz = 0.0;
366 NS_FATAL_ERROR(
"Fwd Carrier id out of the range!!");
373 baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
379 NS_FATAL_ERROR(
"Fwd Carrier id out of the range!!");
386 baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
392 centerFrequencyHz = baseFreqHz +
m_superframeSeq->GetCarrierFrequencyHz(carrierId);
398 centerFrequencyHz = baseFreqHz +
m_superframeSeq->GetCarrierFrequencyHz(carrierId);
406 return centerFrequencyHz;
414 NS_LOG_FUNCTION(
this << chType << carrierId << bandwidthType);
416 double carrierBandwidthHz = 0.0;
429 carrierBandwidthHz =
m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
438 carrierBandwidthHz =
m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
446 return carrierBandwidthHz;
452 NS_LOG_FUNCTION(
this << filePathName);
455 std::ifstream* ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
461 filePathName =
"../../" + filePathName;
462 ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
466 NS_FATAL_ERROR(
"The file " << filePathName <<
" is not found.");
472 std::vector<std::vector<uint32_t>>
475 NS_LOG_FUNCTION(
this << filePathName);
477 std::vector<std::vector<uint32_t>> conf;
480 std::ifstream* ifs =
OpenFile(filePathName);
482 uint32_t beamId, userChannelId, gwId, feederChannelId;
483 *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
487 NS_LOG_DEBUG(
this <<
" beamId = " << beamId <<
", userChannelId = " << userChannelId
488 <<
", gwId = " << gwId <<
", feederChannelId = " << feederChannelId);
491 std::vector<uint32_t> beamConf;
493 beamConf.push_back(beamId);
494 beamConf.push_back(userChannelId);
495 beamConf.push_back(gwId);
496 beamConf.push_back(feederChannelId);
498 conf.push_back(beamConf);
501 *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
513 NS_LOG_FUNCTION(
this << inputFileUtListPositions);
522 NS_LOG_FUNCTION(
this << filePathName);
525 std::ifstream* ifs =
OpenFile(filePathName);
527 double lat, lon, alt;
528 *ifs >> lat >> lon >> alt;
532 NS_LOG_DEBUG(
this <<
" latitude [deg] = " << lat <<
", longitude [deg] = " << lon
533 <<
", altitude [m] = ");
537 container.push_back(coord);
540 *ifs >> lat >> lon >> alt;
547 std::vector<std::string>
550 NS_LOG_FUNCTION(
this << filePathName);
553 std::ifstream* ifs =
OpenFile(startDatePathName);
560 std::vector<std::string> tles;
566 std::string firstLine;
567 std::getline(*ifs, firstLine);
568 std::istringstream iss(firstLine);
573 while (ifs->good() && i < size)
580 std::getline(*ifs, name);
581 std::getline(*ifs, line1);
582 std::getline(*ifs, line2);
584 tle = line1 +
'\n' + line2;
600 std::vector<std::pair<uint32_t, uint32_t>>
603 NS_LOG_FUNCTION(
this << filePathName);
605 std::vector<std::pair<uint32_t, uint32_t>> isls;
608 std::ifstream* ifs =
OpenFile(filePathName);
612 std::string firstLine;
613 std::getline(*ifs, firstLine);
614 std::istringstream iss(firstLine);
619 while (ifs->good() && i < size)
625 std::getline(*ifs, line);
627 std::stringstream ss(line);
631 isls.push_back(std::make_pair(std::stoi(sat1), std::stoi(sat2)));
645 NS_LOG_FUNCTION(
this);
653 NS_LOG_FUNCTION(
this);
661 NS_LOG_FUNCTION(
this);
669 NS_LOG_FUNCTION(
this);
681 std::vector<uint32_t>
684 NS_LOG_FUNCTION(
this);
685 NS_ASSERT((beamId > 0) && (beamId <=
m_beamCount));
693 NS_LOG_FUNCTION(
this);
701 NS_LOG_FUNCTION(
this);
710 NS_LOG_FUNCTION(
this);
712 double bandwidtHz = 0.0;
716 NS_FATAL_ERROR(
"Fwd Carrier id out of the range!!");
719 switch (bandwidthType)
734 NS_FATAL_ERROR(
"Invalid bandwidth type");
745 NS_LOG_FUNCTION(
this);
747 double bandwidtHz = 0.0;
751 NS_FATAL_ERROR(
"Rtn Carrier id out of the range!!");
754 switch (bandwidthType)
769 NS_FATAL_ERROR(
"Invalid bandwidth type");
779 NS_LOG_FUNCTION(
this);
788 NS_LOG_FUNCTION(
this);
797 NS_LOG_FUNCTION(
this);
806 NS_LOG_FUNCTION(
this);
GeoCoordinate class is used to store and operate with geodetic coordinates.
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.
TypeId GetInstanceTypeId(void) const
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.