diff --git a/lib/src/common/log_filter.cc b/lib/src/common/log_filter.cc index b498d466c..4d80a8523 100644 --- a/lib/src/common/log_filter.cc +++ b/lib/src/common/log_filter.cc @@ -91,6 +91,7 @@ void log_filter::all_log(srslte::LOG_LEVEL_ENUM level, str_ptr s_ptr(new std::string(ss.str())); logger_h->log(s_ptr); + delete(s_ptr); } } @@ -131,6 +132,7 @@ void log_filter::all_log(srslte::LOG_LEVEL_ENUM level, } str_ptr s_ptr(new std::string(ss.str())); logger_h->log(s_ptr); + delete s_ptr; } } diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index e4a6242fa..413a02ac1 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -587,7 +587,8 @@ 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; if(pdu_space < (retx.so_end-retx.so_start)) retx.so_end = retx.so_start+pdu_space; @@ -603,10 +604,13 @@ int rlc_am::build_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_retx_t r if(lower >= retx.so_end) break; + if(pdu_space <= 2) + break; + 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; if(pdu_space < (retx.so_end-retx.so_start)) retx.so_end = retx.so_start+pdu_space; @@ -1217,15 +1221,33 @@ void rlc_am::print_rx_segments() bool rlc_am::add_segment_and_check(rlc_amd_rx_pdu_segments_t *pdu, rlc_amd_rx_pdu_t *segment) { - // Ordered insert - std::list::iterator tmpit; - std::list::iterator it = pdu->segments.begin(); - while(it != pdu->segments.end() && it->header.so < segment->header.so) - it++; - pdu->segments.insert(it, *segment); + // Check for first segment + if(0 == segment->header.so) { + std::list::iterator it; + for(it = pdu->segments.begin(); it != pdu->segments.end(); it++) { + pool->deallocate(it->buf); + } + pdu->segments.clear(); + pdu->segments.push_back(*segment); + return false; + } + + // Check segment offset + uint32_t n = 0; + if(!pdu->segments.empty()) { + rlc_amd_rx_pdu_t &back = pdu->segments.back(); + n = back.header.so + back.buf->N_bytes; + } + if(segment->header.so != n) { + pool->deallocate(segment->buf); + return false; + } else { + pdu->segments.push_back(*segment); + } // Check for complete uint32_t so = 0; + std::list::iterator it, tmpit; for(it = pdu->segments.begin(); it != pdu->segments.end(); it++) { if(so != it->header.so) return false; @@ -1287,6 +1309,7 @@ bool rlc_am::add_segment_and_check(rlc_amd_rx_pdu_segments_t *pdu, rlc_amd_rx_pd } handle_data_pdu(full_pdu->msg, full_pdu->N_bytes, header); + pool->deallocate(full_pdu); return true; } diff --git a/lib/test/upper/rlc_am_stress_test.cc b/lib/test/upper/rlc_am_stress_test.cc index 548feb818..dc1540c96 100644 --- a/lib/test/upper/rlc_am_stress_test.cc +++ b/lib/test/upper/rlc_am_stress_test.cc @@ -82,7 +82,7 @@ private: if(((float)rand()/RAND_MAX > fail_rate) && read>0) { rlc2->write_pdu(1, pdu->msg, opp_size); } - usleep(1000); + usleep(100); } running = false; } @@ -139,10 +139,12 @@ class rlc_am_tester ,public thread { public: - rlc_am_tester(rlc_interface_pdcp *rlc_){ + rlc_am_tester(rlc_interface_pdcp *rlc_, std::string name_=""){ rlc = rlc_; run_enable = true; running = false; + rx_pdus = 0; + name = name_; } void stop() @@ -164,6 +166,7 @@ public: { assert(lcid == 1); byte_buffer_pool::get_instance()->deallocate(sdu); + std::cout << "rlc_am_tester " << name << " received " << rx_pdus++ << " PDUs" << std::endl; } void write_pdu_bcch_bch(byte_buffer_t *sdu) {} void write_pdu_bcch_dlsch(byte_buffer_t *sdu) {} @@ -187,13 +190,16 @@ private: pdu->N_bytes = 1500; pdu->msg[0] = sn++; rlc->write_sdu(1, pdu); - usleep(1000); + usleep(100); } running = false; } bool run_enable; bool running; + long rx_pdus; + + std::string name; rlc_interface_pdcp *rlc; }; @@ -207,13 +213,13 @@ void stress_test() log1.set_hex_limit(-1); log2.set_hex_limit(-1); - float fail_rate = 0.1; + float fail_rate = 0.01; rlc rlc1; rlc rlc2; - rlc_am_tester tester1(&rlc1); - rlc_am_tester tester2(&rlc2); + rlc_am_tester tester1(&rlc1, "tester1"); + rlc_am_tester tester2(&rlc2, "tester2"); mac_dummy mac(&rlc1, &rlc2, fail_rate); ue_interface ue; diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index fbd013e3b..0b8c63668 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -482,17 +482,17 @@ void resegment_test_1() // Read the retx PDU from RLC1 and force resegmentation byte_buffer_t retx1; - len = rlc1.read_pdu(retx1.msg, 11); // 4 byte header + 5 data + len = rlc1.read_pdu(retx1.msg, 9); // 4 byte header + 5 data retx1.N_bytes = len; // Write the retx PDU to RLC2 rlc2.write_pdu(retx1.msg, retx1.N_bytes); - assert(9 == rlc1.get_buffer_state()); // 4 byte header + 5 data + assert(9 == rlc1.get_buffer_state()); // Read the remaining segment byte_buffer_t retx2; - len = rlc1.read_pdu(retx2.msg, 11); // 4 byte header + 5 data + len = rlc1.read_pdu(retx2.msg, 9); // 4 byte header + 5 data retx2.N_bytes = len; // Write the retx PDU to RLC2 @@ -591,16 +591,16 @@ void resegment_test_2() // Read the retx PDU from RLC1 and force resegmentation byte_buffer_t retx1; - retx1.N_bytes = rlc1.read_pdu(retx1.msg, 18); // 6 byte header + 10 data + retx1.N_bytes = rlc1.read_pdu(retx1.msg, 16); // 6 byte header + 10 data // Write the retx PDU to RLC2 rlc2.write_pdu(retx1.msg, retx1.N_bytes); - assert(16 == rlc1.get_buffer_state()); // 6 byte header + 10 data + assert(16 == rlc1.get_buffer_state()); // Read the remaining segment byte_buffer_t retx2; - retx2.N_bytes = rlc1.read_pdu(retx2.msg, 18); // 6 byte header + 10 data + retx2.N_bytes = rlc1.read_pdu(retx2.msg, 16); // 6 byte header + 10 data // Write the retx PDU to RLC2 rlc2.write_pdu(retx2.msg, retx2.N_bytes); @@ -696,14 +696,14 @@ void resegment_test_3() // Read the retx PDU from RLC1 and force resegmentation byte_buffer_t retx1; - retx1.N_bytes = rlc1.read_pdu(retx1.msg, 16); // 4 byte header + 10 data + retx1.N_bytes = rlc1.read_pdu(retx1.msg, 14); // 4 byte header + 10 data // Write the retx PDU to RLC2 rlc2.write_pdu(retx1.msg, retx1.N_bytes); // Read the remaining segment byte_buffer_t retx2; - retx2.N_bytes = rlc1.read_pdu(retx2.msg, 16); // 4 byte header + 10 data + retx2.N_bytes = rlc1.read_pdu(retx2.msg, 14); // 4 byte header + 10 data // Write the retx PDU to RLC2 rlc2.write_pdu(retx2.msg, retx2.N_bytes); @@ -799,14 +799,14 @@ void resegment_test_4() // Read the retx PDU from RLC1 and force resegmentation byte_buffer_t retx1; - retx1.N_bytes = rlc1.read_pdu(retx1.msg, 23); // 6 byte header + 15 data + retx1.N_bytes = rlc1.read_pdu(retx1.msg, 21); // 6 byte header + 15 data // Write the retx PDU to RLC2 rlc2.write_pdu(retx1.msg, retx1.N_bytes); // Read the remaining segment byte_buffer_t retx2; - retx2.N_bytes = rlc1.read_pdu(retx2.msg, 23); // 6 byte header + 15 data + retx2.N_bytes = rlc1.read_pdu(retx2.msg, 21); // 6 byte header + 15 data // Write the retx PDU to RLC2 rlc2.write_pdu(retx2.msg, retx2.N_bytes); @@ -902,14 +902,14 @@ void resegment_test_5() // Read the retx PDU from RLC1 and force resegmentation byte_buffer_t retx1; - retx1.N_bytes = rlc1.read_pdu(retx1.msg, 29); // 7 byte header + 20 data + retx1.N_bytes = rlc1.read_pdu(retx1.msg, 27); // 7 byte header + 20 data // Write the retx PDU to RLC2 rlc2.write_pdu(retx1.msg, retx1.N_bytes); // Read the remaining segment byte_buffer_t retx2; - retx2.N_bytes = rlc1.read_pdu(retx2.msg, 29); // 7 byte header + 20 data + retx2.N_bytes = rlc1.read_pdu(retx2.msg, 27); // 7 byte header + 20 data // Write the retx PDU to RLC2 rlc2.write_pdu(retx2.msg, retx2.N_bytes); @@ -1023,11 +1023,11 @@ void resegment_test_6() // Write the retx PDU to RLC2 rlc2.write_pdu(retx1.msg, retx1.N_bytes); - assert(157 == rlc1.get_buffer_state()); + assert(155 == rlc1.get_buffer_state()); // Read the remaining segment byte_buffer_t retx2; - len = rlc1.read_pdu(retx2.msg, 159); + len = rlc1.read_pdu(retx2.msg, 157); retx2.N_bytes = len; // Write the retx PDU to RLC2 diff --git a/srsenb/src/mac/scheduler.cc b/srsenb/src/mac/scheduler.cc index 1f1a72764..51f161d4a 100644 --- a/srsenb/src/mac/scheduler.cc +++ b/srsenb/src/mac/scheduler.cc @@ -1,3 +1,28 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2017 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of srsLTE. + * + * srsUE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsUE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ #include diff --git a/srsenb/test/mac/scheduler_test.cc b/srsenb/test/mac/scheduler_test.cc index e9afd61cb..73dd531b0 100644 --- a/srsenb/test/mac/scheduler_test.cc +++ b/srsenb/test/mac/scheduler_test.cc @@ -1,3 +1,28 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2017 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of srsLTE. + * + * srsUE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsUE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ #include diff --git a/srsenb/test/upper/ip_test.cc b/srsenb/test/upper/ip_test.cc index e1edf981b..8052ed4d7 100644 --- a/srsenb/test/upper/ip_test.cc +++ b/srsenb/test/upper/ip_test.cc @@ -1,3 +1,29 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2017 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of srsLTE. + * + * srsUE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsUE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + #include #include #include