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-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"
33 
34 #include <fstream>
35 #include <sstream>
36 #include <string>
37 #include <utility>
38 #include <vector>
39 
40 NS_LOG_COMPONENT_DEFINE("SatConf");
41 
42 namespace ns3
43 {
44 
45 NS_OBJECT_ENSURE_REGISTERED(SatConf);
46 
47 TypeId
49 {
50  static TypeId tid =
51  TypeId("ns3::SatConf")
52  .SetParent<Object>()
53  .AddConstructor<SatConf>()
54  .AddAttribute("FwdFeederLinkBandwidth",
55  "Bandwidth of the forward link.",
56  DoubleValue(2.0e9),
57  MakeDoubleAccessor(&SatConf::m_fwdFeederLinkBandwidthHz),
58  MakeDoubleChecker<double>())
59  .AddAttribute("FwdFeederLinkBaseFrequency",
60  "Base frequency of the forward feeder link band.",
61  DoubleValue(27.5e9),
62  MakeDoubleAccessor(&SatConf::m_fwdFeederLinkFreqHz),
63  MakeDoubleChecker<double>())
64  .AddAttribute("RtnFeederLinkBandwidth",
65  "Bandwidth of the return feeder link band.",
66  DoubleValue(2.0e9),
67  MakeDoubleAccessor(&SatConf::m_rtnFeederLinkBandwidthHz),
68  MakeDoubleChecker<double>())
69  .AddAttribute("RtnFeederLinkBaseFrequency",
70  "Base frequency of the return feeder link band.",
71  DoubleValue(17.7e9),
72  MakeDoubleAccessor(&SatConf::m_rtnFeederLinkFreqHz),
73  MakeDoubleChecker<double>())
74  .AddAttribute("FwdUserLinkBandwidth",
75  "Bandwidth of the forward user link band.",
76  DoubleValue(0.5e9),
77  MakeDoubleAccessor(&SatConf::m_fwdUserLinkBandwidthHz),
78  MakeDoubleChecker<double>())
79  .AddAttribute("FwdUserLinkBaseFrequency",
80  "Base frequency of the forward user link band.",
81  DoubleValue(19.7e9),
82  MakeDoubleAccessor(&SatConf::m_fwdUserLinkFreqHz),
83  MakeDoubleChecker<double>())
84  .AddAttribute("RtnUserLinkBandwidth",
85  "Bandwidth of the return user link band.",
86  DoubleValue(0.5e9),
87  MakeDoubleAccessor(&SatConf::m_rtnUserLinkBandwidthHz),
88  MakeDoubleChecker<double>())
89  .AddAttribute("RtnUserLinkBaseFrequency",
90  "Base frequency of the return user link band.",
91  DoubleValue(29.5e9),
92  MakeDoubleAccessor(&SatConf::m_rtnUserLinkFreqHz),
93  MakeDoubleChecker<double>())
94  .AddAttribute("FwdUserLinkChannels",
95  "The number of channels in forward user link",
96  UintegerValue(4),
97  MakeUintegerAccessor(&SatConf::m_fwdUserLinkChannelCount),
98  MakeUintegerChecker<uint32_t>(1))
99  .AddAttribute("RtnUserLinkChannels",
100  "The number of channels in return user link",
101  UintegerValue(4),
102  MakeUintegerAccessor(&SatConf::m_rtnUserLinkChannelCount),
103  MakeUintegerChecker<uint32_t>(1))
104  .AddAttribute("FwdFeederLinkChannels",
105  "The number of channels in forward feeder link",
106  UintegerValue(16),
107  MakeUintegerAccessor(&SatConf::m_fwdFeederLinkChannelCount),
108  MakeUintegerChecker<uint32_t>(1))
109  .AddAttribute("RtnFeederLinkChannels",
110  "The number of channels in return feeder link",
111  UintegerValue(16),
112  MakeUintegerAccessor(&SatConf::m_rtnFeederLinkChannelCount),
113  MakeUintegerChecker<uint32_t>(1))
114  .AddAttribute("SuperFrameConfForSeq0",
115  "Super frame configuration used for super frame sequence 0.",
117  MakeEnumAccessor<SatSuperframeConf::SuperFrameConfiguration_t>(
120  "Configuration_0",
122  "Configuration_1",
124  "Configuration_2",
126  "Configuration_3",
128  "Configuration_4"))
129  .AddAttribute("FwdCarrierAllocatedBandwidth",
130  "The allocated carrier bandwidth for forward link carriers [Hz].",
131  DoubleValue(0.125e9),
132  MakeDoubleAccessor(&SatConf::m_fwdCarrierAllocatedBandwidthHz),
133  MakeDoubleChecker<double>())
134  .AddAttribute("FwdCarrierRollOff",
135  "The roll-off factor for forward link carriers.",
136  DoubleValue(0.20),
137  MakeDoubleAccessor(&SatConf::m_fwdCarrierRollOffFactor),
138  MakeDoubleChecker<double>(0.00, 1.00))
139  .AddAttribute("FwdCarrierSpacing",
140  "The carrier spacing factor for forward link carriers.",
141  DoubleValue(0.00),
142  MakeDoubleAccessor(&SatConf::m_fwdCarrierSpacingFactor),
143  MakeDoubleChecker<double>(0.00, 1.00))
144  .AddAttribute("RtnScpcCarrierAllocatedBandwidth",
145  "The allocated carrier bandwidth for SCPC link carriers [Hz].",
146  DoubleValue(0.125e9),
147  MakeDoubleAccessor(&SatConf::m_rtnCarrierAllocatedBandwidthHz),
148  MakeDoubleChecker<double>())
149  .AddAttribute("RtnScpcCarrierRollOff",
150  "The roll-off factor for SCPC link carriers.",
151  DoubleValue(0.20),
152  MakeDoubleAccessor(&SatConf::m_rtnCarrierRollOffFactor),
153  MakeDoubleChecker<double>(0.00, 1.00))
154  .AddAttribute("RtnScpcCarrierSpacing",
155  "The carrier spacing factor for SCPC link carriers.",
156  DoubleValue(0.00),
157  MakeDoubleAccessor(&SatConf::m_rtnCarrierSpacingFactor),
158  MakeDoubleChecker<double>(0.00, 1.00))
159  .AddAttribute("ForwardLinkRegenerationMode",
160  "The regeneration mode used in satellites for forward link.",
161  EnumValue(SatEnums::TRANSPARENT),
162  MakeEnumAccessor<SatEnums::RegenerationMode_t>(
164  MakeEnumChecker(SatEnums::TRANSPARENT,
165  "TRANSPARENT",
167  "REGENERATION_PHY",
169  "REGENERATION_NETWORK"))
170  .AddAttribute("ReturnLinkRegenerationMode",
171  "The regeneration mode used in satellites for return link.",
172  EnumValue(SatEnums::TRANSPARENT),
173  MakeEnumAccessor<SatEnums::RegenerationMode_t>(
175  MakeEnumChecker(SatEnums::TRANSPARENT,
176  "TRANSPARENT",
178  "REGENERATION_PHY",
180  "REGENERATION_LINK",
182  "REGENERATION_NETWORK"))
183 
184  ;
185  return tid;
186 }
187 
188 TypeId
190 {
191  NS_LOG_FUNCTION(this);
192 
193  return GetTypeId();
194 }
195 
197  : m_beamCount(0),
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),
210  m_SuperFrameConfForSeq0(SatSuperframeConf::SUPER_FRAME_CONFIG_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)
219 {
220  NS_LOG_FUNCTION(this);
221 
222  // Nothing done here
223 }
224 
225 void
226 SatConf::Initialize(std::string rtnConf,
227  std::string fwdConf,
228  std::string gwPos,
229  std::string satPos,
230  std::string utPos,
231  std::string wfConf,
232  bool isConstellation)
233 {
234  NS_LOG_FUNCTION(this << rtnConf << fwdConf << gwPos << satPos << utPos << wfConf
235  << isConstellation);
236 
237  Singleton<SatTopology>::Get()->SetForwardLinkRegenerationMode(m_forwardLinkRegenerationMode);
238  Singleton<SatTopology>::Get()->SetReturnLinkRegenerationMode(m_returnLinkRegenerationMode);
239 
240  m_isConstellation = isConstellation;
241 
242  // Load satellite configuration file
243  m_rtnConf = LoadSatConf(rtnConf);
244  m_fwdConf = LoadSatConf(fwdConf);
245 
246  NS_ASSERT(m_rtnConf.size() == m_fwdConf.size());
247  m_beamCount = m_rtnConf.size();
248 
250 
251  // Load GW positions
253 
254  // Load satellite position
255  if (!isConstellation)
256  {
257  LoadPositions(satPos, m_satPosition);
258  }
259 
260  // Load UT positions
262 
263  // Update fwdConf & rtnConf with correct nb of GWs
264  if (m_isConstellation)
265  {
266  uint32_t nbGws = m_gwPositions.size();
267  uint32_t gwId;
268  for (uint32_t i = 0; i < m_fwdConf.size(); i++)
269  {
270  gwId = i % nbGws;
271  m_fwdConf[i][GW_ID_INDEX] = gwId + 1;
272  m_rtnConf[i][GW_ID_INDEX] = gwId + 1;
273  }
274  }
275 
276  Configure(wfConf);
277 }
278 
279 void
280 SatConf::Configure(std::string wfConf)
281 {
282  NS_LOG_FUNCTION(this);
283 
284  // *** configure forward link ***
285 
286  // currently only one carrier in forward link is used.
287  double fwdFeederLinkChannelBandwidthHz =
289  double fwdUserLinkChannelBandwidthHz = m_fwdUserLinkBandwidthHz / m_fwdUserLinkChannelCount;
290 
291  // channel bandwidths for the forward feeder and user links is expected to be equal if forward
292  // generation is physical or transparent
293  if ((fwdFeederLinkChannelBandwidthHz != fwdUserLinkChannelBandwidthHz) &&
296  {
297  NS_FATAL_ERROR("Channel bandwidths for forward feeder and user links are not equal!!!");
298  }
299 
300  if (m_fwdCarrierAllocatedBandwidthHz > fwdFeederLinkChannelBandwidthHz)
301  {
302  NS_FATAL_ERROR("Fwd Link carrier bandwidth exceeds channel bandwidth!!!");
303  }
304 
305  // create forward link carrier configuration and one carrier pushing just one carrier to
306  // container only one carrier supported in forward link currently
307  Ptr<SatFwdCarrierConf> fwdCarrierConf =
308  Create<SatFwdCarrierConf>(m_fwdCarrierAllocatedBandwidthHz,
311  m_forwardLinkCarrierConf.push_back(fwdCarrierConf);
312 
313  // create return link carrier configuration and one carrier pushing just one carrier to
314  // container only one carrier supported in return link currently only used for SCPC
315  Ptr<SatFwdCarrierConf> rtnCarrierConf =
316  Create<SatFwdCarrierConf>(m_rtnCarrierAllocatedBandwidthHz,
319  m_returnLinkCarrierConf.push_back(rtnCarrierConf);
320 
321  // *** configure return link ***
322 
323  double rtnFeederLinkBandwidthHz = m_rtnFeederLinkBandwidthHz / m_rtnFeederLinkChannelCount;
324  double rtnUserLinkBandwidthHz = m_rtnUserLinkBandwidthHz / m_rtnUserLinkChannelCount;
325 
326  // bandwidths of the return feeder and user links is expected to be equal if return generation
327  // is physical or transparent
328  if ((rtnFeederLinkBandwidthHz != rtnUserLinkBandwidthHz) &&
331  {
332  NS_FATAL_ERROR("Bandwidths of return feeder and user links are not equal!!!");
333  }
334 
335  // Create super frame sequence
336  m_superframeSeq = CreateObject<SatSuperframeSeq>();
337 
338  // Create a waveform configuration and add it to super frame sequence.
339  Ptr<SatWaveformConf> waveFormConf = CreateObject<SatWaveformConf>(wfConf);
340  m_superframeSeq->AddWaveformConf(waveFormConf);
341 
342  Ptr<SatSuperframeConf> superFrameConf =
344 
345  superFrameConf->Configure(rtnUserLinkBandwidthHz,
346  m_superframeSeq->GetTargetDuration(),
347  waveFormConf);
348  m_superframeSeq->AddSuperframe(superFrameConf);
349 }
350 
351 double
352 SatConf::GetCarrierFrequencyHz(SatEnums::ChannelType_t chType, uint32_t freqId, uint32_t carrierId)
353 {
354  NS_LOG_FUNCTION(this << chType << freqId << carrierId);
355 
356  double centerFrequencyHz = 0.0;
357  double baseFreqHz = 0.0;
358  double channelBandwidthHz = 0.0;
359  double carrierBandwidthHz = 0.0;
360 
361  switch (chType)
362  {
364  if (carrierId >= m_forwardLinkCarrierConf.size())
365  {
366  NS_FATAL_ERROR("Fwd Carrier id out of the range!!");
367  }
368 
370  carrierBandwidthHz = m_forwardLinkCarrierConf[carrierId]->GetAllocatedBandwidthInHz();
371  baseFreqHz = m_fwdFeederLinkFreqHz + (channelBandwidthHz * (freqId - 1));
372  centerFrequencyHz =
373  baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
374  break;
375 
377  if (carrierId >= m_forwardLinkCarrierConf.size())
378  {
379  NS_FATAL_ERROR("Fwd Carrier id out of the range!!");
380  }
381 
383  carrierBandwidthHz = m_forwardLinkCarrierConf[carrierId]->GetAllocatedBandwidthInHz();
384  baseFreqHz = m_fwdUserLinkFreqHz + (channelBandwidthHz * (freqId - 1));
385  centerFrequencyHz =
386  baseFreqHz + (carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2);
387  break;
388 
391  baseFreqHz = m_rtnFeederLinkFreqHz + (channelBandwidthHz * (freqId - 1));
392  centerFrequencyHz = baseFreqHz + m_superframeSeq->GetCarrierFrequencyHz(carrierId);
393  break;
394 
397  baseFreqHz = m_rtnUserLinkFreqHz + (channelBandwidthHz * (freqId - 1));
398  centerFrequencyHz = baseFreqHz + m_superframeSeq->GetCarrierFrequencyHz(carrierId);
399  break;
400 
401  default:
402  NS_ASSERT(false);
403  break;
404  }
405 
406  return centerFrequencyHz;
407 }
408 
409 double
411  uint32_t carrierId,
412  SatEnums::CarrierBandwidthType_t bandwidthType)
413 {
414  NS_LOG_FUNCTION(this << chType << carrierId << bandwidthType);
415 
416  double carrierBandwidthHz = 0.0;
417 
418  switch (chType)
419  {
421  carrierBandwidthHz = GetFwdLinkCarrierBandwidthHz(carrierId, bandwidthType);
422  break;
423 
425  carrierBandwidthHz = GetFwdLinkCarrierBandwidthHz(carrierId, bandwidthType);
426  break;
427 
429  carrierBandwidthHz = m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
432  {
433  carrierBandwidthHz = GetRtnLinkCarrierBandwidthHz(0, bandwidthType);
434  }
435  break;
436 
438  carrierBandwidthHz = m_superframeSeq->GetCarrierBandwidthHz(carrierId, bandwidthType);
439  break;
440 
441  default:
442  NS_ASSERT(false);
443  break;
444  }
445 
446  return carrierBandwidthHz;
447 }
448 
449 std::ifstream*
450 SatConf::OpenFile(std::string filePathName) const
451 {
452  NS_LOG_FUNCTION(this << filePathName);
453 
454  // READ FROM THE SPECIFIED INPUT FILE
455  std::ifstream* ifs = new std::ifstream(filePathName.c_str(), std::ifstream::in);
456 
457  if (!ifs->is_open())
458  {
459  // script might be launched by test.py, try a different base path
460  delete ifs;
461  filePathName = "../../" + filePathName;
462  ifs = new std::ifstream(filePathName.c_str(), std::ifstream::in);
463 
464  if (!ifs->is_open())
465  {
466  NS_FATAL_ERROR("The file " << filePathName << " is not found.");
467  }
468  }
469  return ifs;
470 }
471 
472 std::vector<std::vector<uint32_t>>
473 SatConf::LoadSatConf(std::string filePathName) const
474 {
475  NS_LOG_FUNCTION(this << filePathName);
476 
477  std::vector<std::vector<uint32_t>> conf;
478 
479  // READ FROM THE SPECIFIED INPUT FILE
480  std::ifstream* ifs = OpenFile(filePathName);
481 
482  uint32_t beamId, userChannelId, gwId, feederChannelId;
483  *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
484 
485  while (ifs->good())
486  {
487  NS_LOG_DEBUG(this << " beamId = " << beamId << ", userChannelId = " << userChannelId
488  << ", gwId = " << gwId << ", feederChannelId = " << feederChannelId);
489 
490  // Store the values
491  std::vector<uint32_t> beamConf;
492 
493  beamConf.push_back(beamId);
494  beamConf.push_back(userChannelId);
495  beamConf.push_back(gwId);
496  beamConf.push_back(feederChannelId);
497 
498  conf.push_back(beamConf);
499 
500  // get next row
501  *ifs >> beamId >> userChannelId >> gwId >> feederChannelId;
502  }
503 
504  ifs->close();
505  delete ifs;
506 
507  return conf;
508 }
509 
510 void
511 SatConf::SetUtPositionsPath(std::string inputFileUtListPositions)
512 {
513  NS_LOG_FUNCTION(this << inputFileUtListPositions);
514 
515  // Load UT positions
516  LoadPositions(inputFileUtListPositions, m_utPositions);
517 }
518 
519 void
520 SatConf::LoadPositions(std::string filePathName, PositionContainer_t& container)
521 {
522  NS_LOG_FUNCTION(this << filePathName);
523 
524  // READ FROM THE SPECIFIED INPUT FILE
525  std::ifstream* ifs = OpenFile(filePathName);
526 
527  double lat, lon, alt;
528  *ifs >> lat >> lon >> alt;
529 
530  while (ifs->good())
531  {
532  NS_LOG_DEBUG(this << " latitude [deg] = " << lat << ", longitude [deg] = " << lon
533  << ", altitude [m] = ");
534 
535  // Store the values
536  GeoCoordinate coord(lat, lon, alt);
537  container.push_back(coord);
538 
539  // get next row
540  *ifs >> lat >> lon >> alt;
541  }
542 
543  ifs->close();
544  delete ifs;
545 }
546 
547 std::vector<std::string>
548 SatConf::LoadTles(std::string filePathName, std::string startDatePathName)
549 {
550  NS_LOG_FUNCTION(this << filePathName);
551 
552  // READ START TIME
553  std::ifstream* ifs = OpenFile(startDatePathName);
554 
555  std::getline(*ifs, m_startTimeStr);
556 
557  ifs->close();
558 
559  // READ TLE
560  std::vector<std::string> tles;
561 
562  ifs = OpenFile(filePathName);
563 
564  double size;
565  uint32_t i = 0;
566  std::string firstLine;
567  std::getline(*ifs, firstLine);
568  std::istringstream iss(firstLine);
569  iss >> size;
570 
571  tles.reserve(size);
572 
573  while (ifs->good() && i < size)
574  {
575  std::string tle;
576  std::string name;
577  std::string line1;
578  std::string line2;
579 
580  std::getline(*ifs, name);
581  std::getline(*ifs, line1);
582  std::getline(*ifs, line2);
583 
584  tle = line1 + '\n' + line2;
585  tles.push_back(tle);
586 
587  i += 1;
588  }
589 
590  NS_ASSERT(tles.size() < SatConstVariables::MAX_SATELLITES);
591 
592  ifs->close();
593  delete ifs;
594 
595  m_tles = tles;
596 
597  return tles;
598 }
599 
600 std::vector<std::pair<uint32_t, uint32_t>>
601 SatConf::LoadIsls(std::string filePathName)
602 {
603  NS_LOG_FUNCTION(this << filePathName);
604 
605  std::vector<std::pair<uint32_t, uint32_t>> isls;
606 
607  // READ FROM THE SPECIFIED INPUT FILE
608  std::ifstream* ifs = OpenFile(filePathName);
609 
610  double size;
611  uint32_t i = 0;
612  std::string firstLine;
613  std::getline(*ifs, firstLine);
614  std::istringstream iss(firstLine);
615  iss >> size;
616 
617  isls.reserve(size);
618 
619  while (ifs->good() && i < size)
620  {
621  std::string line;
622  std::string sat1;
623  std::string sat2;
624 
625  std::getline(*ifs, line);
626 
627  std::stringstream ss(line);
628  ss >> sat1;
629  ss >> sat2;
630 
631  isls.push_back(std::make_pair(std::stoi(sat1), std::stoi(sat2)));
632 
633  i += 1;
634  }
635 
636  ifs->close();
637  delete ifs;
638 
639  return isls;
640 }
641 
642 uint32_t
644 {
645  NS_LOG_FUNCTION(this);
646 
647  return m_beamCount;
648 }
649 
650 uint32_t
652 {
653  NS_LOG_FUNCTION(this);
654 
655  return m_gwPositions.size();
656 }
657 
658 uint32_t
660 {
661  NS_LOG_FUNCTION(this);
662 
663  return m_utPositions.size();
664 }
665 
666 uint32_t
668 {
669  NS_LOG_FUNCTION(this);
670 
671  if (m_isConstellation)
672  {
673  return m_tles.size();
674  }
675  else
676  {
677  return m_satPosition.size();
678  }
679 }
680 
681 std::vector<uint32_t>
683 {
684  NS_LOG_FUNCTION(this);
685  NS_ASSERT((beamId > 0) && (beamId <= m_beamCount));
686 
687  return (dir == SatEnums::LD_RETURN) ? m_rtnConf[beamId - 1] : m_fwdConf[beamId - 1];
688 }
689 
690 uint32_t
692 {
693  NS_LOG_FUNCTION(this);
694 
695  return m_superframeSeq->GetCarrierCount();
696 }
697 
698 uint32_t
700 {
701  NS_LOG_FUNCTION(this);
702 
703  return m_forwardLinkCarrierConf.size();
704 }
705 
706 double
708  SatEnums::CarrierBandwidthType_t bandwidthType) const
709 {
710  NS_LOG_FUNCTION(this);
711 
712  double bandwidtHz = 0.0;
713 
714  if (carrierId >= m_forwardLinkCarrierConf.size())
715  {
716  NS_FATAL_ERROR("Fwd Carrier id out of the range!!");
717  }
718 
719  switch (bandwidthType)
720  {
722  bandwidtHz = m_forwardLinkCarrierConf[carrierId]->GetAllocatedBandwidthInHz();
723  break;
724 
726  bandwidtHz = m_forwardLinkCarrierConf[carrierId]->GetOccupiedBandwidthInHz();
727  break;
728 
730  bandwidtHz = m_forwardLinkCarrierConf[carrierId]->GetEffectiveBandwidthInHz();
731  break;
732 
733  default:
734  NS_FATAL_ERROR("Invalid bandwidth type");
735  break;
736  }
737 
738  return bandwidtHz;
739 }
740 
741 double
743  SatEnums::CarrierBandwidthType_t bandwidthType) const
744 {
745  NS_LOG_FUNCTION(this);
746 
747  double bandwidtHz = 0.0;
748 
749  if (carrierId >= m_returnLinkCarrierConf.size())
750  {
751  NS_FATAL_ERROR("Rtn Carrier id out of the range!!");
752  }
753 
754  switch (bandwidthType)
755  {
757  bandwidtHz = m_returnLinkCarrierConf[carrierId]->GetAllocatedBandwidthInHz();
758  break;
759 
761  bandwidtHz = m_returnLinkCarrierConf[carrierId]->GetOccupiedBandwidthInHz();
762  break;
763 
765  bandwidtHz = m_returnLinkCarrierConf[carrierId]->GetEffectiveBandwidthInHz();
766  break;
767 
768  default:
769  NS_FATAL_ERROR("Invalid bandwidth type");
770  break;
771  }
772 
773  return bandwidtHz;
774 }
775 
777 SatConf::GetGwPosition(uint32_t gwId) const
778 {
779  NS_LOG_FUNCTION(this);
780  NS_ASSERT((gwId > 0) && (gwId <= m_gwPositions.size()));
781 
782  return m_gwPositions[gwId - 1];
783 }
784 
786 SatConf::GetUtPosition(uint32_t utId) const
787 {
788  NS_LOG_FUNCTION(this);
789  NS_ASSERT((utId > 0) && (utId <= m_utPositions.size()));
790 
791  return m_utPositions[utId - 1];
792 }
793 
796 {
797  NS_LOG_FUNCTION(this);
798  NS_ASSERT(m_satPosition.size() == 1);
799 
800  return m_satPosition[0];
801 }
802 
803 std::string
805 {
806  NS_LOG_FUNCTION(this);
807 
808  return m_startTimeStr;
809 }
810 
811 } // namespace ns3
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.