|
|
|
@ -892,6 +892,193 @@ int lost_pdus_trimmed_nack_test(rlc_am_nr_sn_size_t sn_size)
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test if retx queue is cleared of SDUs that are ACK'ed by a late/delayed ACK.
|
|
|
|
|
*/
|
|
|
|
|
int clean_retx_queue_of_acked_sdus_test(rlc_am_nr_sn_size_t sn_size)
|
|
|
|
|
{
|
|
|
|
|
rlc_am_tester tester;
|
|
|
|
|
timer_handler timers(8);
|
|
|
|
|
byte_buffer_t pdu_bufs[NBUFS];
|
|
|
|
|
|
|
|
|
|
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
|
|
|
|
|
rlc_am rlc1(srsran_rat_t::nr, srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
|
|
|
|
|
rlc_am rlc2(srsran_rat_t::nr, srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
|
|
|
|
|
test_delimit_logger delimiter("Clean retx_queue of SDUs that are ACK'ed by a late/delayed ACK ({} bit SN)",
|
|
|
|
|
to_number(sn_size));
|
|
|
|
|
|
|
|
|
|
constexpr uint32_t payload_size = 1;
|
|
|
|
|
uint32_t header_size = sn_size == rlc_am_nr_sn_size_t::size12bits ? 2 : 3;
|
|
|
|
|
uint32_t data_pdu_size = header_size + payload_size;
|
|
|
|
|
uint32_t expect_buffer_state = NBUFS * data_pdu_size;
|
|
|
|
|
|
|
|
|
|
if (not rlc1.configure(rlc_config_t::default_rlc_am_nr_config(to_number(sn_size)))) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rlc_config_t rlc2_config = rlc_config_t::default_rlc_am_nr_config(to_number(sn_size));
|
|
|
|
|
if (not rlc2.configure(rlc2_config)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rlc_am_nr_tx* rlc1_tx = dynamic_cast<rlc_am_nr_tx*>(rlc1.get_tx());
|
|
|
|
|
|
|
|
|
|
// after configuring entity
|
|
|
|
|
TESTASSERT(0 == rlc1.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
basic_test_tx(&rlc1, pdu_bufs, sn_size);
|
|
|
|
|
|
|
|
|
|
// Write 5 PDUs into RLC2
|
|
|
|
|
for (int i = 0; i < NBUFS; i++) {
|
|
|
|
|
if (i != 3) {
|
|
|
|
|
rlc2.write_pdu(pdu_bufs[i].msg, pdu_bufs[i].N_bytes); // Don't write RLC_SN=3.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only after t-reassembly has expired, will the status report include NACKs.
|
|
|
|
|
TESTASSERT_EQ(3, rlc2.get_buffer_state());
|
|
|
|
|
{
|
|
|
|
|
// Read status PDU from RLC2
|
|
|
|
|
byte_buffer_t status_buf;
|
|
|
|
|
int len = rlc2.read_pdu(status_buf.msg, 5);
|
|
|
|
|
status_buf.N_bytes = len;
|
|
|
|
|
|
|
|
|
|
TESTASSERT(0 == rlc2.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// Assert status is correct
|
|
|
|
|
rlc_am_nr_status_pdu_t status_check(sn_size);
|
|
|
|
|
rlc_am_nr_read_status_pdu(&status_buf, sn_size, &status_check);
|
|
|
|
|
TESTASSERT_EQ(3, status_check.ack_sn); // 3 is the next expected SN (i.e. the lost packet.)
|
|
|
|
|
|
|
|
|
|
// Write status PDU to RLC1
|
|
|
|
|
rlc1.write_pdu(status_buf.msg, status_buf.N_bytes);
|
|
|
|
|
|
|
|
|
|
// Check there is nothing pending in RLC1
|
|
|
|
|
TESTASSERT_EQ(0, rlc1.get_buffer_state());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Step timers until reassambly timeout expires
|
|
|
|
|
for (int cnt = 0; cnt < 35; cnt++) {
|
|
|
|
|
timers.step_all();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// t-reassembly has expired. There should be a NACK in the status report.
|
|
|
|
|
constexpr uint32_t status_pdu_ack_size = 3;
|
|
|
|
|
uint32_t status_pdu_nack_size = sn_size == rlc_am_nr_sn_size_t::size12bits ? 2 : 3;
|
|
|
|
|
TESTASSERT_EQ(status_pdu_ack_size + status_pdu_nack_size, rlc2.get_buffer_state());
|
|
|
|
|
{
|
|
|
|
|
// Read status PDU from RLC2
|
|
|
|
|
byte_buffer_t status_buf;
|
|
|
|
|
uint32_t len = rlc2.read_pdu(status_buf.msg, status_pdu_ack_size + status_pdu_nack_size);
|
|
|
|
|
status_buf.N_bytes = len;
|
|
|
|
|
|
|
|
|
|
TESTASSERT_EQ(0, rlc2.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// Assert status is correct
|
|
|
|
|
rlc_am_nr_status_pdu_t status_check(sn_size);
|
|
|
|
|
rlc_am_nr_read_status_pdu(&status_buf, sn_size, &status_check);
|
|
|
|
|
TESTASSERT_EQ(5, status_check.ack_sn); // 5 is the next expected SN.
|
|
|
|
|
TESTASSERT_EQ(1, status_check.nacks.size()); // We lost one PDU.
|
|
|
|
|
TESTASSERT_EQ(3, status_check.nacks[0].nack_sn); // Lost PDU SN=3.
|
|
|
|
|
|
|
|
|
|
// Write status PDU to RLC1
|
|
|
|
|
rlc1.write_pdu(status_buf.msg, status_buf.N_bytes);
|
|
|
|
|
|
|
|
|
|
// Check there is only one Retx of SN=3
|
|
|
|
|
TESTASSERT_EQ(data_pdu_size, rlc1.get_buffer_state());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// now we deliver the late PDU SN=3 to rlc2
|
|
|
|
|
rlc2.write_pdu(pdu_bufs[3].msg, pdu_bufs[3].N_bytes);
|
|
|
|
|
|
|
|
|
|
// Check there is only one Retx of SN=3
|
|
|
|
|
TESTASSERT_EQ(data_pdu_size, rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT_EQ(1, rlc1_tx->get_retx_queue_size());
|
|
|
|
|
|
|
|
|
|
// Step timers until reassambly timeout expires
|
|
|
|
|
for (int cnt = 0; cnt < 35; cnt++) {
|
|
|
|
|
timers.step_all();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// t-reassembly has expired. There should be an ACK in the status report.
|
|
|
|
|
TESTASSERT_EQ(status_pdu_ack_size, rlc2.get_buffer_state());
|
|
|
|
|
{
|
|
|
|
|
// Read status PDU from RLC2
|
|
|
|
|
byte_buffer_t status_buf;
|
|
|
|
|
uint32_t len = rlc2.read_pdu(status_buf.msg, status_pdu_ack_size);
|
|
|
|
|
status_buf.N_bytes = len;
|
|
|
|
|
|
|
|
|
|
TESTASSERT_EQ(0, rlc2.get_buffer_state());
|
|
|
|
|
|
|
|
|
|
// Assert status is correct
|
|
|
|
|
rlc_am_nr_status_pdu_t status_check(sn_size);
|
|
|
|
|
rlc_am_nr_read_status_pdu(&status_buf, sn_size, &status_check);
|
|
|
|
|
TESTASSERT_EQ(5, status_check.ack_sn); // 5 is the next expected SN.
|
|
|
|
|
TESTASSERT_EQ(0, status_check.nacks.size()); // Nothing else lost
|
|
|
|
|
|
|
|
|
|
// Write status PDU to RLC1
|
|
|
|
|
rlc1.write_pdu(status_buf.msg, status_buf.N_bytes);
|
|
|
|
|
|
|
|
|
|
// Check the Retx of SN=3 has been removed
|
|
|
|
|
TESTASSERT_EQ(0, rlc1.get_buffer_state());
|
|
|
|
|
TESTASSERT_EQ(0, rlc1_tx->get_retx_queue_size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
// Attempt to read from rlc1 to verify there nothing to read from it
|
|
|
|
|
byte_buffer_t retx_buf;
|
|
|
|
|
uint32_t len = rlc1.read_pdu(retx_buf.msg, data_pdu_size);
|
|
|
|
|
retx_buf.N_bytes = len;
|
|
|
|
|
TESTASSERT_EQ(0, len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
// rlc2 should not issue further status PDUs as time passes (even after expiry of t_status_prohibit)
|
|
|
|
|
int32_t checktime = 2 * rlc2_config.am_nr.t_status_prohibit;
|
|
|
|
|
for (int cnt = 0; cnt < checktime; cnt++) {
|
|
|
|
|
timers.step_all();
|
|
|
|
|
TESTASSERT_EQ(0, rlc2.get_buffer_state());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check statistics
|
|
|
|
|
rlc_bearer_metrics_t metrics1 = rlc1.get_metrics();
|
|
|
|
|
rlc_bearer_metrics_t metrics2 = rlc2.get_metrics();
|
|
|
|
|
|
|
|
|
|
uint32_t total_tx_pdu_bytes1 = (NBUFS)*data_pdu_size; // (NBUFS) * PDU size
|
|
|
|
|
uint32_t total_rx_pdu_bytes1 = 3 * status_pdu_ack_size + 1 * status_pdu_nack_size; // 3 status PDU (1 with a NACK)
|
|
|
|
|
uint32_t total_tx_pdu_bytes2 =
|
|
|
|
|
3 * status_pdu_ack_size + status_pdu_nack_size; // Three status PDU (one with a NACK, two without)
|
|
|
|
|
uint32_t total_rx_pdu_bytes2 = (NBUFS)*data_pdu_size; // (NBUFS - 1 Lost + 1 Late) * PDU size
|
|
|
|
|
|
|
|
|
|
// 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, metrics1.num_tx_pdus); // 5 transmissions, no re-transmission
|
|
|
|
|
TESTASSERT_EQ(3, metrics1.num_rx_pdus); // 3 status PDUs
|
|
|
|
|
TESTASSERT_EQ(total_tx_pdu_bytes1, metrics1.num_tx_pdu_bytes); // (NBUFS) * PDU size
|
|
|
|
|
TESTASSERT_EQ(total_rx_pdu_bytes1, metrics1.num_rx_pdu_bytes); // 3 status PDU (1 with a NACK)
|
|
|
|
|
TESTASSERT_EQ(0, metrics1.num_lost_sdus); // No lost SDUs
|
|
|
|
|
|
|
|
|
|
// SDU 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);
|
|
|
|
|
// PDU metrics
|
|
|
|
|
TESTASSERT_EQ(3, metrics2.num_tx_pdus); // 3 status PDUs
|
|
|
|
|
TESTASSERT_EQ(5, metrics2.num_rx_pdus); // 5 transmissions, no re-transmission
|
|
|
|
|
TESTASSERT_EQ(total_tx_pdu_bytes2, metrics2.num_tx_pdu_bytes); // Three status PDU (one with a NACK, two without)
|
|
|
|
|
TESTASSERT_EQ(total_rx_pdu_bytes2, metrics2.num_rx_pdu_bytes); // (NBUFS - 1 Lost + 1 Late) * PDU size
|
|
|
|
|
TESTASSERT_EQ(0, metrics2.num_lost_sdus); // No lost SDUs
|
|
|
|
|
return SRSRAN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test the basic segmentation of a single SDU.
|
|
|
|
|
* A single SDU of 3 bytes is segmented into 3 PDUs
|
|
|
|
@ -2682,6 +2869,7 @@ int main()
|
|
|
|
|
TESTASSERT(lost_pdu_test(sn_size) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(lost_pdu_duplicated_nack_test(sn_size) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(lost_pdus_trimmed_nack_test(sn_size) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(clean_retx_queue_of_acked_sdus_test(sn_size) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(basic_segmentation_test(sn_size) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(segment_retx_test(sn_size) == SRSRAN_SUCCESS);
|
|
|
|
|
TESTASSERT(segment_retx_and_loose_segments_test(sn_size) == SRSRAN_SUCCESS);
|
|
|
|
|