1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2022 Northeastern University
4 * Copyright (c) 2022 Sapienza, University of Rome
5 * Copyright (c) 2022 University of Padova
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation;
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Author: Andrea Lacava <thecave003@gmail.com>
21 * Tommaso Zugno <tommasozugno@gmail.com>
22 * Michele Polese <michele.polese@gmail.com>
28 #include "ns3/object.h"
32 #include "OCTET_STRING.h"
33 #include "BIT_STRING.h"
34 #include "PM-Info-Item.h"
37 #include "L3-RRC-Measurements.h"
38 #include "ServingCellMeasurements.h"
39 #include "MeasResultNeighCells.h"
40 #include "MeasResultNR.h"
41 #include "MeasResultEUTRA.h"
42 #include "MeasResultPCell.h"
43 #include "MeasResultListEUTRA.h"
44 #include "MeasResultListNR.h"
45 #include "MeasResultServMO.h"
46 #include "MeasResultServMOList.h"
47 #include "MeasQuantityResults.h"
48 #include "ResultsPerSSB-Index.h"
49 #include "ResultsPerCSI-RS-Index.h"
50 #include "E2SM-RC-ControlMessage-Format1.h"
51 #include "RANParameter-Item.h"
52 #include "RANParameter-ValueType.h"
53 #include "RANParameter-ELEMENT.h"
54 #include "RANParameter-STRUCTURE.h"
60 * Wrapper for class for OCTET STRING
62 class OctetString : public SimpleRefCount<OctetString>
65 OctetString (std::string value, size_t size);
66 OctetString (void *value, size_t size);
68 OCTET_STRING_t *GetPointer ();
69 OCTET_STRING_t GetValue ();
70 std::string DecodeContent ();
73 void CreateBaseOctetString (size_t size);
74 OCTET_STRING_t *m_octetString;
78 * Wrapper for class for BIT STRING
80 class BitString : public SimpleRefCount<BitString>
83 BitString (std::string value, size_t size);
84 BitString (std::string value, size_t size, size_t bits_unused);
86 BIT_STRING_t *GetPointer ();
87 BIT_STRING_t GetValue ();
88 // TODO maybe a to string or a decode method should be created
91 BIT_STRING_t *m_bitString;
94 class NrCellId : public SimpleRefCount<NrCellId>
97 NrCellId (uint16_t value);
99 BIT_STRING_t *GetPointer ();
100 BIT_STRING_t GetValue ();
103 Ptr<BitString> m_bitString;
107 * Wrapper for class for S-NSSAI
109 class Snssai : public SimpleRefCount<Snssai>
112 Snssai (std::string sst);
113 Snssai (std::string sst, std::string sd);
115 SNSSAI_t *GetPointer ();
116 SNSSAI_t GetValue ();
119 OCTET_STRING_t *m_sst;
120 OCTET_STRING_t *m_sd;
125 * Wrapper for class for MeasQuantityResults_t
127 class MeasQuantityResultsWrap : public SimpleRefCount<MeasQuantityResultsWrap>
130 MeasQuantityResultsWrap ();
131 ~MeasQuantityResultsWrap ();
132 MeasQuantityResults_t *GetPointer ();
133 MeasQuantityResults_t GetValue ();
134 void AddRsrp (long rsrp);
135 void AddRsrq (long rsrq);
136 void AddSinr (long sinr);
139 MeasQuantityResults_t *m_measQuantityResults;
143 * Wrapper for class for ResultsPerCSI_RS_Index_t
145 class ResultsPerCsiRsIndex : public SimpleRefCount<ResultsPerCsiRsIndex>
148 ResultsPerCsiRsIndex (long csiRsIndex, MeasQuantityResults_t *csiRsResults);
149 ResultsPerCsiRsIndex (long csiRsIndex);
150 ResultsPerCSI_RS_Index_t *GetPointer ();
151 ResultsPerCSI_RS_Index_t GetValue ();
154 ResultsPerCSI_RS_Index_t *m_resultsPerCsiRsIndex;
158 * Wrapper for class for ResultsPerSSB_Index_t
160 class ResultsPerSSBIndex : public SimpleRefCount<ResultsPerSSBIndex>
163 ResultsPerSSBIndex (long ssbIndex, MeasQuantityResults_t *ssbResults);
164 ResultsPerSSBIndex (long ssbIndex);
165 ResultsPerSSB_Index_t *GetPointer ();
166 ResultsPerSSB_Index_t GetValue ();
169 ResultsPerSSB_Index_t *m_resultsPerSSBIndex;
173 * Wrapper for class for MeasResultNR_t
175 class MeasResultNr : public SimpleRefCount<MeasResultNr>
178 enum ResultCell { SSB = 0, CSI_RS = 1 };
179 MeasResultNr (long physCellId);
182 MeasResultNR_t *GetPointer ();
183 MeasResultNR_t GetValue ();
184 void AddCellResults (ResultCell cell, MeasQuantityResults_t *results);
185 void AddPerSsbIndexResults (ResultsPerSSB_Index_t *resultsSsbIndex);
186 void AddPerCsiRsIndexResults (ResultsPerCSI_RS_Index_t *resultsCsiRsIndex);
187 void AddPhyCellId (long physCellId);
190 MeasResultNR_t *m_measResultNr;
195 * Wrapper for class for MeasResultEUTRA_t
197 class MeasResultEutra : public SimpleRefCount<MeasResultEutra>
200 MeasResultEutra (long eutraPhysCellId, long rsrp, long rsrq, long sinr);
201 MeasResultEutra (long eutraPhysCellId);
202 MeasResultEUTRA_t *GetPointer ();
203 MeasResultEUTRA_t GetValue ();
204 void AddRsrp (long rsrp);
205 void AddRsrq (long rsrq);
206 void AddSinr (long sinr);
209 MeasResultEUTRA_t *m_measResultEutra;
213 * Wrapper for class for MeasResultPCell_t
215 class MeasResultPCellWrap : public SimpleRefCount<MeasResultPCellWrap>
218 MeasResultPCellWrap (long eutraPhysCellId, long rsrpResult, long rsrqResult);
219 MeasResultPCellWrap (long eutraPhysCellId);
220 MeasResultPCell_t *GetPointer ();
221 MeasResultPCell_t GetValue ();
222 void AddRsrpResult (long rsrpResult);
223 void AddRsrqResult (long rsrqResult);
226 MeasResultPCell_t *m_measResultPCell;
230 * Wrapper for class for MeasResultServMO_t
232 class MeasResultServMo : public SimpleRefCount<MeasResultServMo>
235 MeasResultServMo (long servCellId, MeasResultNR_t measResultServingCell,
236 MeasResultNR_t *measResultBestNeighCell);
237 MeasResultServMo (long servCellId, MeasResultNR_t measResultServingCell);
238 MeasResultServMO_t *GetPointer ();
239 MeasResultServMO_t GetValue ();
242 MeasResultServMO_t *m_measResultServMo;
246 * Wrapper for class for ServingCellMeasurements_t
248 class ServingCellMeasurementsWrap : public SimpleRefCount<ServingCellMeasurementsWrap>
251 ServingCellMeasurementsWrap (ServingCellMeasurements_PR present);
252 ServingCellMeasurements_t *GetPointer ();
253 ServingCellMeasurements_t GetValue ();
254 void AddMeasResultPCell (MeasResultPCell_t *measResultPCell);
255 void AddMeasResultServMo (MeasResultServMO_t *measResultServMO);
258 ServingCellMeasurements_t *m_servingCellMeasurements;
259 MeasResultServMOList_t *m_nr_measResultServingMOList;
263 * Wrapper for class for L3 RRC Measurements
265 class L3RrcMeasurements : public SimpleRefCount<L3RrcMeasurements>
268 int MAX_MEAS_RESULTS_ITEMS = 8; // Maximum 8 per UE (standard)
269 L3RrcMeasurements (RRCEvent_t rrcEvent);
270 L3RrcMeasurements (L3_RRC_Measurements_t *l3RrcMeasurements);
271 ~L3RrcMeasurements ();
272 L3_RRC_Measurements_t *GetPointer ();
273 L3_RRC_Measurements_t GetValue ();
275 void AddMeasResultEUTRANeighCells (MeasResultEUTRA_t *measResultItemEUTRA);
276 void AddMeasResultNRNeighCells (MeasResultNR_t *measResultItemNR);
277 void AddServingCellMeasurement (ServingCellMeasurements_t *servingCellMeasurements);
278 void AddNeighbourCellMeasurement (long neighCellId, long sinr);
280 static Ptr<L3RrcMeasurements> CreateL3RrcUeSpecificSinrServing (long servingCellId,
281 long physCellId, long sinr);
283 static Ptr<L3RrcMeasurements> CreateL3RrcUeSpecificSinrNeigh ();
285 // TODO change definition and return the values (to be used for decoding)
286 static void ExtractMeasurementsFromL3RrcMeas (L3_RRC_Measurements_t *l3RrcMeasurements);
289 * Returns the input SINR on a 0-127 scale
291 * Refer to 3GPP TS 38.133 V17.2.0(2021-06), Table 10.1.16.1-1: SS-SINR and CSI-SINR measurement report mapping
296 static double ThreeGppMapSinr (double sinr);
299 void addMeasResultNeighCells (MeasResultNeighCells_PR present);
300 L3_RRC_Measurements_t *m_l3RrcMeasurements;
301 MeasResultListEUTRA_t *m_measResultListEUTRA;
302 MeasResultListNR_t *m_measResultListNR;
303 int m_measItemsCounter;
307 * Wrapper for class for PM_Info_Item_t
309 class MeasurementItem : public SimpleRefCount<MeasurementItem>
312 MeasurementItem (std::string name, long value);
313 MeasurementItem (std::string name, double value);
314 MeasurementItem (std::string name, Ptr<L3RrcMeasurements> value);
316 PM_Info_Item_t *GetPointer ();
317 PM_Info_Item_t GetValue ();
320 MeasurementItem (std::string name);
321 void CreateMeasurementValue (MeasurementValue_PR measurementValue_PR);
322 // Main struct to be compiled
323 PM_Info_Item_t *m_measurementItem;
325 // Accessory structs that we must track to release memory after use
326 MeasurementTypeName_t *m_measName;
327 MeasurementValue_t *m_pmVal;
328 MeasurementType_t *m_pmType;
332 * Wrapper for class for RANParameter_Item_t
334 class RANParameterItem : public SimpleRefCount<RANParameterItem>
337 enum ValueType{ Nothing = 0, Int = 1, OctectString = 2 };
338 RANParameterItem (RANParameter_Item_t *ranParameterItem);
339 ~RANParameterItem ();
340 RANParameter_Item_t *GetPointer ();
341 RANParameter_Item_t GetValue ();
343 ValueType m_valueType;
345 Ptr<OctetString> m_valueStr;
347 static std::vector<RANParameterItem>
348 ExtractRANParametersFromRANParameter (RANParameter_Item_t *ranParameterItem);
352 RANParameter_Item_t *m_ranParameterItem;
353 BOOLEAN_t *m_keyFlag;
357 #endif /* ASN1C_TYPES_H */