Loading...
Searching...
No Matches
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
26
27#include "ns3/address.h"
28#include "ns3/simple-ref-count.h"
29#include "ns3/traced-callback.h"
30
31#include <list>
32#include <map>
33#include <stdint.h>
34#include <utility>
35#include <vector>
36
37namespace ns3
38{
39
62class SatFrameAllocator : public SimpleRefCount<SatFrameAllocator>
63{
64 public:
68 typedef std::vector<Ptr<SatTbtpMessage>> TbtpMsgContainer_t;
69
77 typedef std::pair<std::vector<uint32_t>, bool> UtAllocInfoItem_t;
78
85 typedef std::map<Address, UtAllocInfoItem_t> UtAllocInfoContainer_t;
86
91 {
92 public:
93 uint32_t m_craBytes;
95 uint32_t m_rbdcBytes;
96 uint32_t m_vbdcBytes;
97
99 : m_craBytes(0),
101 m_rbdcBytes(0),
102 m_vbdcBytes(0)
103 {
104 }
105 };
106
110 typedef std::vector<SatFrameAllocReqItem> SatFrameAllocReqItemContainer_t;
111
117 {
118 public:
120 double m_cno;
121 Address m_address;
123
125 : m_generateCtrlSlot(false),
126 m_cno(NAN)
127 {
128 }
129
136 : m_generateCtrlSlot(false),
137 m_cno(NAN),
138 m_reqPerRc(req)
139 {
140 }
141 };
142
146 typedef std::vector<SatFrameAllocReq*> SatFrameAllocContainer_t;
147
158
163 {
164 bool operator()(const Ptr<SatFrameAllocator>& a, const Ptr<SatFrameAllocator>& b) const;
165 };
166
171
180 SatFrameAllocator(Ptr<SatFrameConf> frameConf,
181 uint8_t frameId,
183 Ptr<SatFrameAllocator> parent);
184
190 inline uint32_t GetCarrierMinPayloadInBytes() const
191 {
192 return m_frameConf->GetCarrierMinPayloadInBytes();
193 }
194
200 inline Ptr<SatWaveform> GetMostRobustWaveform() const
201 {
203 }
204
210 inline uint16_t GetCarrierCount() const
211 {
212 return m_maxCarrierCount;
213 }
214
222 void SelectCarriers(uint16_t& amount, uint16_t offset);
223
224 inline double GetCarrierBandwidthHz(bool checkParent = false) const
225 {
226 if (checkParent && m_frameConf->IsSubdivided())
227 {
228 return 0.0;
229 }
230 return m_frameConf->GetCarrierBandwidthHz(SatEnums::EFFECTIVE_BANDWIDTH);
231 }
232
233 inline double GetVolumeBytes() const
234 {
236 }
237
238 inline Ptr<SatFrameAllocator> GetParent() const
239 {
240 return m_parent;
241 }
242
246 void Reset();
247
256 bool GetBestWaveform(double cno, uint32_t& waveFormId, double& cnoThreshold) const;
257
263 double GetCcLoad(CcLevel_t ccLevel);
264
273 bool Allocate(CcLevel_t ccLevel, SatFrameAllocReq* allocReq, uint32_t waveformId);
274
280 void PreAllocateSymbols(double targetLoad, bool fcaEnabled);
281
293 uint32_t maxSizeInBytes,
294 UtAllocInfoContainer_t& utAllocContainer,
295 bool rcBasedAllocationEnabled,
296 TracedCallback<uint32_t> waveformTrace,
297 TracedCallback<uint32_t, uint32_t> utLoadTrace,
298 TracedCallback<uint32_t, double> loadTrace);
299
300 private:
306 {
307 public:
312
317 : m_craSymbols(0.0),
318 m_minRbdcSymbols(0.0),
319 m_rbdcSymbols(0.0),
320 m_vbdcSymbols(0.0)
321 {
322 }
323
330 {
332 }
333 };
334
338 typedef std::vector<SatFrameAllocInfoItem> SatFrameAllocInfoItemContainer_t;
339
346 {
347 public:
353
358
363
367 SatFrameAllocInfo(uint8_t countOfRcs);
368
377 Ptr<SatWaveform> trcWaveForm,
378 bool ctrlSlotPresent,
379 double ctrlSlotLength);
380
387
392 double GetTotalSymbols();
393 };
394
404
410 typedef std::pair<Address, uint8_t> RcAllocItem_t;
411
415 typedef std::map<Address, UtAllocItem_t> UtAllocContainer_t;
416
420 typedef std::list<RcAllocItem_t> RcAllocContainer_t;
421
426 {
427 public:
437
444 CcReqCompare(const UtAllocContainer_t& utAllocContainer,
445 CcReqCompare::CcReqType_t ccReqType);
446
454 bool operator()(RcAllocItem_t rcAlloc1, RcAllocItem_t rcAlloc2);
455
456 private:
461
466 };
467
469
470 // total symbols in frame.
472
473 // available (left) symbols in frame.
475
476 // pre-allocated CRA symbols in frame
478
479 // pre-allocated minimum RBDC symbols in frame
481
482 // pre-allocated RBDC symbols in frame
484
485 // pre-allocated minimum VBDC symbols in frame
487
488 // maximum symbols available in frame
490
491 // maximum carriers available in frame
493
494 // skipped carriers at the beginning of the frame
496
497 // configuration type of the frame
499
500 // Id of the frame
501 uint8_t m_frameId;
502
503 // Burst lengths in use.
505
506 // Waveform configuration
507 Ptr<SatWaveformConf> m_waveformConf;
508
509 // Frame configuration
510 Ptr<SatFrameConf> m_frameConf;
511
512 // Parent allocator in case of carrier subdivision
513 Ptr<SatFrameAllocator> m_parent;
514
515 // UT allocation container
517
518 // RC allocation container
520
521 // The most robust waveform
522 Ptr<SatWaveform> m_mostRobustWaveform;
523
524 // Guard time in symbols to apply
526
532 void ShareSymbols(bool fcaEnabled);
533
543 uint32_t GetOptimalBurtsLengthInSymbols(int64_t symbolsToUse,
544 int64_t symbolsLeft,
545 double cno,
546 uint32_t& waveformId);
547
560 Ptr<SatTimeSlotConf> CreateTimeSlot(uint16_t carrierId,
561 int64_t& utSymbolsToUse,
562 int64_t& carrierSymbolsToUse,
563 int64_t& utSymbolsLeft,
564 int64_t& rcSymbolsLeft,
565 double cno,
566 bool rcBasedAllocationEnabled);
567
579 Ptr<SatTimeSlotConf> CreateCtrlTimeSlot(uint16_t carrierId,
580 int64_t& utSymbolsToUse,
581 int64_t& carrierSymbolsToUse,
582 int64_t& utSymbolsLeft,
583 int64_t& rcSymbolsLeft,
584 bool rcBasedAllocationEnabled);
585
592 void UpdateAndStoreAllocReq(Address address, double cno, SatFrameAllocInfo& req);
593
599 void AcceptRequests(CcLevel_t ccLevel);
600
606 std::vector<Address> SortUts();
607
613 std::vector<uint16_t> SortCarriers();
614
621 std::vector<uint32_t> SortUtRcs(Address ut);
622
631 SatFrameAllocator::UtAllocInfoContainer_t::iterator GetUtAllocItem(
632 UtAllocInfoContainer_t& allocContainer,
633 Address ut);
634
642 Ptr<SatTbtpMessage> CreateNewTbtp(TbtpMsgContainer_t& tbtpContainer);
643};
644
645} // namespace ns3
646
647#endif /* SAT_FRAME_ALLOCATOR_H */
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(SatFrameAllocReqItemContainer_t req)
Construct SatFrameAllocReq.
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
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.
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.
Ptr< SatWaveform > GetMostRobustWaveform() const
Get the most robust waveform used by this frame allocator.
void PreAllocateSymbols(double targetLoad, bool fcaEnabled)
Preallocate symbols for all UTs with RCs allocated to the frame.
Ptr< SatFrameAllocator > GetParent() const
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