Issue-ID: SIM-18 86/4386/1
authorRon Shacham <rshacham@research.att.com>
Tue, 14 Jul 2020 14:48:59 +0000 (10:48 -0400)
committerRon Shacham <rshacham@research.att.com>
Tue, 14 Jul 2020 14:48:59 +0000 (10:48 -0400)
Signed-off-by: Ron Shacham <rshacham@research.att.com>
Change-Id: I721900ab0c0c027ecb19fd6aa86a4396499f3883

e2sim/e2apv1sim/cellMeasReport.txt [new file with mode: 0644]
e2sim/e2apv1sim/encode_e2apv1.cpp
e2sim/e2apv1sim/encode_e2apv1.hpp
e2sim/e2apv1sim/encode_kpm.cpp
e2sim/e2apv1sim/encode_kpm.hpp
e2sim/e2apv1sim/kpm_callbacks.cpp
e2sim/e2apv1sim/ueMeasReport.txt [new file with mode: 0644]

diff --git a/e2sim/e2apv1sim/cellMeasReport.txt b/e2sim/e2apv1sim/cellMeasReport.txt
new file mode 100644 (file)
index 0000000..2c0890f
--- /dev/null
@@ -0,0 +1,40 @@
+{
+    "cellMeasReport": {
+        "du-id": 1000,                            
+        "cellMeasReportList": [  
+           
+           {                                      
+              "nrCellIdentity": 0,                
+              "pdcpByteMeasReport": {
+                  "measTimestampPdcpBytes": "2020-04-09 14:33:33,559",  
+                  "measPeriodPdcpBytes": 10,      
+                  "pdcpBytesDl": 0,               
+                  "pdcpBytesUl": 0                
+              },
+              "prbMeasReport": { 
+                  "measTimestampPrb": "2020-04-09 14:33:33,559", 
+                  "measPeriodPrb": 0,             
+                  "availPrbDl": 0,                
+                  "availPrbUl": 0                 
+              }  
+           },
+
+           {
+              "nrCellIdentity": 1,               
+              "pdcpByteMeasReport": {
+                  "measTimestampPdcpBytes": "2020-04-09 14:33:33,559", 
+                  "measPeriodPdcpBytes": 0, 
+                  "pdcpBytesDl": 0, 
+                  "pdcpBytesUl": 0 
+              },
+              "prbMeasReport": { 
+                  "measTimestampPrb": "2020-04-09 14:33:33,559", 
+                  "measPeriodPrb": 0, 
+                  "availPrbDl": 0, 
+                  "availPrbUl": 0 
+              }  
+           }
+        ]             
+    }
+}
+
index 59c59d6..7484a45 100644 (file)
@@ -8,8 +8,32 @@
 
 
 #include "encode_e2apv1.hpp"
+
+extern "C" {
 #include "E2SM-KPM-RANfunction-Description.h"
 
+#include "e2ap_asn1c_codec.h"
+#include "GlobalE2node-ID.h"
+#include "GlobalE2node-gNB-ID.h"
+#include "GlobalgNB-ID.h"
+#include "OCTET_STRING.h"
+#include "asn_application.h"
+#include "GNB-ID-Choice.h"
+#include "ProtocolIE-Field.h"
+#include "E2setupRequest.h"
+#include "RICaction-ToBeSetup-Item.h"
+#include "RICactions-ToBeSetup-List.h"
+#include "RICeventTriggerDefinition.h"
+#include "RICsubscriptionRequest.h"
+#include "RICsubscriptionResponse.h"
+#include "ProtocolIE-SingleContainer.h"
+#include "RANfunctions-List.h"
+#include "RICindication.h"
+#include "RICsubsequentActionType.h"
+#include "RICsubsequentAction.h"  
+#include "RICtimeToWait.h"
+  
+}
 
 void generate_e2apv1_setup_request(E2AP_PDU_t *e2ap_pdu) {
   
index 29f8d20..e825cb8 100644 (file)
@@ -1,38 +1,25 @@
 
-
+#ifndef ENCODE_E2APV1_HPP
+#define ENCODE_E2APV1_HPP
+/*
 #include <stdio.h>
 #include <unistd.h>
 #include <assert.h>
+*/
 
+//#include <stdio>
+//#include <unistd.h>
+//#include <assert.h>
 
-#include "e2sim_sctp.hpp"
-#include "e2ap_message_handler.hpp"
+//#include "e2sim_sctp.hpp"
+//#include "e2ap_message_handler.hpp"
 #include "encode_kpm.hpp"
 
 
 extern "C" {
-#include "e2sim_defs.h"
+  //#include "e2sim_defs.h"
 #include "E2AP-PDU.h"
-#include "e2ap_asn1c_codec.h"
-#include "GlobalE2node-ID.h"
-#include "GlobalE2node-gNB-ID.h"
-#include "GlobalgNB-ID.h"
-#include "OCTET_STRING.h"
-#include "asn_application.h"
-#include "GNB-ID-Choice.h"
-#include "ProtocolIE-Field.h"
-#include "E2setupRequest.h"
-#include "RICaction-ToBeSetup-Item.h"
-#include "RICactions-ToBeSetup-List.h"
-#include "RICeventTriggerDefinition.h"
-#include "RICsubscriptionRequest.h"
-#include "RICsubscriptionResponse.h"
-#include "ProtocolIE-SingleContainer.h"
-#include "RANfunctions-List.h"
-#include "RICindication.h"
-#include "RICsubsequentActionType.h"
-#include "RICsubsequentAction.h"  
-#include "RICtimeToWait.h"
+
 
 }
 
@@ -51,3 +38,5 @@ void generate_e2apv1_indication_request(E2AP_PDU_t *ind_req_pdu);
 void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqActionIdsAccepted[], long reqActionIdsRejected[], int accept_size, int reject_size, long reqRequestorId, long reqInstanceId);
 
 void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, long requestorId, long instanceId, long ranFunctionId, long actionId, long seqNum, uint8_t *ind_header_buf, int header_length, uint8_t *ind_message_buf, int message_length);
+
+#endif
index 371f455..d518a36 100644 (file)
@@ -1097,21 +1097,101 @@ void encode_kpm_report_style5_parameterized(E2SM_KPM_IndicationMessage_t* indica
 
 
   //We need to convert bytes_dl into array of uint8_t
+
+  int array_size_dl;
+
   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
-  uint8_t buffer[1];
-  buffer[0]= 40000;
-  bytesdl->buf = (uint8_t*)calloc(1,1);
-  memcpy(bytesdl->buf, buffer,1);
-  bytesdl->size = 1;
 
+  if (bytes_dl <= 64) {
+    array_size_dl = 1;
+
+    uint8_t buffer[array_size_dl];
+    buffer[0] = bytes_dl & 0xFF;
+    bytesdl->buf = (uint8_t*)calloc(1,1);
+    memcpy(bytesdl->buf,buffer,1);
+    bytesdl->size = 1;
+
+  } else if (bytes_dl <= 16384) {
+    array_size_dl = 2;
+
+    uint8_t buffer[array_size_dl];
+    buffer[0] = (bytes_dl >> 8) & 0xFF;
+    buffer[1] = bytes_dl & 0xFF;
+    bytesdl->buf = (uint8_t*)calloc(2,1);
+    memcpy(bytesdl->buf,buffer,2);
+    bytesdl->size = 2;
+    
+  } else if (bytes_dl <= 4194304) {
+    array_size_dl = 3;
+
+    uint8_t buffer[array_size_dl];
+    buffer[0] = (bytes_dl >> 16) & 0xFF;
+    buffer[1] = (bytes_dl >> 8) & 0xFF;
+    buffer[2] = bytes_dl & 0xFF;
+    bytesdl->buf = (uint8_t*)calloc(3,1);
+    memcpy(bytesdl->buf,buffer,3);
+    bytesdl->size = 3;    
+    
+  } else if (bytes_dl <= 1073741824) {
+    array_size_dl = 4;
+    uint8_t buffer[array_size_dl];
+    buffer[0] = (bytes_dl >> 24) & 0xFF;
+    buffer[1] = (bytes_dl >> 16) & 0xFF;
+    buffer[2] = (bytes_dl >> 8) & 0xFF;
+    buffer[3] = bytes_dl & 0xFF;
+    bytesdl->buf = (uint8_t*)calloc(4,1);
+    memcpy(bytesdl->buf,buffer,4);
+    bytesdl->size = 4;
+  }
+  
   
   //We need to convert bytes_ul into array of uint8_t
   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
-  uint8_t buffer1[1];
-  buffer1[0] = 50000;
-  bytesul->buf = (uint8_t*)calloc(1,1);
-  memcpy(bytesul->buf, buffer1, 1);
-  bytesul->size = 1;
+
+  int array_size_ul;
+
+  if (bytes_ul <= 64) {
+    array_size_ul = 1;
+
+    uint8_t buffer[array_size_ul];
+    buffer[0] = bytes_ul & 0xFF;
+    bytesul->buf = (uint8_t*)calloc(1,1);
+    memcpy(bytesul->buf,buffer,1);
+    bytesul->size = 1;
+
+  } else if (bytes_ul <= 16384) {
+    array_size_ul = 2;
+
+    uint8_t buffer[array_size_ul];
+    buffer[0] = (bytes_ul >> 8) & 0xFF;
+    buffer[1] = bytes_ul & 0xFF;
+    bytesul->buf = (uint8_t*)calloc(2,1);
+    memcpy(bytesul->buf,buffer,2);
+    bytesul->size = 2;
+    
+  } else if (bytes_ul <= 4194304) {
+    array_size_ul = 3;
+
+    uint8_t buffer[array_size_ul];
+    buffer[0] = (bytes_ul >> 16) & 0xFF;
+    buffer[1] = (bytes_ul >> 8) & 0xFF;
+    buffer[2] = bytes_ul & 0xFF;
+    bytesul->buf = (uint8_t*)calloc(3,1);
+    memcpy(bytesul->buf,buffer,3);
+    bytesul->size = 3;    
+    
+  } else if (bytes_ul <= 1073741824) {
+    array_size_ul = 4;
+    uint8_t buffer[array_size_ul];
+    buffer[0] = (bytes_ul >> 24) & 0xFF;
+    buffer[1] = (bytes_ul >> 16) & 0xFF;
+    buffer[2] = (bytes_ul >> 8) & 0xFF;
+    buffer[3] = bytes_ul & 0xFF;
+    bytesul->buf = (uint8_t*)calloc(4,1);
+    memcpy(bytesul->buf,buffer,4);
+    bytesul->size = 4;
+  }
+  
 
   FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t));
   ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem);
index 60b09e9..682814c 100644 (file)
@@ -1,10 +1,15 @@
-#include "OCUCP-PF-Container.h"
-#include "OCTET_STRING.h"
-#include "asn_application.h"
-#include "E2SM-KPM-IndicationMessage.h"
-#include "FQIPERSlicesPerPlmnListItem.h"
-#include "E2SM-KPM-RANfunction-Description.h"
-#include "Timestamp.h"
+#ifndef ENCODE_KPM_HPP
+#define ENCODE_KPM_HPP
+
+extern "C" {
+  #include "OCUCP-PF-Container.h"
+  #include "OCTET_STRING.h"
+  #include "asn_application.h"
+  #include "E2SM-KPM-IndicationMessage.h"
+  #include "FQIPERSlicesPerPlmnListItem.h"
+  #include "E2SM-KPM-RANfunction-Description.h"
+  #include "Timestamp.h"
+}
 
 void encode_kpm(E2SM_KPM_IndicationMessage_t* indicationmessage);
 
@@ -35,3 +40,6 @@ void encode_kpm_report_rancontainer_cuup_parameterized(E2SM_KPM_IndicationMessag
 void encode_kpm_report_style1_parameterized(E2SM_KPM_IndicationMessage_t* indicationmessage, long fiveqi, long dl_prb_usage, long ul_prb_usage, uint8_t* sd_buf, uint8_t* sst_buf,uint8_t* plmnid_buf, uint8_t* nrcellid_buf, long *dl_prbs, long *ul_prbs);
 
 void encode_kpm_report_style5_parameterized(E2SM_KPM_IndicationMessage_t* indicationmessage, uint8_t *gnbcuupname_buf, int bytes_dl,int bytes_ul, uint8_t *sst_buf, uint8_t *sd_buf, uint8_t *plmnid_buf);
+
+
+#endif
index 4fa4c8d..7f77e94 100644 (file)
@@ -5,18 +5,38 @@
 #include <vector>
 
 
-#include "OCUCP-PF-Container.h"
-#include "OCTET_STRING.h"
-#include "asn_application.h"
-#include "E2SM-KPM-IndicationMessage.h"
-#include "FQIPERSlicesPerPlmnListItem.h"
-#include "E2SM-KPM-RANfunction-Description.h"
-#include "Timestamp.h"
-#include "E2AP-PDU.h"
+
+extern "C" {
+  #include "OCUCP-PF-Container.h"
+  #include "OCTET_STRING.h"
+  #include "asn_application.h"
+  #include "E2SM-KPM-IndicationMessage.h"
+  #include "FQIPERSlicesPerPlmnListItem.h"
+  #include "E2SM-KPM-RANfunction-Description.h"
+  #include "Timestamp.h"
+  #include "E2AP-PDU.h"
+  #include "RICsubscriptionRequest.h"
+  #include "RICsubscriptionResponse.h"
+  #include "RICactionType.h"
+  #include "ProtocolIE-Field.h"
+  #include "ProtocolIE-SingleContainer.h"
+  #include "InitiatingMessage.h"
+}
+  
 #include "encode_kpm.hpp"
+
 #include "encode_e2apv1.hpp"
+
+#include <nlohmann/json.hpp>
+#include <thread>
+
+
+
+
 #include "e2sim.hpp"
 
+using json = nlohmann::json;
+
 using namespace std;
 
 struct neighbor_cell_entry {
@@ -38,6 +58,261 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long
   
   simfile.open("simulation.txt", ios::in);
 
+  cout << "step1" << endl;
+    
+  std::ifstream ue_stream("ueMeasReport.txt");
+  std::ifstream cell_stream("cellMeasReport.txt");
+
+  json all_ues_json;
+
+  ue_stream  >> all_ues_json;
+
+  json all_cells_json;
+
+  cell_stream >> all_cells_json;
+
+  asn_codec_ctx_t *opt_cod;
+
+  cout << "UE RF Measurements" << endl;
+  cout << "******************" << endl;
+
+  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;
+    cout << "UE number " + i << endl;
+    cout << "**********" << endl;
+    json::json_pointer p1(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/nrCellIdentity");
+    nextCellId = all_ues_json[p1].get<int>();
+    cout << "Serving Cell " << nextCellId << endl;
+    
+    json::json_pointer p2(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rsrp");
+    nextRsrp = all_ues_json[p2].get<int>();
+    cout << "  RSRP " << nextRsrp << endl;
+    json::json_pointer p3(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rsrq");
+    nextRsrq = all_ues_json[p3].get<int>();
+    cout << "  RSRQ " << nextRsrq << endl;
+    json::json_pointer p4(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/servingCellRfReport/rssinr");
+    nextRssinr = all_ues_json[p4].get<int>();
+    cout << "  RSSINR " << nextRssinr << endl;
+
+    json::json_pointer p5(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList");
+
+    int numNeighborCells = (all_ues_json[p5]).size();
+
+
+    //REPORT Message 3 -- Encode and send OCUCP user-level report
+    
+    E2SM_KPM_IndicationMessage_t *ind_msg3 =
+      (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
+    E2AP_PDU *pdu3 = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
+    
+    uint8_t *crnti_buf = (uint8_t*)calloc(1,2);
+
+    if (nextCellId == 0) {
+      uint8_t *buf2 = (uint8_t*)"12";
+      memcpy(crnti_buf, buf2, 2);
+    } else if (nextCellId == 1) {
+      uint8_t *buf2 = (uint8_t*)"22";
+      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());
+        
+    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 += "]";
+    
+    const uint8_t *neighbor_buf = reinterpret_cast<const uint8_t*>(neighbor_str.c_str());
+    
+    printf("Neighbor string\n%s", neighbor_buf);
+
+    uint8_t *plmnid_buf = (uint8_t*)"747";
+    uint8_t *nrcellid_buf = (uint8_t*)"12340";
+    
+    encode_kpm_report_rancontainer_cucp_parameterized(ind_msg3, plmnid_buf, nrcellid_buf, crnti_buf, serving_buf, neighbor_buf);
+    
+    uint8_t e2smbuffer3[8192];
+    size_t e2smbuffer_size3 = 8192;
+
+    
+    asn_enc_rval_t er3 = asn_encode_to_buffer(opt_cod,
+                                             ATS_ALIGNED_BASIC_PER,
+                                             &asn_DEF_E2SM_KPM_IndicationMessage,
+                                             ind_msg3, e2smbuffer3, e2smbuffer_size3);
+    
+    fprintf(stderr, "er encded is %d\n", er3.encoded);
+    fprintf(stderr, "after encoding message\n");
+    uint8_t *e2smheader_buf3 = (uint8_t*)"header";
+    
+    generate_e2apv1_indication_request_parameterized(pdu3, requestorId,
+                                                    instanceId, ranFunctionId,
+                                                    actionId, seqNum, e2smheader_buf3, 6, e2smbuffer3, er3.encoded);
+    
+    encode_and_send_sctp_data(pdu3, socket_fd);
+    
+    seqNum++;
+        
+  }
+
+
+  cout << "Cell Measurements" << endl;
+  cout << "******************" << endl;
+
+  int numCellMeasReports = (all_cells_json["/cellMeasReport/cellMeasReportList"_json_pointer]).size();
+
+  uint8_t *sst_buf = (uint8_t*)"1";
+  uint8_t *sd_buf = (uint8_t*)"100";
+  uint8_t *plmnid_buf = (uint8_t*)"747";
+  
+  for (int i = 0; i < numCellMeasReports; i++) {
+
+    int nextCellId;
+    int nextPdcpBytesDL;
+    int nextPdcpBytesUL;
+    int nextPRBBytesDL;
+    int nextPRBBytesUL;
+
+    json::json_pointer p1(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/nrCellIdentity");
+    nextCellId = all_cells_json[p1].get<int>();
+    cout << std::string("Cell number ") << nextCellId << endl;
+    
+    cout << "**********" << endl;
+    
+    json::json_pointer p2(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/pdcpByteMeasReport/pdcpBytesDl");
+    nextPdcpBytesDL = all_cells_json[p2].get<int>();
+    cout << std::string("  PDCP Bytes DL ") << nextPdcpBytesDL << endl;
+
+    json::json_pointer p3(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/pdcpByteMeasReport/pdcpBytesUl");
+    nextPdcpBytesUL = all_cells_json[p3].get<int>();    
+    cout << std::string("  PDCP Bytes UL ") << nextPdcpBytesUL << endl;
+
+    uint8_t *buf = (uint8_t*)"GNBCUUP5";
+    
+    int bytes_dl = nextPdcpBytesDL;
+
+    int bytes_ul = nextPdcpBytesUL;
+
+    //    int bytes_dl = 3905;
+    //    int bytes_ul = 1609321;    
+    
+    E2SM_KPM_IndicationMessage_t *ind_msg2 =
+      (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
+    E2AP_PDU *pdu2 = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
+    
+    encode_kpm_report_style5_parameterized(ind_msg2 , buf, bytes_dl, bytes_ul, sst_buf, sd_buf, plmnid_buf);
+    
+    uint8_t e2smbuffer2[8192];
+    size_t e2smbuffer_size2 = 8192;
+    
+    asn_enc_rval_t er2 = asn_encode_to_buffer(opt_cod,
+                                             ATS_ALIGNED_BASIC_PER,
+                                             &asn_DEF_E2SM_KPM_IndicationMessage,
+                                             ind_msg2, e2smbuffer2, e2smbuffer_size2);
+    
+    fprintf(stderr, "er encded is %d\n", er2.encoded);
+    fprintf(stderr, "after encoding message\n");
+    uint8_t *e2smheader_buf2 = (uint8_t*)"header";
+    
+    generate_e2apv1_indication_request_parameterized(pdu2, requestorId,
+                                                    instanceId, ranFunctionId,
+                                                    actionId, seqNum, e2smheader_buf2, 6, e2smbuffer2, er2.encoded);
+    
+    encode_and_send_sctp_data(pdu2, socket_fd);
+    
+    seqNum++;
+
+    
+
+    json::json_pointer p4(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/prbMeasReport/availPrbDl");
+    nextPRBBytesDL = all_cells_json[p4].get<int>();    
+    cout << std::string("  PRB Bytes DL ") << all_cells_json[p4] << endl;
+
+    json::json_pointer p5(std::string("/cellMeasReport/cellMeasReportList/") + std::to_string(i) +"/prbMeasReport/availPrbUl");
+    nextPRBBytesUL = all_cells_json[p5].get<int>();
+    cout << std::string("  PRB Bytes UL ") << all_cells_json[p5] << endl;
+
+
+    //REPORT Message 1 -- Encode and send ODU cell-level report
+    
+    E2SM_KPM_IndicationMessage_t *ind_msg1 =
+      (E2SM_KPM_IndicationMessage_t*)calloc(1,sizeof(E2SM_KPM_IndicationMessage_t));
+    E2AP_PDU *pdu = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU));
+    
+    long fiveqi = 7;
+
+    uint8_t *nrcellid_buf = (uint8_t*)"12340";
+    long dl_prbs = nextPRBBytesDL;
+    long ul_prbs = nextPRBBytesUL;
+    
+    encode_kpm_report_style1_parameterized(ind_msg1, fiveqi, dl_prbs, ul_prbs, sst_buf, sd_buf, plmnid_buf, nrcellid_buf, &dl_prbs, &ul_prbs);
+    
+    uint8_t e2smbuffer[8192];
+    size_t e2smbuffer_size = 8192;
+    
+    asn_enc_rval_t er = asn_encode_to_buffer(opt_cod,
+                                            ATS_ALIGNED_BASIC_PER,
+                                            &asn_DEF_E2SM_KPM_IndicationMessage,
+                                            ind_msg1, e2smbuffer, e2smbuffer_size);
+    
+    fprintf(stderr, "er encded is %d\n", er.encoded);
+    fprintf(stderr, "after encoding message\n");
+    uint8_t *e2smheader_buf = (uint8_t*)"header";
+    
+    uint8_t *cpid_buf = (uint8_t*)"CPID";
+    
+    fprintf(stderr, "About to encode Indication\n");
+    generate_e2apv1_indication_request_parameterized(pdu, requestorId,
+                                                    instanceId, ranFunctionId,
+                                                    actionId, seqNum, e2smheader_buf, 6, e2smbuffer, er.encoded);
+    
+    encode_and_send_sctp_data(pdu, socket_fd);
+    
+    seqNum++;
+    
+  }
+
+
+  /*
   if (simfile.is_open()) {
 
     while (getline(simfile, line)) {
@@ -193,6 +468,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long
     simfile.close();
 
   }
+  */
 
 }
 
diff --git a/e2sim/e2apv1sim/ueMeasReport.txt b/e2sim/e2apv1sim/ueMeasReport.txt
new file mode 100644 (file)
index 0000000..32bf4d4
--- /dev/null
@@ -0,0 +1,65 @@
+{      
+    "ueMeasReport": {  
+        "du-id": 1000,                            
+        "ueMeasReportList":  [             
+           {                                      
+                         "measTimeStampRf": "2020-04-09 14:33:33,559", 
+                         "nrCellIdentity": 0,    
+              "servingCellRfReport": {
+                  "rsrp": 10,                     
+                  "rsrq": 0,                     
+                  "rssinr": 0                
+              },
+                         "neighbourCellList": [
+                                       {
+                                               "nbCellIdentity": 1,
+                                               "nbCellRfReport": {
+                                                       "rsrp": 10,                     
+                                                       "rsrq": 0,                     
+                                                       "rssinr": 0 
+                                               }
+                                       }, 
+                                       {
+                                               "nbCellIdentity": 2,
+                                               "nbCellRfReport": {
+                                                       "rsrp": 10,                     
+                                                       "rsrq": 0,                     
+                                                       "rssinr": 0 
+                                               }
+                                       }
+                ]
+              
+           },
+                  
+           {                                      
+                         "measTimeStampRf": "2020-04-09 14:33:33,559", 
+                         "nrCellIdentity": 1,                
+              "servingCellRfReport": {
+                  "rsrp": 10,                     
+                  "rsrq": 0,                     
+                  "rssinr": 0                
+              },
+                         "neighbourCellList": [
+                                       {
+                                               "nbCellIdentity": 0,
+                                               "nbCellRfReport": {
+                                                       "rsrp": 10,                     
+                                                       "rsrq": 0,                     
+                                                       "rssinr": 0 
+                                               }
+                                       }, 
+                                       {
+                                               "nbCellIdentity": 2,
+                                               "nbCellRfReport": {
+                                                       "rsrp": 10,                     
+                                                       "rsrq": 0,                     
+                                                       "rssinr": 0 
+                                               }
+                                       }
+                ]
+              
+           }
+        ]             
+    }
+}
+