Commit dc9cada6 authored by nikaeinn's avatar nikaeinn
Browse files

Add PDCP stats and update agent and RAN APIs

parent e996f5d0
......@@ -762,6 +762,7 @@ include_directories("${OPENAIR_DIR}/targets/ARCH/EXMIMO/DEFS")
include_directories("${OPENAIR2_DIR}/ENB_APP")
include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC")
include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/RRC")
include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/PDCP")
include_directories("${OPENAIR2_DIR}/UTIL/OSA")
include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds6.1.1/liblfds611/inc")
include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/inc")
......@@ -852,6 +853,7 @@ if (FLEXRAN_AGENT_SB_IF)
${OPENAIR2_DIR}/ENB_APP/flexran_agent_common_internal.c
${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c
${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/RRC/flexran_agent_rrc.c
${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/PDCP/flexran_agent_pdcp.c
${OPENAIR2_DIR}/ENB_APP/flexran_agent.c
${OPENAIR2_DIR}/ENB_APP/flexran_agent_task_manager.c
${OPENAIR2_DIR}/ENB_APP/flexran_agent_net_comm.c
......
......@@ -128,7 +128,7 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
rlc_reports[j]->retransmission_queue_hol_delay = 100;
rlc_reports[j]->has_retransmission_queue_hol_delay = 0;
//TODO DONE:Set current size of the pending message in bytes
rlc_reports[j]->status_pdu_size = flexran_get_tx_queue_size(enb_id, i, j + 1);
rlc_reports[j]->status_pdu_size = flexran_get_num_pdus_buffer(enb_id , i, j + 1);
rlc_reports[j]->has_status_pdu_size = 1;
}
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file flexran_agent_pdcp.c
* \brief FlexRAN agent Control Module PDCP
* \author shahab SHARIAT BAGHERI
* \date 2017
* \version 0.1
*/
#include "flexran_agent_pdcp.h"
/*Trigger boolean for PDCP measurement*/
bool triggered_pdcp = false;
/*Flags showing if a pdcp agent has already been registered*/
unsigned int pdcp_agent_registered[NUM_MAX_ENB];
/*Array containing the Agent-PDCP interfaces*/
AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB];
// NUMBER_OF_UE_MAX
void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id,
const mid_t ue_id,
Protocol__FlexPdcpStats *pdcp_aggr_stats){
int lcid=0;
/* only calculate the DRBs */
//LOG_I(FLEXRAN_AGENT, "enb %d ue %d \n", mod_id, ue_id);
for (lcid=NUM_MAX_SRB ; lcid < NUM_MAX_SRB + NUM_MAX_DRB; lcid++){
pdcp_aggr_stats->pkt_tx += flexran_get_pdcp_tx(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_tx_bytes += flexran_get_pdcp_tx_bytes(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_tx_rate_s += flexran_get_pdcp_tx_rate_s(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_tx_throughput_s += flexran_get_pdcp_tx_throughput_s(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_tx_aiat += flexran_get_pdcp_tx_aiat(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_tx_aiat_s += flexran_get_pdcp_tx_aiat_s(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_rx += flexran_get_pdcp_rx(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_rx_bytes += flexran_get_pdcp_rx_bytes(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_rx_rate_s += flexran_get_pdcp_rx_rate_s(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_rx_goodput_s += flexran_get_pdcp_rx_goodput_s(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_rx_aiat += flexran_get_pdcp_rx_aiat(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_rx_aiat_s += flexran_get_pdcp_rx_aiat_s(mod_id,ue_id,lcid);
pdcp_aggr_stats->pkt_rx_oo += flexran_get_pdcp_rx_oo(mod_id,ue_id,lcid);
}
}
int flexran_agent_pdcp_stats_reply(mid_t mod_id,
const report_config_t *report_config,
Protocol__FlexUeStatsReport **ue_report,
Protocol__FlexCellStatsReport **cell_report) {
// Protocol__FlexHeader *header;
int i, j, k;
// int cc_id = 0;
/* Allocate memory for list of UE reports */
if (report_config->nr_ue > 0) {
for (i = 0; i < report_config->nr_ue; i++) {
/* Check flag for creation of buffer status report */
if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PDCP_STATS) {
Protocol__FlexPdcpStats *pdcp_aggr_stats;
pdcp_aggr_stats = malloc(sizeof(Protocol__FlexPdcpStats));
if (pdcp_aggr_stats == NULL)
goto error;
protocol__flex_pdcp_stats__init(pdcp_aggr_stats);
flexran_agent_pdcp_aggregate_stats(mod_id, i, pdcp_aggr_stats);
pdcp_aggr_stats->has_pkt_tx=1;
pdcp_aggr_stats->has_pkt_tx_bytes =1;
pdcp_aggr_stats->has_pkt_tx_rate_s=1;
pdcp_aggr_stats->has_pkt_tx_throughput_s =1;
pdcp_aggr_stats->has_pkt_tx_aiat =1;
pdcp_aggr_stats->has_pkt_tx_aiat_s =1;
pdcp_aggr_stats->pkt_tx_sn = flexran_get_pdcp_tx_sn(mod_id, i, DEFAULT_DRB);
pdcp_aggr_stats->has_pkt_tx_sn =1;
pdcp_aggr_stats->has_pkt_rx =1;
pdcp_aggr_stats->has_pkt_rx_bytes =1;
pdcp_aggr_stats->has_pkt_rx_rate_s =1;
pdcp_aggr_stats->has_pkt_rx_goodput_s =1;
pdcp_aggr_stats->has_pkt_rx_aiat =1;
pdcp_aggr_stats->has_pkt_rx_aiat_s =1;
pdcp_aggr_stats->has_pkt_rx_oo =1;
pdcp_aggr_stats->pkt_rx_sn = flexran_get_pdcp_rx_sn(mod_id, i, DEFAULT_DRB);
pdcp_aggr_stats->has_pkt_rx_sn =1;
ue_report[i]->pdcp_stats = pdcp_aggr_stats;
}
}
} else {
LOG_D(FLEXRAN_AGENT, "no UE\n");
}
return 0;
error:
LOG_W(FLEXRAN_AGENT, "Can't allocate PDCP stats\n");
/* if (cell_report != NULL)
free(cell_report);
if (ue_report != NULL)
free(ue_report);
*/
return -1;
}
int flexran_agent_register_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface) {
if (pdcp_agent_registered[mod_id]) {
LOG_E(PDCP, "PDCP agent for eNB %d is already registered\n", mod_id);
return -1;
}
//xface->flexran_pdcp_stats_measurement = NULL;
pdcp_agent_registered[mod_id] = 1;
agent_pdcp_xface[mod_id] = xface;
return 0;
}
int flexran_agent_unregister_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface) {
//xface->agent_ctxt = NULL;
//xface->flexran_pdcp_stats_measurement = NULL;
pdcp_agent_registered[mod_id] = 0;
agent_pdcp_xface[mod_id] = NULL;
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file flexran_agent_pdcp.h
* \brief FlexRAN agent Control Module PDCP header
* \author shahab SHARIAT BAGHERI
* \date 2017
* \version 0.1
*/
#ifndef FLEXRAN_AGENT_PDCP_H_
#define FLEXRAN_AGENT_PDCP_H_
#include "header.pb-c.h"
#include "flexran.pb-c.h"
#include "stats_messages.pb-c.h"
#include "stats_common.pb-c.h"
#include "flexran_agent_common.h"
#include "flexran_agent_defs.h"
#include "flexran_agent_pdcp_defs.h"
#include "flexran_agent_ran_api.h"
/**********************************
* FlexRAN agent - technology PDCP API
**********************************/
/* Send to the controller all the pdcp stat updates that occured during this subframe*/
int flexran_agent_pdcp_stats_reply(mid_t mod_id,
const report_config_t *report_config,
Protocol__FlexUeStatsReport **ue_report,
Protocol__FlexCellStatsReport **cell_report);
/* Get the stats from RAN API and aggregate them per USER*/
void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id,
const mid_t ue_id,
Protocol__FlexPdcpStats *pdcp_aggr_stats);
/*Register technology specific interface callbacks*/
int flexran_agent_register_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface);
/*Unregister technology specific callbacks*/
int flexran_agent_unregister_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface*xface);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef __FLEXRAN_AGENT_PDCP_PRIMITIVES_H__
#define __FLEXRAN_AGENT_PDCP_PRIMITIVES_H__
#include "flexran_agent_defs.h"
#include "flexran.pb-c.h"
#include "header.pb-c.h"
/*PDCP aggregated Packet stats */
/*
typedef struct pdcp_aggr_stats_s {
int32_t rnti;
int32_t pkt_tx;
int32_t pkt_tx_bytes;
int32_t pkt_tx_sn;
int32_t pkt_tx_rate_s;
int32_t pkt_tx_throughput_s;
int32_t pkt_tx_aiat;
int32_t pkt_tx_aiat_s;
int32_t pkt_rx;
int32_t pkt_rx_bytes;
int32_t pkt_rx_sn;
int32_t pkt_rx_rate_s;
int32_t pkt_rx_goodput_s;
int32_t pkt_rx_aiat;
int32_t pkt_rx_aiat_s;
int32_t pkt_rx_oo;
} pdcp_aggr_stats_t;
*/
/* FLEXRAN AGENT-PDCP Interface */
typedef struct {
// PDCP statistics
void (*flexran_pdcp_stats_measurement)(mid_t mod_id, uint16_t rnti, uint16_t seq_num, uint32_t size);
} AGENT_PDCP_xface;
#endif
......@@ -33,33 +33,15 @@
#include "log.h"
/*Trigger boolean for RRC measurement*/
bool triggered_rrc = false;
/*Flags showing if a rrc agent has already been registered*/
/*Flags showing if an rrc agent has already been registered*/
unsigned int rrc_agent_registered[NUM_MAX_ENB];
/*Array containing the Agent-RRC interfaces*/
AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB];
/* Ringbuffer related structs used for maintaining the dl rrc config messages */
//message_queue_t *rrc_dl_config_queue;
struct lfds700_misc_prng_state rrc_ps[NUM_MAX_ENB];
struct lfds700_ringbuffer_element *rrc_dl_config_array[NUM_MAX_ENB];
struct lfds700_ringbuffer_state rrc_ringbuffer_state[NUM_MAX_ENB];
void flexran_agent_init_rrc_agent(mid_t mod_id) {
lfds700_misc_library_init_valid_on_current_logical_core();
lfds700_misc_prng_init(&rrc_ps[mod_id]);
int num_elements = RINGBUFFER_SIZE + 1;
//Allow RINGBUFFER_SIZE messages to be stored in the ringbuffer at any time
rrc_dl_config_array[mod_id] = malloc( sizeof(struct lfds700_ringbuffer_element) * num_elements);
lfds700_ringbuffer_init_valid_on_current_logical_core( &rrc_ringbuffer_state[mod_id], rrc_dl_config_array[mod_id], num_elements, &rrc_ps[mod_id], NULL );
}
void flexran_agent_ue_state_change(mid_t mod_id, uint32_t rnti, uint8_t state_change) {
int size;
......@@ -280,155 +262,25 @@ int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg) {
/* this is called by RRC as a part of rrc xface . The controller previously requested this*/
void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults) {
// int i, m, k;
int priority = 0; // Warning Preventing
void *data;
int size;
err_code_t err_code;
Protocol__FlexUeStatsReport **ue_report;
Protocol__FlexCellStatsReport **cell_report;
Protocol__FlexStatsReply *stats_reply_msg;
Protocol__FlexranMessage *msg;
Protocol__FlexHeader *header;
int xid = 0;
int i;
if (flexran_create_header(xid, PROTOCOL__FLEX_TYPE__FLPT_STATS_REPLY, &header) != 0)
goto error;
int i, m, k;
// int priority = 0; // Warning Preventing
// void *data;
// int size;
err_code_t err_code = -100;
triggered_rrc = true;
int num;
num = flexran_get_num_ues (mod_id);
meas_stats = malloc(sizeof(rrc_meas_stats) * num);
stats_reply_msg = malloc(sizeof(Protocol__FlexStatsReply));
for (i = 0; i < num; i++){
meas_stats[i].rnti = flexran_get_ue_crnti(mod_id, i);
meas_stats[i].meas_id = measResults->measId;
meas_stats[i].rsrp = measResults->measResultPCell.rsrpResult - 140;
meas_stats[i].rsrq = (measResults->measResultPCell.rsrqResult)/2 - 20;
if (stats_reply_msg == NULL)
goto error;
protocol__flex_stats_reply__init(stats_reply_msg);
stats_reply_msg->header = header;
stats_reply_msg->n_ue_report = 1;
stats_reply_msg->n_cell_report = 1;
/****** LOCK ******************************************************************/
// pthread_spin_lock(&rrc_meas_t_lock);
// struct rrc_meas_trigg *ctxt;
// ctxt = rrc_meas_get_trigg(p->rnti, p->meas->measId);
// pthread_spin_unlock(&rrc_meas_t_lock);
/****** UNLOCK ****************************************************************/
// if (ctxt == NULL) {
// flexran_RRC_meas_reconf(p->rnti, -1, p->meas->measId, NULL, NULL);
// Free the measurement report received from UE.
// ASN_STRUCT_FREE(asn_DEF_MeasResults, p->meas);
// /* Free the params. */
// free(p);
// return 0;
// }
/* Check here whether trigger is registered in agent and then proceed.
*/
// if (em_has_trigger(mod_id, ctxt->t_id, RRC_MEAS_TRIGGER) == 0) {
// flexran_RRC_meas_reconf(p->rnti, -1, p->meas->measId, NULL, NULL);
// /* Trigger does not exist in agent so remove from wrapper as well. */
// if (rrc_meas_rem_trigg(ctxt) < 0) {
// goto error;
// }
// }
/* Set the RNTI of the UE. */
// repl->rnti = p->rnti;
/* Set the request status. */
// if (p->reconfig_success == 0) {
// repl->status = STATS_REQ_STATUS__SREQS_FAILURE;
// goto error;
// }
/* Successful outcome. */
// repl->status = STATS_REQ_STATUS__SREQS_SUCCESS;
/* Set the measurement ID of measurement. */
// repl->has_measid = 1;
// repl->measid = measResults->measId;
/* Fill the Primary Cell RSRP and RSRQ. */
// repl->has_pcell_rsrp = 1;
// repl->has_pcell_rsrq = 1;
// #ifdef Rel10
// repl->has_pcell_rsrp = 1;
// repl->has_pcell_rsrq = 1;
// repl->pcell_rsrp = measResults2->measResultPCell.rsrpResult - 140;
// repl->pcell_rsrq = (measResults2->measResultPCell.rsrqResult)/2 - 20;
ue_report = malloc(sizeof(Protocol__FlexUeStatsReport *) * 1);
if (ue_report == NULL)
goto error;
for (i = 0; i < 1; i++) {
ue_report[i] = malloc(sizeof(Protocol__FlexUeStatsReport));
if(ue_report[i] == NULL)
goto error;
protocol__flex_ue_stats_report__init(ue_report[i]);
ue_report[i]->rnti = flexran_get_ue_crnti(mod_id, 0);
ue_report[i]->has_rnti = 1;
ue_report[i]->flags = 65536;
ue_report[i]->has_flags = 1;
}
cell_report = malloc(sizeof(Protocol__FlexCellStatsReport *) * 1);
if (cell_report == NULL)
goto error;
for (i = 0; i < 1; i++) {
cell_report[i] = malloc(sizeof(Protocol__FlexCellStatsReport));
if(cell_report[i] == NULL)
goto error;
protocol__flex_cell_stats_report__init(cell_report[i]);
cell_report[i]->carrier_index = 0; //report_config->cc_report_type[i].cc_id;
cell_report[i]->has_carrier_index = 1;
cell_report[i]->flags = 0; // report_config->cc_report_type[i].cc_report_flags;
cell_report[i]->has_flags = 1;
}
Protocol__FlexRrcMeasurements *rrc_measurements;
rrc_measurements = malloc(sizeof(Protocol__FlexRrcMeasurements));
if (rrc_measurements == NULL)
goto error;
protocol__flex_rrc_measurements__init(rrc_measurements);
rrc_measurements->measid = measResults->measId;
rrc_measurements->has_measid = 1;
rrc_measurements->pcell_rsrp = measResults->measResultPCell.rsrpResult - 140;
rrc_measurements->has_pcell_rsrp = 1;
rrc_measurements->pcell_rsrq = (measResults->measResultPCell.rsrqResult)/2 - 20;
rrc_measurements->has_pcell_rsrq = 1 ;
ue_report[0]->rrc_measurements = rrc_measurements;
// #else
// repl->has_pcell_rsrp = 1;
// repl->has_pcell_rsrq = 1;
// repl->pcell_rsrp = RSRP_meas_mapping[meas->
// measResultServCell.rsrpResult];
// repl->pcell_rsrq = RSRQ_meas_mapping[meas->
// measResultServCell.rsrqResult];
// #endif
// repl->neigh_meas = NULL;
// if (meas->measResultNeighCells != NULL) {
......@@ -595,34 +447,34 @@ void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults
// free(p);
stats_reply_msg->cell_report = cell_report;
// stats_reply_msg->cell_report = cell_report;
stats_reply_msg->ue_report = ue_report;
// stats_reply_msg->ue_report = ue_report;
msg = malloc(sizeof(Protocol__FlexranMessage));
if(msg == NULL)
goto error;
protocol__flexran_message__init(msg);
msg->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG;
msg->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__SUCCESSFUL_OUTCOME;
msg->stats_reply_msg = stats_reply_msg;
// msg = malloc(sizeof(Protocol__FlexranMessage));
// if(msg == NULL)
// goto error;
// protocol__flexran_message__init(msg);
// msg->msg_case = PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG;
// msg->msg_dir = PROTOCOL__FLEXRAN_DIRECTION__SUCCESSFUL_OUTCOME;
// msg->stats_reply_msg = stats_reply_msg;
data = flexran_agent_pack_message(msg, &size);
// data = flexran_agent_pack_message(msg, &size);
if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) {
// if (flexran_agent_msg_send(mod_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) {
err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING;
goto error;
}
// err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING;
// goto error;
// }
LOG_I(FLEXRAN_AGENT,"RRC Trigger is done \n");
// LOG_I(FLEXRAN_AGENT,"RRC Trigger is done \n");
return;
error:
// error:
LOG_E(FLEXRAN_AGENT, "Could not send UE state message becasue of %d \n",err_code);
// LOG_E(FLEXRAN_AGENT, "Could not send UE state message becasue of %d \n",err_code);
/* Free the measurement report received from UE. */
// ASN_STRUCT_FREE(asn_DEF_MeasResults, p->meas);
/* Free the params. */
......@@ -631,6 +483,98 @@ void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults
}
int flexran_agent_rrc_stats_reply(mid_t mod_id,
const report_config_t *report_config,
Protocol__FlexUeStatsReport **ue_report,
Protocol__FlexCellStatsReport **cell_report) {
// Protocol__FlexHeader *header;
int i, j, k;
// int cc_id = 0;
int enb_id = mod_id;
/* Allocate memory for list of UE reports */
if (report_config->nr_ue > 0) {