From 8873b7c42f1c1d2b060e7760071cc83f9ccbe334 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 15 Feb 2021 17:41:54 +0000 Subject: [PATCH] Added computation for the metrics --- lib/include/srslte/upper/pdcp_entity_base.h | 4 +++- lib/src/upper/pdcp_entity_lte.cc | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srslte/upper/pdcp_entity_base.h index 0e04a09b2..68cfaacee 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srslte/upper/pdcp_entity_base.h @@ -13,6 +13,7 @@ #ifndef SRSLTE_PDCP_ENTITY_BASE_H #define SRSLTE_PDCP_ENTITY_BASE_H +#include "srslte/adt/accumulators.h" #include "srslte/common/buffer_pool.h" #include "srslte/common/common.h" #include "srslte/common/interfaces_common.h" @@ -169,7 +170,8 @@ protected: void append_mac(const unique_byte_buffer_t& sdu, uint8_t* mac); // Metrics helpers - pdcp_bearer_metrics_t metrics = {}; + pdcp_bearer_metrics_t metrics = {}; + srslte::rolling_average tx_pdu_ack_latency_ms; }; inline uint32_t pdcp_entity_base::HFN(uint32_t count) diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 88c9f60d6..dc77f52a3 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -549,6 +549,7 @@ bool pdcp_entity_lte::store_sdu(uint32_t tx_count, const unique_byte_buffer_t& s sdu_copy->N_bytes = sdu->N_bytes; // Metrics + sdu_copy->set_timestamp(); metrics.num_tx_buffered_pdus++; metrics.num_tx_buffered_pdus_bytes += sdu->N_bytes; @@ -596,10 +597,20 @@ void pdcp_entity_lte::notify_delivery(const std::vector& pdcp_sns) return; } + // Metrics + tx_pdu_ack_latency_ms.push(std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - it->second->get_timestamp()) + .count()); + metrics.num_tx_acked_bytes += it->second->N_bytes; + metrics.num_tx_buffered_pdus_bytes -= it->second->N_bytes; + metrics.num_tx_buffered_pdus--; + // If ACK'ed bytes are equal to (or exceed) PDU size, remove PDU and disarm timer. undelivered_sdus_queue.erase(sn); discard_timers_map.erase(sn); } + + metrics.num_tx_buffered_pdus = undelivered_sdus_queue.size(); } /****************************************************************************