BackgroundCellChannelModel.h Source File

Simu5G: BackgroundCellChannelModel.h Source File
Simu5G
BackgroundCellChannelModel.h
1//
2// Simu5G
3//
4// Copyright (C) 2019-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 __BACKGROUNDCELLCHANNELMODEL_H_
14#define __BACKGROUNDCELLCHANNELMODEL_H_
15
16#include <inet/common/ModuleRefByPar.h>
17
18#include "simu5g/common/LteCommon.h"
19#include "simu5g/common/binder/Binder.h"
20
21namespace simu5g {
22
23using namespace omnetpp;
24
26
44class BackgroundCellChannelModel : public cSimpleModule
45{
46 // carrier frequency for this cell
47 GHz carrierFrequency_;
48 double carrierFrequencyHz_;
49 double carrierFrequencyGHz_;
50 double log10CarrierFrequencyGHz_;
51
52 // eNodeB Height
53 double hNodeB_;
54
55 // UE Height
56 double hUe_;
57
58 // average Building Heights
59 double hBuilding_;
60
61 // true if the UE is inside a building
62 bool inside_building_;
63
64 // distance from the building wall
65 double inside_distance_;
66
67 // Average street's width
68 double wStreet_;
69
70 // scenario
71 DeploymentScenario scenario_;
72
73 //Antenna gain of eNodeB
74 double antennaGainEnB_;
75
76 //Antenna gain of micro node
77 double antennaGainMicro_;
78
79 //Antenna gain of UE
80 double antennaGainUe_;
81
82 //Thermal noise
83 double thermalNoise_;
84
85 //pointer to Binder module
86 inet::ModuleRefByPar<Binder> binder_;
87
88 //Cable loss
89 double cableLoss_;
90
91 //UE noise figure
92 double ueNoiseFigure_;
93
94 //eNodeB noise figure
95 double bsNoiseFigure_;
96
97 //if true, shadowing is enabled
98 bool shadowing_;
99
100 //Enable or disable fading
101 bool fading_;
102
103 //Number of fading paths in jakes fading
104 int fadingPaths_;
105
106 //avg delay spread in jakes fading
107 double delayRMS_;
108
109 // enable/disable intercell interference computation
110 bool enableBackgroundCellInterference_;
111 bool enableDownlinkInterference_;
112 bool enableUplinkInterference_;
113
114 // Store the last computed shadowing for each user
115 std::map<MacNodeId, std::pair<inet::simtime_t, double>> lastComputedSF_;
116
117 // map that stores for each user if is in Line of Sight or not with eNodeB
118 std::map<MacNodeId, bool> losMap_;
119
120 //correlation distance used in shadowing computation and
121 //also used to recompute the probability of LOS
122 double correlationDistance_;
123
124 typedef std::pair<inet::simtime_t, inet::Coord> Position;
125
126 // last position of current user
127 std::map<MacNodeId, std::queue<Position>> positionHistory_;
128
129 // last position of current user at which probability of LOS
130 // was computed.
131 std::map<MacNodeId, Position> lastCorrelationPoint_;
132
133 bool tolerateMaxDistViolation_;
134
135 //Struct used to store information about jakes fading
136 struct JakesFadingData
137 {
138 std::vector<double> angleOfArrival;
139 std::vector<simtime_t> delaySpread;
140
141 friend std::ostream& operator<<(std::ostream& os, const JakesFadingData& e)
142 {
143 os << "paths=" << e.angleOfArrival.size();
144 return os;
145 }
146 };
147
148 // for each node and for each band we store information about jakes fading
149 std::map<MacNodeId, std::vector<JakesFadingData>> jakesFadingMap_;
150
151 typedef std::vector<JakesFadingData> JakesFadingVector;
152 typedef std::map<MacNodeId, JakesFadingVector> JakesFadingMap;
153
154 enum FadingType
155 {
156 RAYLEIGH, JAKES
157 };
158
159 //Fading type (JAKES or RAYLEIGH)
160 FadingType fadingType_;
161
162 //enable or disable the dynamic computation of LOS NLOS probability for each user
163 bool dynamicLos_;
164
165 //if dynamicLos is false this boolean is initialized to true if all users will be in LOS or false otherwise
166 bool fixedLos_;
167
168 // TR 36.814 path-loss, LOS-probability and shadowing-sigma formulas;
169 // owned, created in initialize(). The main channel model's ext-cell path
170 // is permanently pinned to the same study (see its extCellPathLoss_),
171 // so background cells and ext cells evaluate identical formulas.
172 Tr36814PathLossModel *pathLoss_ = nullptr;
173
174 /*
175 * Compute Attenuation caused by pathloss and shadowing (optional)
176 */
177 virtual double getAttenuation(MacNodeId nodeId, Direction dir, inet::Coord bgBsCoord, inet::Coord bgUeCoord);
178 /*
179 * Compute the path-loss attenuation according to the selected scenario
180 *
181 * @param distance between UE and eNodeB
182 * @param los line-of-sight flag
183 */
184 virtual double computePathLoss(double distance, double dbp, bool los);
185 /*
186 * Compute Rayleigh fading
187 *
188 * @param i index in the trace file
189 * @param nodeid mac node id of UE
190 */
191 double rayleighFading(MacNodeId id, unsigned int band);
192 /*
193 * Compute Jakes fading
194 *
195 * @param speed speed of UE
196 * @param nodeid mac node id of UE
197 * @param band logical band id
198 * @param cqiDl if true, the jakesMap in the UE side should be used
199 * @param isBgUe if true, this is called for a background UE
200 */
201 double jakesFading(MacNodeId nodeId, double speed, unsigned int band, unsigned int numBands);
202 /*
203 * Compute LOS probability
204 *
205 * @param d distance between UE and eNodeB
206 * @param nodeid mac node id of UE
207 */
208 void computeLosProbability(double d, MacNodeId nodeId);
209
210 JakesFadingMap *getJakesMap()
211 {
212 return &jakesFadingMap_;
213 }
214
215 /* compute speed (m/s) for a given node
216 * @param nodeid mac node id of UE
217 * @return the speed in m/s
218 */
219 double computeSpeed(const MacNodeId nodeId, const inet::Coord coord);
220
221 /*
222 * compute the euclidean distance between the current position and the
223 * last position used to calculate the LOS probability
224 */
225 double computeCorrelationDistance(const MacNodeId nodeId, const inet::Coord coord);
226
227 /*
228 * update base point if the distance to the previous value is greater than the
229 * correlationDistance_
230 */
231 void updateCorrelationDistance(const MacNodeId nodeId, const inet::Coord coord);
232
233 /*
234 * Updates position for a given node
235 * @param nodeid mac node id of UE
236 */
237 void updatePositionHistory(const MacNodeId nodeId, const inet::Coord coord);
238
239 double computeShadowing(double sqrDistance, MacNodeId nodeId, double speed);
240
241 double computeAngle(inet::Coord center, inet::Coord point);
242 double computeVerticalAngle(inet::Coord center, inet::Coord point);
243 double getTwoDimDistance(inet::Coord a, inet::Coord b);
244 double computeAngularAttenuation(double hAngle, double vAngle);
245
246 bool computeDownlinkInterference(MacNodeId bgUeId, inet::Coord bgUePos, GHz carrierFrequency, const RbMap& rbmap, unsigned int numBands, std::vector<double> *interference);
247 bool computeUplinkInterference(MacNodeId bgUeId, inet::Coord bgUePos, GHz carrierFrequency, const RbMap& rbmap, unsigned int numBands, std::vector<double> *interference);
248 bool computeBackgroundCellInterference(MacNodeId bgUeId, inet::Coord bgUeCoord, int bgBsId, inet::Coord bgBsCoord, GHz carrierFrequency, const RbMap& rbmap, Direction dir, unsigned int numBands, std::vector<double> *interference);
249
250 protected:
251 void initialize(int stage) override;
252 int numInitStages() const override { return inet::NUM_INIT_STAGES; }
253
254 public:
256
257 // set carrier frequency
258 void setCarrierFrequency(GHz carrierFrequency) {
259 carrierFrequency_ = carrierFrequency;
260 carrierFrequencyGHz_ = GHz(carrierFrequency).get();
261 carrierFrequencyHz_ = Hz(carrierFrequency).get();
262 log10CarrierFrequencyGHz_ = log10(carrierFrequencyGHz_);
263 }
264
265 /*
266 * Compute SINR for each band for user nodeId according to pathloss, shadowing (optional) and multipath fading
267 */
268 virtual std::vector<double> getSINR(MacNodeId bgUeId, inet::Coord bgUePos, TrafficGeneratorBase *bgUe, BackgroundScheduler *bgScheduler, Direction dir);
269
270 /*
271 * Compute received power for a background UE according to pathloss
272 *
273 */
274 virtual double getReceivedPower_bgUe(double txPower, inet::Coord txPos, inet::Coord rxPos, Direction dir, bool losStatus, const BackgroundScheduler *bgScheduler);
275};
276
277} //namespace
278
279#endif
Definition BackgroundCellChannelModel.h:45
Definition Tr36814PathLossModel.h:31
Definition AlertReceiver.h:24
std::map< Remote, std::map< Band, unsigned int > > RbMap
Definition LteTypes.h:145