Skip to content
Snippets Groups Projects
Commit 7f8bab62 authored by eurecom's avatar eurecom Committed by mir
Browse files

KPM Subscriptions 1,2,3 working

parent 9425c79e
No related branches found
No related tags found
1 merge request!29Dev to master before release 2
......@@ -30,6 +30,9 @@
#include <unistd.h>
#include <pthread.h>
static
uint64_t period_ms = 300;
static
byte_array_t copy_str_to_ba(const char* str)
{
......@@ -50,16 +53,9 @@ static
pthread_mutex_t mtx;
static
void sm_cb_kpm(sm_ag_if_rd_t const* rd)
void display_kpm_ind_msg_frm_1_meas(kpm_ind_msg_format_1_t const *msg_frm_1)
{
assert(rd != NULL);
assert(rd->type == INDICATION_MSG_AGENT_IF_ANS_V0);
assert(rd->ind.type == KPM_STATS_V3_0);
// Reading Indication Message Format 1
kpm_ind_data_t const* ind = &rd->ind.kpm.ind;
kpm_ric_ind_hdr_format_1_t const* hdr_frm_1 = &ind->hdr.kpm_ric_ind_hdr_format_1;
kpm_ind_msg_format_1_t const* msg_frm_1 = &ind->msg.frm_1;
assert(msg_frm_1 != NULL);
{
......@@ -73,6 +69,7 @@ void sm_cb_kpm(sm_ag_if_rd_t const* rd)
// Reported list of cell level measurements per granularity period
for (size_t j = 0; j<msg_frm_1->meas_data_lst_len; j++)
{
for (size_t z = 0; z<msg_frm_1->meas_data_lst[j].meas_record_len; z++)
{
if (msg_frm_1->meas_info_lst_len > 0)
......@@ -93,11 +90,13 @@ void sm_cb_kpm(sm_ag_if_rd_t const* rd)
{
if (strcmp(meas_info_name_str, "RRU.PrbTotDl") == 0)
{
printf("RRU.PrbTotDl = %d [PRBs]\n", msg_frm_1->meas_data_lst[j].meas_record_lst[z].int_val);
printf("Style 1\n");
printf("RRU.PrbTotDl = %d [%%]\n", msg_frm_1->meas_data_lst[j].meas_record_lst[z].int_val);
}
else if (strcmp(meas_info_name_str, "RRU.PrbTotUl") == 0)
{
printf("RRU.PrbTotUl = %d [PRBs]\n", msg_frm_1->meas_data_lst[j].meas_record_lst[z].int_val);
printf("Style 1\n");
printf("RRU.PrbTotUl = %d [%%]\n", msg_frm_1->meas_data_lst[j].meas_record_lst[z].int_val);
}
else
{
......@@ -120,11 +119,156 @@ void sm_cb_kpm(sm_ag_if_rd_t const* rd)
}
}
if (msg_frm_1->meas_data_lst[j].incomplete_flag && *msg_frm_1->meas_data_lst[j].incomplete_flag == TRUE_ENUM_VALUE)
printf("Measurement Record not reliable");
printf("Measurement Record not reliable\n");
}
}
}
static
void display_kpm_ind_msg_frm_2_meas(kpm_ind_msg_format_2_t const *msg_frm_2)
{
assert(msg_frm_2 != NULL);
for (size_t j = 0; j<msg_frm_2->meas_data_lst_len; j++)
{
printf("Style 2\n");
for (size_t z = 0; z<msg_frm_2->meas_data_lst[j].meas_record_len; z++)
{
if (msg_frm_2->meas_info_cond_ue_lst_len > 0)
{
// Matching Condition
for(size_t i = 0; i < msg_frm_2->meas_info_cond_ue_lst[z].matching_cond_lst_len; i++)
{
switch (msg_frm_2->meas_info_cond_ue_lst[z].matching_cond_lst[i].cond_type)
{
case TEST_INFO:
{
assert(msg_frm_2->meas_info_cond_ue_lst[z].matching_cond_lst[i].test_info_lst.test_cond_type == GBR_TEST_COND_TYPE);
assert(*msg_frm_2->meas_info_cond_ue_lst[z].matching_cond_lst[i].test_info_lst.test_cond == LESSTHAN_TEST_COND);
assert(msg_frm_2->meas_info_cond_ue_lst[z].matching_cond_lst[i].test_info_lst.test_cond_value->type == INTEGER_TEST_COND_VALUE);
printf("Test Condition: GBR rate < %lu\n", *msg_frm_2->meas_info_cond_ue_lst[z].matching_cond_lst[i].test_info_lst.test_cond_value->int_value);
break;
}
default:
assert(false && "Not yet implemented");
}
}
// List of Matched UEs
if (msg_frm_2->meas_info_cond_ue_lst[z].ue_id_matched_lst != NULL)
{
for(size_t i = 0; i < msg_frm_2->meas_info_cond_ue_lst[z].ue_id_matched_lst_len; i++)
{
switch(msg_frm_2->meas_info_cond_ue_lst[z].ue_id_matched_lst[i].type)
{
case GNB_UE_ID_E2SM:
printf("#%ld UE connected to gNB with amf_ue_ngap_id = %lu\n", i, msg_frm_2->meas_info_cond_ue_lst[z].ue_id_matched_lst[i].gnb.amf_ue_ngap_id);
break;
case GNB_DU_UE_ID_E2SM:
printf("#%ld UE connected to gNB-DU with gnb_cu_ue_f1ap = %u\n", i, msg_frm_2->meas_info_cond_ue_lst[z].ue_id_matched_lst[i].gnb_du.gnb_cu_ue_f1ap);
break;
default:
assert(false && "Not yet implemented UE ID type");
}
}
}
else
{
printf("No matched UEs with this test condition\n");
}
switch (msg_frm_2->meas_info_cond_ue_lst[z].meas_type.type)
{
case NAME_MEAS_TYPE:
{
// Get the Measurement Name
char meas_info_name_str[msg_frm_2->meas_info_cond_ue_lst[z].meas_type.name.len + 1];
memcpy(meas_info_name_str, msg_frm_2->meas_info_cond_ue_lst[z].meas_type.name.buf, msg_frm_2->meas_info_cond_ue_lst[z].meas_type.name.len);
meas_info_name_str[msg_frm_2->meas_info_cond_ue_lst[z].meas_type.name.len] = '\0';
// Get the value of the Measurement
switch (msg_frm_2->meas_data_lst[j].meas_record_lst[z].value)
{
case INTEGER_MEAS_VALUE:
{
if (strcmp(meas_info_name_str, "DRB.UEThpDl") == 0)
{
printf("DRB.UEThpDl = %d [kb/s]\n", msg_frm_2->meas_data_lst[j].meas_record_lst[z].int_val);
}
else if (strcmp(meas_info_name_str, "DRB.UEThpUl") == 0)
{
printf("DRB.UEThpUl = %d [kb/s]\n", msg_frm_2->meas_data_lst[j].meas_record_lst[z].int_val);
}
else
{
printf("Measurement Name not yet implemented\n");
//assert(false && "Measurement Name not yet implemented");
}
break;
}
default:
assert("Value not recognized");
}
break;
}
default:
assert(false && "Measurement Type not yet implemented");
}
}
if (msg_frm_2->meas_data_lst[j].incomplete_flag && *msg_frm_2->meas_data_lst[j].incomplete_flag == TRUE_ENUM_VALUE)
printf("Measurement Record not reliable\n");
}
}
counter++;
}
static
void sm_cb_kpm(sm_ag_if_rd_t const* rd)
{
assert(rd != NULL);
assert(rd->type == INDICATION_MSG_AGENT_IF_ANS_V0);
assert(rd->ind.type == KPM_STATS_V3_0);
// Reading Indication Message Format 1
kpm_ind_data_t const* ind = &rd->ind.kpm.ind;
kpm_ric_ind_hdr_format_1_t const* hdr_frm_1 = &ind->hdr.kpm_ric_ind_hdr_format_1;
static int counter = 1;
int64_t now = time_now_us();
printf("\n%7d KPM ind_msg latency = %lu [μs]\n", counter, now - hdr_frm_1->collectStartTime*1000000); // xApp <-> E2 Node
// Check the Indication Message Type
switch (ind->msg.type)
{
case FORMAT_1_INDICATION_MESSAGE:
display_kpm_ind_msg_frm_1_meas(&ind->msg.frm_1);
break;
case FORMAT_2_INDICATION_MESSAGE:
display_kpm_ind_msg_frm_2_meas(&ind->msg.frm_2);
break;
default:
assert(false && "Wrong Indication Message Received");
}
counter++;
// {
// lock_guard(&mtx);
// }
}
......@@ -169,16 +313,6 @@ kpm_act_def_format_1_t gen_act_def_frm_1_cell(const char** act)
return dst;
}
static
kpm_act_def_t gen_act_def_cell(const char** act)
{
kpm_act_def_t dst = {0};
dst.type = FORMAT_1_ACTION_DEFINITION;
dst.frm_1 = gen_act_def_frm_1_cell(act);
return dst;
}
/* UE LEVEL */
......@@ -226,7 +360,7 @@ kpm_act_def_format_1_t gen_act_def_frm_1_ue(const char** act)
{
kpm_act_def_format_1_t dst = {0};
dst.gran_period_ms = 100;
dst.gran_period_ms = period_ms;
// [1, 65535]
size_t count = 0;
......@@ -310,16 +444,85 @@ kpm_act_def_format_2_t gen_act_def_frm_2_ue(const char** act)
}
static
kpm_act_def_t gen_act_def_ue(const char** act)
matching_condition_format_3_lst_t gen_matching_cond_frm_3_lst(void)
{
kpm_act_def_t dst = {0};
matching_condition_format_3_lst_t dst = {0};
// Test information list as matching condition
dst.cond_type = TEST_INFO;
dst.test_info_lst.test_cond_type = GBR_TEST_COND_TYPE;
dst.test_info_lst.GBR = TRUE_TEST_COND_TYPE;
dst.test_info_lst.test_cond = calloc(1, sizeof(test_cond_e));
assert(dst.test_info_lst.test_cond != NULL && "Memory exhausted");
*dst.test_info_lst.test_cond = LESSTHAN_TEST_COND;
dst.test_info_lst.test_cond_value = calloc(1, sizeof(test_cond_value_t));
assert(dst.test_info_lst.test_cond_value != NULL && "Memory exhausted");
dst.test_info_lst.test_cond_value->type = INTEGER_TEST_COND_VALUE;
dst.test_info_lst.test_cond_value->int_value = calloc(1, sizeof(int64_t));
assert(dst.test_info_lst.test_cond_value->int_value != NULL && "Memory exhausted");
*dst.test_info_lst.test_cond_value->int_value = 10000000; // unit?
dst.type = FORMAT_2_ACTION_DEFINITION;
dst.frm_2 = gen_act_def_frm_2_ue(act);
return dst;
}
static
meas_info_format_3_lst_t gen_meas_info_format_3_lst(const char* act)
{
meas_info_format_3_lst_t dst = {0};
// Measurement Type
dst.meas_type.type = NAME_MEAS_TYPE;
dst.meas_type.name = copy_str_to_ba(act);
// Matching Condition List [1, 32768]
dst.matching_cond_lst_len = 1; // ADD ONE FOR LABEL AND THE OTHER ONE FOR TEST LIST
dst.matching_cond_lst = calloc(dst.matching_cond_lst_len, sizeof(matching_condition_format_3_lst_t));
assert(dst.matching_cond_lst != NULL && "Memory exhausted");
for(size_t i = 0; i < dst.matching_cond_lst_len; i++){
dst.matching_cond_lst[i] = gen_matching_cond_frm_3_lst();
}
// Bin Range Definition
// Optional
dst.bin_range_def = NULL;
return dst;
}
static
kpm_act_def_format_3_t gen_act_def_frm_3_ue(const char** act)
{
kpm_act_def_format_3_t dst = {0};
// Measurement Information List [1, 65535]
size_t count = 0;
while (act[count] != NULL) {
count++;
}
dst.meas_info_lst_len = count;
dst.meas_info_lst = calloc(dst.meas_info_lst_len, sizeof(meas_info_format_3_lst_t));
assert(dst.meas_info_lst != NULL && "Memory exhausted");
for(size_t i = 0; i < dst.meas_info_lst_len; i++) {
dst.meas_info_lst[i] = gen_meas_info_format_3_lst(act[i]);
}
// Granularity Period
// Mandatory
dst.gran_period_ms = period_ms;
// Cell Global ID
// Optional
dst.cell_global_id = NULL;
return dst;
}
static
......@@ -333,6 +536,66 @@ kpm_event_trigger_def_t gen_ev_trig(uint64_t period)
return dst;
}
static
kpm_sub_data_t gen_kpm_sub_style_1(void)
{
kpm_sub_data_t kpm_sub = {0};
// Generate Event Trigger
kpm_sub.ev_trg_def = gen_ev_trig(period_ms);
// Generate Action Definition
kpm_sub.sz_ad = 1;
kpm_sub.ad = calloc(1, sizeof(kpm_act_def_t));
assert(kpm_sub.ad != NULL && "Memory exhausted");
const char *act_cell[] = {"RRU.PrbTotDl", "RRU.PrbTotUl", NULL}; // 3GPP TS 28.552
kpm_sub.ad[0].type = FORMAT_1_ACTION_DEFINITION;
kpm_sub.ad[0].frm_1 = gen_act_def_frm_1_cell(act_cell);
return kpm_sub;
}
static
kpm_sub_data_t gen_kpm_sub_style_2(void)
{
kpm_sub_data_t kpm_sub = {0};
// Generate Event Trigger
kpm_sub.ev_trg_def = gen_ev_trig(period_ms);
// Generate Action Definition
kpm_sub.sz_ad = 1;
kpm_sub.ad = calloc(1, sizeof(kpm_act_def_t));
assert(kpm_sub.ad != NULL && "Memory exhausted");
const char *act_ue[] = {"DRB.UEThpDl", "DRB.UEThpDl.QOS", "DRB.UEThpDl.SNSSAI", "DRB.UEThpUl", "DRB.UEThpUl.QOS", "DRB.UEThpUl.SNSSAI", NULL}; // 3GPP TS 28.552
kpm_sub.ad[0].type = FORMAT_2_ACTION_DEFINITION;
kpm_sub.ad[0].frm_2 = gen_act_def_frm_2_ue(act_ue);
return kpm_sub;
}
static
kpm_sub_data_t gen_kpm_sub_style_3(void)
{
kpm_sub_data_t kpm_sub = {0};
// Generate Event Trigger
kpm_sub.ev_trg_def = gen_ev_trig(period_ms);
// Generate Action Definition
kpm_sub.sz_ad = 1;
kpm_sub.ad = calloc(1, sizeof(kpm_act_def_t));
assert(kpm_sub.ad != NULL && "Memory exhausted");
const char *act_ue[] = {"DRB.UEThpDl", "DRB.UEThpUl", NULL}; // 3GPP TS 28.552
kpm_sub.ad[0].type = FORMAT_3_ACTION_DEFINITION;
kpm_sub.ad[0].frm_3 = gen_act_def_frm_3_ue(act_ue);
return kpm_sub;
}
int main(int argc, char *argv[])
{
fr_args_t args = init_fr_args(argc, argv);
......@@ -374,34 +637,29 @@ int main(int argc, char *argv[])
kpm_sub.ev_trg_def = gen_ev_trig(period_ms);
printf("[xApp]: reporting period = %lu [ms]\n", period_ms);
kpm_sub.sz_ad = 1;
kpm_sub.ad = calloc(1, sizeof(kpm_act_def_t));
assert(kpm_sub.ad != NULL && "Memory exhausted");
// KPM SUBSCRIPTION FOR CELL LEVEL MEASUREMENTS Style 1
kpm_sub_data_t kpm_sub_1 = gen_kpm_sub_style_1();
defer({ free_kpm_sub_data(&kpm_sub_1); });
const char *act_cell[] = {"RRU.PrbTotDl", "RRU.PrbTotUl", NULL}; // 3GPP TS 28.552
*kpm_sub.ad = gen_act_def_cell(act_cell);
// KPM SUBSCRIPTION FOR UE LEVEL MEASUREMENTS
kpm_sub_data_t kpm_sub_1 = {0};
defer({ free_kpm_sub_data(&kpm_sub_1); });
// KPM SUBSCRIPTION FOR UE LEVEL MEASUREMENTS Style 2
kpm_sub_data_t kpm_sub_2 = gen_kpm_sub_style_2();
defer({ free_kpm_sub_data(&kpm_sub_2); });
kpm_sub_1.ev_trg_def = gen_ev_trig(period_ms);
kpm_sub_1.sz_ad = 1;
kpm_sub_1.ad = calloc(1, sizeof(kpm_act_def_t));
assert(kpm_sub_1.ad != NULL && "Memory exhausted");
// KPM SUBSCRIPTION FOR UE LEVEL MEASUREMENTS Style 3
kpm_sub_data_t kpm_sub_3 = gen_kpm_sub_style_3();
defer({ free_kpm_sub_data(&kpm_sub_3); });
// Generate Action for UE LEVEL measurements
const char *act_ue[] = {"DRB.UEThpDl", "DRB.UEThpDl.QOS", "DRB.UEThpDl.SNSSAI", "DRB.UEThpUl", "DRB.UEThpUl.QOS", "DRB.UEThpUl.SNSSAI", NULL}; // 3GPP TS 28.552
// const char *act_ue[] = {"DRB.UEThpDl", "DRB.UEThpUl", NULL}; // 3GPP TS 28.552
*kpm_sub_1.ad = gen_act_def_ue(act_ue);
const int KPM_ran_function = 1;
kpm_handle[i] = report_sm_xapp_api(&nodes.n[i].id, KPM_ran_function, &kpm_sub, sm_cb_kpm);
kpm_handle[i] = report_sm_xapp_api(&nodes.n[i].id, KPM_ran_function, &kpm_sub_1, sm_cb_kpm);
kpm_handle[i] = report_sm_xapp_api(&nodes.n[i].id, KPM_ran_function, &kpm_sub_2, sm_cb_kpm);
kpm_handle[i] = report_sm_xapp_api(&nodes.n[i].id, KPM_ran_function, &kpm_sub_3, sm_cb_kpm);
assert(kpm_handle[i].success == true);
assert(kpm_handle[i].success == true);
}
////////////
......
......@@ -160,7 +160,6 @@ byte_array_t kpm_enc_action_def_asn(kpm_act_def_t const* action_def)
}
byte_array_t const ba = encode(&pdu, E2SM_KPM_ACTION_DEFINITION_ENUM);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_E2SM_KPM_ActionDefinition, &pdu);
return ba;
......@@ -241,8 +240,8 @@ byte_array_t kpm_enc_ind_msg_asn(kpm_ind_msg_t const* ind_msg)
}
//xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, pdu);
//fflush(stdout);
xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, &pdu);
fflush(stdout);
byte_array_t const ba = encode(&pdu, E2SM_KPM_INDICATION_MESSAGE_ENUM);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment