- 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;
- std::string ueId;
-
- fprintf(stderr,"UE number %d\n", i);
-
- json::json_pointer p001(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/ue-id");
- ueId = all_ues_json[p001].get<std::string>();
- fprintf(stderr, "UEID %s\n", ueId.c_str());
-
- 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[3] = {0, };
-
- if (ueId.find("Pedestrian") != string::npos) {
- std::string ind = ueId.substr(11);
- fprintf(stderr, "ind is %s\n", ind.c_str());
-
- int indval = std::stoi(ind);
-
- if (indval < 10) {
- crnti_buf[1] = indval;
- crnti_buf[0] = 0;
- } else {
- crnti_buf[0] = indval/10;
- crnti_buf[1] = indval % 10;
- }
-
- } else if (ueId.find("Car") != string::npos) {
- crnti_buf[0] = 4;
- crnti_buf[1] = 1;
- }
-
- // uint8_t *buf2 = (uint8_t*)"12";
-
- 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 += ",";
-
- }
-
-
- uint8_t neighbor_cellid_buf[6] = {0, };
- neighbor_cellid_buf[0] = 0x22;
- neighbor_cellid_buf[1] = 0x5B;
- neighbor_cellid_buf[2] = 0xD6;
- neighbor_cellid_buf[3] = nextNbCell;
- neighbor_cellid_buf[4] = 0x70;
-
- char cid_buf[25] = {0, };
- get_cell_id(neighbor_cellid_buf,cid_buf);
-
-
- neighbor_str += "{\"CID\" : \"" + std::string(cid_buf) + "\", \"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 nrcellid_buf[6] = {0, };
- nrcellid_buf[0] = 0x22;
- nrcellid_buf[1] = 0x5B;
- nrcellid_buf[2] = 0xD6;
- nrcellid_buf[3] = nextCellId;
- nrcellid_buf[4] = 0x70;
-
- uint8_t gnbid_buf[4] = {0, };
- gnbid_buf[0] = 0x22;
- gnbid_buf[1] = 0x5B;
- gnbid_buf[2] = 0xD6;
-
- uint8_t cuupid_buf[2] = {0, };
- cuupid_buf[0] = 20000;
-
- uint8_t duid_buf[2] = {0, };
- duid_buf[0] = 20000;
-
- uint8_t *cuupname_buf = (uint8_t*)"GNBCUUP5";
-
-
- 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] = {0, };
- size_t e2sm_message_buf_size_cucp_ue = 8192;
-
- asn_codec_ctx_t *opt_cod;
-
-
- 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);
- ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_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, plmnid_buf, sst_buf, sd_buf, fqival, qcival, nrcellid_buf, gnbid_buf, 0, cuupid_buf, duid_buf, cuupname_buf);
- fprintf(stderr, "Now printing xer outside of function call\n");
- xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationHeader, ind_header_cucp_ue);
-
- uint8_t e2sm_header_buf_cucp_ue[8192] = {0, };
- 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);
- ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, ind_header_cucp_ue);
-
- fprintf(stderr, "er encded is %d\n", er_header_cucp_ue.encoded);
- fprintf(stderr, "error buf is %s\n", (char*)e2sm_header_buf_cucp_ue);
- fprintf(stderr, "after encoding header\n");
-
- 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);
-
- seqNum++;
-
- std::this_thread::sleep_for (std::chrono::milliseconds(50));
-
- //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] = {0, };
- size_t e2sm_message_buf_size_cuup_ue = 8192;
-
- asn_codec_ctx_t *opt_cod2;
-
-
- 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);
- ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_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, plmnid_buf, sst_buf, sd_buf, fqival, qcival, nrcellid_buf, gnbid_buf, 0, cuupid_buf, duid_buf, cuupname_buf);
-
- uint8_t e2sm_header_buf_cuup_ue[8192] = {0, };
- 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);
- ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, ind_header_cuup_ue);
-
-
- E2AP_PDU *pdu_cuup_ue = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
-
- encoding::generate_e2apv1_indication_request_parameterized(pdu_cuup_ue, requestorId,
- instanceId, ranFunctionId,
- actionId, seqNum, e2sm_header_buf_cuup_ue,
- er_header_cuup_ue.encoded,
- e2sm_message_buf_cuup_ue, er_message_cuup_ue.encoded);
-
- e2sim.encode_and_send_sctp_data(pdu_cuup_ue);
-
- seqNum++;
-
- std::this_thread::sleep_for (std::chrono::milliseconds(50));
-
- //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] = {0, };
- size_t e2sm_message_buf_size_du_ue = 8192;
-
- asn_codec_ctx_t *opt_cod3;
-
-
- 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);
- ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_message_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, plmnid_buf, sst_buf, sd_buf, fqival, qcival, nrcellid_buf, gnbid_buf, 0, cuupid_buf, duid_buf, cuupname_buf);
-
- uint8_t e2sm_header_buf_du_ue[8192] = {0, };
- 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);
- ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, ind_header_du_ue);
-
-
- E2AP_PDU *pdu_du_ue = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
-
- encoding::generate_e2apv1_indication_request_parameterized(pdu_du_ue, requestorId,
- instanceId, ranFunctionId,
- actionId, seqNum,
- e2sm_header_buf_du_ue, er_header_du_ue.encoded,
- e2sm_message_buf_du_ue, er_message_du_ue.encoded);
-
- e2sim.encode_and_send_sctp_data(pdu_du_ue);
-
- seqNum++;
-
- std::this_thread::sleep_for (std::chrono::milliseconds(50));
-
- fprintf(stderr, "done with ue meas report\n");
- }