From fc3cd24177234339a2e344b702ff614ccd073e40 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 25 Jun 2020 17:03:12 +0200 Subject: [PATCH] rlc_um: fix counting of lost PDUs * change try_push() return value to indicate whether the addition of the SDU to the tx queue was successful or not * count lost PDUs --- lib/include/srslte/upper/rlc_metrics.h | 4 ++-- lib/include/srslte/upper/rlc_um_base.h | 2 +- lib/src/upper/rlc_um_base.cc | 10 +++++++--- lib/src/upper/rlc_um_lte.cc | 8 ++++++++ lib/test/upper/rlc_stress_test.cc | 2 ++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/include/srslte/upper/rlc_metrics.h b/lib/include/srslte/upper/rlc_metrics.h index d1851f71d..ab12cb9a8 100644 --- a/lib/include/srslte/upper/rlc_metrics.h +++ b/lib/include/srslte/upper/rlc_metrics.h @@ -34,8 +34,8 @@ typedef struct { uint64_t num_tx_bytes; uint64_t num_rx_bytes; - uint32_t num_lost_pdus; - uint32_t num_dropped_sdus; + uint32_t num_lost_pdus; //< Lost PDUs registered at Rx + uint32_t num_dropped_sdus; //< Count dropped SDUs at Tx due to bearer inactivity or empty buffer } rlc_bearer_metrics_t; typedef struct { diff --git a/lib/include/srslte/upper/rlc_um_base.h b/lib/include/srslte/upper/rlc_um_base.h index af8d7f09b..85e19390d 100644 --- a/lib/include/srslte/upper/rlc_um_base.h +++ b/lib/include/srslte/upper/rlc_um_base.h @@ -82,7 +82,7 @@ protected: void empty_queue(); void write_sdu(unique_byte_buffer_t sdu); void discard_sdu(uint32_t discard_sn); - void try_write_sdu(unique_byte_buffer_t sdu); + int try_write_sdu(unique_byte_buffer_t sdu); void reset_metrics(); bool has_data(); virtual uint32_t get_buffer_state() = 0; diff --git a/lib/src/upper/rlc_um_base.cc b/lib/src/upper/rlc_um_base.cc index f76097722..6fd6f666d 100644 --- a/lib/src/upper/rlc_um_base.cc +++ b/lib/src/upper/rlc_um_base.cc @@ -102,14 +102,16 @@ void rlc_um_base::write_sdu(unique_byte_buffer_t sdu, bool blocking) if (blocking) { tx->write_sdu(std::move(sdu)); } else { - tx->try_write_sdu(std::move(sdu)); + if (tx->try_write_sdu(std::move(sdu)) != SRSLTE_SUCCESS) { + metrics.num_dropped_sdus++; + } } } void rlc_um_base::discard_sdu(uint32_t discard_sn) { if (not tx_enabled || not tx) { - log->debug("%s is currently deactivated. Ignoring SDU discard(SN %u)\n", rb_name.c_str(), discard_sn); + log->debug("%s is currently deactivated. Ignoring SDU discard (SN %u)\n", rb_name.c_str(), discard_sn); metrics.num_dropped_sdus++; return; } @@ -251,7 +253,7 @@ void rlc_um_base::rlc_um_base_tx::write_sdu(unique_byte_buffer_t sdu) } } -void rlc_um_base::rlc_um_base_tx::try_write_sdu(unique_byte_buffer_t sdu) +int rlc_um_base::rlc_um_base_tx::try_write_sdu(unique_byte_buffer_t sdu) { if (sdu) { uint8_t* msg_ptr = sdu->msg; @@ -260,6 +262,7 @@ void rlc_um_base::rlc_um_base_tx::try_write_sdu(unique_byte_buffer_t sdu) if (ret) { log->info_hex( msg_ptr, nof_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rb_name.c_str(), nof_bytes, tx_sdu_queue.size()); + return SRSLTE_SUCCESS; } else { log->info_hex(ret.error()->msg, ret.error()->N_bytes, @@ -271,6 +274,7 @@ void rlc_um_base::rlc_um_base_tx::try_write_sdu(unique_byte_buffer_t sdu) } else { log->warning("NULL SDU pointer in write_sdu()\n"); } + return SRSLTE_ERROR; } void rlc_um_base::rlc_um_base_tx::discard_sdu(uint32_t discard_sn) diff --git a/lib/src/upper/rlc_um_lte.cc b/lib/src/upper/rlc_um_lte.cc index b98da8778..4d31adedf 100644 --- a/lib/src/upper/rlc_um_lte.cc +++ b/lib/src/upper/rlc_um_lte.cc @@ -374,6 +374,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus() rx_window[vr_ur].buf->msg += len; rx_window[vr_ur].buf->N_bytes -= len; rx_sdu->clear(); + metrics.num_lost_pdus++; break; } @@ -387,6 +388,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus() vr_ur, vr_ur_in_rx_sdu); rx_sdu->clear(); + metrics.num_lost_pdus++; } else { log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, @@ -423,6 +425,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus() if (pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { log->warning("Dropping remainder of lost PDU (lower edge last segments)\n"); rx_sdu->clear(); + metrics.num_lost_pdus++; } else { log->info_hex( rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (lower edge last segments)", rb_name.c_str(), vr_ur); @@ -486,6 +489,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus() rx_window[vr_ur].buf->msg += len; rx_window[vr_ur].buf->N_bytes -= len; rx_sdu->clear(); + metrics.num_lost_pdus++; // Reset flag, it is safe to process all remaining segments of this PDU pdu_lost = false; @@ -499,6 +503,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus() rx_sdu->N_bytes, len); rx_sdu->clear(); + metrics.num_lost_pdus++; goto clean_up_rx_window; } @@ -551,6 +556,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus() // Advance data pointers and continue with next segment rx_window[vr_ur].buf->msg += len; rx_window[vr_ur].buf->N_bytes -= len; + metrics.num_lost_pdus++; } pdu_lost = false; } @@ -560,6 +566,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus() !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { log->warning("Dropping PDU %d during last segment handling due to lost start segment\n", vr_ur); rx_sdu->clear(); + metrics.num_lost_pdus++; goto clean_up_rx_window; } @@ -587,6 +594,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus() if (pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { log->warning("Dropping remainder of lost PDU (update vr_ur last segments)\n"); rx_sdu->clear(); + metrics.num_lost_pdus++; } else { log->info_hex( rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (update vr_ur last segments)", rb_name.c_str(), vr_ur); diff --git a/lib/test/upper/rlc_stress_test.cc b/lib/test/upper/rlc_stress_test.cc index ac4462c9e..e0ccdf715 100644 --- a/lib/test/upper/rlc_stress_test.cc +++ b/lib/test/upper/rlc_stress_test.cc @@ -534,6 +534,7 @@ void stress_test(stress_test_args_t args) static_cast(tester1.get_nof_rx_pdus() / args.test_duration_sec), metrics.bearer[lcid].num_tx_bytes, metrics.bearer[lcid].num_rx_bytes); + printf("rlc1_num_lost=%d\n", metrics.bearer[lcid].num_lost_pdus); rlc2.get_metrics(metrics); printf("RLC2 received %d SDUs in %ds (%.2f/s), Tx=%" PRIu64 " B, Rx=%" PRIu64 " B\n", @@ -542,6 +543,7 @@ void stress_test(stress_test_args_t args) static_cast(tester2.get_nof_rx_pdus() / args.test_duration_sec), metrics.bearer[lcid].num_tx_bytes, metrics.bearer[lcid].num_rx_bytes); + printf("rlc2_num_lost=%d\n", metrics.bearer[lcid].num_lost_pdus); } int main(int argc, char** argv)