diff --git a/lib/include/srslte/interfaces/enb_metrics_interface.h b/lib/include/srslte/interfaces/enb_metrics_interface.h index ca3c25c0f..02168e874 100644 --- a/lib/include/srslte/interfaces/enb_metrics_interface.h +++ b/lib/include/srslte/interfaces/enb_metrics_interface.h @@ -27,9 +27,14 @@ namespace srsenb { +struct rlc_metrics_t { + std::vector ues; +}; + struct stack_metrics_t { mac_metrics_t mac; rrc_metrics_t rrc; + rlc_metrics_t rlc; s1ap_metrics_t s1ap; }; diff --git a/lib/include/srslte/upper/rlc_metrics.h b/lib/include/srslte/upper/rlc_metrics.h index e3f3dc5a3..599bb81b6 100644 --- a/lib/include/srslte/upper/rlc_metrics.h +++ b/lib/include/srslte/upper/rlc_metrics.h @@ -25,13 +25,14 @@ typedef struct { uint64_t num_tx_sdu_bytes; uint64_t num_rx_sdu_bytes; uint32_t num_lost_sdus; //< Count dropped SDUs at Tx due to bearer inactivity or empty buffer + uint64_t sdu_tx_latency_us; // PDU metrics uint32_t num_tx_pdus; uint32_t num_rx_pdus; uint64_t num_tx_pdu_bytes; uint64_t num_rx_pdu_bytes; - uint32_t num_lost_pdus; //< Lost PDUs registered at Rx + uint32_t num_lost_pdus; //< Lost PDUs registered at Rx } rlc_bearer_metrics_t; typedef struct { diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index a07c84777..96d0307a1 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -840,10 +840,11 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt #ifdef ENABLE_TIMESTAMP long latency_us = tx_sdu->get_latency_us().count(); mean_pdu_latency_us.push(latency_us); + parent->metrics.sdu_tx_latency_us = mean_pdu_latency_us.value(); log->debug("%s Complete SDU scheduled for tx. Stack latency (last/average): %ld/%ld us\n", RB_NAME, latency_us, - (long)mean_pdu_latency_us.value()); + (long)parent->metrics.sdu_tx_latency_us); #else log->debug("%s Complete SDU scheduled for tx.\n", rb_name.c_str()); #endif @@ -888,10 +889,11 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt #ifdef ENABLE_TIMESTAMP long latency_us = tx_sdu->get_latency_us().count(); mean_pdu_latency_us.push(latency_us); + parent->metrics.sdu_tx_latency_us = mean_pdu_latency_us.value(); log->debug("%s Complete SDU scheduled for tx. Stack latency (last/average): %ld/%ld us\n", RB_NAME, latency_us, - (long)mean_pdu_latency_us.value()); + (long)parent->metrics.sdu_tx_latency_us); #else log->debug("%s Complete SDU scheduled for tx.\n", rb_name.c_str()); #endif diff --git a/srsenb/hdr/stack/upper/rlc.h b/srsenb/hdr/stack/upper/rlc.h index 341697477..aea174b10 100644 --- a/srsenb/hdr/stack/upper/rlc.h +++ b/srsenb/hdr/stack/upper/rlc.h @@ -11,6 +11,7 @@ */ #include "srslte/interfaces/enb_interfaces.h" +#include "srslte/interfaces/enb_metrics_interface.h" #include "srslte/interfaces/ue_interfaces.h" #include "srslte/upper/rlc.h" #include @@ -36,6 +37,7 @@ public: srslte::timer_handler* timers_, srslte::log_ref log_h); void stop(); + void get_metrics(rlc_metrics_t& m, const uint32_t nof_tti); // rlc_interface_rrc void clear_buffer(uint16_t rnti); diff --git a/srsenb/src/stack/enb_stack_lte.cc b/srsenb/src/stack/enb_stack_lte.cc index d076981ed..06fe640be 100644 --- a/srsenb/src/stack/enb_stack_lte.cc +++ b/srsenb/src/stack/enb_stack_lte.cc @@ -172,6 +172,9 @@ bool enb_stack_lte::get_metrics(stack_metrics_t* metrics) auto ret = enb_task_queue.try_push([this]() { stack_metrics_t metrics{}; mac.get_metrics(metrics.mac); + if (not metrics.mac.ues.empty()) { + rlc.get_metrics(metrics.rlc, metrics.mac.ues[0].nof_tti); + } rrc.get_metrics(metrics.rrc); s1ap.get_metrics(metrics.s1ap); pending_stack_metrics.push(metrics); diff --git a/srsenb/src/stack/upper/rlc.cc b/srsenb/src/stack/upper/rlc.cc index 9faca0c3e..632a5147b 100644 --- a/srsenb/src/stack/upper/rlc.cc +++ b/srsenb/src/stack/upper/rlc.cc @@ -43,6 +43,16 @@ void rlc::stop() pthread_rwlock_destroy(&rwlock); } +void rlc::get_metrics(rlc_metrics_t& m, const uint32_t nof_tti) +{ + m.ues.resize(users.size()); + size_t count = 0; + for (auto& user : users) { + user.second.rlc->get_metrics(m.ues[count], nof_tti); + count++; + } +} + void rlc::add_user(uint16_t rnti) { pthread_rwlock_rdlock(&rwlock);