Commit cf670617 authored by mir's avatar mir

Compiling E2 + new bearer + RLC sojourn time

parent 7e9a7d90
#include "ran_func_kpm.h" #include "ran_func_kpm.h"
#include "../../flexric/test/rnd/fill_rnd_data_kpm.h" #include "../../flexric/test/rnd/fill_rnd_data_kpm.h"
#include "../../flexric/src/util/time_now_us.h" #include "../../flexric/src/util/time_now_us.h"
#include "../../../LAYER2/nr_rlc/nr_rlc_oai_api.h"
//#include "../../../LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
//#include "../../../RRC/NR/nr_rrc_defs.h"
//#include "../../../RRC/NR/rrc_gNB_UE_context.h"
//#include "../../../../common/ran_context.h"
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
...@@ -36,26 +42,41 @@ ue_id_e2sm_t fill_ue_id_data(void) ...@@ -36,26 +42,41 @@ ue_id_e2sm_t fill_ue_id_data(void)
return ue_id_data; return ue_id_data;
} }
// Forward declaration
int get_single_ue_rnti(void);
static static
kpm_ind_msg_format_1_t fill_kpm_ind_msg_frm_1(void) kpm_ind_msg_format_1_t fill_kpm_ind_msg_frm_1(void)
{ {
kpm_ind_msg_format_1_t msg_frm_1 = {0}; kpm_ind_msg_format_1_t msg_frm_1 = {0};
int const rnti = get_single_ue_rnti();
int const srb_flag = 0;
int const rb_id = 4;
nr_rlc_statistics_t out[2] = {0};
bool rc = nr_rlc_get_statistics(rnti, srb_flag, rb_id, &out[0]);
assert(rc == true);
rc = nr_rlc_get_statistics(rnti, srb_flag, rb_id + 1, &out[1]);
assert(rc == false && "At least for one bearer");
// Measurement Data // Measurement Data
uint32_t num_drbs = 2; uint32_t num_drbs = 1 + rc;
msg_frm_1.meas_data_lst_len = num_drbs; // (rand() % 65535) + 1; msg_frm_1.meas_data_lst_len = num_drbs; // (rand() % 65535) + 1;
msg_frm_1.meas_data_lst = calloc(msg_frm_1.meas_data_lst_len, sizeof(*msg_frm_1.meas_data_lst)); msg_frm_1.meas_data_lst = calloc(msg_frm_1.meas_data_lst_len, sizeof(*msg_frm_1.meas_data_lst));
assert(msg_frm_1.meas_data_lst != NULL && "Memory exhausted" ); assert(msg_frm_1.meas_data_lst != NULL && "Memory exhausted" );
for (size_t i = 0; i < msg_frm_1.meas_data_lst_len; i++){ for (size_t i = 0; i < msg_frm_1.meas_data_lst_len; i++){
// Measurement Record // Measurement Record
msg_frm_1.meas_data_lst[i].meas_record_len = 1; // (rand() % 65535) + 1; msg_frm_1.meas_data_lst[i].meas_record_len = num_drbs; // (rand() % 65535) + 1;
msg_frm_1.meas_data_lst[i].meas_record_lst = calloc(msg_frm_1.meas_data_lst[i].meas_record_len, sizeof(meas_record_lst_t)); msg_frm_1.meas_data_lst[i].meas_record_lst = calloc(msg_frm_1.meas_data_lst[i].meas_record_len, sizeof(meas_record_lst_t));
assert(msg_frm_1.meas_data_lst[i].meas_record_lst != NULL && "Memory exhausted" ); assert(msg_frm_1.meas_data_lst[i].meas_record_lst != NULL && "Memory exhausted" );
for (size_t j = 0; j < msg_frm_1.meas_data_lst[i].meas_record_len; j++){ for (size_t j = 0; j < msg_frm_1.meas_data_lst[i].meas_record_len; j++){
msg_frm_1.meas_data_lst[i].meas_record_lst[j].value = REAL_MEAS_VALUE; // rand()%END_MEAS_VALUE; msg_frm_1.meas_data_lst[i].meas_record_lst[j].value = REAL_MEAS_VALUE; // rand()%END_MEAS_VALUE;
msg_frm_1.meas_data_lst[i].meas_record_lst[j].real_val = (rand() % 256) + 0.1; msg_frm_1.meas_data_lst[i].meas_record_lst[j].real_val = out[0].txsdu_avg_time_to_tx;
} }
} }
...@@ -89,7 +110,7 @@ kpm_ind_msg_format_3_t fill_kpm_ind_msg_frm_3_sta(void) ...@@ -89,7 +110,7 @@ kpm_ind_msg_format_3_t fill_kpm_ind_msg_frm_3_sta(void)
{ {
kpm_ind_msg_format_3_t msg_frm_3 = {0}; kpm_ind_msg_format_3_t msg_frm_3 = {0};
uint32_t num_ues = 1; uint32_t const num_ues = 1;
msg_frm_3.ue_meas_report_lst_len = num_ues; // (rand() % 65535) + 1; msg_frm_3.ue_meas_report_lst_len = num_ues; // (rand() % 65535) + 1;
msg_frm_3.meas_report_per_ue = calloc(msg_frm_3.ue_meas_report_lst_len, sizeof(meas_report_per_ue_t)); msg_frm_3.meas_report_per_ue = calloc(msg_frm_3.ue_meas_report_lst_len, sizeof(meas_report_per_ue_t));
...@@ -145,7 +166,6 @@ kpm_ind_hdr_t fill_kpm_ind_hdr_sta(void) ...@@ -145,7 +166,6 @@ kpm_ind_hdr_t fill_kpm_ind_hdr_sta(void)
void read_kpm_sm(void* data) void read_kpm_sm(void* data)
{ {
assert(data != NULL); assert(data != NULL);
//assert(data->type == KPM_STATS_V3_0);
kpm_rd_ind_data_t* kpm = (kpm_rd_ind_data_t*)data; kpm_rd_ind_data_t* kpm = (kpm_rd_ind_data_t*)data;
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
/* rlc */ /* rlc */
#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h" #include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h"
#include "openair2/RRC/NR/nr_rrc_defs.h"
#include <executables/softmodem-common.h> #include <executables/softmodem-common.h>
extern RAN_CONTEXT_t RC; extern RAN_CONTEXT_t RC;
......
...@@ -37,11 +37,11 @@ static void nr_rlc_entity_get_stats( ...@@ -37,11 +37,11 @@ static void nr_rlc_entity_get_stats(
{ {
// printf("Stats from the RLC entity asked\n"); // printf("Stats from the RLC entity asked\n");
*out = entity->stats; *out = entity->stats;
if (entity->avg_time_is_on) // if (entity->avg_time_is_on)
out->txsdu_avg_time_to_tx = time_average_get_average(entity->txsdu_avg_time_to_tx, out->txsdu_avg_time_to_tx = time_average_get_average(entity->txsdu_avg_time_to_tx,
time_average_now()); time_average_now());
else // else
out->txsdu_avg_time_to_tx = 0; // out->txsdu_avg_time_to_tx = 0;
} }
nr_rlc_entity_t *new_nr_rlc_entity_am( nr_rlc_entity_t *new_nr_rlc_entity_am(
......
...@@ -23,81 +23,13 @@ ...@@ -23,81 +23,13 @@
#define _NR_RLC_ENTITY_H_ #define _NR_RLC_ENTITY_H_
#include <stdint.h> #include <stdint.h>
#include "openair2/RRC/NR/rrc_gNB_radio_bearers.h" #include "../../../openair2/RRC/NR/rrc_gNB_radio_bearers.h"
#include "../../../openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h"
#include "common/utils/time_stat.h" #include "common/utils/time_stat.h"
#define NR_SDU_MAX 16000 /* max NR PDCP SDU size is 9000, let's take more */ #define NR_SDU_MAX 16000 /* max NR PDCP SDU size is 9000, let's take more */
typedef enum {
NR_RLC_AM,
NR_RLC_UM,
NR_RLC_TM,
} nr_rlc_mode_t;
typedef struct {
nr_rlc_mode_t mode; /* AM, UM, or TM */
/* PDU stats */
/* TX */
uint32_t txpdu_pkts; /* aggregated number of transmitted RLC PDUs */
uint32_t txpdu_bytes; /* aggregated amount of transmitted bytes in RLC PDUs */
/* TODO? */
uint32_t txpdu_wt_ms; /* aggregated head-of-line tx packet waiting time to be transmitted (i.e. send to the MAC layer) */
uint32_t txpdu_dd_pkts; /* aggregated number of dropped or discarded tx packets by RLC */
uint32_t txpdu_dd_bytes; /* aggregated amount of bytes dropped or discarded tx packets by RLC */
uint32_t txpdu_retx_pkts; /* aggregated number of tx pdus/pkts to be re-transmitted (only applicable to RLC AM) */
uint32_t txpdu_retx_bytes; /* aggregated amount of bytes to be re-transmitted (only applicable to RLC AM) */
uint32_t txpdu_segmented; /* aggregated number of segmentations */
uint32_t txpdu_status_pkts; /* aggregated number of tx status pdus/pkts (only applicable to RLC AM) */
uint32_t txpdu_status_bytes; /* aggregated amount of tx status bytes (only applicable to RLC AM) */
/* TODO? */
uint32_t txbuf_occ_bytes; /* current tx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */
/* TODO? */
uint32_t txbuf_occ_pkts; /* current tx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */
/* txbuf_wd_ms: the time window for which the txbuf occupancy value is obtained - NOT IMPLEMENTED */
/* RX */
uint32_t rxpdu_pkts; /* aggregated number of received RLC PDUs */
uint32_t rxpdu_bytes; /* amount of bytes received by the RLC */
uint32_t rxpdu_dup_pkts; /* aggregated number of duplicate packets */
uint32_t rxpdu_dup_bytes; /* aggregated amount of duplicated bytes */
uint32_t rxpdu_dd_pkts; /* aggregated number of rx packets dropped or discarded by RLC */
uint32_t rxpdu_dd_bytes; /* aggregated amount of rx bytes dropped or discarded by RLC */
uint32_t rxpdu_ow_pkts; /* aggregated number of out of window received RLC pdu */
uint32_t rxpdu_ow_bytes; /* aggregated number of out of window bytes received RLC pdu */
uint32_t rxpdu_status_pkts; /* aggregated number of rx status pdus/pkts (only applicable to RLC AM) */
uint32_t rxpdu_status_bytes; /* aggregated amount of rx status bytes (only applicable to RLC AM) */
/* rxpdu_rotout_ms: flag indicating rx reordering timeout in ms - NOT IMPLEMENTED */
/* rxpdu_potout_ms: flag indicating the poll retransmit time out in ms - NOT IMPLEMENTED */
/* rxpdu_sptout_ms: flag indicating status prohibit timeout in ms - NOT IMPLEMENTED */
/* TODO? */
uint32_t rxbuf_occ_bytes; /* current rx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */
/* TODO? */
uint32_t rxbuf_occ_pkts; /* current rx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */
/* SDU stats */
/* TX */
uint32_t txsdu_pkts; /* number of SDUs delivered */
uint32_t txsdu_bytes; /* number of bytes of SDUs delivered */
/* RX */
uint32_t rxsdu_pkts; /* number of SDUs received */
uint32_t rxsdu_bytes; /* number of bytes of SDUs received */
uint32_t rxsdu_dd_pkts; /* number of dropped or discarded SDUs */
uint32_t rxsdu_dd_bytes; /* number of bytes of SDUs dropped or discarded */
/* Average time for an SDU to be passed to MAC.
* Actually measures the time it takes for any part of an SDU to be
* passed to MAC for the first time, that is: the first TX of (part of) the
* SDU.
* Since the MAC schedules in advance, it does not measure the time of
* transmission over the air, just the time to reach the MAC layer.
*/
double txsdu_avg_time_to_tx;
} nr_rlc_statistics_t;
typedef struct { typedef struct {
int status_size; int status_size;
int tx_size; int tx_size;
......
...@@ -547,8 +547,8 @@ static int generate_tx_pdu(nr_rlc_entity_um_t *entity, char *buffer, int size) ...@@ -547,8 +547,8 @@ static int generate_tx_pdu(nr_rlc_entity_um_t *entity, char *buffer, int size)
// sdu->sdu->time_of_arrival = 0; // sdu->sdu->time_of_arrival = 0;
time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time); time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time);
double av = time_average_get_average(entity->common.txsdu_avg_time_to_tx, time_average_now() ); // double av = time_average_get_average(entity->common.txsdu_avg_time_to_tx, time_average_now() );
printf("Average time in the RLC SDU %lf us \n", av); // printf("Average time in the RLC SDU %lf us \n", av);
} }
nr_rlc_free_sdu_segment(sdu); nr_rlc_free_sdu_segment(sdu);
...@@ -577,6 +577,14 @@ int nr_rlc_entity_um_generate_pdu(nr_rlc_entity_t *_entity, ...@@ -577,6 +577,14 @@ int nr_rlc_entity_um_generate_pdu(nr_rlc_entity_t *_entity,
return generate_tx_pdu(entity, buffer, size); return generate_tx_pdu(entity, buffer, size);
} }
double nr_rlc_entity_um_sojourn_time(nr_rlc_entity_um_t const *entity)
{
double const av = time_average_get_average(entity->common.txsdu_avg_time_to_tx, time_average_now() );
return av;
}
/*************************************************************************/ /*************************************************************************/
/* SDU RX functions */ /* SDU RX functions */
/*************************************************************************/ /*************************************************************************/
......
...@@ -77,4 +77,6 @@ void nr_rlc_entity_um_reestablishment(nr_rlc_entity_t *_entity); ...@@ -77,4 +77,6 @@ void nr_rlc_entity_um_reestablishment(nr_rlc_entity_t *_entity);
void nr_rlc_entity_um_delete(nr_rlc_entity_t *entity); void nr_rlc_entity_um_delete(nr_rlc_entity_t *entity);
int nr_rlc_entity_um_available_tx_space(nr_rlc_entity_t *entity); int nr_rlc_entity_um_available_tx_space(nr_rlc_entity_t *entity);
double nr_rlc_entity_um_sojourn_time(nr_rlc_entity_um_t const *entity);
#endif /* _NR_RLC_ENTITY_UM_H_ */ #endif /* _NR_RLC_ENTITY_UM_H_ */
...@@ -1048,7 +1048,7 @@ void nr_rlc_activate_avg_time_to_tx( ...@@ -1048,7 +1048,7 @@ void nr_rlc_activate_avg_time_to_tx(
} }
/* returns false in case of error, true if everything ok */ /* returns false in case of error, true if everything ok */
const bool nr_rlc_get_statistics( bool nr_rlc_get_statistics(
int rnti, int rnti,
int srb_flag, int srb_flag,
int rb_id, int rb_id,
......
...@@ -29,15 +29,100 @@ ...@@ -29,15 +29,100 @@
*/ */
#include "NR_RLC-BearerConfig.h" #ifndef NR_RLC_OAI_API_H_MIR
#include "NR_RLC-Config.h" #define NR_RLC_OAI_API_H_MIR
#include "NR_LogicalChannelIdentity.h"
#include "NR_RadioBearerConfig.h"
#include "NR_CellGroupConfig.h"
#include "openair2/RRC/NR/nr_rrc_proto.h"
struct NR_RLC_Config; //#include "../../../openair2/RRC/NR/nr_rrc_proto.h"
struct NR_LogicalChannelConfig;
//#include "openair2/../cmake_targets/ran_build/build/openair2/RRC/NR/MESSAGES/NR_RLC-BearerConfig.h"
//#include "NR_RLC-Config.h"
//#include "NR_LogicalChannelIdentity.h"
//#include "NR_RadioBearerConfig.h"
//#include "NR_CellGroupConfig.h"
//#include "openair2/LAYER2/nr_rlc/nr_rlc_entity.h"
#include <stdint.h>
#include <stdbool.h>
typedef int32_t sdu_size_t;
typedef unsigned int logical_chan_id_t;
typedef uint16_t rnti_t;
typedef enum {
NR_RLC_AM,
NR_RLC_UM,
NR_RLC_TM,
} nr_rlc_mode_t;
typedef struct {
nr_rlc_mode_t mode; /* AM, UM, or TM */
/* PDU stats */
/* TX */
uint32_t txpdu_pkts; /* aggregated number of transmitted RLC PDUs */
uint32_t txpdu_bytes; /* aggregated amount of transmitted bytes in RLC PDUs */
/* TODO? */
uint32_t txpdu_wt_ms; /* aggregated head-of-line tx packet waiting time to be transmitted (i.e. send to the MAC layer) */
uint32_t txpdu_dd_pkts; /* aggregated number of dropped or discarded tx packets by RLC */
uint32_t txpdu_dd_bytes; /* aggregated amount of bytes dropped or discarded tx packets by RLC */
uint32_t txpdu_retx_pkts; /* aggregated number of tx pdus/pkts to be re-transmitted (only applicable to RLC AM) */
uint32_t txpdu_retx_bytes; /* aggregated amount of bytes to be re-transmitted (only applicable to RLC AM) */
uint32_t txpdu_segmented; /* aggregated number of segmentations */
uint32_t txpdu_status_pkts; /* aggregated number of tx status pdus/pkts (only applicable to RLC AM) */
uint32_t txpdu_status_bytes; /* aggregated amount of tx status bytes (only applicable to RLC AM) */
/* TODO? */
uint32_t txbuf_occ_bytes; /* current tx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */
/* TODO? */
uint32_t txbuf_occ_pkts; /* current tx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */
/* txbuf_wd_ms: the time window for which the txbuf occupancy value is obtained - NOT IMPLEMENTED */
/* RX */
uint32_t rxpdu_pkts; /* aggregated number of received RLC PDUs */
uint32_t rxpdu_bytes; /* amount of bytes received by the RLC */
uint32_t rxpdu_dup_pkts; /* aggregated number of duplicate packets */
uint32_t rxpdu_dup_bytes; /* aggregated amount of duplicated bytes */
uint32_t rxpdu_dd_pkts; /* aggregated number of rx packets dropped or discarded by RLC */
uint32_t rxpdu_dd_bytes; /* aggregated amount of rx bytes dropped or discarded by RLC */
uint32_t rxpdu_ow_pkts; /* aggregated number of out of window received RLC pdu */
uint32_t rxpdu_ow_bytes; /* aggregated number of out of window bytes received RLC pdu */
uint32_t rxpdu_status_pkts; /* aggregated number of rx status pdus/pkts (only applicable to RLC AM) */
uint32_t rxpdu_status_bytes; /* aggregated amount of rx status bytes (only applicable to RLC AM) */
/* rxpdu_rotout_ms: flag indicating rx reordering timeout in ms - NOT IMPLEMENTED */
/* rxpdu_potout_ms: flag indicating the poll retransmit time out in ms - NOT IMPLEMENTED */
/* rxpdu_sptout_ms: flag indicating status prohibit timeout in ms - NOT IMPLEMENTED */
/* TODO? */
uint32_t rxbuf_occ_bytes; /* current rx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */
/* TODO? */
uint32_t rxbuf_occ_pkts; /* current rx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */
/* SDU stats */
/* TX */
uint32_t txsdu_pkts; /* number of SDUs delivered */
uint32_t txsdu_bytes; /* number of bytes of SDUs delivered */
/* RX */
uint32_t rxsdu_pkts; /* number of SDUs received */
uint32_t rxsdu_bytes; /* number of bytes of SDUs received */
uint32_t rxsdu_dd_pkts; /* number of dropped or discarded SDUs */
uint32_t rxsdu_dd_bytes; /* number of bytes of SDUs dropped or discarded */
/* Average time for an SDU to be passed to MAC.
* Actually measures the time it takes for any part of an SDU to be
* passed to MAC for the first time, that is: the first TX of (part of) the
* SDU.
* Since the MAC schedules in advance, it does not measure the time of
* transmission over the air, just the time to reach the MAC layer.
*/
double txsdu_avg_time_to_tx;
} nr_rlc_statistics_t;
//struct NR_RLC_Config;
//struct NR_LogicalChannelConfig;
typedef struct NR_RLC_BearerConfig NR_RLC_BearerConfig_t;
void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig); void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig);
void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig); void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig);
...@@ -63,3 +148,10 @@ void nr_rlc_activate_srb0(int rnti, struct gNB_MAC_INST_s *mac, void *rawUE, ...@@ -63,3 +148,10 @@ void nr_rlc_activate_srb0(int rnti, struct gNB_MAC_INST_s *mac, void *rawUE,
const uint8_t *sdu, const uint8_t *sdu,
sdu_size_t sdu_len, sdu_size_t sdu_len,
void *rawUE)); void *rawUE));
bool nr_rlc_get_statistics(
int rnti,
int srb_flag,
int rb_id,
nr_rlc_statistics_t *out);
#endif
...@@ -66,7 +66,10 @@ void nr_pdcp_submit_sdap_ctrl_pdu(ue_id_t ue_id, rb_id_t sdap_ctrl_pdu_drb, nr_s ...@@ -66,7 +66,10 @@ void nr_pdcp_submit_sdap_ctrl_pdu(ue_id_t ue_id, rb_id_t sdap_ctrl_pdu_drb, nr_s
return; return;
} }
static int get_single_ue_rnti(void)
#ifdef MIR_FLAG
int get_single_ue_rnti(void)
{ {
NR_UE_info_t *ue = NULL; NR_UE_info_t *ue = NULL;
UE_iterator(RC.nrmac[0]->UE_info.list, it) { UE_iterator(RC.nrmac[0]->UE_info.list, it) {
...@@ -87,7 +90,6 @@ static int get_single_ue_rnti(void) ...@@ -87,7 +90,6 @@ static int get_single_ue_rnti(void)
} }
#ifdef MIR_FLAG
//static_assert(0!=0, "Compiled"); //static_assert(0!=0, "Compiled");
......
...@@ -170,4 +170,8 @@ nr_sdap_entity_t *nr_sdap_get_entity(ue_id_t ue_id, int pdusession_id); ...@@ -170,4 +170,8 @@ nr_sdap_entity_t *nr_sdap_get_entity(ue_id_t ue_id, int pdusession_id);
/* Entity Handling Related Functions */ /* Entity Handling Related Functions */
void delete_nr_sdap_entity(ue_id_t ue_id); void delete_nr_sdap_entity(ue_id_t ue_id);
// mir hack
int get_single_ue_rnti(void);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment