+ try {
+ all_ues_json = json::parse(str);
+
+ valid = true;
+ } catch (...) {
+ fprintf(stderr, "Exception on reading json\n");
+ }
+
+ if (valid) {
+
+ fprintf(stderr, "key is valid\n");
+
+ std::string first_key = all_ues_json.begin().key();
+ fprintf(stderr, "first key is %s\n", first_key.c_str());
+
+ if (first_key.compare("ueMeasReport") == 0) {
+
+ fprintf(stderr, "it is equal to ue meas report\n");
+
+ int numMeasReports = (all_ues_json["/ueMeasReport/ueMeasReportList"_json_pointer]).size();
+
+
+ for (int i = 0; i < numMeasReports; i++) {
+ int nextCellId;
+ int nextRsrp;
+ int nextRsrq;
+ int nextRssinr;
+ float tput;
+ int prb_usage;
+ fprintf(stderr,"UE number %d\n", i);
+
+ json::json_pointer p0(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/throughput");
+ tput = all_ues_json[p0].get<float>();
+ fprintf(stderr, "Throughput %f\n", tput);
+
+ json::json_pointer p00(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/prb_usage");
+ prb_usage = all_ues_json[p00].get<int>();
+ fprintf(stderr, "Throughput %d\n", prb_usage);
+
+ json::json_pointer p1(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/nrCellIdentity");
+ nextCellId = all_ues_json[p1].get<int>();
+ fprintf(stderr, "Serving Cell %d\n",nextCellId);
+
+ json::json_pointer p2(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rsrp");
+ nextRsrp = all_ues_json[p2].get<int>();
+ fprintf(stderr," RSRP %d\n", nextRsrp);
+
+ json::json_pointer p3(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rsrq");
+ nextRsrq = all_ues_json[p3].get<int>();
+ fprintf(stderr," RSRQ %d\n",nextRsrq);
+
+ json::json_pointer p4(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rssinr");
+ nextRssinr = all_ues_json[p4].get<int>();
+ fprintf(stderr," RSSINR %d\n", nextRssinr);
+
+ json::json_pointer p5(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList");
+
+ uint8_t *crnti_buf = (uint8_t*)calloc(1,2);
+
+ uint8_t *buf2 = (uint8_t*)"12";
+ memcpy(crnti_buf, buf2, 2);
+
+
+ std::string serving_str = "{\"rsrp\": " + std::to_string(nextRsrp) + ", \"rsrq\": " +
+ std::to_string(nextRsrq) + ", \"rssinr\": " + std::to_string(nextRssinr) + "}";
+ const uint8_t *serving_buf = reinterpret_cast<const uint8_t*>(serving_str.c_str());
+
+ int numNeighborCells = (all_ues_json[p5]).size();
+
+ std::string neighbor_str = "[";
+
+ int nextNbCell;
+ int nextNbRsrp;
+ int nextNbRsrq;
+ int nextNbRssinr;
+
+ for (int j = 0; j < numNeighborCells; j++) {
+ json::json_pointer p8(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList/" + std::to_string(j) + "/nbCellIdentity");
+ nextNbCell = all_ues_json[p8].get<int>();
+ //cout << "Neighbor Cell " << all_ues_json[p8] << endl;
+ json::json_pointer p9(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i)
+ +"/neighbourCellList/" + std::to_string(j) + "/nbCellRfReport/rsrp");
+ nextNbRsrp = all_ues_json[p9].get<int>();
+ //cout << " RSRP " << nextNbRsrp << endl;
+
+ json::json_pointer p10(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i)
+ +"/neighbourCellList/" + std::to_string(j) + "/nbCellRfReport/rsrq");
+ nextNbRsrq = all_ues_json[p10].get<int>();
+ //cout << " RSRQ " << nextNbRsrq << endl;
+
+ json::json_pointer p11(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i)
+ +"/neighbourCellList/" + std::to_string(j) + "/nbCellRfReport/rssinr");
+ nextNbRssinr = all_ues_json[p11].get<int>();
+ //cout << " RSSINR " << nextNbRssinr << endl;
+
+ if (j != 0) {
+ neighbor_str += ",";
+
+ }
+
+ neighbor_str += "{\"CID\" : \"" + std::to_string(nextNbCell) + "\", \"Cell-RF\" : \"{\"rsrp\": " + std::to_string(nextNbRsrp) +
+ ", \"rsrq\": " + std::to_string(nextNbRsrq) + ", \"rssinr\": " + std::to_string(nextNbRssinr) + "}}";
+
+ }
+
+ neighbor_str += "]";
+
+ fprintf(stderr,"This is neighbor str %s\n", neighbor_str.c_str());
+
+ //Creating UE-level RAN-Container CUCP message
+
+ fprintf(stderr,"Creating UE-level RAN-Container CUCP message\n");
+
+ const uint8_t *neighbor_buf = reinterpret_cast<const uint8_t*>(neighbor_str.c_str());
+ uint8_t *plmnid_buf = (uint8_t*)"747";
+ uint8_t *nrcellid_buf = (uint8_t*)"12340";
+
+ E2SM_KPM_IndicationMessage_t *ind_msg_cucp_ue =
+ (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
+
+ encode_kpm_report_rancontainer_cucp_parameterized(ind_msg_cucp_ue, plmnid_buf, nrcellid_buf, crnti_buf, serving_buf, neighbor_buf);
+
+ uint8_t e2sm_message_buf_cucp_ue[8192];
+ size_t e2sm_message_buf_size_cucp_ue = 8192;
+
+ asn_codec_ctx_t *opt_cod;
+
+ long requestorId = 9;
+ long instanceId = 8;
+ long ranFunctionId = 2;
+ long actionId = 4;
+
+ asn_enc_rval_t er_message_cucp_ue = asn_encode_to_buffer(opt_cod,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationMessage,
+ ind_msg_cucp_ue, e2sm_message_buf_cucp_ue, e2sm_message_buf_size_cucp_ue);
+
+ fprintf(stderr, "er encded is %d\n", er_message_cucp_ue.encoded);
+ fprintf(stderr, "after encoding message\n");
+
+ E2SM_KPM_IndicationHeader_t* ind_header_cucp_ue =
+ (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t));
+ encode_e2sm_kpm_indication_header(ind_header_cucp_ue);
+
+ uint8_t e2sm_header_buf_cucp_ue[8192];
+ size_t e2sm_header_buf_size_cucp_ue = 8192;
+
+ asn_enc_rval_t er_header_cucp_ue = asn_encode_to_buffer(opt_cod,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationHeader,
+ ind_header_cucp_ue, e2sm_header_buf_cucp_ue, e2sm_header_buf_size_cucp_ue);
+
+ E2AP_PDU *pdu_cucp_ue = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
+
+ encoding::generate_e2apv1_indication_request_parameterized(pdu_cucp_ue, requestorId,
+ instanceId, ranFunctionId,
+ actionId, seqNum, e2sm_header_buf_cucp_ue,
+ er_header_cucp_ue.encoded, e2sm_message_buf_cucp_ue,
+ er_message_cucp_ue.encoded);
+
+ // e2sim.encode_and_send_sctp_data(pdu_cucp_ue);
+
+ //Creating UE-level RAN-Container CUUP message
+
+ fprintf(stderr,"Creating UE-level RAN-Container CUUP message\n");
+
+ E2SM_KPM_IndicationMessage_t *ind_msg_cuup_ue =
+ (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
+
+ long bytes = (long)(tput * 100);
+
+ encode_kpm_report_rancontainer_cuup_parameterized(ind_msg_cuup_ue, plmnid_buf, nrcellid_buf, crnti_buf, bytes, 0);
+
+ uint8_t e2sm_message_buf_cuup_ue[8192];
+ size_t e2sm_message_buf_size_cuup_ue = 8192;
+
+ asn_codec_ctx_t *opt_cod2;
+
+ long requestorId2 = 9;
+ long instanceId2 = 8;
+ long ranFunctionId2 = 2;
+ long actionId2 = 4;
+
+ asn_enc_rval_t er_message_cuup_ue = asn_encode_to_buffer(opt_cod2,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationMessage,
+ ind_msg_cuup_ue, e2sm_message_buf_cuup_ue, e2sm_message_buf_size_cuup_ue);
+
+ fprintf(stderr, "er encded is %d\n", er_message_cuup_ue.encoded);
+ fprintf(stderr, "after encoding message\n");
+
+ E2SM_KPM_IndicationHeader_t* ind_header_cuup_ue =
+ (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t));
+ encode_e2sm_kpm_indication_header(ind_header_cuup_ue);
+
+ uint8_t e2sm_header_buf_cuup_ue[8192];
+ size_t e2sm_header_buf_size_cuup_ue = 8192;
+
+ asn_enc_rval_t er_header_cuup_ue = asn_encode_to_buffer(opt_cod,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationHeader,
+ ind_header_cuup_ue, e2sm_header_buf_cuup_ue, e2sm_header_buf_size_cuup_ue);
+
+
+ E2AP_PDU *pdu_cuup_ue = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
+
+ encoding::generate_e2apv1_indication_request_parameterized(pdu_cuup_ue, requestorId2,
+ instanceId2, ranFunctionId2,
+ actionId2, seqNum, e2sm_header_buf_cuup_ue,
+ er_header_cuup_ue.encoded,
+ e2sm_message_buf_cuup_ue, er_message_cuup_ue.encoded);
+
+ //Creating UE-level RAN-Container DU message
+
+ fprintf(stderr,"Creating UE-level RAN-Container DU message\n");
+
+ E2SM_KPM_IndicationMessage_t *ind_message_du_ue =
+ (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
+
+ encode_kpm_report_rancontainer_du_parameterized(ind_message_du_ue,
+ plmnid_buf, nrcellid_buf, crnti_buf, prb_usage, 0);
+
+ uint8_t e2sm_message_buf_du_ue[8192];
+ size_t e2sm_message_buf_size_du_ue = 8192;
+
+ asn_codec_ctx_t *opt_cod3;
+
+ long requestorId3 = 9;
+ long instanceId3 = 8;
+ long ranFunctionId3 = 2;
+ long actionId3 = 4;
+
+ asn_enc_rval_t er_message_du_ue = asn_encode_to_buffer(opt_cod3,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationMessage,
+ ind_message_du_ue,
+ e2sm_message_buf_du_ue,
+ e2sm_message_buf_size_du_ue);
+
+ fprintf(stderr, "er encded is %d\n", er_message_du_ue.encoded);
+ fprintf(stderr, "after encoding message\n");
+
+ E2SM_KPM_IndicationHeader_t* ind_header_du_ue =
+ (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t));
+ encode_e2sm_kpm_indication_header(ind_header_du_ue);
+
+ uint8_t e2sm_header_buf_du_ue[8192];
+ size_t e2sm_header_buf_size_du_ue = 8192;
+
+ asn_enc_rval_t er_header_du_ue = asn_encode_to_buffer(opt_cod,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationHeader,
+ ind_header_du_ue, e2sm_header_buf_du_ue,
+ e2sm_header_buf_size_du_ue);
+
+
+ E2AP_PDU *pdu_du_ue = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
+
+ encoding::generate_e2apv1_indication_request_parameterized(pdu_du_ue, requestorId3,
+ instanceId3, ranFunctionId3,
+ actionId3, seqNum,
+ e2sm_header_buf_du_ue, er_header_du_ue.encoded,
+ e2sm_message_buf_du_ue, er_message_du_ue.encoded);
+
+ fprintf(stderr, "done with ue meas report\n");
+ }
+
+ } else if (first_key.compare("cellMeasReport") == 0) {
+
+ fprintf(stderr, "it is equal to cell meas report\n");
+
+ int numMeasReports = (all_ues_json["/cellMeasReport/cellMeasReportList"_json_pointer]).size();
+
+ for (int i = 0; i < numMeasReports; i++) {
+ int nextCellId;
+
+ float bytes_dl;
+ float bytes_ul;
+ int prb_dl;
+ int prb_ul;
+
+ fprintf(stderr,"UE number %d\n", i);
+
+ json::json_pointer p0(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/pdcpByteMeasReport/pdcpBytesDl");
+ bytes_dl = all_ues_json[p0].get<float>();
+ fprintf(stderr, "Bytes DL %f\n", bytes_dl);
+
+ json::json_pointer p1(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/pdcpByteMeasReport/pdcpBytesUl");
+ bytes_ul = all_ues_json[p1].get<float>();
+ fprintf(stderr, "Bytes UL %f\n", bytes_ul);
+
+ json::json_pointer p2(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/prbMeasReport/availPrbDl");
+ prb_dl = all_ues_json[p2].get<int>();
+ fprintf(stderr, "Avail PRB DL %d\n", prb_dl);
+
+ json::json_pointer p3(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/prbMeasReport/availPrbUl");
+ prb_ul = all_ues_json[p3].get<int>();
+ fprintf(stderr, "Avail PRB UL %d\n", prb_ul);
+
+ uint8_t *buf = (uint8_t*)"GNBCUUP5";
+
+ uint8_t *sst_buf = (uint8_t*)"1";
+ uint8_t *sd_buf = (uint8_t*)"100";
+ uint8_t *plmnid_buf = (uint8_t*)"747";
+
+
+ //Encoding Style 5 Message Body
+
+ fprintf(stderr, "Encoding Style 5 Message body\n");
+
+ asn_codec_ctx_t *opt_cod;
+
+ E2SM_KPM_IndicationMessage_t *ind_msg_style5 =
+ (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
+ E2AP_PDU *pdu_style5 = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
+
+ encode_kpm_report_style5_parameterized(ind_msg_style5 , buf, bytes_dl, bytes_ul, sst_buf, sd_buf, plmnid_buf);
+
+ uint8_t e2sm_message_buf_style5[8192];
+ size_t e2sm_message_buf_size_style5 = 8192;
+
+ asn_enc_rval_t er_message_style5 = asn_encode_to_buffer(opt_cod,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationMessage,
+ ind_msg_style5, e2sm_message_buf_style5, e2sm_message_buf_size_style5);
+
+ fprintf(stderr, "er encded is %d\n", er_message_style5.encoded);
+ fprintf(stderr, "after encoding message\n");
+
+ //Encode header
+ // encode_kpm_indication_header();
+
+ int seqNum0 = 1;
+
+ long requestorId = 9;
+ long instanceId = 8;
+ long ranFunctionId = 2;
+ long actionId = 4;
+
+ E2SM_KPM_IndicationHeader_t* ind_header_style5 =
+ (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t));
+ encode_e2sm_kpm_indication_header(ind_header_style5);
+
+ uint8_t e2sm_header_buf_style5[8192];
+ size_t e2sm_header_buf_size_style5 = 8192;
+
+ asn_enc_rval_t er_header_style5 = asn_encode_to_buffer(opt_cod,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationHeader,
+ ind_header_style5,
+ e2sm_header_buf_style5, e2sm_header_buf_size_style5);
+
+
+ encoding::generate_e2apv1_indication_request_parameterized(pdu_style5, requestorId,
+ instanceId, ranFunctionId,
+ actionId, seqNum0, e2sm_header_buf_style5,
+ er_header_style5.encoded, e2sm_message_buf_style5,
+ er_message_style5.encoded);
+
+ // e2sim.encode_and_send_sctp_data(pdu2);
+
+ //Encoding Style 1 Message Body
+
+ fprintf(stderr, "Encoding Style 1 Message body\n");
+ asn_codec_ctx_t *opt_cod2;
+
+
+ E2SM_KPM_IndicationMessage_t *ind_message_style1 =
+ (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
+ E2AP_PDU *pdu_style1 = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
+
+ long fiveqi = 7;
+
+ uint8_t *nrcellid_buf = (uint8_t*)"12340";
+
+ long l_dl_prbs = prb_dl;
+ long l_ul_prbs = prb_ul;
+
+ encode_kpm_report_style1_parameterized(ind_message_style1, fiveqi,
+ prb_dl, prb_ul, sst_buf, sd_buf,
+ plmnid_buf, nrcellid_buf, &l_dl_prbs, &l_ul_prbs);
+
+ uint8_t e2sm_message_buf_style1[8192];
+ size_t e2sm_message_buf_size_style1 = 8192;
+
+ asn_enc_rval_t er_message_style1 = asn_encode_to_buffer(opt_cod2,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationMessage,
+ ind_message_style1,
+ e2sm_message_buf_style1, e2sm_message_buf_size_style1);
+
+ fprintf(stderr, "er encded is %d\n", er_message_style1.encoded);
+ fprintf(stderr, "after encoding message\n");
+
+
+ uint8_t *cpid_buf2 = (uint8_t*)"CPID";
+
+ fprintf(stderr, "About to encode Indication\n");
+
+ E2SM_KPM_IndicationHeader_t* ind_header_style1 =
+ (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t));
+ encode_e2sm_kpm_indication_header(ind_header_style1);
+
+ uint8_t e2sm_header_buf_style1[8192];
+ size_t e2sm_header_buf_size_style1 = 8192;
+
+ asn_enc_rval_t er_header_style1 = asn_encode_to_buffer(opt_cod,
+ ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_KPM_IndicationHeader,
+ ind_header_style1,
+ e2sm_header_buf_style1, e2sm_header_buf_size_style1);
+
+ encoding::generate_e2apv1_indication_request_parameterized(pdu_style1, requestorId,
+ instanceId, ranFunctionId,
+ actionId, seqNum, e2sm_header_buf_style1,
+ er_header_style1.encoded,
+ e2sm_message_buf_style1, er_message_style1.encoded);
+
+ // e2sim.encode_and_send_sctp_data(pdu);
+
+
+
+ }
+ }
+ }
+ }
+
+ asn_codec_ctx_t *opt_cod;
+