From e18cb5ba5ba3d3561d5648f17cc2cd0f5663fcaf Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Mon, 12 Feb 2018 13:42:59 +0000 Subject: [PATCH] Fixing RLC AM tests, adding extra check for segment handling --- lib/src/upper/rlc_am.cc | 11 +++++++++++ lib/test/upper/rlc_am_stress_test.cc | 12 +++++++++--- lib/test/upper/rlc_am_test.cc | 28 ++++++++++++++-------------- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index 72fbbde17..59ce25576 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -1221,6 +1221,17 @@ 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) { + // 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()) { diff --git a/lib/test/upper/rlc_am_stress_test.cc b/lib/test/upper/rlc_am_stress_test.cc index cfed3d6e7..dc1540c96 100644 --- a/lib/test/upper/rlc_am_stress_test.cc +++ b/lib/test/upper/rlc_am_stress_test.cc @@ -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) {} @@ -194,6 +197,9 @@ private: bool run_enable; bool running; + long rx_pdus; + + std::string name; rlc_interface_pdcp *rlc; }; @@ -212,8 +218,8 @@ void stress_test() 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