23 #include "../utils/satellite-env-variables.h"
26 #include <ns3/singleton.h>
32 NS_LOG_COMPONENT_DEFINE(
"SatStaticBstp");
41 m_beamFeederFreqIdMap(),
44 NS_LOG_FUNCTION(
this);
52 NS_LOG_FUNCTION(
this);
54 std::string dataPath = Singleton<SatEnvVariables>::Get()->LocateDataDirectory() +
"/";
63 NS_LOG_FUNCTION(
this << filePathName);
66 std::ifstream* ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
72 filePathName =
"../../" + filePathName;
73 ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
77 NS_FATAL_ERROR(
"The file " << filePathName <<
" is not found.");
84 while (std::getline(*ifs, line,
'\n'))
87 std::stringstream ssLine;
90 std::vector<uint32_t> tempVector;
94 while (std::getline(ssLine, col,
','))
96 std::stringstream ssCol;
100 tempVector.push_back(uCol);
103 NS_ASSERT(tempVector.size() >= 2);
105 m_bstp.push_back(tempVector);
108 NS_ASSERT(!
m_bstp.empty());
114 std::vector<uint32_t>
117 NS_LOG_FUNCTION(
this);
121 NS_ASSERT(iter <
m_bstp.size());
139 uint32_t feederFreqId,
142 NS_LOG_FUNCTION(
this << beamId << userFreqId << feederFreqId << gwId);
144 NS_ASSERT(userFreqId == 1);
155 NS_LOG_FUNCTION(
this);
159 NS_FATAL_ERROR(
"BSTP container is empty!");
163 std::map<uint32_t, uint32_t> beamIds;
164 std::map<uint32_t, std::vector<uint32_t>> gwFeederFreqs;
167 for (uint32_t i = 0; i <
m_bstp.size(); i++)
170 gwFeederFreqs.clear();
173 std::vector<uint32_t> confEntry =
m_bstp.at(i);
174 for (uint32_t j = 1; j < confEntry.size(); j++)
176 uint32_t beamId = confEntry.at(j);
178 std::vector<uint32_t>::iterator eIt =
179 std::find(enabledBeams.begin(), enabledBeams.end(), beamId);
180 if (eIt != enabledBeams.end())
182 enabledBeams.erase(eIt);
186 if ((beamIds.insert(std::make_pair(beamId, 0))).second ==
false)
188 NS_FATAL_ERROR(
"Beam id: " << confEntry.at(j)
189 <<
" is located twice in the BSTP line: " << i);
194 std::map<uint32_t, uint32_t>::iterator gwIt =
m_beamGwMap.find(beamId);
199 uint32_t feederFreqId = ffIt->second;
200 uint32_t gwId = gwIt->second;
203 std::map<uint32_t, std::vector<uint32_t>>::iterator findGw =
204 gwFeederFreqs.find(gwId);
207 if (findGw == gwFeederFreqs.end())
209 std::vector<uint32_t> ffIds;
210 ffIds.push_back(feederFreqId);
211 gwFeederFreqs.insert(std::make_pair(gwId, ffIds));
217 std::vector<uint32_t>::iterator findFfIt =
218 std::find(findGw->second.begin(), findGw->second.end(), feederFreqId);
222 if (findFfIt != findGw->second.end())
224 NS_FATAL_ERROR(
"Feeder link freq id: " << feederFreqId
225 <<
" already found for GW: "
230 findGw->second.push_back(feederFreqId);
235 NS_LOG_WARN(
"Beam id: " << beamId <<
" is not enabled, but it located at BSTP!");
242 if (enabledBeams.size() > 0)
244 NS_FATAL_ERROR(
"All enabled beams are not in the BSTP configuration!");
std::map< uint32_t, uint32_t > m_beamGwMap
void LoadBstp(std::string filePathName)
Load BSTP configuration from a file.
void CheckValidity()
Check validity of the individual BSTP configuration line.
std::vector< uint32_t > GetNextConf() const
Get the next configuration file.
uint32_t m_currentIterator
std::vector< std::vector< uint32_t > > m_bstp
std::map< uint32_t, uint32_t > m_beamFeederFreqIdMap
std::vector< uint32_t > m_enabledBeams
SatStaticBstp()
Default constructor.
void AddEnabledBeamInfo(uint32_t beamId, uint32_t userFreqId, uint32_t feederFreqId, uint32_t gwId)
Add the information about which spot-beams are enabled in this simulation.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.