23 #include "../utils/satellite-env-variables.h"
26 #include <ns3/singleton.h>
37 NS_LOG_COMPONENT_DEFINE(
"SatStaticBstp");
46 m_beamFeederFreqIdMap(),
49 NS_LOG_FUNCTION(
this);
57 NS_LOG_FUNCTION(
this);
66 NS_LOG_FUNCTION(
this << filePathName);
69 std::ifstream* ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
75 filePathName =
"../../" + filePathName;
76 ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
80 NS_FATAL_ERROR(
"The file " << filePathName <<
" is not found.");
87 while (std::getline(*ifs, line,
'\n'))
90 std::stringstream ssLine;
93 std::vector<uint32_t> tempVector;
97 while (std::getline(ssLine, col,
','))
99 std::stringstream ssCol;
103 tempVector.push_back(uCol);
106 NS_ASSERT(tempVector.size() >= 2);
108 m_bstp.push_back(tempVector);
111 NS_ASSERT(!
m_bstp.empty());
117 std::vector<uint32_t>
120 NS_LOG_FUNCTION(
this);
124 NS_ASSERT(iter <
m_bstp.size());
142 uint32_t feederFreqId,
145 NS_LOG_FUNCTION(
this << beamId << userFreqId << feederFreqId << gwId);
147 NS_ASSERT(userFreqId == 1);
158 NS_LOG_FUNCTION(
this);
162 NS_FATAL_ERROR(
"BSTP container is empty!");
166 std::map<uint32_t, uint32_t> beamIds;
167 std::map<uint32_t, std::vector<uint32_t>> gwFeederFreqs;
170 for (uint32_t i = 0; i <
m_bstp.size(); i++)
173 gwFeederFreqs.clear();
176 std::vector<uint32_t> confEntry =
m_bstp.at(i);
177 for (uint32_t j = 1; j < confEntry.size(); j++)
179 uint32_t beamId = confEntry.at(j);
181 std::vector<uint32_t>::iterator eIt =
182 std::find(enabledBeams.begin(), enabledBeams.end(), beamId);
183 if (eIt != enabledBeams.end())
185 enabledBeams.erase(eIt);
189 if ((beamIds.insert(std::make_pair(beamId, 0))).second ==
false)
191 NS_FATAL_ERROR(
"Beam id: " << confEntry.at(j)
192 <<
" is located twice in the BSTP line: " << i);
197 std::map<uint32_t, uint32_t>::iterator gwIt =
m_beamGwMap.find(beamId);
202 uint32_t feederFreqId = ffIt->second;
203 uint32_t gwId = gwIt->second;
206 std::map<uint32_t, std::vector<uint32_t>>::iterator findGw =
207 gwFeederFreqs.find(gwId);
210 if (findGw == gwFeederFreqs.end())
212 std::vector<uint32_t> ffIds;
213 ffIds.push_back(feederFreqId);
214 gwFeederFreqs.insert(std::make_pair(gwId, ffIds));
220 std::vector<uint32_t>::iterator findFfIt =
221 std::find(findGw->second.begin(), findGw->second.end(), feederFreqId);
225 if (findFfIt != findGw->second.end())
227 NS_FATAL_ERROR(
"Feeder link freq id: " << feederFreqId
228 <<
" already found for GW: "
233 findGw->second.push_back(feederFreqId);
238 NS_LOG_WARN(
"Beam id: " << beamId <<
" is not enabled, but it located at BSTP!");
245 if (enabledBeams.size() > 0)
247 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.