From 38206bea69101f4e9c38e986d37b8b84c23ed88a Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 5 Nov 2020 12:02:35 +0000 Subject: [PATCH] Fixed RLC AM fixed header size in get_buffer_state function. Fixed RLC AM tests accordingly. --- lib/src/upper/rlc_am_lte.cc | 6 +++--- lib/test/upper/rlc_am_test.cc | 31 ++++++++++++++++--------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index dd6f81cb3..333b29134 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -335,7 +335,7 @@ uint32_t rlc_am_lte::rlc_am_lte_tx::get_buffer_state() // Room needed for fixed header of data PDUs if (n_bytes > 0 && n_sdus > 0) { - n_bytes += 3; + n_bytes += 2; // Two bytes for fixed header with SN length = 10 log->debug("%s Total buffer state - %d SDUs (%d B)\n", RB_NAME, n_sdus, n_bytes); } @@ -827,7 +827,7 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt uint32_t pdu_space = SRSLTE_MIN(nof_bytes, pdu->get_tailroom()); uint8_t* pdu_ptr = pdu->msg; - if (pdu_space <= head_len + 1) { + if (pdu_space <= head_len) { log->info( "%s Cannot build a PDU - %d bytes available, %d bytes required for header\n", RB_NAME, nof_bytes, head_len); return 0; @@ -863,7 +863,7 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt } // Pull SDUs from queue - while (pdu_space > head_len + 1 && tx_sdu_queue.size() > 0 && header.N_li < RLC_AM_WINDOW_SIZE) { + while (pdu_space > head_len && tx_sdu_queue.size() > 0 && header.N_li < RLC_AM_WINDOW_SIZE) { if (last_li > 0) { header.li[header.N_li] = last_li; header.N_li++; diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index 223d98904..9ba3945b8 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -125,12 +125,13 @@ void basic_test_tx(rlc_am_lte* rlc, byte_buffer_t pdu_bufs[NBUFS]) rlc->write_sdu(std::move(sdu_bufs[i])); } - assert(14 == rlc->get_buffer_state()); + assert(13 == rlc->get_buffer_state()); // 2 Bytes for fixed header + 6 for LIs + 5 for payload // Read 5 PDUs from RLC1 (1 byte each) for (int i = 0; i < NBUFS; i++) { - uint32_t len = rlc->read_pdu(pdu_bufs[i].msg, 4); // 3 bytes for header + payload + uint32_t len = rlc->read_pdu(pdu_bufs[i].msg, 3); // 2 bytes for header + 1 byte payload pdu_bufs[i].N_bytes = len; + assert(3 == len); } assert(0 == rlc->get_buffer_state()); @@ -212,7 +213,7 @@ bool concat_test() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(14 == rlc1.get_buffer_state()); + assert(13 == rlc1.get_buffer_state()); // 2 Bytes for fixed header + 6 for LIs + 5 for payload // Read 1 PDUs from RLC1 containing all 5 SDUs byte_buffer_t pdu_buf; @@ -266,7 +267,7 @@ bool segment_test(bool in_seq_rx) rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(59 == rlc1.get_buffer_state()); + assert(58 == rlc1.get_buffer_state()); // 2 bytes for header + 6 bytes for LI + 50 bytes for payload // Read PDUs from RLC1 (force segmentation) byte_buffer_t pdu_bufs[20]; @@ -347,12 +348,12 @@ bool retx_test() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(14 == rlc1.get_buffer_state()); + assert(13 == rlc1.get_buffer_state()); // Read 5 PDUs from RLC1 (1 byte each) byte_buffer_t pdu_bufs[NBUFS]; for (int i = 0; i < NBUFS; i++) { - len = rlc1.read_pdu(pdu_bufs[i].msg, 4); // 2 byte header + 1 byte payload + len = rlc1.read_pdu(pdu_bufs[i].msg, 3); // 2 byte header + 1 byte payload pdu_bufs[i].N_bytes = len; } @@ -538,7 +539,7 @@ bool resegment_test_1() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(59 == rlc1.get_buffer_state()); + assert(58 == rlc1.get_buffer_state()); // 2 bytes for fixed header, 6 bytes for LIs, 50 bytes for data // Read 5 PDUs from RLC1 (10 bytes each) byte_buffer_t pdu_bufs[NBUFS]; @@ -636,7 +637,7 @@ bool resegment_test_2() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(59 == rlc1.get_buffer_state()); + assert(58 == rlc1.get_buffer_state()); // Read 5 PDUs from RLC1 (5 bytes, 10 bytes, 20 bytes, 10 bytes, 5 bytes) byte_buffer_t pdu_bufs[NBUFS]; @@ -731,7 +732,7 @@ bool resegment_test_3() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(59 == rlc1.get_buffer_state()); + assert(58 == rlc1.get_buffer_state()); // Read 5 PDUs from RLC1 (5 bytes, 5 bytes, 20 bytes, 10 bytes, 10 bytes) byte_buffer_t pdu_bufs[NBUFS]; @@ -821,7 +822,7 @@ bool resegment_test_4() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(59 == rlc1.get_buffer_state()); + assert(58 == rlc1.get_buffer_state()); // Read 5 PDUs from RLC1 (5 bytes, 5 bytes, 30 bytes, 5 bytes, 5 bytes) byte_buffer_t pdu_bufs[NBUFS]; @@ -913,7 +914,7 @@ bool resegment_test_5() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(59 == rlc1.get_buffer_state()); + assert(58 == rlc1.get_buffer_state()); // Read 5 PDUs from RLC1 (2 bytes, 3 bytes, 40 bytes, 3 bytes, 2 bytes) byte_buffer_t pdu_bufs[NBUFS]; @@ -1013,7 +1014,7 @@ bool resegment_test_6() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(369 == rlc1.get_buffer_state()); + assert(368 == rlc1.get_buffer_state()); // Read PDUs from RLC1 (10, 10, 10, 270, 54) byte_buffer_t pdu_bufs[5]; @@ -1134,7 +1135,7 @@ bool resegment_test_7() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(65 == rlc1.get_buffer_state()); + assert(64 == rlc1.get_buffer_state()); // Read PDUs from RLC1 (15 bytes each) byte_buffer_t pdu_bufs[N_PDU_BUFS]; @@ -1298,7 +1299,7 @@ bool resegment_test_8() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(65 == rlc1.get_buffer_state()); + assert(64 == rlc1.get_buffer_state()); // Read PDUs from RLC1 (15 bytes each) byte_buffer_t pdu_bufs[N_PDU_BUFS]; @@ -1547,7 +1548,7 @@ bool status_pdu_test() rlc1.write_sdu(std::move(sdu_bufs[i])); } - assert(14 == rlc1.get_buffer_state()); + assert(13 == rlc1.get_buffer_state()); // Read 5 PDUs from RLC1 (1 byte each) byte_buffer_t pdu_bufs[NBUFS];