satellite-frame-allocator.h
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  *
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: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
21 #ifndef SAT_FRAME_ALLOCATOR_H
22 #define SAT_FRAME_ALLOCATOR_H
23 
25 #include "satellite-frame-conf.h"
26 
27 #include <ns3/address.h>
28 #include <ns3/simple-ref-count.h>
29 #include <ns3/traced-callback.h>
30 
31 namespace ns3
32 {
33 
56 class SatFrameAllocator : public SimpleRefCount<SatFrameAllocator>
57 {
58  public:
62  typedef std::vector<Ptr<SatTbtpMessage>> TbtpMsgContainer_t;
63 
71  typedef std::pair<std::vector<uint32_t>, bool> UtAllocInfoItem_t;
72 
79  typedef std::map<Address, UtAllocInfoItem_t> UtAllocInfoContainer_t;
80 
85  {
86  public:
87  uint32_t m_craBytes;
88  uint32_t m_minRbdcBytes;
89  uint32_t m_rbdcBytes;
90  uint32_t m_vbdcBytes;
91 
93  : m_craBytes(0),
94  m_minRbdcBytes(0),
95  m_rbdcBytes(0),
96  m_vbdcBytes(0)
97  {
98  }
99  };
100 
104  typedef std::vector<SatFrameAllocReqItem> SatFrameAllocReqItemContainer_t;
105 
111  {
112  public:
114  double m_cno;
115  Address m_address;
117 
119  : m_generateCtrlSlot(false),
120  m_cno(NAN)
121  {
122  }
123 
130  : m_generateCtrlSlot(false),
131  m_cno(NAN),
132  m_reqPerRc(req)
133  {
134  }
135  };
136 
140  typedef std::vector<SatFrameAllocReq*> SatFrameAllocContainer_t;
141 
145  typedef enum
146  {
151  } CcLevel_t;
152 
157  {
158  bool operator()(const Ptr<SatFrameAllocator>& a, const Ptr<SatFrameAllocator>& b) const;
159  };
160 
165 
174  SatFrameAllocator(Ptr<SatFrameConf> frameConf,
175  uint8_t frameId,
177  Ptr<SatFrameAllocator> parent);
178 
184  inline uint32_t GetCarrierMinPayloadInBytes() const
185  {
186  return m_frameConf->GetCarrierMinPayloadInBytes();
187  }
188 
194  inline Ptr<SatWaveform> GetMostRobustWaveform() const
195  {
196  return m_mostRobustWaveform;
197  }
198 
204  inline uint16_t GetCarrierCount() const
205  {
206  return m_maxCarrierCount;
207  }
208 
216  void SelectCarriers(uint16_t& amount, uint16_t offset);
217 
218  inline double GetCarrierBandwidthHz(bool checkParent = false) const
219  {
220  if (checkParent && m_frameConf->IsSubdivided())
221  return 0.0;
222  return m_frameConf->GetCarrierBandwidthHz(SatEnums::EFFECTIVE_BANDWIDTH);
223  }
224 
225  inline double GetVolumeBytes() const
226  {
227  return m_maxSymbolsPerCarrier;
228  }
229 
230  inline Ptr<SatFrameAllocator> GetParent() const
231  {
232  return m_parent;
233  }
234 
238  void Reset();
239 
248  bool GetBestWaveform(double cno, uint32_t& waveFormId, double& cnoThreshold) const;
249 
255  double GetCcLoad(CcLevel_t ccLevel);
256 
265  bool Allocate(CcLevel_t ccLevel, SatFrameAllocReq* allocReq, uint32_t waveformId);
266 
272  void PreAllocateSymbols(double targetLoad, bool fcaEnabled);
273 
285  uint32_t maxSizeInBytes,
286  UtAllocInfoContainer_t& utAllocContainer,
287  bool rcBasedAllocationEnabled,
288  TracedCallback<uint32_t> waveformTrace,
289  TracedCallback<uint32_t, uint32_t> utLoadTrace,
290  TracedCallback<uint32_t, double> loadTrace);
291 
292  private:
298  {
299  public:
300  double m_craSymbols;
304 
309  : m_craSymbols(0.0),
310  m_minRbdcSymbols(0.0),
311  m_rbdcSymbols(0.0),
312  m_vbdcSymbols(0.0)
313  {
314  }
315 
322  {
324  }
325  };
326 
330  typedef std::vector<SatFrameAllocInfoItem> SatFrameAllocInfoItemContainer_t;
331 
338  {
339  public:
341  double m_craSymbols;
345 
350 
355 
359  SatFrameAllocInfo(uint8_t countOfRcs);
360 
369  Ptr<SatWaveform> trcWaveForm,
370  bool ctrlSlotPresent,
371  double ctrlSlotLength);
372 
379 
384  double GetTotalSymbols();
385  };
386 
390  typedef struct
391  {
392  double m_cno;
395  } UtAllocItem_t;
396 
402  typedef std::pair<Address, uint8_t> RcAllocItem_t;
403 
407  typedef std::map<Address, UtAllocItem_t> UtAllocContainer_t;
408 
412  typedef std::list<RcAllocItem_t> RcAllocContainer_t;
413 
418  {
419  public:
423  typedef enum
424  {
428  } CcReqType_t;
429 
436  CcReqCompare(const UtAllocContainer_t& utAllocContainer,
437  CcReqCompare::CcReqType_t ccReqType);
438 
446  bool operator()(RcAllocItem_t rcAlloc1, RcAllocItem_t rcAlloc2);
447 
448  private:
453 
458  };
459 
461 
462  // total symbols in frame.
464 
465  // available (left) symbols in frame.
467 
468  // pre-allocated CRA symbols in frame
470 
471  // pre-allocated minimum RBDC symbols in frame
473 
474  // pre-allocated RBDC symbols in frame
476 
477  // pre-allocated minimum VBDC symbols in frame
479 
480  // maximum symbols available in frame
482 
483  // maximum carriers available in frame
485 
486  // skipped carriers at the beginning of the frame
488 
489  // configuration type of the frame
491 
492  // Id of the frame
493  uint8_t m_frameId;
494 
495  // Burst lengths in use.
497 
498  // Waveform configuration
499  Ptr<SatWaveformConf> m_waveformConf;
500 
501  // Frame configuration
502  Ptr<SatFrameConf> m_frameConf;
503 
504  // Parent allocator in case of carrier subdivision
505  Ptr<SatFrameAllocator> m_parent;
506 
507  // UT allocation container
509 
510  // RC allocation container
512 
513  // The most robust waveform
514  Ptr<SatWaveform> m_mostRobustWaveform;
515 
516  // Guard time in symbols to apply
518 
524  void ShareSymbols(bool fcaEnabled);
525 
535  uint32_t GetOptimalBurtsLengthInSymbols(int64_t symbolsToUse,
536  int64_t symbolsLeft,
537  double cno,
538  uint32_t& waveformId);
539 
552  Ptr<SatTimeSlotConf> CreateTimeSlot(uint16_t carrierId,
553  int64_t& utSymbolsToUse,
554  int64_t& carrierSymbolsToUse,
555  int64_t& utSymbolsLeft,
556  int64_t& rcSymbolsLeft,
557  double cno,
558  bool rcBasedAllocationEnabled);
559 
571  Ptr<SatTimeSlotConf> CreateCtrlTimeSlot(uint16_t carrierId,
572  int64_t& utSymbolsToUse,
573  int64_t& carrierSymbolsToUse,
574  int64_t& utSymbolsLeft,
575  int64_t& rcSymbolsLeft,
576  bool rcBasedAllocationEnabled);
577 
584  void UpdateAndStoreAllocReq(Address address, double cno, SatFrameAllocInfo& req);
585 
591  void AcceptRequests(CcLevel_t ccLevel);
592 
598  std::vector<Address> SortUts();
599 
605  std::vector<uint16_t> SortCarriers();
606 
613  std::vector<uint32_t> SortUtRcs(Address ut);
614 
623  SatFrameAllocator::UtAllocInfoContainer_t::iterator GetUtAllocItem(
624  UtAllocInfoContainer_t& allocContainer,
625  Address ut);
626 
634  Ptr<SatTbtpMessage> CreateNewTbtp(TbtpMsgContainer_t& tbtpContainer);
635 };
636 
637 } // namespace ns3
638 
639 #endif /* SAT_FRAME_ALLOCATOR_H */
CcReqCompare class for CC type comparisons.
CcReqType_t
Definition for different comparison types.
CcReqCompare(const UtAllocContainer_t &utAllocContainer, CcReqCompare::CcReqType_t ccReqType)
Construct CcReqCompare.
bool operator()(RcAllocItem_t rcAlloc1, RcAllocItem_t rcAlloc2)
Comparison operator to compare two RC allocations.
CcReqType_t m_ccReqType
Type used for comparisons.
const UtAllocContainer_t & m_utAllocContainer
Reference to UT allocation container.
SatFrameAllocInfo is used to hold a frame's allocation info in symbols.
SatFrameAllocInfoItemContainer_t m_allocInfoPerRc
Information for the RCs.
SatFrameAllocInfo()
Construct empty SatFrameAllocInfo.
double GetTotalSymbols()
Get total symbols of the item.
SatFrameAllocInfoItem UpdateTotalCounts()
Update total count of SatFrameAllocInfo from RCs.
Allocation information item for requests and allocations [symbols] used internally by SatFrameAllocat...
SatFrameAllocInfoItem()
Construct SatFrameAllocInfoItem.
double GetTotalSymbols()
Get symbols allocated/requested by this item.
SatFrameAllocReq is used to define frame allocation parameters when requesting allocation from SatFra...
SatFrameAllocReq(SatFrameAllocReqItemContainer_t req)
Construct SatFrameAllocReq.
Allocation information item for the UT/RC requests [bytes].
helper class for Satellite Superframe Allocator.
std::list< RcAllocItem_t > RcAllocContainer_t
Container for RC allocation items.
void ShareSymbols(bool fcaEnabled)
Share symbols between all UTs and RCs allocated to the frame.
std::vector< uint16_t > SortCarriers()
Sort carriers belonging to this frame.
Ptr< SatWaveform > m_mostRobustWaveform
Ptr< SatFrameAllocator > GetParent() const
double GetCcLoad(CcLevel_t ccLevel)
Get frame load by requested CC.
std::vector< SatFrameAllocReq * > SatFrameAllocContainer_t
Container to store SatFrameAllocReq item pointers.
SatSuperframeConf::ConfigType_t m_configType
void SelectCarriers(uint16_t &amount, uint16_t offset)
Set the amount of carriers used in this frame.
std::map< Address, UtAllocItem_t > UtAllocContainer_t
Map container for UT allocation items.
SatFrameAllocator::UtAllocInfoContainer_t::iterator GetUtAllocItem(UtAllocInfoContainer_t &allocContainer, Address ut)
Get UT allocation item from given container.
bool Allocate(CcLevel_t ccLevel, SatFrameAllocReq *allocReq, uint32_t waveformId)
Allocate symbols to this frame, if criteria are fulfilled.
bool GetBestWaveform(double cno, uint32_t &waveFormId, double &cnoThreshold) const
Get the best waveform supported by this allocator based on given C/N0.
Ptr< SatWaveform > GetMostRobustWaveform() const
Get the most robust waveform used by this frame allocator.
SatWaveformConf::BurstLengthContainer_t m_burstLenghts
Ptr< SatWaveformConf > m_waveformConf
void Reset()
Reset frame allocator.
SatFrameAllocator()
Default constructor (not in used)
std::vector< Address > SortUts()
Sort UTs allocated to this frame.
std::pair< std::vector< uint32_t >, bool > UtAllocInfoItem_t
Pair used to store UT allocation information.
Ptr< SatTimeSlotConf > CreateTimeSlot(uint16_t carrierId, int64_t &utSymbolsToUse, int64_t &carrierSymbolsToUse, int64_t &utSymbolsLeft, int64_t &rcSymbolsLeft, double cno, bool rcBasedAllocationEnabled)
Create time slot according to configuration type.
void UpdateAndStoreAllocReq(Address address, double cno, SatFrameAllocInfo &req)
Update RC/CC requested according to carrier limit.
void AcceptRequests(CcLevel_t ccLevel)
Accept UT/RC requests of the frame according to given CC level.
std::vector< SatFrameAllocInfoItem > SatFrameAllocInfoItemContainer_t
Container to store SatFrameAllocInfoItem items.
std::vector< Ptr< SatTbtpMessage > > TbtpMsgContainer_t
Container to store generated TBTP messages.
uint32_t GetOptimalBurtsLengthInSymbols(int64_t symbolsToUse, int64_t symbolsLeft, double cno, uint32_t &waveformId)
Get optimal burst length in symbols.
uint32_t GetCarrierMinPayloadInBytes() const
Get minimum payload of a carrier in bytes.
Ptr< SatFrameAllocator > m_parent
Ptr< SatTimeSlotConf > CreateCtrlTimeSlot(uint16_t carrierId, int64_t &utSymbolsToUse, int64_t &carrierSymbolsToUse, int64_t &utSymbolsLeft, int64_t &rcSymbolsLeft, bool rcBasedAllocationEnabled)
Create control time slot.
Ptr< SatTbtpMessage > CreateNewTbtp(TbtpMsgContainer_t &tbtpContainer)
Creates new TBTP to given container with information of the last TBTP in container.
void GenerateTimeSlots(SatFrameAllocator::TbtpMsgContainer_t &tbtpContainer, uint32_t maxSizeInBytes, UtAllocInfoContainer_t &utAllocContainer, bool rcBasedAllocationEnabled, TracedCallback< uint32_t > waveformTrace, TracedCallback< uint32_t, uint32_t > utLoadTrace, TracedCallback< uint32_t, double > loadTrace)
Generate time slots for UT/RCs i.e.
@ CC_LEVEL_CRA_RBDC
CC level CRA + RBDC.
@ CC_LEVEL_CRA_RBDC_VBDC
CC level CRA + RBDC + VBDC.
@ CC_LEVEL_CRA_MIN_RBDC
CC level CRA + Minimum RBDC.
std::map< Address, UtAllocInfoItem_t > UtAllocInfoContainer_t
Map container to store UT allocation information.
std::pair< Address, uint8_t > RcAllocItem_t
Pair used as RC allocation item.
uint16_t GetCarrierCount() const
Get the amount of carriers used in this frame.
void PreAllocateSymbols(double targetLoad, bool fcaEnabled)
Preallocate symbols for all UTs with RCs allocated to the frame.
double GetCarrierBandwidthHz(bool checkParent=false) const
std::vector< SatFrameAllocReqItem > SatFrameAllocReqItemContainer_t
Container to store SatFrameAllocReqItem items.
std::vector< uint32_t > SortUtRcs(Address ut)
Sort RCs in given UT.
ConfigType_t
Enum for configuration types.
std::vector< uint32_t > BurstLengthContainer_t
Define BurstLengthContainer.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
BandwidthComparator is a custom functor meant as comparison function for std::map.
bool operator()(const Ptr< SatFrameAllocator > &a, const Ptr< SatFrameAllocator > &b) const