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>
25 #ifndef KPM_INDICATION_H
26 #define KPM_INDICATION_H
28 #include "ns3/object.h"
32 #include "E2SM-KPM-RANfunction-Description.h"
33 #include "E2SM-KPM-IndicationHeader.h"
34 #include "E2SM-KPM-IndicationMessage.h"
35 #include "RAN-Container.h"
36 #include "PF-Container.h"
37 #include "OCUUP-PF-Container.h"
38 #include "OCUCP-PF-Container.h"
39 #include "ODU-PF-Container.h"
40 #include "PF-ContainerListItem.h"
41 #include "asn1c-types.h"
46 class KpmIndicationHeader : public SimpleRefCount<KpmIndicationHeader>
49 enum GlobalE2nodeType { gNB = 0, eNB = 1, ng_eNB = 2, en_gNB = 3 };
51 const static int TIMESTAMP_LIMIT_SIZE = 8;
53 * Holds the values to be used to fill the RIC Indication header
55 struct KpmRicIndicationHeaderValues
57 // E2SM-KPM Indication Header Format 1
59 std::string m_gnbId; //!< gNB ID bit string
61 // uint64_t m_cuUpId; //!< gNB-CU-UP ID, integer [0, 2^36-1], optional
63 // Cell Global ID (NR CGI) IE
64 uint16_t m_nrCellId; //!< NR, bit string
67 std::string m_plmId; //!< PLMN identity, octet string, 3 bytes
69 // Slice ID (S-NSSAI) IE // TODO not supported
70 // std::string m_sst; //!< SNSSAI sST, 1 byte
71 // std::string m_sd; //!< SNSSAI sD, 3 bytes, optional
73 // FiveQI IE // TODO not supported
74 // uint8_t m_fiveqi; //!< fiveQI, integer [0, 255], optional
76 // QCI IE // TODO not supported
77 // long m_qci; //!< QCI, integer [0, 255], optional
79 // TODO this value is placed in a fiels which seems not to be defined
80 // in the specs. See line 301 in encode_kpm.cpp
81 // the field is called gNB_DU_ID
82 // it should be part of KPM Node ID IE
85 // TODO this value is placed in a fiels which seems not to be defined
86 // in the specs. See line 290 in encode_kpm.cpp, the field is called
90 // CollectionTimeStamp
94 KpmIndicationHeader (GlobalE2nodeType nodeType,KpmRicIndicationHeaderValues values);
95 ~KpmIndicationHeader ();
101 * Fills the KPM INDICATION Header descriptor
102 * This function fills the RIC Indication Header with the provided
105 * \param descriptor object representing the KPM INDICATION Header
106 * \param values struct holding the values to be used to fill the header
108 void FillAndEncodeKpmRicIndicationHeader (E2SM_KPM_IndicationHeader_t* descriptor,
109 KpmRicIndicationHeaderValues values);
111 void Encode (E2SM_KPM_IndicationHeader_t* descriptor);
113 GlobalE2nodeType m_nodeType;
116 class MeasurementItemList : public SimpleRefCount<MeasurementItemList>
119 Ptr<OctetString> m_id; // ID, contains the UE IMSI if used to carry UE-specific measurement items
120 std::vector<Ptr<MeasurementItem>> m_items; //!< list of Measurement Information Items
122 MeasurementItemList ();
123 MeasurementItemList (std::string ueId);
124 ~MeasurementItemList ();
126 // NOTE defined here to avoid undefined references
128 void AddItem (std::string name, T value)
130 Ptr<MeasurementItem> item = Create<MeasurementItem> (name, value);
131 m_items.push_back (item);
134 std::vector<Ptr<MeasurementItem>> GetItems();
135 OCTET_STRING_t GetId ();
139 * Base class to carry PM Container values
141 class PmContainerValues : public SimpleRefCount<PmContainerValues>
144 virtual ~PmContainerValues () = default;
148 * Contains the values to be inserted in the O-CU-CP Measurement Container
150 class OCuCpContainerValues : public PmContainerValues
153 uint16_t m_numActiveUes; //!< mean number of RRC connections
157 * Contains the values to be inserted in the O-CU-UP Measurement Container
159 class OCuUpContainerValues : public PmContainerValues
162 std::string m_plmId; //!< PLMN identity, octet string, 3 bytes
163 long m_pDCPBytesUL; //!< total PDCP bytes transmitted UL
164 long m_pDCPBytesDL; //!< total PDCP bytes transmitted DL
168 * Contains the values to be inserted in the O-DU EPC Measurement Container
170 class EpcDuPmContainer : public SimpleRefCount<EpcDuPmContainer>
173 long m_qci; //!< QCI value
174 long m_dlPrbUsage; //!< Used number of PRBs in an average of DL for the monitored slice during E2 reporting period
175 long m_ulPrbUsage; //!< Used number of PRBs in an average of UL for the monitored slice during E2 reporting period
176 virtual ~EpcDuPmContainer () = default;
180 * Contains the values to be inserted in the O-DU 5GC Measurement Container
182 class FiveGcDuPmContainer : public SimpleRefCount<FiveGcDuPmContainer>
185 // Snssai m_sliceId; //!< S-NSSAI
186 long m_fiveQi; //!< 5QI value
187 long m_dlPrbUsage; //!< Used number of PRBs in an average of DL for the monitored slice during E2 reporting period
188 long m_ulPrbUsage; //!< Used number of PRBs in an average of UL for the monitored slice during E2 reporting period
189 virtual ~FiveGcDuPmContainer () = default;
192 class ServedPlmnPerCell : public SimpleRefCount<ServedPlmnPerCell>
195 std::string m_plmId; //!< PLMN identity, octet string, 3 bytes
197 std::set<Ptr<EpcDuPmContainer>> m_perQciReportItems;
200 class CellResourceReport : public SimpleRefCount<CellResourceReport>
203 std::string m_plmId; //!< PLMN identity, octet string, 3 bytes
205 long dlAvailablePrbs;
206 long ulAvailablePrbs;
207 std::set<Ptr<ServedPlmnPerCell>> m_servedPlmnPerCellItems;
211 * Contains the values to be inserted in the O-DU Measurement Container
213 class ODuContainerValues : public PmContainerValues
216 std::set<Ptr<CellResourceReport>> m_cellResourceReportItems;
219 class KpmIndicationMessage : public SimpleRefCount<KpmIndicationMessage>
224 * Holds the values to be used to fill the RIC Indication Message
226 struct KpmIndicationMessageValues
228 std::string m_cellObjectId; //!< Cell Object ID
229 Ptr<PmContainerValues> m_pmContainerValues; //!< struct containing values to be inserted in the PM Container
230 Ptr<MeasurementItemList> m_cellMeasurementItems; //!< list of cell-specific Measurement Information Items
231 std::set<Ptr<MeasurementItemList>> m_ueIndications; //!< list of Measurement Information Items
234 KpmIndicationMessage (KpmIndicationMessageValues values);
235 ~KpmIndicationMessage ();
241 static void CheckConstraints (KpmIndicationMessageValues values);
242 void FillPmContainer (PF_Container_t *ranContainer,
243 Ptr<PmContainerValues> values);
244 void FillOCuUpContainer (PF_Container_t *ranContainer,
245 Ptr<OCuUpContainerValues> values);
246 void FillOCuCpContainer (PF_Container_t *ranContainer,
247 Ptr<OCuCpContainerValues> values);
248 void FillODuContainer (PF_Container_t *ranContainer,
249 Ptr<ODuContainerValues> values);
250 void FillAndEncodeKpmIndicationMessage (E2SM_KPM_IndicationMessage_t *descriptor,
251 KpmIndicationMessageValues values);
252 void Encode (E2SM_KPM_IndicationMessage_t *descriptor);
256 #endif /* KPM_INDICATION_H */