lib,rlc_am_nr: Fixed some metrics calculation. Added more precise metrics checking to unit tests

master
Pedro Alvarez 3 years ago
parent 5eaa56e6ba
commit b497d773ce

@ -149,6 +149,7 @@ public:
// Data handling methods
void handle_data_pdu_full(uint8_t* payload, uint32_t nof_bytes, rlc_am_nr_pdu_header_t& header);
bool inside_rx_window(uint32_t sn);
void write_to_upper_layers(uint32_t lcid, unique_byte_buffer_t sdu);
// Metrics
uint32_t get_sdu_rx_latency_ms() final;

@ -107,9 +107,11 @@ void rlc_am::reestablish()
***************************************************************************/
void rlc_am::write_sdu(unique_byte_buffer_t sdu)
{
uint32_t nof_bytes = sdu->N_bytes;
if (tx_base->write_sdu(std::move(sdu)) == SRSRAN_SUCCESS) {
std::lock_guard<std::mutex> lock(metrics_mutex);
metrics.num_tx_sdus++;
metrics.num_tx_sdu_bytes += nof_bytes;
}
}

@ -470,7 +470,7 @@ void rlc_am_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_bytes)
memcpy(rx_sdu.buf->msg, payload + hdr_len, nof_bytes - hdr_len); // Don't copy header
rx_sdu.buf->N_bytes = nof_bytes - hdr_len;
rx_sdu.fully_received = true;
parent->pdcp->write_pdu(parent->lcid, std::move(rx_window[header.sn].buf));
write_to_upper_layers(parent->lcid, std::move(rx_window[header.sn].buf));
} else {
// Check if all bytes of the RLC SDU with SN = x are received:
// TODO
@ -680,6 +680,15 @@ void rlc_am_nr_rx::timer_expired(uint32_t timeout_id)
}
}
void rlc_am_nr_rx::write_to_upper_layers(uint32_t lcid, unique_byte_buffer_t sdu)
{
uint32_t nof_bytes = sdu->N_bytes;
parent->pdcp->write_pdu(lcid, std::move(sdu));
std::lock_guard<std::mutex> lock(parent->metrics_mutex);
parent->metrics.num_rx_sdus++;
parent->metrics.num_rx_sdu_bytes += nof_bytes;
}
/*
* Metrics
*/

@ -115,8 +115,36 @@ int basic_test()
rlc_am_nr_tx_state_t st = tx1->get_tx_state();
TESTASSERT_EQ(5, st.tx_next_ack);
TESTASSERT_EQ(0, tx1->get_tx_window_size());
// Check statistics
TESTASSERT(rx_is_tx(rlc1.get_metrics(), rlc2.get_metrics()));
rlc_bearer_metrics_t metrics1 = rlc1.get_metrics();
rlc_bearer_metrics_t metrics2 = rlc2.get_metrics();
// RLC1 PDU metrics
TESTASSERT_EQ(5, metrics1.num_tx_sdus);
TESTASSERT_EQ(0, metrics1.num_rx_sdus);
TESTASSERT_EQ(5, metrics1.num_tx_sdu_bytes);
TESTASSERT_EQ(0, metrics1.num_rx_sdu_bytes);
TESTASSERT_EQ(0, metrics1.num_lost_sdus);
// RLC1 SDU metrics
TESTASSERT_EQ(5, metrics1.num_tx_pdus);
TESTASSERT_EQ(1, metrics1.num_rx_pdus); // One status PDU
TESTASSERT_EQ(15, metrics1.num_tx_pdu_bytes); // 2 Bytes * NBUFFS (header size) + NBUFFS (data) = 15
TESTASSERT_EQ(3, metrics1.num_rx_pdu_bytes); // One status PDU
TESTASSERT_EQ(0, metrics1.num_lost_sdus); // No lost SDUs
// RLC2 PDU metrics
TESTASSERT_EQ(0, metrics2.num_tx_sdus);
TESTASSERT_EQ(5, metrics2.num_rx_sdus);
TESTASSERT_EQ(0, metrics2.num_tx_sdu_bytes);
TESTASSERT_EQ(5, metrics2.num_rx_sdu_bytes);
TESTASSERT_EQ(0, metrics2.num_lost_sdus);
// RLC2 SDU metrics
TESTASSERT_EQ(1, metrics2.num_tx_pdus); // One status PDU
TESTASSERT_EQ(5, metrics2.num_rx_pdus); // 5 SDUs
TESTASSERT_EQ(3, metrics2.num_tx_pdu_bytes); // One status PDU
TESTASSERT_EQ(15, metrics2.num_rx_pdu_bytes); // 2 Bytes * NBUFFS (header size) + NBUFFS (data) = 15
TESTASSERT_EQ(0, metrics2.num_lost_sdus); // No lost SDUs
return SRSRAN_SUCCESS;
}
@ -217,8 +245,36 @@ int lost_pdu_test()
TESTASSERT(0 == rlc2.get_buffer_state());
}
// Check statistics
TESTASSERT(rx_is_tx(rlc1.get_metrics(), rlc2.get_metrics()));
rlc_bearer_metrics_t metrics1 = rlc1.get_metrics();
rlc_bearer_metrics_t metrics2 = rlc2.get_metrics();
// SDU metrics
TESTASSERT_EQ(5, metrics1.num_tx_sdus);
TESTASSERT_EQ(0, metrics1.num_rx_sdus);
TESTASSERT_EQ(5, metrics1.num_tx_sdu_bytes);
TESTASSERT_EQ(0, metrics1.num_rx_sdu_bytes);
TESTASSERT_EQ(0, metrics1.num_lost_sdus);
// PDU metrics
TESTASSERT_EQ(5 + 1, metrics1.num_tx_pdus); // One re-transmission
TESTASSERT_EQ(2, metrics1.num_rx_pdus); // One status PDU
TESTASSERT_EQ(18, metrics1.num_tx_pdu_bytes); // 2 Bytes * NBUFFS (header size) + NBUFFS (data) + 1 rext (3) = 18
TESTASSERT_EQ(3 + 5, metrics1.num_rx_pdu_bytes); // Two status PDU (one with a NACK)
TESTASSERT_EQ(0, metrics1.num_lost_sdus); // No lost SDUs
// PDU metrics
TESTASSERT_EQ(0, metrics2.num_tx_sdus);
TESTASSERT_EQ(5, metrics2.num_rx_sdus);
TESTASSERT_EQ(0, metrics2.num_tx_sdu_bytes);
TESTASSERT_EQ(5, metrics2.num_rx_sdu_bytes);
TESTASSERT_EQ(0, metrics2.num_lost_sdus);
// SDU metrics
TESTASSERT_EQ(2, metrics2.num_tx_pdus); // Two status PDUs
TESTASSERT_EQ(5, metrics2.num_rx_pdus); // 5 PDUs (6 tx'ed, but one was lost)
TESTASSERT_EQ(5 + 3, metrics2.num_tx_pdu_bytes); // Two status PDU (one with a NACK)
TESTASSERT_EQ(15, metrics2.num_rx_pdu_bytes); // 2 Bytes * NBUFFS (header size) + NBUFFS (data) = 15
TESTASSERT_EQ(0, metrics2.num_lost_sdus); // No lost SDUs
return SRSRAN_SUCCESS;
}

Loading…
Cancel
Save