lib,rlc_am_nr: fix generation of status report when NACKs of lost SDU segments are present.

master
Pedro Alvarez 3 years ago
parent 7206517846
commit 12e530a800

@ -24,6 +24,8 @@
namespace srsran { namespace srsran {
const static uint32_t max_tx_queue_size = 256; const static uint32_t max_tx_queue_size = 256;
const static uint32_t so_end_of_sdu = 0xFFFF;
/**************************************************************************** /****************************************************************************
* RLC AM NR entity * RLC AM NR entity
***************************************************************************/ ***************************************************************************/
@ -1254,13 +1256,40 @@ uint32_t rlc_am_nr_rx::get_status_pdu(rlc_am_nr_status_pdu_t* status, uint32_t m
uint32_t i = status->ack_sn; uint32_t i = status->ack_sn;
while (rx_mod_base_nr(i) <= rx_mod_base_nr(st.rx_highest_status)) { while (rx_mod_base_nr(i) <= rx_mod_base_nr(st.rx_highest_status)) {
if (rx_window.has_sn(i) || i == st.rx_highest_status) { if ((rx_window.has_sn(i) && rx_window[i].fully_received) || i == st.rx_highest_status) {
// only update ACK_SN if this SN has been received, or if we reached the maximum possible SN // only update ACK_SN if this SN has been fully received, or if we reached the maximum possible SN
status->ack_sn = i; status->ack_sn = i;
} else { } else {
if (not rx_window.has_sn(i)) {
// No segment received, NACK the whole SDU
status->nacks[status->N_nack].nack_sn = i;
status->N_nack++;
} else if (not rx_window[i].fully_received) {
// Some segments were received, but not all.
// NACK non consecutive missing bytes
uint32_t last_so = 0;
bool last_segment_rx = false;
for (auto segm = rx_window[i].segments.begin(); segm != rx_window[i].segments.end(); segm++) {
if (segm->header.so != last_so) {
// Some bytes were not received
status->nacks[status->N_nack].nack_sn = i;
status->nacks[status->N_nack].so_start = last_so;
status->nacks[status->N_nack].so_end = segm->header.so;
status->N_nack++;
}
if (segm->header.si == rlc_nr_si_field_t::last_segment) {
last_segment_rx = true;
}
last_so = segm->header.so + segm->buf->N_bytes;
}
if (not last_segment_rx) {
status->nacks[status->N_nack].nack_sn = i; status->nacks[status->N_nack].nack_sn = i;
status->nacks[status->N_nack].so_start = last_so;
status->nacks[status->N_nack].so_end = so_end_of_sdu;
status->N_nack++; status->N_nack++;
} }
}
}
// make sure we don't exceed grant size (FIXME) // make sure we don't exceed grant size (FIXME)
rlc_am_nr_write_status_pdu(*status, rlc_am_nr_sn_size_t::size12bits, &tmp_buf); rlc_am_nr_write_status_pdu(*status, rlc_am_nr_sn_size_t::size12bits, &tmp_buf);
@ -1313,7 +1342,7 @@ void rlc_am_nr_rx::timer_expired(uint32_t timeout_id)
*/ */
for (uint32_t tmp_sn = st.rx_next_status_trigger; tmp_sn < st.rx_next_status_trigger + RLC_AM_WINDOW_SIZE; for (uint32_t tmp_sn = st.rx_next_status_trigger; tmp_sn < st.rx_next_status_trigger + RLC_AM_WINDOW_SIZE;
tmp_sn++) { tmp_sn++) {
if (not rx_window.has_sn(tmp_sn) || not rx_window[tmp_sn].fully_received) { if (not rx_window.has_sn(tmp_sn)) {
st.rx_highest_status = tmp_sn; st.rx_highest_status = tmp_sn;
break; break;
} }

@ -650,20 +650,14 @@ int retx_segment_test()
} }
TESTASSERT(0 == rlc1.get_buffer_state()); TESTASSERT(0 == rlc1.get_buffer_state());
return SRSRAN_SUCCESS;
// Write 15 - 3 PDUs into RLC2 // Write 15 - 3 PDUs into RLC2
for (int i = 0; i < n_pdu_bufs; i++) { for (int i = 0; i < n_pdu_bufs; i++) {
if (i != 3) { if (i != 3 && i != 7 && i != 11) {
rlc2.write_pdu(pdu_bufs[i]->msg, pdu_bufs[i]->N_bytes); // Lose first segment of RLC_SN=1. rlc2.write_pdu(pdu_bufs[i]->msg, pdu_bufs[i]->N_bytes); // Lose first segment of RLC_SN=1.
} }
if (i != 3) {
rlc2.write_pdu(pdu_bufs[i]->msg, pdu_bufs[i]->N_bytes); // Lose middle segment of RLC_SN=2.
}
if (i != 3) {
rlc2.write_pdu(pdu_bufs[i]->msg, pdu_bufs[i]->N_bytes); // Lose last segment of RLC_SN=3.
}
} }
/*
// Only after t-reassembly has expired, will the status report include NACKs. // Only after t-reassembly has expired, will the status report include NACKs.
TESTASSERT(3 == rlc2.get_buffer_state()); TESTASSERT(3 == rlc2.get_buffer_state());
{ {
@ -677,7 +671,7 @@ int retx_segment_test()
// Assert status is correct // Assert status is correct
rlc_am_nr_status_pdu_t status_check = {}; rlc_am_nr_status_pdu_t status_check = {};
rlc_am_nr_read_status_pdu(&status_buf, rlc_am_nr_sn_size_t::size12bits, &status_check); rlc_am_nr_read_status_pdu(&status_buf, rlc_am_nr_sn_size_t::size12bits, &status_check);
TESTASSERT(status_check.ack_sn == 3); // 3 is the next expected SN (i.e. the lost packet.) TESTASSERT(status_check.ack_sn == 1); // 1 is the next expected SN (i.e. the first lost packet.)
// Write status PDU to RLC1 // Write status PDU to RLC1
rlc1.write_pdu(status_buf.msg, status_buf.N_bytes); rlc1.write_pdu(status_buf.msg, status_buf.N_bytes);
@ -689,11 +683,12 @@ int retx_segment_test()
} }
// t-reassembly has expired. There should be a NACK in the status report. // t-reassembly has expired. There should be a NACK in the status report.
TESTASSERT(5 == rlc2.get_buffer_state()); // There should be 3 NACKs with SO_start and SO_end
TESTASSERT(20 == rlc2.get_buffer_state()); // 2 bytes for ACK + 3 * 6 for NACK with SO = 20.
{ {
// Read status PDU from RLC2 // Read status PDU from RLC2
byte_buffer_t status_buf; byte_buffer_t status_buf;
int len = rlc2.read_pdu(status_buf.msg, 5); int len = rlc2.read_pdu(status_buf.msg, 20);
status_buf.N_bytes = len; status_buf.N_bytes = len;
TESTASSERT(0 == rlc2.get_buffer_state()); TESTASSERT(0 == rlc2.get_buffer_state());
@ -702,7 +697,7 @@ int retx_segment_test()
rlc_am_nr_status_pdu_t status_check = {}; rlc_am_nr_status_pdu_t status_check = {};
rlc_am_nr_read_status_pdu(&status_buf, rlc_am_nr_sn_size_t::size12bits, &status_check); rlc_am_nr_read_status_pdu(&status_buf, rlc_am_nr_sn_size_t::size12bits, &status_check);
TESTASSERT(status_check.ack_sn == 5); // 5 is the next expected SN. TESTASSERT(status_check.ack_sn == 5); // 5 is the next expected SN.
TESTASSERT(status_check.N_nack == 1); // We lost one PDU. TESTASSERT(status_check.N_nack == 3); // We lost one PDU.
TESTASSERT(status_check.nacks[0].nack_sn == 3); // Lost PDU SN=3. TESTASSERT(status_check.nacks[0].nack_sn == 3); // Lost PDU SN=3.
// Write status PDU to RLC1 // Write status PDU to RLC1
@ -711,7 +706,7 @@ int retx_segment_test()
// Check there is an Retx of SN=3 // Check there is an Retx of SN=3
TESTASSERT(5 == rlc1.get_buffer_state()); TESTASSERT(5 == rlc1.get_buffer_state());
} }
/*
{ {
// Re-transmit PDU in 3 segments // Re-transmit PDU in 3 segments
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -807,11 +802,11 @@ int main()
// start log back-end // start log back-end
srslog::init(); srslog::init();
TESTASSERT(window_checker_test() == SRSRAN_SUCCESS); // TESTASSERT(window_checker_test() == SRSRAN_SUCCESS);
TESTASSERT(basic_test() == SRSRAN_SUCCESS); // TESTASSERT(basic_test() == SRSRAN_SUCCESS);
TESTASSERT(lost_pdu_test() == SRSRAN_SUCCESS); // TESTASSERT(lost_pdu_test() == SRSRAN_SUCCESS);
TESTASSERT(basic_segmentation_test() == SRSRAN_SUCCESS); // TESTASSERT(basic_segmentation_test() == SRSRAN_SUCCESS);
TESTASSERT(segment_retx_test() == SRSRAN_SUCCESS); // TESTASSERT(segment_retx_test() == SRSRAN_SUCCESS);
TESTASSERT(retx_segment_test() == SRSRAN_SUCCESS); TESTASSERT(retx_segment_test() == SRSRAN_SUCCESS);
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }

Loading…
Cancel
Save