satellite-conf.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Jani Puttonen <jani.puttonen@magister.fi>
19  */
20 
21 #include "satellite-conf.h"
22 
23 #include "ns3/double.h"
24 #include "ns3/enum.h"
25 #include "ns3/log.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"
32 
33 NS_LOG_COMPONENT_DEFINE("SatConf");
34 
35 namespace ns3
36 {
37 
38 NS_OBJECT_ENSURE_REGISTERED(SatConf);
39 
40 TypeId
42 {
43  static TypeId tid =
44  TypeId("ns3::SatConf")
45  .SetParent<Object>()
46  .AddConstructor<SatConf>()
47  .AddAttribute("FwdFeederLinkBandwidth",
48  "Bandwidth of the forward link.",
49  DoubleValue(2.0e9),
50  MakeDoubleAccessor(&SatConf::m_fwdFeederLinkBandwidthHz),
51  MakeDoubleChecker<double>())
52  .AddAttribute("FwdFeederLinkBaseFrequency",
53  "Base frequency of the forward feeder link band.",
54  DoubleValue(27.5e9),
55  MakeDoubleAccessor(&SatConf::m_fwdFeederLinkFreqHz),
56  MakeDoubleChecker<double>())
57  .AddAttribute("RtnFeederLinkBandwidth",
58  "Bandwidth of the return feeder link band.",
59  DoubleValue(2.0e9),
60  MakeDoubleAccessor(&SatConf::m_rtnFeederLinkBandwidthHz),
61  MakeDoubleChecker<double>())
62  .AddAttribute("RtnFeederLinkBaseFrequency",
63  "Base frequency of the return feeder link band.",
64  DoubleValue(17.7e9),
65  MakeDoubleAccessor(&SatConf::m_rtnFeederLinkFreqHz),
66  MakeDoubleChecker<double>())
67  .AddAttribute("FwdUserLinkBandwidth",
68  "Bandwidth of the forward user link band.",
69  DoubleValue(0.5e9),
70  MakeDoubleAccessor(&SatConf::m_fwdUserLinkBandwidthHz),
71  MakeDoubleChecker<double>())
72  .AddAttribute("FwdUserLinkBaseFrequency",
73  "Base frequency of the forward user link band.",
74  DoubleValue(19.7e9),
75  MakeDoubleAccessor(&SatConf::m_fwdUserLinkFreqHz),
76  MakeDoubleChecker<double>())
77  .AddAttribute("RtnUserLinkBandwidth",
78  "Bandwidth of the return user link band.",
79  DoubleValue(0.5e9),
80  MakeDoubleAccessor(&SatConf::m_rtnUserLinkBandwidthHz),
81  MakeDoubleChecker<double>())
82  .AddAttribute("RtnUserLinkBaseFrequency",
83  "Base frequency of the return user link band.",
84  DoubleValue(29.5e9),
85  MakeDoubleAccessor(&SatConf::m_rtnUserLinkFreqHz),
86  MakeDoubleChecker<double>())
87  .AddAttribute("FwdUserLinkChannels",
88  "The number of channels in forward user link",
89  UintegerValue(4),
90  MakeUintegerAccessor(&SatConf::m_fwdUserLinkChannelCount),
91  MakeUintegerChecker<uint32_t>(1))
92  .AddAttribute("RtnUserLinkChannels",
93  "The number of channels in return user link",
94  UintegerValue(4),
95  MakeUintegerAccessor(&SatConf::m_rtnUserLinkChannelCount),
96  MakeUintegerChecker<uint32_t>(1))
97  .AddAttribute("FwdFeederLinkChannels",
98  "The number of channels in forward feeder link",
99  UintegerValue(16),
100  MakeUintegerAccessor(&SatConf::m_fwdFeederLinkChannelCount),
101  MakeUintegerChecker<uint32_t>(1))
102  .AddAttribute("RtnFeederLinkChannels",
103  "The number of channels in return feeder link",
104  UintegerValue(16),
105  MakeUintegerAccessor(&SatConf::m_rtnFeederLinkChannelCount),
106  MakeUintegerChecker<uint32_t>(1))
107  .AddAttribute("SuperFrameConfForSeq0",
108  "Super frame configuration used for super frame sequence 0.",
110  MakeEnumAccessor(&SatConf::m_SuperFrameConfForSeq0),
112  "Configuration_0",
114  "Configuration_1",
116  "Configuration_2",
118  "Configuration_3",
120  "Configuration_4"))
121  .AddAttribute("FwdCarrierAllocatedBandwidth",
122  "The allocated carrier bandwidth for forward link carriers [Hz].",
123  DoubleValue(0.125e9),
124  MakeDoubleAccessor(&SatConf::m_fwdCarrierAllocatedBandwidthHz),
125  MakeDoubleChecker<double>())
126  .AddAttribute("FwdCarrierRollOff",
127  "The roll-off factor for forward link carriers.",
128  DoubleValue(0.20),
129  MakeDoubleAccessor(&SatConf::m_fwdCarrierRollOffFactor),
130  MakeDoubleChecker<double>(0.00, 1.00))
131  .AddAttribute("FwdCarrierSpacing",
132  "The carrier spacing factor for forward link carriers.",
133  DoubleValue(0.00),
134  MakeDoubleAccessor(&SatConf::m_fwdCarrierSpacingFactor),
135  MakeDoubleChecker<double>(0.00, 1.00))
136  .AddAttribute("RtnScpcCarrierAllocatedBandwidth",
137  "The allocated carrier bandwidth for SCPC link carriers [Hz].",
138  DoubleValue(0.125e9),
139  MakeDoubleAccessor(&SatConf::m_rtnCarrierAllocatedBandwidthHz),
140  MakeDoubleChecker<double>())
141  .AddAttribute("RtnScpcCarrierRollOff",
142  "The roll-off factor for SCPC link carriers.",
143  DoubleValue(0.20),
144  MakeDoubleAccessor(&SatConf::m_rtnCarrierRollOffFactor),
145  MakeDoubleChecker<double>(0.00, 1.00))
146  .AddAttribute("RtnScpcCarrierSpacing",
147  "The carrier spacing factor for SCPC link carriers.",
148  DoubleValue(0.00),
149  MakeDoubleAccessor(&SatConf::m_rtnCarrierSpacingFactor),
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"),
154  MakeStringAccessor(&SatConf::m_utPositionInputFileName),
155  MakeStringChecker())
156  .AddAttribute("ForwardLinkRegenerationMode",
157  "The regeneration mode used in satellites for forward link.",
158  EnumValue(SatEnums::TRANSPARENT),
159  MakeEnumAccessor(&SatConf::m_forwardLinkRegenerationMode),
160  MakeEnumChecker(SatEnums::TRANSPARENT,
161  "TRANSPARENT",
163  "REGENERATION_PHY",
165  "REGENERATION_NETWORK"))
166  .AddAttribute("ReturnLinkRegenerationMode",
167  "The regeneration mode used in satellites for return link.",
168  EnumValue(SatEnums::TRANSPARENT),
169  MakeEnumAccessor(&SatConf::m_returnLinkRegenerationMode),
170  MakeEnumChecker(SatEnums::TRANSPARENT,
171  "TRANSPARENT",
173  "REGENERATION_PHY",
175  "REGENERATION_LINK",
177  "REGENERATION_NETWORK"))
178 
179  ;
180  return tid;
181 }
182 
183 TypeId
185 {
186  NS_LOG_FUNCTION(this);
187 
188  return GetTypeId();
189 }
190 
192  : m_beamCount(0),
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),
205  m_SuperFrameConfForSeq0(SatSuperframeConf::SUPER_FRAME_CONFIG_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)
214 {
215  NS_LOG_FUNCTION(this);
216 
217  // Nothing done here
218 }
219 
220 void
221 SatConf::Initialize(std::string rtnConf,
222  std::string fwdConf,
223  std::string gwPos,
224  std::string satPos,
225  std::string wfConf,
226  std::string tle,
227  bool isConstellation)
228 {
229  NS_LOG_FUNCTION(this);
230 
231  m_isConstellation = isConstellation;
232 
233  std::string dataPath = Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/";
234  std::string dataPathTle = Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/tle/";
235 
236  // Load satellite configuration file
237  m_rtnConf = LoadSatConf(dataPath + rtnConf);
238  m_fwdConf = LoadSatConf(dataPath + fwdConf);
239 
240  NS_ASSERT(m_rtnConf.size() == m_fwdConf.size());
241  m_beamCount = m_rtnConf.size();
242 
244 
245  // Load GW positions
246  LoadPositions(dataPath + gwPos, m_gwPositions);
247 
248  // Load UT positions
250 
251  // Load satellite position
252  LoadPositions(dataPath + satPos, m_geoSatPosition);
253 
254  // Load TLE information if case of only one satellite
255  LoadTle(dataPathTle + tle, m_tleSat);
256 
257  // Update fwdConf & rtnConf with correct nb of GWs
258  if (m_isConstellation)
259  {
260  uint32_t nbGws = m_gwPositions.size();
261  uint32_t gwId;
262  for (uint32_t i = 0; i < m_fwdConf.size(); i++)
263  {
264  gwId = i % nbGws;
265  m_fwdConf[i][GW_ID_INDEX] = gwId + 1;
266  m_rtnConf[i][GW_ID_INDEX] = gwId + 1;
267  }
268  }
269 
270  Configure(dataPath + wfConf);
271 }
272 
273 void
274 SatConf::Configure(std::string wfConf)
275 {
276  NS_LOG_FUNCTION(this);
277 
278  // *** configure forward link ***
279 
280  // currently only one carrier in forward link is used.
281  double fwdFeederLinkChannelBandwidthHz =
283  double fwdUserLinkChannelBandwidthHz = m_fwdUserLinkBandwidthHz / m_fwdUserLinkChannelCount;
284 
285  // channel bandwidths for the forward feeder and user links is expected to be equal if forward
286  // generation is physical or transparent
287  if ((fwdFeederLinkChannelBandwidthHz != fwdUserLinkChannelBandwidthHz) &&
290  {
291  NS_FATAL_ERROR("Channel bandwidths for forward feeder and user links are not equal!!!");
292  }
293 
294  if (m_fwdCarrierAllocatedBandwidthHz > fwdFeederLinkChannelBandwidthHz)
295  {
296  NS_FATAL_ERROR("Fwd Link carrier bandwidth exceeds channel bandwidth!!!");
297  }
298 
299  // create forward link carrier configuration and one carrier pushing just one carrier to
300  // container only one carrier supported in forward link currently
301  Ptr<SatFwdCarrierConf> fwdCarrierConf =
302  Create<SatFwdCarrierConf>(m_fwdCarrierAllocatedBandwidthHz,
305  m_forwardLinkCarrierConf.push_back(fwdCarrierConf);
306 
307  // create return link carrier configuration and one carrier pushing just one carrier to
308  // container only one carrier supported in return link currently only used for SCPC
309  Ptr<SatFwdCarrierConf> rtnCarrierConf =
310  Create<SatFwdCarrierConf>(m_rtnCarrierAllocatedBandwidthHz,
313  m_returnLinkCarrierConf.push_back(rtnCarrierConf);
314 
315  // *** configure return link ***
316 
317  double rtnFeederLinkBandwidthHz = m_rtnFeederLinkBandwidthHz / m_rtnFeederLinkChannelCount;
318  double rtnUserLinkBandwidthHz = m_rtnUserLinkBandwidthHz / m_rtnUserLinkChannelCount;
319 
320  // bandwidths of the return feeder and user links is expected to be equal if return generation
321  // is physical or transparent
322  if ((rtnFeederLinkBandwidthHz != rtnUserLinkBandwidthHz) &&
325  {
326  NS_FATAL_ERROR("Bandwidths of return feeder and user links are not equal!!!");
327  }
328 
329  // Create super frame sequence
330  m_superframeSeq = CreateObject<SatSuperframeSeq>();
331 
332  // Create a waveform configuration and add it to super frame sequence.
333  Ptr<SatWaveformConf> waveFormConf = CreateObject<SatWaveformConf>(wfConf);
334  m_superframeSeq->AddWaveformConf(waveFormConf);
335 
336  Ptr<SatSuperframeConf> superFrameConf =
338 
339  superFrameConf->Configure(rtnUserLinkBandwidthHz,
340  m_superframeSeq->GetTargetDuration(),
341  waveFormConf);
342  m_superframeSeq->AddSuperframe(superFrameConf);
343 }
344 
345 double
346 SatConf::GetCarrierFrequencyHz(SatEnums::ChannelType_t chType, uint32_t freqId, uint32_t carrierId)
347 {
348  NS_LOG_FUNCTION(this << chType << freqId << carrierId);
349 
350  double centerFrequencyHz = 0.0;
351  double baseFreqHz = 0.0;
352  double channelBandwidthHz = 0.0;
353  double carrierBandwidthHz = 0.0;
354 
355  switch (chType)
356  {
358  if (carrierId >= m_forwardLinkCarrierConf.size())
359  {
360  NS_FATAL_ERROR("Fwd Carrier id out of the range!!");
361  }
362 
364  carrierBandwidthHz = m_forwardLinkCarrierConf[carrierId]->GetAllocatedBandwidthInHz();
365  baseFreqHz = m_fwdFeederLinkFreqHz + (channelBandwidthHz * (freqId - 1));
366  centerFrequencyHz =
367  baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
368  break;
369 
371  if (carrierId >= m_forwardLinkCarrierConf.size())
372  {
373  NS_FATAL_ERROR("Fwd Carrier id out of the range!!");
374  }
375 
377  carrierBandwidthHz = m_forwardLinkCarrierConf[carrierId]->GetAllocatedBandwidthInHz();
378  baseFreqHz = m_fwdUserLinkFreqHz + (channelBandwidthHz * (freqId - 1));
379  centerFrequencyHz =
380  baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
381  break;
382 
385  baseFreqHz = m_rtnFeederLinkFreqHz + (channelBandwidthHz * (freqId - 1));
386  centerFrequencyHz = baseFreqHz + m_superframeSeq->GetCarrierFrequencyHz(carrierId);
387  break;
388 
391  baseFreqHz = m_rtnUserLinkFreqHz + (channelBandwidthHz * (freqId - 1));
392  centerFrequencyHz = baseFreqHz + m_superframeSeq->GetCarrierFrequencyHz(carrierId);
393  break;
394 
395  default:
396  NS_ASSERT(false);
397  break;
398  }
399 
400  return centerFrequencyHz;
401 }
402 
403 double
405  uint32_t carrierId,
406  SatEnums::CarrierBandwidthType_t bandwidthType)
407 {
408  NS_LOG_FUNCTION(this << chType << carrierId << bandwidthType);
409 
410  double carrierBandwidthHz = 0.0;
411 
412  switch (chType)
413  {
415  carrierBandwidthHz = GetFwdLinkCarrierBandwidthHz(carrierId, bandwidthType);
416  break;
417 
419  carrierBandwidthHz = GetFwdLinkCarrierBandwidthHz(carrierId, bandwidthType);
420  break;
421 
423  carrierBandwidthHz = m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
426  {
427  carrierBandwidthHz = GetRtnLinkCarrierBandwidthHz(0, bandwidthType);
428  }
429  break;
430 
432  carrierBandwidthHz = m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
433  break;
434 
435  default:
436  NS_ASSERT(false);
437  break;
438  }
439 
440  return carrierBandwidthHz;
441 }
442 
443 std::ifstream*
444 SatConf::OpenFile(std::string filePathName) const
445 {
446  NS_LOG_FUNCTION(this << filePathName);
447 
448  // READ FROM THE SPECIFIED INPUT FILE
449  std::ifstream* ifs = new std::ifstream(filePathName.c_str(), std::ifstream::in);
450 
451  if (!ifs->is_open())
452  {
453  // script might be launched by test.py, try a different base path
454  delete ifs;
455  filePathName = "../../" + filePathName;
456  ifs = new std::ifstream(filePathName.c_str(), std::ifstream::in);
457 
458  if (!ifs->is_open())
459  {
460  NS_FATAL_ERROR("The file " << filePathName << " is not found.");
461  }
462  }
463  return ifs;
464 }
465 
466 std::vector<std::vector<uint32_t>>
467 SatConf::LoadSatConf(std::string filePathName) const
468 {
469  NS_LOG_FUNCTION(this << filePathName);
470 
471  std::vector<std::vector<uint32_t>> conf;
472 
473  // READ FROM THE SPECIFIED INPUT FILE
474  std::ifstream* ifs = OpenFile(filePathName);
475 
476  uint32_t beamId, userChannelId, gwId, feederChannelId;
477  *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
478 
479  while (ifs->good())
480  {
481  NS_LOG_DEBUG(this << " beamId = " << beamId << ", userChannelId = " << userChannelId
482  << ", gwId = " << gwId << ", feederChannelId = " << feederChannelId);
483 
484  // Store the values
485  std::vector<uint32_t> beamConf;
486 
487  beamConf.push_back(beamId);
488  beamConf.push_back(userChannelId);
489  beamConf.push_back(gwId);
490  beamConf.push_back(feederChannelId);
491 
492  conf.push_back(beamConf);
493 
494  // get next row
495  *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
496  }
497 
498  ifs->close();
499  delete ifs;
500 
501  return conf;
502 }
503 
504 void
505 SatConf::LoadPositions(std::string filePathName, PositionContainer_t& container)
506 {
507  NS_LOG_FUNCTION(this << filePathName);
508 
509  // READ FROM THE SPECIFIED INPUT FILE
510  std::ifstream* ifs = OpenFile(filePathName);
511 
512  double lat, lon, alt;
513  *ifs >> lat >> lon >> alt;
514 
515  while (ifs->good())
516  {
517  NS_LOG_DEBUG(this << " latitude [deg] = " << lat << ", longitude [deg] = " << lon
518  << ", altitude [m] = ");
519 
520  // Store the values
521  GeoCoordinate coord(lat, lon, alt);
522  container.push_back(coord);
523 
524  // get next row
525  *ifs >> lat >> lon >> alt;
526  }
527 
528  ifs->close();
529  delete ifs;
530 }
531 
532 void
533 SatConf::LoadTle(std::string filePathName, std::string& tleInfo)
534 {
535  NS_LOG_FUNCTION(this << filePathName);
536 
537  // READ FROM THE SPECIFIED INPUT FILE
538  std::ifstream* ifs = OpenFile(filePathName);
539 
540  std::stringstream buffer;
541  buffer << ifs->rdbuf();
542  tleInfo = buffer.str();
543 
544  ifs->close();
545  delete ifs;
546 }
547 
548 std::vector<std::string>
549 SatConf::LoadTles(std::string filePathName)
550 {
551  NS_LOG_FUNCTION(this << filePathName);
552 
553  std::vector<std::string> tles;
554 
555  // READ FROM THE SPECIFIED INPUT FILE
556  std::ifstream* ifs = OpenFile(filePathName);
557 
558  double size;
559  uint32_t i = 0;
560  std::string firstLine;
561  std::getline(*ifs, firstLine);
562  std::istringstream iss(firstLine);
563  iss >> size;
564 
565  tles.reserve(size);
566 
567  while (ifs->good() && i < size)
568  {
569  std::string tle;
570  std::string name;
571  std::string line1;
572  std::string line2;
573 
574  std::getline(*ifs, name);
575  std::getline(*ifs, line1);
576  std::getline(*ifs, line2);
577 
578  tle = line1 + '\n' + line2;
579  tles.push_back(tle);
580 
581  i += 1;
582  }
583 
584  NS_ASSERT(tles.size() < SatConstVariables::MAX_SATELLITES);
585 
586  ifs->close();
587  delete ifs;
588 
589  m_tles = tles;
590 
591  return tles;
592 }
593 
594 std::vector<std::pair<uint32_t, uint32_t>>
595 SatConf::LoadIsls(std::string filePathName)
596 {
597  NS_LOG_FUNCTION(this << filePathName);
598 
599  std::vector<std::pair<uint32_t, uint32_t>> isls;
600 
601  // READ FROM THE SPECIFIED INPUT FILE
602  std::ifstream* ifs = OpenFile(filePathName);
603 
604  double size;
605  uint32_t i = 0;
606  std::string firstLine;
607  std::getline(*ifs, firstLine);
608  std::istringstream iss(firstLine);
609  iss >> size;
610 
611  isls.reserve(size);
612 
613  while (ifs->good() && i < size)
614  {
615  std::string line;
616  std::string sat1;
617  std::string sat2;
618 
619  std::getline(*ifs, line);
620 
621  std::stringstream ss(line);
622  ss >> sat1;
623  ss >> sat2;
624 
625  isls.push_back(std::make_pair(std::stoi(sat1), std::stoi(sat2)));
626 
627  i += 1;
628  }
629 
630  ifs->close();
631  delete ifs;
632 
633  return isls;
634 }
635 
636 uint32_t
638 {
639  NS_LOG_FUNCTION(this);
640 
641  return m_beamCount;
642 }
643 
644 uint32_t
646 {
647  NS_LOG_FUNCTION(this);
648 
649  return m_gwPositions.size();
650 }
651 
652 uint32_t
654 {
655  NS_LOG_FUNCTION(this);
656 
657  return m_utPositions.size();
658 }
659 
660 uint32_t
662 {
663  NS_LOG_FUNCTION(this);
664 
665  if (m_isConstellation)
666  {
667  return m_tles.size();
668  }
669  else
670  {
671  return m_geoSatPosition.size();
672  }
673 }
674 
675 std::vector<uint32_t>
677 {
678  NS_LOG_FUNCTION(this);
679  NS_ASSERT((beamId > 0) && (beamId <= m_beamCount));
680 
681  return (dir == SatEnums::LD_RETURN) ? m_rtnConf[beamId - 1] : m_fwdConf[beamId - 1];
682 }
683 
684 uint32_t
686 {
687  NS_LOG_FUNCTION(this);
688 
689  return m_superframeSeq->GetCarrierCount();
690 }
691 
692 uint32_t
694 {
695  NS_LOG_FUNCTION(this);
696 
697  return m_forwardLinkCarrierConf.size();
698 }
699 
702 {
703  NS_LOG_FUNCTION(this);
704 
706 }
707 
710 {
711  NS_LOG_FUNCTION(this);
712 
714 }
715 
716 double
718  SatEnums::CarrierBandwidthType_t bandwidthType) const
719 {
720  NS_LOG_FUNCTION(this);
721 
722  double bandwidtHz = 0.0;
723 
724  if (carrierId >= m_forwardLinkCarrierConf.size())
725  {
726  NS_FATAL_ERROR("Fwd Carrier id out of the range!!");
727  }
728 
729  switch (bandwidthType)
730  {
732  bandwidtHz = m_forwardLinkCarrierConf[carrierId]->GetAllocatedBandwidthInHz();
733  break;
734 
736  bandwidtHz = m_forwardLinkCarrierConf[carrierId]->GetOccupiedBandwidthInHz();
737  break;
738 
740  bandwidtHz = m_forwardLinkCarrierConf[carrierId]->GetEffectiveBandwidthInHz();
741  break;
742 
743  default:
744  NS_FATAL_ERROR("Invalid bandwidth type");
745  break;
746  }
747 
748  return bandwidtHz;
749 }
750 
751 double
753  SatEnums::CarrierBandwidthType_t bandwidthType) const
754 {
755  NS_LOG_FUNCTION(this);
756 
757  double bandwidtHz = 0.0;
758 
759  if (carrierId >= m_returnLinkCarrierConf.size())
760  {
761  NS_FATAL_ERROR("Rtn Carrier id out of the range!!");
762  }
763 
764  switch (bandwidthType)
765  {
767  bandwidtHz = m_returnLinkCarrierConf[carrierId]->GetAllocatedBandwidthInHz();
768  break;
769 
771  bandwidtHz = m_returnLinkCarrierConf[carrierId]->GetOccupiedBandwidthInHz();
772  break;
773 
775  bandwidtHz = m_returnLinkCarrierConf[carrierId]->GetEffectiveBandwidthInHz();
776  break;
777 
778  default:
779  NS_FATAL_ERROR("Invalid bandwidth type");
780  break;
781  }
782 
783  return bandwidtHz;
784 }
785 
787 SatConf::GetGwPosition(uint32_t gwId) const
788 {
789  NS_LOG_FUNCTION(this);
790  NS_ASSERT((gwId > 0) && (gwId <= m_gwPositions.size()));
791 
792  return m_gwPositions[gwId - 1];
793 }
794 
796 SatConf::GetUtPosition(uint32_t utId) const
797 {
798  NS_LOG_FUNCTION(this);
799  NS_ASSERT((utId > 0) && (utId <= m_utPositions.size()));
800 
801  return m_utPositions[utId - 1];
802 }
803 
806 {
807  NS_LOG_FUNCTION(this);
808  NS_ASSERT(m_geoSatPosition.size() == 1);
809 
810  return m_geoSatPosition[0];
811 }
812 
813 std::string
815 {
816  NS_LOG_FUNCTION(this);
817  NS_ASSERT(m_tleSat.size() != 0);
818 
819  return m_tleSat;
820 }
821 
822 void
823 SatConf::SetUtPositionInputFileName(std::string utPositionInputFileName)
824 {
825  m_utPositionInputFileName = utPositionInputFileName;
826 }
827 
828 } // namespace ns3
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.