LteAmc.h Source File

Simu5G: LteAmc.h Source File
Simu5G
LteAmc.h
1//
2// Simu5G
3//
4// Copyright (C) 2012-2021 Giovanni Nardini, Giovanni Stea, Antonio Virdis et al. (University of Pisa)
5// Copyright (C) 2022-2026 Giovanni Nardini, Giovanni Stea et al. (University of Pisa)
6//
7// This file is part of a software released under the license included in file
8// "license.pdf". Please read LICENSE and README files before using it.
9// The above files and the present reference are part of the software itself,
10// and cannot be removed from it.
11//
12
13#ifndef _LTE_LTEAMC_H_
14#define _LTE_LTEAMC_H_
15
16#include "simu5g/common/LteDefs.h"
17#include "simu5g/common/cellInfo/CellInfo.h"
18#include "simu5g/stack/phy/feedback/LteFeedback.h"
19#include "simu5g/stack/phy/feedback/LteSummaryBuffer.h"
20#include "simu5g/stack/mac/amc/AmcPilot.h"
21#include "simu5g/stack/mac/amc/LteMcs.h"
22#include "simu5g/stack/mac/amc/UserTxParams.h"
23#include "simu5g/stack/mac/LteMacEnb.h"
24#include "simu5g/common/binder/Binder.h"
25
26namespace simu5g {
27
28using namespace omnetpp;
29
31class AmcPilot;
33class CellInfo;
35class LteMacEnb;
36
37typedef std::map<Remote, std::vector<std::vector<LteSummaryBuffer>>> History_;
38
44class LteAmc : public cSimpleModule
45{
46 protected:
48 virtual AmcPilot *createAmcPilot(const char *amcMode);
49
50 // D2D routing seams: the base services DL/UL directly and routes any other
51 // (D2D) direction here. The base implementations reject the direction; the
52 // D2D AMC subclasses override them to service the D2D structures.
53 virtual void printTxParamsForDirection(Direction dir, GHz carrierFrequency);
54 virtual bool existTxParamsForDirection(MacNodeId id, Direction dir, GHz carrierFrequency);
55 virtual const UserTxParams& setTxParamsForDirection(MacNodeId id, Direction dir, UserTxParams& info, GHz carrierFrequency);
56 virtual const UserTxParams& getTxParamsForDirection(MacNodeId id, Direction dir, GHz carrierFrequency);
57 virtual McsTable *getMcsTableForDirection(Direction dir);
58 virtual void rescaleMcsForDirection(double rePerRb, Direction dir);
59 virtual void detachUserForDirection(MacNodeId nodeId, Direction dir);
60 virtual void attachUserForDirection(MacNodeId nodeId, Direction dir);
61 virtual void testUeForDirection(MacNodeId nodeId, Direction dir);
62
63 public:
64 void printParameters();
65 void printFbhb(Direction dir);
66 void printTxParams(Direction dir, GHz carrierFrequency);
67
68 protected:
69 opp_component_ptr<LteMacEnb> mac_;
70 opp_component_ptr<Binder> binder_;
71 opp_component_ptr<CellInfo> cellInfo_;
72 AmcPilot *pilot_ = nullptr;
73 RbAllocationType allocationType_;
74 int numBands_;
75 MacNodeId nodeId_;
76 MacCellId cellId_;
77 McsTable dlMcsTable_;
78 McsTable ulMcsTable_;
79 double mcsScaleDl_;
80 double mcsScaleUl_;
81 int numAntennas_;
82 RemoteSet remoteSet_;
83 ConnectedUesMap dlConnectedUe_;
84 ConnectedUesMap ulConnectedUe_;
85 std::map<MacNodeId, unsigned int> dlNodeIndex_;
86 std::map<MacNodeId, unsigned int> ulNodeIndex_;
87 std::vector<MacNodeId> dlRevNodeIndex_;
88 std::vector<MacNodeId> ulRevNodeIndex_;
89
90 // one tx param per carrier
91 std::map<GHz, std::vector<UserTxParams>> dlTxParams_;
92 std::map<GHz, std::vector<UserTxParams>> ulTxParams_;
93
94 int fType_; //CQI synchronization Debugging
95
96 // one History per carrier
97 std::map<GHz, History_> dlFeedbackHistory_;
98 std::map<GHz, History_> ulFeedbackHistory_;
99
100 unsigned int fbhbCapacityDl_;
101 unsigned int fbhbCapacityUl_;
102 simtime_t lb_;
103 simtime_t ub_;
104 double cqiComputationWeight_;
105
106 History_ *getHistory(Direction dir, GHz carrierFrequency);
107
108 public:
109 LteAmc() {}
110 virtual ~LteAmc();
111
112 protected:
113 void initialize(int stage) override;
114 int numInitStages() const override { return inet::NUM_INIT_STAGES; }
115 void handleMessage(cMessage *msg) override { throw cRuntimeError("LteAmc does not handle messages"); }
116
117 public:
118 void setfType(int f)
119 {
120 fType_ = f;
121 }
122
123 int getfType()
124 {
125 return fType_;
126 }
127
128 virtual void pushFeedback(MacNodeId id, Direction dir, LteFeedback fb, GHz carrierFrequency);
129 virtual const LteSummaryFeedback& getFeedback(MacNodeId id, Remote antenna, TxMode txMode, const Direction dir, GHz carrierFrequency);
130
131 const RemoteSet *getAntennaSet()
132 {
133 return &remoteSet_;
134 }
135
136 bool existTxParams(MacNodeId id, const Direction dir, GHz carrierFrequency);
137 virtual const UserTxParams& getTxParams(MacNodeId id, const Direction dir, GHz carrierFrequency);
138 virtual const UserTxParams& setTxParams(MacNodeId id, const Direction dir, UserTxParams& info, GHz carrierFrequency);
139 virtual const UserTxParams& computeTxParams(MacNodeId id, const Direction dir, GHz carrierFrequency);
140 virtual unsigned int computeBitsOnNRbs(MacNodeId id, Band b, unsigned int blocks, const Direction dir, GHz carrierFrequency);
141 virtual unsigned int computeBitsOnNRbs(MacNodeId id, Band b, Codeword cw, unsigned int blocks, const Direction dir, GHz carrierFrequency);
142 virtual unsigned int computeBytesOnNRbs(MacNodeId id, Band b, unsigned int blocks, const Direction dir, GHz carrierFrequency);
143 virtual unsigned int computeBytesOnNRbs(MacNodeId id, Band b, Codeword cw, unsigned int blocks, const Direction dir, GHz carrierFrequency);
144
145 virtual unsigned int computeBitsPerRbBackground(Cqi cqi, const Direction dir, GHz carrierFrequency);
146
147 // multiband version of the above function. It returns the number of bytes that can fit in the given "blocks" of the given "band"
148 virtual unsigned int computeBytesOnNRbs_MB(MacNodeId id, Band b, unsigned int blocks, const Direction dir, GHz carrierFrequency);
149 virtual unsigned int computeBitsOnNRbs_MB(MacNodeId id, Band b, unsigned int blocks, const Direction dir, GHz carrierFrequency);
150 bool setPilotUsableBands(MacNodeId id, UsableBands usableBands);
151 UsableBands *getPilotUsableBands(MacNodeId id);
152
153 // utilities - do not involve pilot invocation
154 virtual unsigned int getItbsPerCqi(Cqi cqi, const Direction dir);
155
156 /*
157 * Access the correct itbs2tbs conversion table given cqi and layer number
158 */
159 virtual const unsigned int *readTbsVect(Cqi cqi, unsigned int layers, Direction dir);
160
161 /*
162 * given <cqi> and <layers> returns bytes allocable in <blocks>
163 */
164 virtual unsigned int blockGain(Cqi cqi, unsigned int layers, unsigned int blocks, Direction dir);
165
166 /*
167 * given <cqi> and <layers> returns blocks capable of carrying <bytes>
168 */
169 virtual unsigned int bytesGain(Cqi cqi, unsigned int layers, unsigned int bytes, Direction dir);
170
171 // ---------------------------
172 void writeCqiWeight(double weight);
173 virtual Cqi readWbCqi(const CqiVector& cqi);
174 virtual void detachUser(MacNodeId nodeId, Direction dir);
175 virtual void attachUser(MacNodeId nodeId, Direction dir);
176 void testUe(MacNodeId nodeId, Direction dir);
177 AmcPilot *getPilot() const
178 {
179 return pilot_;
180 }
181
182 CellInfo *getCellInfo()
183 {
184 return cellInfo_;
185 }
186
187 Binder *getBinder()
188 {
189 return binder_;
190 }
191
192 MacNodeId getMacNodeId()
193 {
194 return nodeId_;
195 }
196
197 // Resolve the next hop (serving node) for the given destination, or the
198 // destination itself if this cell is its master.
199 MacNodeId getServingNodeOrSelf(MacNodeId dst);
200
201 inet::Coord getUePosition(MacNodeId id)
202 {
203 return cellInfo_->getUePosition(id);
204 }
205
206 virtual std::vector<Cqi> readMultiBandCqi(MacNodeId id, const Direction dir, GHz carrierFrequency);
207
208 int getSystemNumBands() { return numBands_; }
209
210 void setPilotMode(PilotComputationModes mode);
211};
212
213} //namespace
214
215#endif
Abstract AMC Pilot class.
Definition AmcPilot.h:35
There is one CellInfo module for each eNB (thus one for each cell). Keeps cross-layer information abo...
Definition CellInfo.h:30
Lte AMC module for Omnet++ simulator.
Definition LteAmc.h:45
virtual AmcPilot * createAmcPilot(const char *amcMode)
Factory for the AMC pilot selected by the amcMode parameter; supported names depend on the AMC implem...
Definition LteMcs.h:61
Definition AlertReceiver.h:24
unsigned short Band
Logical band.
Definition LteTypes.h:140
unsigned short Codeword
Codeword.
Definition LteCommon.h:202
MacNodeId MacCellId
Cell node ID. It is numerically equal to eNodeB MAC node ID.
Definition LteTypes.h:66
unsigned short Cqi
Channel Quality Indicator.
Definition LteTypes.h:133