satellite-frame-conf.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions Ltd
4  * Copyright (c) 2018 CNES
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Sami Rantanen <sami.rantanen@magister.fi>
20  * Author: Mathias Ettinger <mettinger@toulouse.viveris.fr>
21  */
22 
23 #include "satellite-frame-conf.h"
24 
25 #include <ns3/boolean.h>
26 #include <ns3/double.h>
27 #include <ns3/enum.h>
28 #include <ns3/log.h>
29 #include <ns3/object.h>
30 #include <ns3/uinteger.h>
31 
32 #include <algorithm>
33 #include <cmath>
34 #include <istream>
35 #include <limits>
36 #include <string>
37 #include <tuple>
38 #include <utility>
39 
40 NS_LOG_COMPONENT_DEFINE("SatFrameConf");
41 
42 namespace ns3
43 {
44 
45 // BTU conf
46 
48  : m_allocatedBandwidthInHz(0.0),
49  m_occupiedBandwidthInHz(0.0),
50  m_effectiveBandwidthInHz(0.0),
51  m_duration(0.0)
52 {
53  NS_LOG_FUNCTION(this);
54 
55  // default constructor should not be used
56  NS_ASSERT(false);
57 }
58 
59 SatBtuConf::SatBtuConf(double bandwidthInHz,
60  double rollOff,
61  double spacing,
62  uint32_t spreadingFactor)
63  : m_allocatedBandwidthInHz(bandwidthInHz),
64  m_spreadingFactor(spreadingFactor)
65 {
66  NS_LOG_FUNCTION(this);
67 
68  if ((spacing < 0.00) && (spacing > 1.00))
69  {
70  NS_FATAL_ERROR("Spacing for BTU is out of range. Check frame configuration parameters "
71  "(attributes)!!!");
72  }
73 
74  if ((rollOff < 0.00) && (rollOff > 1.00))
75  {
76  NS_FATAL_ERROR("Roll-off for BTU is out of range. Check frame configuration parameters "
77  "(attributes)!!!");
78  }
79 
80  m_occupiedBandwidthInHz = spreadingFactor * m_allocatedBandwidthInHz / (rollOff + 1.00);
82  spreadingFactor * m_allocatedBandwidthInHz / ((spacing + 1.00) * (rollOff + 1.00));
83 
84  m_duration = Seconds(1 / m_effectiveBandwidthInHz);
85 }
86 
88 {
89  NS_LOG_FUNCTION(this);
90 }
91 
92 // Time Slot conf
93 
95  : m_startTime(0),
96  m_waveFormId(0),
97  m_frameCarrierId(0),
98  m_rcIndex(0),
99  m_slotType(SatTimeSlotConf::SLOT_TYPE_TRC)
100 {
101  NS_LOG_FUNCTION(this);
102 
103  // default constructor should not be used
104  NS_ASSERT(false);
105 }
106 
108  uint32_t waveFormId,
109  uint16_t frameCarrierId,
111  : m_startTime(startTime),
112  m_waveFormId(waveFormId),
113  m_frameCarrierId(frameCarrierId),
114  m_rcIndex(0),
115  m_slotType(slotType)
116 {
117  NS_LOG_FUNCTION(this);
118 }
119 
121 {
122  NS_LOG_FUNCTION(this);
123 }
124 
125 // Frame conf
126 
128  : m_bandwidthHz(0.0),
129  m_duration(0.0),
130  m_isRandomAccess(false),
131  m_parent(nullptr),
132  m_btuConf(nullptr),
133  m_allocationChannel(0),
134  m_carrierCount(0),
135  m_maxSymbolsPerCarrier(0),
136  m_minPayloadPerCarrierInBytes(0)
137 {
138  NS_LOG_FUNCTION(this);
139 
140  // default constructor should not be used
141  NS_ASSERT(false);
142 }
143 
145  : m_bandwidthHz(parameters.m_bandwidthHz),
146  m_isRandomAccess(parameters.m_isRandomAccess),
147  m_isLogon(parameters.m_isLogon),
148  m_parent(parameters.m_parent),
149  m_btuConf(parameters.m_btuConf),
150  m_waveformConf(parameters.m_waveformConf),
151  m_allocationChannel(parameters.m_allocationChannel)
152 {
153  NS_LOG_FUNCTION(this);
154 
155  m_carrierCount = m_bandwidthHz / m_btuConf->GetAllocatedBandwidthInHz();
156 
157  if (m_carrierCount == 0)
158  {
159  NS_FATAL_ERROR("No carriers can be created for the frame with given BTU and bandwidth. "
160  "Check frame configuration parameters (attributes)!!! ");
161  }
162  else
163  {
164  NS_LOG_INFO("Carriers count " << m_carrierCount);
165  }
166 
167  uint32_t defWaveFormId = m_waveformConf->GetDefaultWaveformId();
168  Ptr<SatWaveform> defWaveform = m_waveformConf->GetWaveform(defWaveFormId);
169 
170  // calculate slot details based on given parameters and default waveform
171  Time timeSlotDuration = defWaveform->GetBurstDuration(m_btuConf->GetSymbolRateInBauds());
172  uint32_t carrierSlotCount =
173  parameters.m_targetDuration.GetSeconds() / timeSlotDuration.GetSeconds();
175 
176  if (carrierSlotCount == 0)
177  {
178  NS_FATAL_ERROR("Time slots cannot be created with target frame duration. Check frame "
179  "target duration!!!");
180  }
181  else
182  {
183  NS_LOG_INFO("Carrier slot count " << carrierSlotCount);
184  }
185 
186  m_duration = Time(carrierSlotCount * timeSlotDuration.GetInteger());
187 
188  m_maxSymbolsPerCarrier = carrierSlotCount * defWaveform->GetBurstLengthInSymbols();
189 
190  if (parameters.m_defaultWaveformInUse || (m_waveformConf->IsAcmEnabled() == false))
191  {
192  m_minPayloadPerCarrierInBytes = carrierSlotCount * defWaveform->GetPayloadInBytes();
193  }
194  else
195  {
196  uint32_t mostRobustWaveFormId;
197 
198  if (!m_waveformConf->GetMostRobustWaveformId(mostRobustWaveFormId,
199  defWaveform->GetBurstLengthInSymbols()))
200  {
201  NS_FATAL_ERROR("Most robust waveform not found, error in waveform configuration ???");
202  }
203 
204  Ptr<SatWaveform> waveform = m_waveformConf->GetWaveform(mostRobustWaveFormId);
205  m_minPayloadPerCarrierInBytes = carrierSlotCount * waveform->GetPayloadInBytes();
206  }
207 
208  uint32_t frameTimeSlotCount = 0;
209 
210  // Created time slots for every carrier and add them to frame configuration
211  for (uint32_t i = 0; i < m_carrierCount; i++)
212  {
213  for (uint32_t j = 0; j < carrierSlotCount; j++)
214  {
215  Time guardTime = Seconds((m_guardTimeSymbols / 2) / m_btuConf->GetSymbolRateInBauds());
216  Ptr<SatTimeSlotConf> timeSlot =
217  Create<SatTimeSlotConf>(Time(j * timeSlotDuration.GetInteger()) + guardTime,
218  defWaveFormId,
219  i,
221  AddTimeSlotConf(timeSlot);
222 
223  frameTimeSlotCount++;
224 
225  if (parameters.m_checkSlotLimit && (frameTimeSlotCount > m_maxTimeSlotCount))
226  {
227  NS_FATAL_ERROR("Time slot count is over limit. Check frame configuration!!!");
228  }
229  }
230  }
231 }
232 
234 {
235  NS_LOG_FUNCTION(this);
236 }
237 
238 double
239 SatFrameConf::GetCarrierFrequencyHz(uint16_t carrierId) const
240 {
241  NS_LOG_FUNCTION(this << carrierId);
242 
243  if (carrierId >= m_carrierCount)
244  {
245  NS_FATAL_ERROR("Carrier Id out of range");
246  }
247 
248  double carrierBandwidthHz = m_btuConf->GetAllocatedBandwidthInHz();
249 
250  return ((carrierBandwidthHz * carrierId) + (carrierBandwidthHz / 2.0));
251 }
252 
253 double
255 {
256  NS_LOG_FUNCTION(this << bandwidthType);
257 
258  double bandwidth = 0.0;
259 
260  switch (bandwidthType)
261  {
263  bandwidth = m_btuConf->GetAllocatedBandwidthInHz();
264  break;
265 
267  bandwidth = m_btuConf->GetOccupiedBandwidthInHz();
268  break;
269 
271  bandwidth = m_btuConf->GetEffectiveBandwidthInHz();
272  break;
273 
274  default:
275  NS_FATAL_ERROR("Invalid bandwidth type!!!");
276  break;
277  }
278 
279  return bandwidth;
280 }
281 
282 uint8_t
284 {
285  NS_LOG_FUNCTION(this);
286 
287  uint8_t subdivisionLevel = 0;
288  Ptr<SatFrameConf> parent = m_parent;
289 
290  while (parent != nullptr)
291  {
292  ++subdivisionLevel;
293  parent = parent->m_parent;
294  }
295 
296  NS_LOG_INFO("Subdivision level is " << (uint32_t)subdivisionLevel);
297  return subdivisionLevel;
298 }
299 
300 uint16_t
302 {
303  NS_LOG_FUNCTION(this);
304 
305  uint16_t slotCount = 0;
306 
307  if (m_timeSlotConfMap.empty() == false)
308  {
309  slotCount = m_timeSlotConfMap.size() * m_timeSlotConfMap.begin()->second.size();
310  }
311 
312  return slotCount;
313 }
314 
315 Ptr<SatTimeSlotConf>
316 SatFrameConf::GetTimeSlotConf(uint16_t carrierId, uint16_t index) const
317 {
318  NS_LOG_FUNCTION(this);
319 
320  Ptr<SatTimeSlotConf> foundTimeSlot = nullptr;
321 
322  SatTimeSlotConfMap_t::const_iterator foundCarrier = m_timeSlotConfMap.find(carrierId);
323 
324  if (foundCarrier != m_timeSlotConfMap.end() && index < foundCarrier->second.size())
325  {
326  foundTimeSlot = foundCarrier->second[index];
327  }
328  else
329  {
330  NS_FATAL_ERROR("Index is invalid!!!");
331  }
332 
333  return foundTimeSlot;
334 }
335 
336 Ptr<SatTimeSlotConf>
337 SatFrameConf::GetTimeSlotConf(uint16_t index) const
338 {
339  NS_LOG_FUNCTION(this);
340 
341  Ptr<SatTimeSlotConf> foundTimeSlot = nullptr;
342  uint32_t carrierId = index / m_timeSlotConfMap.begin()->second.size();
343  uint16_t timeSlotIndex = index % m_timeSlotConfMap.begin()->second.size();
344 
345  foundTimeSlot = GetTimeSlotConf(carrierId, timeSlotIndex);
346 
347  return foundTimeSlot;
348 }
349 
351 SatFrameConf::GetTimeSlotConfs(uint16_t carrierId) const
352 {
353  NS_LOG_FUNCTION(this);
354 
355  SatTimeSlotConfContainer_t timeSlots;
356 
357  SatTimeSlotConfMap_t::const_iterator it = m_timeSlotConfMap.find(carrierId);
358 
359  if (it != m_timeSlotConfMap.end())
360  {
361  timeSlots = it->second;
362  }
363  else
364  {
365  NS_FATAL_ERROR("Carrier not found!!!");
366  }
367 
368  return timeSlots;
369 }
370 
371 uint16_t
372 SatFrameConf::AddTimeSlotConf(Ptr<SatTimeSlotConf> conf)
373 {
374  NS_LOG_FUNCTION(this << conf);
375 
376  // find container for the Carrier from map
377  SatTimeSlotConfMap_t::iterator it = m_timeSlotConfMap.find(conf->GetCarrierId());
378 
379  // If not found, add new Carrier container to map,
380  // otherwise use container found from map
381  if (it == m_timeSlotConfMap.end())
382  {
383  std::pair<SatTimeSlotConfMap_t::iterator, bool> result = m_timeSlotConfMap.insert(
384  std::make_pair(conf->GetCarrierId(), SatTimeSlotConfContainer_t()));
385 
386  if (result.second)
387  {
388  it = result.first;
389  }
390  else
391  {
392  it = m_timeSlotConfMap.end();
393  }
394  }
395 
396  // container creation for carrier has failed, so we need to crash
397  if (it == m_timeSlotConfMap.end())
398  {
399  NS_FATAL_ERROR("Cannot insert slot to container!!!");
400  }
401 
402  // store time slot info to carrier specific container
403  it->second.push_back(conf);
404 
405  return 0;
406 }
407 
408 NS_OBJECT_ENSURE_REGISTERED(SatSuperframeConf);
409 
410 // Super frame configuration interface.
411 
412 Ptr<SatSuperframeConf>
414 {
415  NS_LOG_FUNCTION_NOARGS();
416 
417  Ptr<SatSuperframeConf> superFrameConf;
418 
419  switch (conf)
420  {
422  superFrameConf = CreateObject<SatSuperframeConf0>();
423  break;
424 
426  superFrameConf = CreateObject<SatSuperframeConf1>();
427  break;
428 
430  superFrameConf = CreateObject<SatSuperframeConf2>();
431  break;
432 
434  superFrameConf = CreateObject<SatSuperframeConf3>();
435  break;
436 
438  superFrameConf = CreateObject<SatSuperframeConf4>();
439  break;
440 
441  default:
442  NS_FATAL_ERROR("Not supported super frame configuration!!!");
443  break;
444  }
445 
446  return superFrameConf;
447 }
448 
450  : m_usedBandwidthHz(0.0),
451  m_duration(0.0),
452  m_frameCount(0),
453  m_configType(CONFIG_TYPE_0),
454  m_carrierCount(0),
455  m_logonEnabled(false),
456  m_logonChannelIndex(0)
457 {
458  NS_LOG_FUNCTION(this);
459 }
460 
462 {
463  NS_LOG_FUNCTION(this);
464 }
465 
466 TypeId
468 {
469  static TypeId tid = TypeId("ns3::SatSuperframeConf").SetParent<Object>();
470 
471  return tid;
472 }
473 
474 TypeId
476 {
477  NS_LOG_FUNCTION(this);
478  return GetTypeId();
479 }
480 
481 void
483  double bandwidthInHz,
484  double rollOff,
485  double spacing,
486  uint32_t spreadingFactor,
487  uint8_t subdivisionLevel)
488 {
489  NS_LOG_FUNCTION(this << &frameConfParameters << bandwidthInHz << rollOff << spacing
490  << (uint32_t)subdivisionLevel);
491  uint32_t frameId = m_frames.size();
492 
493  // in case of random access frame, store carriers to RA channel container
494  if (frameConfParameters.m_isRandomAccess)
495  {
496  // Create BTU conf according to given attributes
497  frameConfParameters.m_btuConf =
498  Create<SatBtuConf>(bandwidthInHz, rollOff, spacing, spreadingFactor);
499  Ptr<SatFrameConf> frameConf = Create<SatFrameConf>(frameConfParameters);
500 
501  uint16_t raBaseIndex = m_raChannels.size();
502  uint16_t carriersCount = frameConf->GetCarrierCount();
503 
504  if (frameConf->IsLogon() && carriersCount > 1)
505  {
506  NS_FATAL_ERROR("Logon frame can have only one carrier, this one have " << carriersCount
507  << " carriers.");
508  }
509 
510  if (frameConf->IsLogon() && m_logonEnabled)
511  {
512  NS_FATAL_ERROR("Logon frame cannot be set several times.");
513  }
514 
515  if (frameConf->IsLogon())
516  {
518  m_logonEnabled = true;
519  }
520 
521  for (uint32_t i = 0; i < carriersCount; i++)
522  {
523  // Only number of the RA channels definable by uint8_t data type can used
524  // This is needed to take into account when configuring frames and defined which of them
525  // are random access channels
526  if ((raBaseIndex + i) >= std::numeric_limits<uint8_t>::max())
527  {
528  NS_FATAL_ERROR("RA channels maximum count is exceeded!!!");
529  }
530 
531  m_raChannels.push_back(
532  std::make_tuple(frameId, i, frameConf->GetAllocationChannelId()));
533  }
534 
535  m_frames.push_back(frameConf);
536  m_carrierCount += carriersCount;
537  }
538  else
539  {
540  for (uint8_t i = 0; i <= subdivisionLevel; ++i)
541  {
542  double subdivisionAmount = std::pow(2.0, static_cast<double>(i));
543 
544  // Create BTU conf according to given attributes
545  frameConfParameters.m_btuConf = Create<SatBtuConf>(bandwidthInHz / subdivisionAmount,
546  rollOff,
547  spacing,
548  spreadingFactor);
549  Ptr<SatFrameConf> frameConf = Create<SatFrameConf>(frameConfParameters);
550 
551  if (frameConf->IsLogon())
552  {
553  NS_FATAL_ERROR("Logon frame must use Random Access.");
554  }
555 
556  m_frames.push_back(frameConf);
557  m_carrierCount += frameConf->GetCarrierCount();
558 
559  // Update parent for the next subdivided frame conf
560  frameConfParameters.m_parent = frameConf;
561  }
562  }
563 }
564 
565 Ptr<SatFrameConf>
567 {
568  NS_LOG_FUNCTION(this << (uint32_t)index);
569 
570  return m_frames[index];
571 }
572 
573 uint32_t
575 {
576  NS_LOG_FUNCTION(this);
577 
578  return m_carrierCount;
579 }
580 
581 uint32_t
582 SatSuperframeConf::GetCarrierId(uint8_t frameId, uint16_t frameCarrierId) const
583 {
584  NS_LOG_FUNCTION(this);
585 
586  if (frameId > m_frames.size())
587  {
588  NS_FATAL_ERROR("Frame ID out of range.");
589  }
590 
591  uint32_t carrierId = frameCarrierId;
592 
593  for (uint8_t i = 0; i < frameId; i++)
594  {
595  carrierId += m_frames[i]->GetCarrierCount();
596  }
597 
598  return carrierId;
599 }
600 
601 double
603 {
604  NS_LOG_FUNCTION(this);
605 
606  double frameStartFrequency = 0.0;
607  uint32_t carrierIdInFrame = carrierId;
608 
609  uint8_t frameId = GetCarrierFrame(carrierId);
610 
611  for (uint8_t i = 0; i < frameId; ++i)
612  {
613  carrierIdInFrame -= m_frames[i]->GetCarrierCount();
614  frameStartFrequency += m_frames[i]->GetBandwidthHz();
615  }
616 
617  double carrierFrequencyInFrame = m_frames[frameId]->GetCarrierFrequencyHz(carrierIdInFrame);
618 
619  return frameStartFrequency + carrierFrequencyInFrame;
620 }
621 
622 double
624  SatEnums::CarrierBandwidthType_t bandwidthType) const
625 {
626  NS_LOG_FUNCTION(this);
627 
628  uint8_t frameId = GetCarrierFrame(carrierId);
629 
630  return m_frames[frameId]->GetCarrierBandwidthHz(bandwidthType);
631 }
632 
633 Ptr<SatFrameConf>
634 SatSuperframeConf::GetCarrierFrameConf(uint32_t carrierId) const
635 {
636  NS_LOG_FUNCTION(this << carrierId);
637 
638  uint8_t frameId = GetCarrierFrame(carrierId);
639 
640  return m_frames[frameId];
641 }
642 
643 bool
645 {
646  NS_LOG_FUNCTION(this);
647 
648  uint8_t frameId = GetCarrierFrame(carrierId);
649 
650  return m_frames[frameId]->IsRandomAccess();
651 }
652 
653 void
654 SatSuperframeConf::SetFrameAllocatedBandwidthHz(uint8_t frameIndex, double bandwidthHz)
655 {
656  NS_LOG_FUNCTION(this << (uint32_t)frameIndex << bandwidthHz);
657 
658  if (frameIndex >= m_maxFrameCount)
659  {
660  NS_FATAL_ERROR("Frame index out of range!!!");
661  }
662 
663  m_frameAllocatedBandwidth[frameIndex] = bandwidthHz;
664 }
665 
666 void
667 SatSuperframeConf::SetFrameCarrierAllocatedBandwidthHz(uint8_t frameIndex, double bandwidthHz)
668 {
669  NS_LOG_FUNCTION(this << (uint32_t)frameIndex << bandwidthHz);
670 
671  if (frameIndex >= m_maxFrameCount)
672  {
673  NS_FATAL_ERROR("Frame index out of range!!!");
674  }
675 
676  m_frameCarrierAllocatedBandwidth[frameIndex] = bandwidthHz;
677 }
678 
679 void
680 SatSuperframeConf::SetFrameCarrierSpacing(uint8_t frameIndex, double spacing)
681 {
682  NS_LOG_FUNCTION(this << (uint32_t)frameIndex << spacing);
683 
684  if (frameIndex >= m_maxFrameCount)
685  {
686  NS_FATAL_ERROR("Frame index out of range!!!");
687  }
688 
689  m_frameCarrierSpacing[frameIndex] = spacing;
690 }
691 
692 void
693 SatSuperframeConf::SetFrameCarrierRollOff(uint8_t frameIndex, double rollOff)
694 {
695  NS_LOG_FUNCTION(this << (uint32_t)frameIndex << rollOff);
696 
697  if (frameIndex >= m_maxFrameCount)
698  {
699  NS_FATAL_ERROR("Frame index out of range!!!");
700  }
701 
702  m_frameCarrierRollOff[frameIndex] = rollOff;
703 }
704 
705 void
706 SatSuperframeConf::SetFrameCarrierSpreadingFactor(uint8_t frameIndex, uint32_t spreadingFactor)
707 {
708  NS_LOG_FUNCTION(this << frameIndex << spreadingFactor);
709 
710  if (frameIndex >= m_maxFrameCount)
711  {
712  NS_FATAL_ERROR("Frame index out of range!!!");
713  }
714 
715  m_frameCarrierSpreadingFactor[frameIndex] = spreadingFactor;
716 }
717 
718 void
719 SatSuperframeConf::SetFrameRandomAccess(uint8_t frameIndex, bool randomAccess)
720 {
721  NS_LOG_FUNCTION(this << (uint32_t)frameIndex << randomAccess);
722 
723  if (frameIndex >= m_maxFrameCount)
724  {
725  NS_FATAL_ERROR("Frame index out of range!!!");
726  }
727 
728  m_frameIsRandomAccess[frameIndex] = randomAccess;
729 }
730 
731 void
732 SatSuperframeConf::SetFrameLogon(uint8_t frameIndex, bool logon)
733 {
734  NS_LOG_FUNCTION(this << (uint32_t)frameIndex << logon);
735 
736  if (frameIndex >= m_maxFrameCount)
737  {
738  NS_FATAL_ERROR("Frame index out of range!!!");
739  }
740 
741  m_frameIsLogon[frameIndex] = logon;
742 }
743 
744 void
745 SatSuperframeConf::SetFrameAllocationChannelId(uint8_t frameIndex, uint8_t allocationChannel)
746 {
747  NS_LOG_FUNCTION(this << (uint32_t)frameIndex << (uint32_t)allocationChannel);
748 
749  if (frameIndex >= m_maxFrameCount)
750  {
751  NS_FATAL_ERROR("Frame index out of range!!!");
752  }
753 
754  m_frameAllocationChannel[frameIndex] = allocationChannel;
755 }
756 
757 void
758 SatSuperframeConf::SetFrameGuardTimeSymbols(uint8_t frameIndex, uint8_t guardTimeSymbols)
759 {
760  NS_LOG_FUNCTION(this << (uint32_t)frameIndex << guardTimeSymbols);
761 
762  if (frameIndex >= m_maxFrameCount)
763  {
764  NS_FATAL_ERROR("Frame index out of range!!!");
765  }
766 
767  m_frameGuardTimeSymbols[frameIndex] = guardTimeSymbols;
768 }
769 
770 double
772 {
773  NS_LOG_FUNCTION(this << (uint32_t)frameIndex);
774 
775  if (frameIndex >= m_maxFrameCount)
776  {
777  NS_FATAL_ERROR("Frame index out of range!!!");
778  }
779 
780  return m_frameAllocatedBandwidth[frameIndex];
781 }
782 
783 double
785 {
786  NS_LOG_FUNCTION(this << (uint32_t)frameIndex);
787 
788  if (frameIndex >= m_maxFrameCount)
789  {
790  NS_FATAL_ERROR("Frame index out of range!!!");
791  }
792 
793  return m_frameCarrierAllocatedBandwidth[frameIndex];
794 }
795 
796 double
798 {
799  NS_LOG_FUNCTION(this << (uint32_t)frameIndex);
800 
801  if (frameIndex >= m_maxFrameCount)
802  {
803  NS_FATAL_ERROR("Frame index out of range!!!");
804  }
805 
806  return m_frameCarrierSpacing[frameIndex];
807 }
808 
809 double
811 {
812  NS_LOG_FUNCTION(this << (uint32_t)frameIndex);
813 
814  if (frameIndex >= m_maxFrameCount)
815  {
816  NS_FATAL_ERROR("Frame index out of range!!!");
817  }
818 
819  return m_frameCarrierRollOff[frameIndex];
820 }
821 
822 uint32_t
824 {
825  NS_LOG_FUNCTION(this << frameIndex);
826 
827  if (frameIndex >= m_maxFrameCount)
828  {
829  NS_FATAL_ERROR("Frame index out of range!!!");
830  }
831 
832  return m_frameCarrierSpreadingFactor[frameIndex];
833 }
834 
835 bool
836 SatSuperframeConf::IsFrameRandomAccess(uint8_t frameIndex) const
837 {
838  NS_LOG_FUNCTION(this << (uint32_t)frameIndex);
839 
840  if (frameIndex >= m_frames.size())
841  {
842  NS_FATAL_ERROR("Frame index out of range!!!");
843  }
844 
845  return m_frames[frameIndex]->IsRandomAccess();
846 }
847 
848 bool
849 SatSuperframeConf::IsFrameLogon(uint8_t frameIndex) const
850 {
851  NS_LOG_FUNCTION(this << (uint32_t)frameIndex);
852 
853  if (frameIndex >= m_frames.size())
854  {
855  NS_FATAL_ERROR("Frame index out of range!!!");
856  }
857 
858  return m_frames[frameIndex]->IsLogon();
859 }
860 
861 uint8_t
863 {
864  NS_LOG_FUNCTION(this << (uint32_t)frameIndex);
865 
866  if (frameIndex >= m_maxFrameCount)
867  {
868  NS_FATAL_ERROR("Frame index out of range!!!");
869  }
870 
871  return m_frameAllocationChannel[frameIndex];
872 }
873 
874 uint8_t
876 {
877  NS_LOG_FUNCTION(this << (uint32_t)frameIndex);
878 
879  if (frameIndex >= m_maxFrameCount)
880  {
881  NS_FATAL_ERROR("Frame index out of range!!!");
882  }
883 
884  return m_frameGuardTimeSymbols[frameIndex];
885 }
886 
887 bool
889 {
890  NS_LOG_FUNCTION(this);
891 
892  return m_logonEnabled;
893 }
894 
895 uint32_t
897 {
898  NS_LOG_FUNCTION(this);
899 
900  return m_logonChannelIndex;
901 }
902 
903 void
904 SatSuperframeConf::Configure(double allocatedBandwidthHz,
905  Time targetDuration,
906  Ptr<SatWaveformConf> waveformConf)
907 {
908  NS_LOG_FUNCTION(this);
909 
910  if (m_configType == CONFIG_TYPE_0 && waveformConf->IsAcmEnabled() == true)
911  {
912  NS_LOG_WARN("Superframe is configured to use config type 0, thus ACM should be disabled!");
913  }
914 
915  if (m_configType == CONFIG_TYPE_1 && waveformConf->IsAcmEnabled() == false)
916  {
917  NS_FATAL_ERROR(
918  "Superframe is configured to use config type 1, thus ACM should be enabled!");
919  }
920 
921  DoConfigure();
922 
923  bool useDefaultWaveform = false;
924  bool checkSlotLimit = true;
925  uint8_t subdivisionLevels = 0;
926 
932  m_duration = targetDuration;
933 
934  // make actual configuration
935 
936  switch (m_configType)
937  {
938  case CONFIG_TYPE_0:
939  useDefaultWaveform = true;
940  break;
941  case CONFIG_TYPE_1:
942  break;
943  case CONFIG_TYPE_2:
944  checkSlotLimit = false;
945  break;
946  case CONFIG_TYPE_3:
947  checkSlotLimit = false;
948  subdivisionLevels = m_maxCarrierSubdivision;
949  break;
950  case CONFIG_TYPE_4:
951  useDefaultWaveform = true;
952  checkSlotLimit = false;
953  break;
954  default:
955  NS_FATAL_ERROR("Not supported configuration type " << m_configType << "!!!");
956  break;
957  }
958 
959  m_raChannels.clear();
960  m_frames.clear();
961  m_carrierCount = 0;
962 
963  for (uint8_t frameIndex = 0; frameIndex < m_frameCount; frameIndex++)
964  {
965  // Create frame without allocating a BTU yet
966  SatFrameConf::SatFrameConfParams_t frameConfParameters;
967  frameConfParameters.m_bandwidthHz = m_frameAllocatedBandwidth[frameIndex];
968  frameConfParameters.m_targetDuration = targetDuration;
969  frameConfParameters.m_parent = nullptr;
970  frameConfParameters.m_btuConf = nullptr;
971  frameConfParameters.m_waveformConf = waveformConf;
972  frameConfParameters.m_allocationChannel = m_frameAllocationChannel[frameIndex];
973  frameConfParameters.m_isRandomAccess = m_frameIsRandomAccess[frameIndex];
974  frameConfParameters.m_isLogon = m_frameIsLogon[frameIndex];
975  frameConfParameters.m_defaultWaveformInUse = useDefaultWaveform;
976  frameConfParameters.m_checkSlotLimit = checkSlotLimit;
977  frameConfParameters.m_guardTimeSymbols = m_frameGuardTimeSymbols[frameIndex];
978 
980 
981  // Add created frame to super frame configuration, creating
982  // the BTU and the carrier subdivision in the process if need bee
983  AddFrameConf(frameConfParameters,
985  m_frameCarrierRollOff[frameIndex],
986  m_frameCarrierSpacing[frameIndex],
987  m_frameCarrierSpreadingFactor[frameIndex],
988  subdivisionLevels);
989  }
990 
991  if (m_frames.size() != m_frameCount)
992  {
993  NS_ASSERT_MSG(m_configType == CONFIG_TYPE_3,
994  "SatSuperframeConf::Configure: Error: configured more frames than requested");
995  m_frameCount = m_frames.size();
996  }
997 
998  // check if configured frames exceeds given band
999  if (m_usedBandwidthHz > allocatedBandwidthHz)
1000  {
1001  NS_FATAL_ERROR("Bandwidth of super frame exceeds allocated bandwidth");
1002  }
1003 }
1004 
1007 {
1008  NS_LOG_FUNCTION(this);
1009 
1011 
1012  if (raChannel < m_raChannels.size())
1013  {
1014  uint8_t frameId;
1015  uint32_t carrierId;
1016  std::tie(frameId, carrierId, std::ignore) = m_raChannels[raChannel];
1017 
1018  timeSlots = m_frames[frameId]->GetTimeSlotConfs(carrierId);
1019  }
1020  else
1021  {
1022  NS_FATAL_ERROR("Channel out of range!!!");
1023  }
1024 
1025  return timeSlots;
1026 }
1027 
1028 uint16_t
1030 {
1031  NS_LOG_FUNCTION(this);
1032 
1033  uint16_t slotCount = 0;
1034 
1035  if (raChannel < m_raChannels.size())
1036  {
1037  uint8_t frameId;
1038  uint32_t carrierId;
1039  std::tie(frameId, carrierId, std::ignore) = m_raChannels[raChannel];
1040 
1041  slotCount = m_frames[frameId]->GetTimeSlotConfs(carrierId).size();
1042  }
1043  else
1044  {
1045  NS_FATAL_ERROR("Channel out of range!!!");
1046  }
1047 
1048  return slotCount;
1049 }
1050 
1051 uint8_t
1053 {
1054  NS_LOG_FUNCTION(this);
1055  return m_raChannels.size();
1056 }
1057 
1058 uint8_t
1060 {
1061  NS_LOG_FUNCTION(this);
1062 
1063  uint8_t frameId = 0;
1064 
1065  if (raChannel < m_raChannels.size())
1066  {
1067  frameId = std::get<0>(m_raChannels[raChannel]);
1068  }
1069  else
1070  {
1071  NS_FATAL_ERROR("Channel out of range!!!");
1072  }
1073 
1074  return frameId;
1075 }
1076 
1077 uint8_t
1079 {
1080  NS_LOG_FUNCTION(this);
1081 
1082  uint8_t allocationChannel = 0;
1083 
1084  if (raChannel < m_raChannels.size())
1085  {
1086  allocationChannel = std::get<2>(m_raChannels[raChannel]);
1087  }
1088  else
1089  {
1090  NS_FATAL_ERROR("Channel out of range!!!");
1091  }
1092 
1093  return allocationChannel;
1094 }
1095 
1096 uint32_t
1098 {
1099  NS_LOG_FUNCTION(this);
1100 
1101  uint32_t payloadInBytes = 0;
1102 
1103  if (raChannel < m_raChannels.size())
1104  {
1105  uint8_t frameId = std::get<0>(m_raChannels[raChannel]);
1106  Ptr<SatTimeSlotConf> timeSlotConf = (*m_frames[frameId]->GetTimeSlotConfs(0).begin());
1107  Ptr<SatWaveform> waveform =
1108  m_frames[frameId]->GetWaveformConf()->GetWaveform(timeSlotConf->GetWaveFormId());
1109 
1110  payloadInBytes = waveform->GetPayloadInBytes();
1111  }
1112  else
1113  {
1114  NS_FATAL_ERROR("Channel " << raChannel << " out of range!!!");
1115  }
1116 
1117  return payloadInBytes;
1118 }
1119 
1120 std::string
1122 {
1123  std::string name = "Frame";
1124  return name + GetNumberAsString(index);
1125 }
1126 
1127 // macro to call base class converter function with shorter name in macro ADD_FRAME_ATTRIBUTES
1128 #define GetIndexAsFrameName(index) SatSuperframeConf::GetIndexAsFrameName(index)
1129 
1130 // macro to ease definition of attributes for several frames
1131 #define ADD_FRAME_ATTRIBUTES(index, \
1132  frameBandwidth, \
1133  carrierBandwidth, \
1134  carrierSpacing, \
1135  carrierRollOff, \
1136  spreadingFactor, \
1137  randomAccess, \
1138  lowerLayerService, \
1139  logon, \
1140  guardTime) \
1141  .AddAttribute(GetIndexAsFrameName(index) + "_AllocatedBandwidthHz", \
1142  std::string("The allocated bandwidth [Hz] for ") + GetIndexAsFrameName(index), \
1143  TypeId::ATTR_CONSTRUCT, \
1144  DoubleValue(frameBandwidth), \
1145  MakeDoubleAccessor(&SatSuperframeConf::SetFrame##index##AllocatedBandwidthHz, \
1146  &SatSuperframeConf::GetFrame##index##AllocatedBandwidthHz), \
1147  MakeDoubleChecker<double>()) \
1148  .AddAttribute( \
1149  GetIndexAsFrameName(index) + std::string("_CarrierAllocatedBandwidthHz"), \
1150  std::string("The allocated carrier bandwidth [Hz] for ") + GetIndexAsFrameName(index), \
1151  TypeId::ATTR_CONSTRUCT, \
1152  DoubleValue(carrierBandwidth), \
1153  MakeDoubleAccessor(&SatSuperframeConf::SetFrame##index##CarrierAllocatedBandwidthHz, \
1154  &SatSuperframeConf::GetFrame##index##CarrierAllocatedBandwidthHz), \
1155  MakeDoubleChecker<double>()) \
1156  .AddAttribute(GetIndexAsFrameName(index) + std::string("_CarrierRollOff"), \
1157  std::string("The roll-off factor for ") + GetIndexAsFrameName(index), \
1158  TypeId::ATTR_CONSTRUCT, \
1159  DoubleValue(carrierSpacing), \
1160  MakeDoubleAccessor(&SatSuperframeConf::SetFrame##index##CarrierRollOff, \
1161  &SatSuperframeConf::GetFrame##index##CarrierRollOff), \
1162  MakeDoubleChecker<double>(0.00, 1.00)) \
1163  .AddAttribute(GetIndexAsFrameName(index) + std::string("_CarrierSpacing"), \
1164  std::string("The carrier spacing factor for ") + GetIndexAsFrameName(index), \
1165  TypeId::ATTR_CONSTRUCT, \
1166  DoubleValue(carrierRollOff), \
1167  MakeDoubleAccessor(&SatSuperframeConf::SetFrame##index##CarrierSpacing, \
1168  &SatSuperframeConf::GetFrame##index##CarrierSpacing), \
1169  MakeDoubleChecker<double>(0.00, 1.00)) \
1170  .AddAttribute(GetIndexAsFrameName(index) + std::string("_SpreadingFactor"), \
1171  std::string("The carrier spreading factor for ") + \
1172  GetIndexAsFrameName(index), \
1173  TypeId::ATTR_CONSTRUCT, \
1174  UintegerValue(spreadingFactor), \
1175  MakeUintegerAccessor(&SatSuperframeConf::SetFrame##index##SpreadingFactor, \
1176  &SatSuperframeConf::GetFrame##index##SpreadingFactor), \
1177  MakeUintegerChecker<uint32_t>(1, std::numeric_limits<uint32_t>::max())) \
1178  .AddAttribute(GetIndexAsFrameName(index) + std::string("_RandomAccessFrame"), \
1179  std::string("Flag to tell if ") + GetIndexAsFrameName(index) + \
1180  std::string(" is used for random access"), \
1181  TypeId::ATTR_CONSTRUCT, \
1182  BooleanValue(randomAccess), \
1183  MakeBooleanAccessor(&SatSuperframeConf::SetFrame##index##RandomAccess, \
1184  &SatSuperframeConf::IsFrame##index##RandomAccess), \
1185  MakeBooleanChecker()) \
1186  .AddAttribute( \
1187  GetIndexAsFrameName(index) + std::string("_LowerLayerService"), \
1188  std::string("Lower layer service to use for ") + GetIndexAsFrameName(index), \
1189  TypeId::ATTR_CONSTRUCT, \
1190  UintegerValue(lowerLayerService), \
1191  MakeUintegerAccessor(&SatSuperframeConf::SetFrame##index##AllocationChannelId, \
1192  &SatSuperframeConf::GetFrame##index##AllocationChannelId), \
1193  MakeUintegerChecker<uint8_t>()) \
1194  .AddAttribute(GetIndexAsFrameName(index) + std::string("_LogonFrame"), \
1195  std::string("Flag to tell if ") + GetIndexAsFrameName(index) + \
1196  std::string(" is used for logon"), \
1197  TypeId::ATTR_CONSTRUCT, \
1198  BooleanValue(logon), \
1199  MakeBooleanAccessor(&SatSuperframeConf::SetFrame##index##Logon, \
1200  &SatSuperframeConf::IsFrame##index##Logon), \
1201  MakeBooleanChecker()) \
1202  .AddAttribute(GetIndexAsFrameName(index) + std::string("_GuardTimeSymbols"), \
1203  std::string("Set the guard time of ") + GetIndexAsFrameName(index) + \
1204  std::string(" in symbols"), \
1205  TypeId::ATTR_CONSTRUCT, \
1206  UintegerValue(guardTime), \
1207  MakeUintegerAccessor(&SatSuperframeConf::SetFrame##index##GuardTimeSymbols, \
1208  &SatSuperframeConf::GetFrame##index##GuardTimeSymbols), \
1209  MakeUintegerChecker<uint8_t>())
1210 
1211 // macro to ease definition of attributes for several super frames
1212 #define ADD_SUPER_FRAME_ATTRIBUTES(frameCount, configType, maxSubdivision) \
1213  .AddAttribute("FrameCount", \
1214  "The number of frames in super frame.", \
1215  TypeId::ATTR_CONSTRUCT, \
1216  UintegerValue(frameCount), \
1217  MakeUintegerAccessor(&SatSuperframeConf::SetFrameCount, \
1218  &SatSuperframeConf::GetFrameCount), \
1219  MakeUintegerChecker<uint32_t>(1, SatSuperframeConf::m_maxFrameCount)) \
1220  .AddAttribute( \
1221  "FrameConfigType", \
1222  "The frame configuration type used for super frame.", \
1223  TypeId::ATTR_CONSTRUCT, \
1224  EnumValue(configType), \
1225  MakeEnumAccessor<SatSuperframeConf::ConfigType_t>(&SatSuperframeConf::SetConfigType, \
1226  &SatSuperframeConf::GetConfigType), \
1227  MakeEnumChecker(SatSuperframeConf::CONFIG_TYPE_0, \
1228  "ConfigType_0", \
1229  SatSuperframeConf::CONFIG_TYPE_1, \
1230  "ConfigType_1", \
1231  SatSuperframeConf::CONFIG_TYPE_2, \
1232  "ConfigType_2", \
1233  SatSuperframeConf::CONFIG_TYPE_3, \
1234  "ConfigType_3", \
1235  SatSuperframeConf::CONFIG_TYPE_4, \
1236  "ConfigType_4")) \
1237  .AddAttribute( \
1238  "MaxCarrierSubdivision", \
1239  "The maximum amount of subdivision for a single carrier (ConfigType_3 only).", \
1240  TypeId::ATTR_CONSTRUCT, \
1241  UintegerValue(maxSubdivision), \
1242  MakeUintegerAccessor(&SatSuperframeConf::SetMaxSubdivision, \
1243  &SatSuperframeConf::GetMaxSubdivision), \
1244  MakeUintegerChecker<uint8_t>(0))
1245 
1246 uint8_t
1247 SatSuperframeConf::GetCarrierFrame(uint32_t carrierId) const
1248 {
1249  NS_LOG_FUNCTION(this);
1250 
1251  uint32_t currentFrame = 0;
1252  uint32_t lastIdInFrame = m_frames[0]->GetCarrierCount() - 1;
1253 
1254  while (carrierId > lastIdInFrame)
1255  {
1256  ++currentFrame;
1257  lastIdInFrame += m_frames[currentFrame]->GetCarrierCount();
1258  }
1259 
1260  return currentFrame;
1261 }
1262 
1263 uint8_t
1264 SatSuperframeConf::GetRaChannel(uint32_t carrierId) const
1265 {
1266  NS_LOG_FUNCTION(this);
1267 
1268  uint8_t raChannelId = 0;
1269  uint8_t frameId = GetCarrierFrame(carrierId);
1270 
1271  if (m_frames[frameId]->IsRandomAccess())
1272  {
1273  uint32_t carrierIdInFrame = carrierId;
1274 
1275  for (uint8_t i = 0; i < frameId; i++)
1276  {
1277  carrierIdInFrame -= m_frames[i]->GetCarrierCount();
1278 
1279  // increase RA channel id (index) by count of RA carriers before asked carrier/frame
1280  if (m_frames[i]->IsRandomAccess())
1281  {
1282  raChannelId += m_frames[i]->GetCarrierCount();
1283  }
1284  }
1285 
1286  // increase RA channel id (index) by carrier id of the asked carrier/frame
1287  raChannelId += carrierIdInFrame;
1288  }
1289 
1290  return raChannelId;
1291 }
1292 
1293 NS_OBJECT_ENSURE_REGISTERED(SatSuperframeConf0);
1294 
1295 // Super frame configuration 0.
1296 
1298 {
1299  NS_LOG_FUNCTION(this);
1300 }
1301 
1303 {
1304  NS_LOG_FUNCTION(this);
1305 }
1306 
1307 TypeId
1309 {
1310  static TypeId tid =
1311  TypeId("ns3::SatSuperframeConf0")
1312  .SetParent<ns3::SatSuperframeConf>()
1313  .AddConstructor<SatSuperframeConf0>() ADD_SUPER_FRAME_ATTRIBUTES(
1314  10,
1316  5) ADD_FRAME_ATTRIBUTES(0, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1317  ADD_FRAME_ATTRIBUTES(1, 1.25e6, 1.25e6, 0.20, 0.30, 1, true, 0, false, 0)
1318  ADD_FRAME_ATTRIBUTES(2, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1319  ADD_FRAME_ATTRIBUTES(3, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1321  1.25e7,
1322  1.25e6,
1323  0.20,
1324  0.30,
1325  1,
1326  false,
1327  0,
1328  false,
1329  0) ADD_FRAME_ATTRIBUTES(5,
1330  1.25e7,
1331  1.25e6,
1332  0.20,
1333  0.30,
1334  1,
1335  false,
1336  0,
1337  false,
1338  0)
1340  1.25e7,
1341  1.25e6,
1342  0.20,
1343  0.30,
1344  1,
1345  false,
1346  0,
1347  false,
1348  0) ADD_FRAME_ATTRIBUTES(7,
1349  1.25e7,
1350  1.25e6,
1351  0.20,
1352  0.30,
1353  1,
1354  false,
1355  0,
1356  false,
1357  0)
1359  1.25e7,
1360  1.25e6,
1361  0.20,
1362  0.30,
1363  1,
1364  false,
1365  0,
1366  false,
1367  0) ADD_FRAME_ATTRIBUTES(9,
1368  1.25e7,
1369  1.25e6,
1370  0.20,
1371  0.30,
1372  1,
1373  false,
1374  0,
1375  false,
1376  0);
1377 
1378  return tid;
1379 }
1380 
1381 TypeId
1383 {
1384  NS_LOG_FUNCTION(this);
1385  return GetTypeId();
1386 }
1387 
1388 void
1390 {
1391  NS_LOG_FUNCTION(this);
1392 }
1393 
1394 NS_OBJECT_ENSURE_REGISTERED(SatSuperframeConf1);
1395 
1396 // Super frame configuration 1.
1397 
1399 {
1400  NS_LOG_FUNCTION(this);
1401 }
1402 
1404 {
1405  NS_LOG_FUNCTION(this);
1406 }
1407 
1408 TypeId
1410 {
1411  static TypeId tid =
1412  TypeId("ns3::SatSuperframeConf1")
1413  .SetParent<ns3::SatSuperframeConf>()
1414  .AddConstructor<SatSuperframeConf1>() ADD_SUPER_FRAME_ATTRIBUTES(
1415  10,
1417  0) ADD_FRAME_ATTRIBUTES(0, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1418  ADD_FRAME_ATTRIBUTES(1, 1.25e6, 1.25e6, 0.20, 0.30, 1, true, 0, false, 0)
1419  ADD_FRAME_ATTRIBUTES(2, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1420  ADD_FRAME_ATTRIBUTES(3, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1422  1.25e7,
1423  1.25e6,
1424  0.20,
1425  0.30,
1426  1,
1427  false,
1428  0,
1429  false,
1430  0) ADD_FRAME_ATTRIBUTES(5,
1431  1.25e7,
1432  1.25e6,
1433  0.20,
1434  0.30,
1435  1,
1436  false,
1437  0,
1438  false,
1439  0)
1441  1.25e7,
1442  1.25e6,
1443  0.20,
1444  0.30,
1445  1,
1446  false,
1447  0,
1448  false,
1449  0) ADD_FRAME_ATTRIBUTES(7,
1450  1.25e7,
1451  1.25e6,
1452  0.20,
1453  0.30,
1454  1,
1455  false,
1456  0,
1457  false,
1458  0)
1460  1.25e7,
1461  1.25e6,
1462  0.20,
1463  0.30,
1464  1,
1465  false,
1466  0,
1467  false,
1468  0) ADD_FRAME_ATTRIBUTES(9,
1469  1.25e7,
1470  1.25e6,
1471  0.20,
1472  0.30,
1473  1,
1474  false,
1475  0,
1476  false,
1477  0);
1478 
1479  return tid;
1480 }
1481 
1482 TypeId
1484 {
1485  NS_LOG_FUNCTION(this);
1486  return GetTypeId();
1487 }
1488 
1489 void
1491 {
1492  NS_LOG_FUNCTION(this);
1493 }
1494 
1495 NS_OBJECT_ENSURE_REGISTERED(SatSuperframeConf2);
1496 
1497 // Super frame configuration 2.
1498 
1500 {
1501  NS_LOG_FUNCTION(this);
1502 }
1503 
1505 {
1506  NS_LOG_FUNCTION(this);
1507 }
1508 
1509 TypeId
1511 {
1512  static TypeId tid =
1513  TypeId("ns3::SatSuperframeConf2")
1514  .SetParent<ns3::SatSuperframeConf>()
1515  .AddConstructor<SatSuperframeConf2>() ADD_SUPER_FRAME_ATTRIBUTES(
1516  10,
1518  0) ADD_FRAME_ATTRIBUTES(0, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1519  ADD_FRAME_ATTRIBUTES(1, 1.25e6, 1.25e6, 0.20, 0.30, 1, true, 0, false, 0)
1520  ADD_FRAME_ATTRIBUTES(2, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1521  ADD_FRAME_ATTRIBUTES(3, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1523  1.25e7,
1524  1.25e6,
1525  0.20,
1526  0.30,
1527  1,
1528  false,
1529  0,
1530  false,
1531  0) ADD_FRAME_ATTRIBUTES(5,
1532  1.25e7,
1533  1.25e6,
1534  0.20,
1535  0.30,
1536  1,
1537  false,
1538  0,
1539  false,
1540  0)
1542  1.25e7,
1543  1.25e6,
1544  0.20,
1545  0.30,
1546  1,
1547  false,
1548  0,
1549  false,
1550  0) ADD_FRAME_ATTRIBUTES(7,
1551  1.25e7,
1552  1.25e6,
1553  0.20,
1554  0.30,
1555  1,
1556  false,
1557  0,
1558  false,
1559  0)
1561  1.25e7,
1562  1.25e6,
1563  0.20,
1564  0.30,
1565  1,
1566  false,
1567  0,
1568  false,
1569  0) ADD_FRAME_ATTRIBUTES(9,
1570  1.25e7,
1571  1.25e6,
1572  0.20,
1573  0.30,
1574  1,
1575  false,
1576  0,
1577  false,
1578  0);
1579 
1580  return tid;
1581 }
1582 
1583 TypeId
1585 {
1586  NS_LOG_FUNCTION(this);
1587  return GetTypeId();
1588 }
1589 
1590 void
1592 {
1593  NS_LOG_FUNCTION(this);
1594 }
1595 
1596 NS_OBJECT_ENSURE_REGISTERED(SatSuperframeConf3);
1597 
1598 // Super frame configuration 3.
1599 
1601 {
1602  NS_LOG_FUNCTION(this);
1603 }
1604 
1606 {
1607  NS_LOG_FUNCTION(this);
1608 }
1609 
1610 TypeId
1612 {
1613  static TypeId tid =
1614  TypeId("ns3::SatSuperframeConf3")
1615  .SetParent<ns3::SatSuperframeConf>()
1616  .AddConstructor<SatSuperframeConf3>() ADD_SUPER_FRAME_ATTRIBUTES(
1617  10,
1619  5) ADD_FRAME_ATTRIBUTES(0, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1620  ADD_FRAME_ATTRIBUTES(1, 1.25e6, 1.25e6, 0.20, 0.30, 1, true, 0, false, 0)
1621  ADD_FRAME_ATTRIBUTES(2, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1622  ADD_FRAME_ATTRIBUTES(3, 1.25e7, 1.25e6, 0.20, 0.30, 1, false, 0, false, 0)
1624  1.25e7,
1625  1.25e6,
1626  0.20,
1627  0.30,
1628  1,
1629  false,
1630  0,
1631  false,
1632  0) ADD_FRAME_ATTRIBUTES(5,
1633  1.25e7,
1634  1.25e6,
1635  0.20,
1636  0.30,
1637  1,
1638  false,
1639  0,
1640  false,
1641  0)
1643  1.25e7,
1644  1.25e6,
1645  0.20,
1646  0.30,
1647  1,
1648  false,
1649  0,
1650  false,
1651  0) ADD_FRAME_ATTRIBUTES(7,
1652  1.25e7,
1653  1.25e6,
1654  0.20,
1655  0.30,
1656  1,
1657  false,
1658  0,
1659  false,
1660  0)
1662  1.25e7,
1663  1.25e6,
1664  0.20,
1665  0.30,
1666  1,
1667  false,
1668  0,
1669  false,
1670  0) ADD_FRAME_ATTRIBUTES(9,
1671  1.25e7,
1672  1.25e6,
1673  0.20,
1674  0.30,
1675  1,
1676  false,
1677  0,
1678  false,
1679  0);
1680 
1681  return tid;
1682 }
1683 
1684 TypeId
1686 {
1687  NS_LOG_FUNCTION(this);
1688  return GetTypeId();
1689 }
1690 
1691 void
1693 {
1694  NS_LOG_FUNCTION(this);
1695 }
1696 
1697 NS_OBJECT_ENSURE_REGISTERED(SatSuperframeConf4);
1698 
1699 // Super frame configuration 4.
1700 
1702 {
1703  NS_LOG_FUNCTION(this);
1704 }
1705 
1707 {
1708  NS_LOG_FUNCTION(this);
1709 }
1710 
1711 TypeId
1713 {
1714  static TypeId tid =
1715  TypeId("ns3::SatSuperframeConf4")
1716  .SetParent<ns3::SatSuperframeConf>()
1717  .AddConstructor<SatSuperframeConf4>()
1720  3.0e5,
1721  3.0e5,
1722  0.25,
1723  0.0,
1724  16,
1725  true,
1726  0,
1727  false,
1728  0) // create frame only to store waveformconf
1729  ;
1730 
1731  return tid;
1732 }
1733 
1734 TypeId
1736 {
1737  NS_LOG_FUNCTION(this);
1738  return GetTypeId();
1739 }
1740 
1741 void
1743 {
1744  NS_LOG_FUNCTION(this);
1745 }
1746 
1747 } // namespace ns3
~SatBtuConf()
Destructor for SatBtuConf.
SatBtuConf()
Default constructor for SatBtuConf.
CarrierBandwidthType_t
Types of bandwidth.
uint8_t GetSubdivisionLevel() const
Get the subdivision level of this frame.
uint16_t AddTimeSlotConf(Ptr< SatTimeSlotConf > conf)
Add time slot.
uint32_t m_minPayloadPerCarrierInBytes
static const uint16_t m_maxTimeSlotCount
double GetCarrierBandwidthHz(SatEnums::CarrierBandwidthType_t bandwidthType) const
Get carrier bandwidth in frame.
Ptr< SatTimeSlotConf > GetTimeSlotConf(uint16_t index) const
Get time slot configuration of the frame.
Ptr< SatWaveformConf > m_waveformConf
SatTimeSlotConfMap_t m_timeSlotConfMap
std::vector< Ptr< SatTimeSlotConf > > SatTimeSlotConfContainer_t
Define type SatTimeSlotConfContainer_t.
double GetCarrierFrequencyHz(uint16_t carrierId) const
Get carrier center frequency in frame.
Ptr< SatBtuConf > m_btuConf
~SatFrameConf()
Destructor for SatFrameConf.
Ptr< SatFrameConf > m_parent
SatTimeSlotConfContainer_t GetTimeSlotConfs(uint16_t carrierId) const
Get time slot of the specific carrier.
uint16_t GetTimeSlotCount() const
Get time slot count of the frame.
SatFrameConf()
Default constructor for SatFrameConf.
This class implements super frame configuration 0.
virtual void DoConfigure()
Do frame specific configuration as needed.
static TypeId GetTypeId(void)
Get the type ID.
~SatSuperframeConf0()
Destructor for SatSuperframeConf.
SatSuperframeConf0()
Default constructor for SatSuperframeConf.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
This class implements super frame configuration 1.
SatSuperframeConf1()
Default constructor for SatSuperframeConf.
static TypeId GetTypeId(void)
Get the type ID.
~SatSuperframeConf1()
Destructor for SatSuperframeConf.
virtual void DoConfigure()
Do frame specific configuration as needed.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
This class implements sup.
~SatSuperframeConf2()
Destructor for SatSuperframeConf.
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoConfigure()
Do frame specific configuration as needed.
SatSuperframeConf2()
Default constructor for SatSuperframeConf.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
This class implements super frame configuration 3.
~SatSuperframeConf3()
Destructor for SatSuperframeConf.
virtual void DoConfigure()
Do frame specific configuration as needed.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
static TypeId GetTypeId(void)
Get the type ID.
SatSuperframeConf3()
Default constructor for SatSuperframeConf.
This class implements super frame configuration 4.
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoConfigure()
Do frame specific configuration as needed.
SatSuperframeConf4()
Default constructor for SatSuperframeConf.
~SatSuperframeConf4()
Destructor for SatSuperframeConf.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
This abstract class defines and implements interface of configuration for super frames.
SatSuperframeConf()
Default constructor for SatSuperframeConf.
void SetFrameCarrierSpacing(uint8_t frameIndex, double spacing)
SatFrameConf::SatTimeSlotConfContainer_t GetRaSlots(uint8_t raChannel)
Get RA channel time slots.
SatFrameConfList_t m_frames
double m_frameCarrierSpacing[m_maxFrameCount]
uint8_t m_frameGuardTimeSymbols[m_maxFrameCount]
uint32_t GetCarrierCount() const
Get carrier count in the super frame.
static std::string GetNumberAsString(T number)
Template method to convert number to string.
double GetFrameCarrierSpacing(uint8_t frameIndex) const
double GetFrameAllocatedBandwidthHz(uint8_t frameIndex) const
Ptr< SatFrameConf > GetCarrierFrameConf(uint32_t carrierId) const
Get the frame configuration of the requested carrier.
void SetFrameGuardTimeSymbols(uint8_t frameIndex, uint8_t guardTimeSymbols)
bool m_frameIsLogon[m_maxFrameCount]
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
uint16_t GetRaSlotCount(uint8_t raChannel)
Get RA channel time slot count.
void SetFrameRandomAccess(uint8_t frameIndex, bool randomAccess)
void SetFrameAllocatedBandwidthHz(uint8_t frameIndex, double bandwidthHz)
uint8_t GetRaChannel(uint32_t carrierId) const
Get the RA channel id (index) corresponding to given (global) carrier id.
void SetFrameLogon(uint8_t frameIndex, bool logon)
void SetFrameAllocationChannelId(uint8_t frameIndex, uint8_t allocationChannel)
std::vector< RaChannelInfo_t > m_raChannels
double m_frameCarrierAllocatedBandwidth[m_maxFrameCount]
double GetCarrierFrequencyHz(uint32_t carrierId) const
Get the center frequency of the requested carrier.
uint32_t GetRaChannelTimeSlotPayloadInBytes(uint8_t raChannel) const
Get the payload of the RA channel time slot in bytes.
uint8_t GetFrameGuardTimeSymbols(uint8_t frameIndex) const
static std::string GetIndexAsFrameName(uint32_t index)
Method to convert frame index to frame name.
double GetFrameCarrierAllocatedBandwidthHz(uint8_t frameIndex) const
void AddFrameConf(SatFrameConf::SatFrameConfParams_t frameConfParameters, double bandwidthInHz, double rollOff, double spacing, uint32_t spreadingFactor, uint8_t subdivisionLevel)
Add frame configuration to super frame configuration.
double GetFrameCarrierRollOff(uint8_t frameIndex) const
SuperFrameConfiguration_t
Configurable 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 const uint8_t m_maxFrameCount
static Ptr< SatSuperframeConf > CreateSuperframeConf(SuperFrameConfiguration_t conf)
Create pre-configured super frame configuration-.
uint8_t GetRaChannelFrameId(uint8_t raChannel) const
Get RA channel frame ID.
void SetFrameCarrierRollOff(uint8_t frameIndex, double rollOff)
uint8_t GetFrameAllocationChannelId(uint8_t frameIndex) const
void SetFrameCarrierAllocatedBandwidthHz(uint8_t frameIndex, double bandwidthHz)
double GetCarrierBandwidthHz(uint32_t carrierId, SatEnums::CarrierBandwidthType_t bandwidthType) const
Get the bandwidth of the requested carrier.
uint8_t m_frameAllocationChannel[m_maxFrameCount]
bool IsFrameLogon(uint8_t frameIndex) const
double m_frameAllocatedBandwidth[m_maxFrameCount]
void Configure(double allocatedBandwidthHz, Time targetDuration, Ptr< SatWaveformConf > waveformConf)
Configures super frame configuration according to set attributes.
uint32_t m_frameCarrierSpreadingFactor[m_maxFrameCount]
virtual void DoConfigure()=0
Do frame specific configuration as needed.
double m_frameCarrierRollOff[m_maxFrameCount]
uint32_t GetCarrierId(uint8_t frameId, uint16_t frameCarrierId) const
Get carrier id of the super frame.
~SatSuperframeConf()
Destructor for SatSuperframeConf.
bool m_frameIsRandomAccess[m_maxFrameCount]
void SetFrameCarrierSpreadingFactor(uint8_t frameIndex, uint32_t spreadingFactor)
static TypeId GetTypeId(void)
Get the type ID.
Ptr< SatFrameConf > GetFrameConf(uint8_t id) const
Get frame conf of the super frame.
uint8_t GetRaChannelCount() const
Get the number of the RA channels in super frame configuration.
uint32_t GetFrameCarrierSpreadingFactor(uint8_t frameIndex) const
bool IsFrameRandomAccess(uint8_t frameIndex) const
uint32_t GetLogonChannelIndex() const
uint8_t GetCarrierFrame(uint32_t carrierId) const
Get frame id where given global carrier ID belongs to.
uint8_t GetRaChannelAllocationChannelId(uint8_t raChannel) const
Get RA channel allocation channel ID.
@ CONFIG_TYPE_4
Configuration type 4 (ESSA)
@ CONFIG_TYPE_2
Configuration type 2.
@ CONFIG_TYPE_1
Configuration type 1.
@ CONFIG_TYPE_0
Configuration type 0.
@ CONFIG_TYPE_3
Configuration type 3.
bool IsRandomAccessCarrier(uint32_t carrierId) const
Check if given carrier is random access carrier.
This class implements configuration for time slots (for super frames / frames)
SatTimeSlotConf()
Default constructor for SatTimeSlotConf.
SatTimeSlotType_t
Types for time slot.
@ SLOT_TYPE_TRC
Control or traffic slot.
~SatTimeSlotConf()
Destructor for SatTimeSlotConf.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
#define ADD_SUPER_FRAME_ATTRIBUTES(frameCount, configType, maxSubdivision)
#define ADD_FRAME_ATTRIBUTES(index, frameBandwidth, carrierBandwidth, carrierSpacing, carrierRollOff, spreadingFactor, randomAccess, lowerLayerService, logon, guardTime)
Helper struct to reduce the number of parameters fed into the SatFrameConf constructor.