diff --git a/lib/include/srslte/common/common.h b/lib/include/srslte/common/common.h index 41a89fb36..ddd558016 100644 --- a/lib/include/srslte/common/common.h +++ b/lib/include/srslte/common/common.h @@ -63,7 +63,7 @@ #define SRSLTE_MAX_BUFFER_SIZE_BYTES 12756 #define SRSLTE_BUFFER_HEADER_OFFSET 1024 -//#define SRSLTE_BUFFER_POOL_LOG_ENABLED +#define SRSLTE_BUFFER_POOL_LOG_ENABLED #ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED #define pool_allocate (pool->allocate(__FUNCTION__)) diff --git a/lib/include/srslte/upper/rlc_am.h b/lib/include/srslte/upper/rlc_am.h index e28e11618..5a93750a4 100644 --- a/lib/include/srslte/upper/rlc_am.h +++ b/lib/include/srslte/upper/rlc_am.h @@ -189,6 +189,7 @@ private: bool inside_tx_window(uint16_t sn); bool inside_rx_window(uint16_t sn); void debug_state(); + void print_rx_segments(); bool add_segment_and_check(rlc_amd_rx_pdu_segments_t *pdu, rlc_amd_rx_pdu_t *segment); int required_buffer_size(rlc_amd_retx_t retx); diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index b360b24c8..d71ade7ca 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -587,7 +587,7 @@ int rlc_am::build_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_retx_t r rrc->get_rb_name(lcid).c_str(), nof_bytes, head_len); return 0; } - pdu_space = nof_bytes-head_len-2; + pdu_space = nof_bytes-head_len-1; if(pdu_space < (retx.so_end-retx.so_start)) retx.so_end = retx.so_start+pdu_space; @@ -606,7 +606,7 @@ int rlc_am::build_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_retx_t r upper += old_header.li[i]; head_len = rlc_am_packed_length(&new_header); - pdu_space = nof_bytes-head_len-2; + pdu_space = nof_bytes-head_len-1; if(pdu_space < (retx.so_end-retx.so_start)) retx.so_end = retx.so_start+pdu_space; @@ -934,6 +934,7 @@ void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_a log->console("Fatal Error: Could not allocate PDU in handle_data_pdu_segment()\n"); exit(-1); } + memcpy(segment.buf->msg, payload, nof_bytes); segment.buf->N_bytes = nof_bytes; memcpy(&segment.header, &header, sizeof(rlc_amd_pdu_header_t)); @@ -986,6 +987,7 @@ void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_a } } + print_rx_segments(); debug_state(); } @@ -1169,6 +1171,20 @@ void rlc_am::debug_state() } +void rlc_am::print_rx_segments() +{ + std::map::iterator it; + std::stringstream ss; + ss << "rx_segments:" << std::endl; + for(it=rx_segments.begin();it!=rx_segments.end();it++) { + std::list::iterator segit; + for(segit = it->second.segments.begin(); segit != it->second.segments.end(); segit++) { + ss << " SN:" << segit->header.sn << " SO:" << segit->header.so << " N:" << segit->buf->N_bytes << std::endl; + } + } + log->debug("%s\n", ss.str().c_str()); +} + bool rlc_am::add_segment_and_check(rlc_amd_rx_pdu_segments_t *pdu, rlc_amd_rx_pdu_t *segment) { // Ordered insert diff --git a/lib/test/upper/rlc_am_stress_test.cc b/lib/test/upper/rlc_am_stress_test.cc index d3e24751b..ad1a0c716 100644 --- a/lib/test/upper/rlc_am_stress_test.cc +++ b/lib/test/upper/rlc_am_stress_test.cc @@ -67,7 +67,11 @@ private: void run_thread() { running = true; - byte_buffer_t *pdu = byte_buffer_pool::get_instance()->allocate(); + byte_buffer_t *pdu = byte_buffer_pool::get_instance()->allocate("mac_reader::run_thread"); + if (!pdu) { + printf("Fatal Error: Could not allocate PDU in mac_reader::run_thread\n"); + exit(-1); + } while(run_enable) { float r = (float)rand()/RAND_MAX; @@ -173,7 +177,11 @@ private: uint8_t sn = 0; running = true; while(run_enable) { - byte_buffer_t *pdu = byte_buffer_pool::get_instance()->allocate(); + byte_buffer_t *pdu = byte_buffer_pool::get_instance()->allocate("rlc_am_tester::run_thread"); + if (!pdu) { + printf("Fatal Error: Could not allocate PDU in rlc_am_tester::run_thread\n"); + exit(-1); + } pdu->N_bytes = 1500; pdu->msg[0] = sn++; rlc->write_sdu(1, pdu);