Fixed RLC AM fixed header size in get_buffer_state function. Fixed RLC AM tests accordingly.

master
Pedro Alvarez 4 years ago committed by Andre Puschmann
parent 99f94d9a1a
commit 38206bea69

@ -335,7 +335,7 @@ uint32_t rlc_am_lte::rlc_am_lte_tx::get_buffer_state()
// Room needed for fixed header of data PDUs // Room needed for fixed header of data PDUs
if (n_bytes > 0 && n_sdus > 0) { 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); 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()); uint32_t pdu_space = SRSLTE_MIN(nof_bytes, pdu->get_tailroom());
uint8_t* pdu_ptr = pdu->msg; uint8_t* pdu_ptr = pdu->msg;
if (pdu_space <= head_len + 1) { if (pdu_space <= head_len) {
log->info( log->info(
"%s Cannot build a PDU - %d bytes available, %d bytes required for header\n", RB_NAME, nof_bytes, head_len); "%s Cannot build a PDU - %d bytes available, %d bytes required for header\n", RB_NAME, nof_bytes, head_len);
return 0; 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 // 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) { if (last_li > 0) {
header.li[header.N_li] = last_li; header.li[header.N_li] = last_li;
header.N_li++; header.N_li++;

@ -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])); 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) // Read 5 PDUs from RLC1 (1 byte each)
for (int i = 0; i < NBUFS; i++) { 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; pdu_bufs[i].N_bytes = len;
assert(3 == len);
} }
assert(0 == rlc->get_buffer_state()); assert(0 == rlc->get_buffer_state());
@ -212,7 +213,7 @@ bool concat_test()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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 // Read 1 PDUs from RLC1 containing all 5 SDUs
byte_buffer_t pdu_buf; byte_buffer_t pdu_buf;
@ -266,7 +267,7 @@ bool segment_test(bool in_seq_rx)
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read PDUs from RLC1 (force segmentation)
byte_buffer_t pdu_bufs[20]; byte_buffer_t pdu_bufs[20];
@ -347,12 +348,12 @@ bool retx_test()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read 5 PDUs from RLC1 (1 byte each)
byte_buffer_t pdu_bufs[NBUFS]; byte_buffer_t pdu_bufs[NBUFS];
for (int i = 0; i < NBUFS; i++) { 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; pdu_bufs[i].N_bytes = len;
} }
@ -538,7 +539,7 @@ bool resegment_test_1()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read 5 PDUs from RLC1 (10 bytes each)
byte_buffer_t pdu_bufs[NBUFS]; byte_buffer_t pdu_bufs[NBUFS];
@ -636,7 +637,7 @@ bool resegment_test_2()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read 5 PDUs from RLC1 (5 bytes, 10 bytes, 20 bytes, 10 bytes, 5 bytes)
byte_buffer_t pdu_bufs[NBUFS]; byte_buffer_t pdu_bufs[NBUFS];
@ -731,7 +732,7 @@ bool resegment_test_3()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read 5 PDUs from RLC1 (5 bytes, 5 bytes, 20 bytes, 10 bytes, 10 bytes)
byte_buffer_t pdu_bufs[NBUFS]; byte_buffer_t pdu_bufs[NBUFS];
@ -821,7 +822,7 @@ bool resegment_test_4()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read 5 PDUs from RLC1 (5 bytes, 5 bytes, 30 bytes, 5 bytes, 5 bytes)
byte_buffer_t pdu_bufs[NBUFS]; byte_buffer_t pdu_bufs[NBUFS];
@ -913,7 +914,7 @@ bool resegment_test_5()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read 5 PDUs from RLC1 (2 bytes, 3 bytes, 40 bytes, 3 bytes, 2 bytes)
byte_buffer_t pdu_bufs[NBUFS]; byte_buffer_t pdu_bufs[NBUFS];
@ -1013,7 +1014,7 @@ bool resegment_test_6()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read PDUs from RLC1 (10, 10, 10, 270, 54)
byte_buffer_t pdu_bufs[5]; byte_buffer_t pdu_bufs[5];
@ -1134,7 +1135,7 @@ bool resegment_test_7()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read PDUs from RLC1 (15 bytes each)
byte_buffer_t pdu_bufs[N_PDU_BUFS]; byte_buffer_t pdu_bufs[N_PDU_BUFS];
@ -1298,7 +1299,7 @@ bool resegment_test_8()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read PDUs from RLC1 (15 bytes each)
byte_buffer_t pdu_bufs[N_PDU_BUFS]; byte_buffer_t pdu_bufs[N_PDU_BUFS];
@ -1547,7 +1548,7 @@ bool status_pdu_test()
rlc1.write_sdu(std::move(sdu_bufs[i])); 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) // Read 5 PDUs from RLC1 (1 byte each)
byte_buffer_t pdu_bufs[NBUFS]; byte_buffer_t pdu_bufs[NBUFS];

Loading…
Cancel
Save