13#ifndef _LTE_LTEALLOCATIONMODULE_H_
14#define _LTE_LTEALLOCATIONMODULE_H_
16#include "simu5g/common/LteCommon.h"
17#include "simu5g/stack/mac/allocator/LteAllocatorUtils.h"
19#include "simu5g/stack/mac/LteMacEnb.h"
23using namespace omnetpp;
27class LteAllocationModule
36 opp_component_ptr<LteMacEnb> mac_;
39 unsigned int bands_ = 0;
45 bool usedInLastSlot_ =
false;
61 std::vector<std::vector<unsigned int>> totalRbsMatrix_;
68 std::vector<std::vector<unsigned int>> allocatedRbsMatrix_;
75 std::vector<std::vector<std::vector<unsigned int>>> freeRbsMatrix_;
87 unsigned int resourceBlocks_;
92 typedef std::list<AllocationElem> AllocationList;
94 typedef std::map<Band, AllocationList> PerBandAllocationMap;
96 typedef std::map<Band, unsigned int> PerBandAllocatedRbsMap;
99 struct AllocatedRbsPerUeInfo
107 std::map<Remote, PerBandAllocatedRbsMap> ueAllocatedRbsMap_;
111 std::map<Remote, unsigned int> antennaAllocatedRbs_;
114 RemoteSet availableAntennaSet_;
117 Remote currentAntenna_ = MACRO;
121 AllocatedRbsPerUeInfo()
123 availableAntennaSet_.insert(MACRO);
127 typedef std::map<MacNodeId, AllocatedRbsPerUeInfo> AllocatedRbsPerUeMap;
134 AllocatedRbsPerUeMap allocatedRbsUe_;
137 virtual void ensureNodeInitialized(
const MacNodeId nodeId);
145 typedef std::map<MacNodeId, unsigned int> UeAllocatedBlocksMap;
146 typedef std::map<MacNodeId, unsigned int> UeAllocatedBytesMap;
149 struct AllocatedRbsPerBandInfo
159 AllocatedRbsPerBandInfo()
170 typedef std::map<Band, AllocatedRbsPerBandInfo> AllocatedRbsPerBandMap;
177 std::vector<std::vector<AllocatedRbsPerBandMap>> allocatedRbsPerBand_;
182 std::vector<std::vector<AllocatedRbsPerBandMap>> prevAllocatedRbsPerBand_;
187 LteAllocationModule(LteMacEnb *mac,
const Direction direction);
190 virtual ~LteAllocationModule() {}
193 virtual void init(
const unsigned int resourceBlocks,
const unsigned int bands);
196 virtual void reset(
const unsigned int resourceBlocks,
const unsigned int bands);
200 virtual unsigned int computeTotalRbs();
203 virtual unsigned int availableBlocks(
const MacNodeId nodeId,
const Plane plane,
const Band band);
206 virtual unsigned int availableBlocks(
const MacNodeId nodeId,
const Remote antenna,
const Band band);
211 bool addBlocks(
const Remote antenna,
const Band band,
const MacNodeId nodeId,
const unsigned int blocks,
212 const unsigned int bytes);
215 virtual bool addBlocks(
const Band band,
const MacNodeId nodeId,
const unsigned int blocks,
const unsigned int bytes);
218 virtual unsigned int removeBlocks(
const Remote antenna,
const Band band,
const MacNodeId nodeId);
232 unsigned int getBlocks(
const Remote antenna,
const Band band,
const MacNodeId nodeId)
234 Plane plane = MAIN_PLANE;
235 return allocatedRbsPerBand_[plane][antenna][band].ueAllocatedRbsMap_[nodeId];
241 virtual unsigned int getAllocatedBlocks(Plane plane,
const Remote antenna,
const Band band);
242 virtual unsigned int getInterferingBlocks(Plane plane,
const Remote antenna,
const Band band);
244 unsigned int getBytes(
const Remote antenna,
const Band band,
const MacNodeId nodeId)
246 Plane plane = MAIN_PLANE;
247 return allocatedRbsPerBand_[plane][antenna][band].ueAllocatedBytesMap_[nodeId];
251 unsigned int getBlocks(
const MacNodeId nodeId)
253 return allocatedRbsUe_[nodeId].allocatedBlocks_;
257 unsigned int getBlocks(
const Plane plane,
const Remote antenna)
259 return allocatedRbsMatrix_[plane][antenna];
262 virtual unsigned int rbOccupation(
const MacNodeId nodeId,
RbMap& rbMap);
265 AllocatedRbsPerUeMap::const_iterator getAllocatedBlocksUeBegin()
267 return allocatedRbsUe_.begin();
270 AllocatedRbsPerUeMap::const_iterator getAllocatedBlocksUeEnd()
272 return allocatedRbsUe_.end();
275 std::vector<std::vector<unsigned int>>::const_iterator getAllocatedBlocksBegin()
277 return allocatedRbsMatrix_.begin();
280 std::vector<std::vector<unsigned int>>::const_iterator getAllocatedBlocksEnd()
282 return allocatedRbsMatrix_.end();
286 AllocationList::const_iterator getAllocatedBlocksUeAllocationListBegin(
const Remote antenna,
const Band b,
287 const MacNodeId nodeId)
289 return allocatedRbsUe_[nodeId].allocationMap_[antenna][b].begin();
292 AllocationList::const_iterator getAllocatedBlocksUeAllocationListEnd(
const Remote antenna,
const Band b,
293 const MacNodeId nodeId)
295 return allocatedRbsUe_[nodeId].allocationMap_[antenna][b].end();
303 virtual void storeAllocation(std::vector<std::vector<AllocatedRbsPerBandMapA>> allocatedRbsPerBand, std::set<Band> *untouchableBands =
nullptr)
309 virtual std::set<Band> getAllocatorOccupiedBands()
311 std::set<Band> bandVector;
316 unsigned int getNumBands()
Definition AlertReceiver.h:24
unsigned short Band
Logical band.
Definition LteTypes.h:140
std::map< Remote, std::map< Band, unsigned int > > RbMap
Definition LteTypes.h:145
This structure contains information for a single band.
Definition LteAllocationModule.h:150
UeAllocatedBlocksMap ueAllocatedRbsMap_
Stores for each UE the amount of blocks allocated in the structure band.
Definition LteAllocationModule.h:152
UeAllocatedBytesMap ueAllocatedBytesMap_
Stores for each UE the amount of bytes allocated in the structure band.
Definition LteAllocationModule.h:154
unsigned int allocated_
Stores the amount of blocks allocated to every UE in the structure band.
Definition LteAllocationModule.h:157
std::map< Remote, PerBandAllocationMap > allocationMap_
When an allocation is performed, the amount of blocks requested and the amount of bytes is registered...
Definition LteAllocationModule.h:109
unsigned int allocatedBlocks_
Stores the amount of blocks allocated in every band by the structure UE.
Definition LteAllocationModule.h:102
unsigned int allocatedBytes_
Stores the amount of bytes allocated to every UE in the structure band.
Definition LteAllocationModule.h:104