lib,pcdp_nr: added checks for stopped reordering timer and correct state

when receiving out-of-order packets in unit tests.
master
Pedro Alvarez 2 years ago
parent eb819cb9d0
commit e87416ff99

@ -52,12 +52,6 @@ public:
void notify_delivery(const pdcp_sn_vector_t& pdcp_sns) final; void notify_delivery(const pdcp_sn_vector_t& pdcp_sns) final;
void notify_failure(const pdcp_sn_vector_t& pdcp_sns) final; void notify_failure(const pdcp_sn_vector_t& pdcp_sns) final;
// State variable setters (should be used only for testing)
void set_tx_next(uint32_t tx_next_) { tx_next = tx_next_; }
void set_rx_next(uint32_t rx_next_) { rx_next = rx_next_; }
void set_rx_deliv(uint32_t rx_deliv_) { rx_deliv = rx_deliv_; }
void set_rx_reord(uint32_t rx_reord_) { rx_reord = rx_reord_; }
void get_bearer_state(pdcp_lte_state_t* state) override; void get_bearer_state(pdcp_lte_state_t* state) override;
void set_bearer_state(const pdcp_lte_state_t& state, bool set_fmc) override; void set_bearer_state(const pdcp_lte_state_t& state, bool set_fmc) override;
@ -69,6 +63,17 @@ public:
// State variable getters (useful for testing) // State variable getters (useful for testing)
uint32_t nof_discard_timers() { return discard_timers_map.size(); } uint32_t nof_discard_timers() { return discard_timers_map.size(); }
bool is_reordering_timer_running() { return reordering_timer.is_running(); }
// State variable setters (should be used only for testing)
void set_tx_next(uint32_t tx_next_) { tx_next = tx_next_; }
void set_rx_next(uint32_t rx_next_) { rx_next = rx_next_; }
void set_rx_deliv(uint32_t rx_deliv_) { rx_deliv = rx_deliv_; }
void set_rx_reord(uint32_t rx_reord_) { rx_reord = rx_reord_; }
uint32_t get_tx_next() const { return tx_next; }
uint32_t get_rx_next() const { return rx_next; }
uint32_t get_rx_deliv() const { return rx_deliv; }
uint32_t get_rx_reord() const { return rx_reord; }
private: private:
srsue::rlc_interface_pdcp* rlc = nullptr; srsue::rlc_interface_pdcp* rlc = nullptr;

@ -15,15 +15,17 @@
/* /*
* Genric function to test reception of in-sequence packets * Genric function to test reception of in-sequence packets
*/ */
int test_rx(std::vector<pdcp_test_event_t> events, class test_rx_helper
const pdcp_initial_state& init_state,
uint8_t pdcp_sn_len,
uint32_t n_sdus_exp,
const srsran::unique_byte_buffer_t& sdu_exp,
srslog::basic_logger& logger)
{ {
srsran::pdcp_config_t cfg_rx = {1, public:
pdcp_nr_test_helper pdcp_hlp_rx;
srsran::pdcp_entity_nr& pdcp_rx;
gw_dummy& gw_rx;
srsue::stack_test_dummy& stack;
srslog::basic_logger& logger;
test_rx_helper(uint8_t pdcp_sn_len, srslog::basic_logger& logger) :
pdcp_hlp_rx({1,
srsran::PDCP_RB_IS_DRB, srsran::PDCP_RB_IS_DRB,
srsran::SECURITY_DIRECTION_DOWNLINK, srsran::SECURITY_DIRECTION_DOWNLINK,
srsran::SECURITY_DIRECTION_UPLINK, srsran::SECURITY_DIRECTION_UPLINK,
@ -31,30 +33,40 @@ int test_rx(std::vector<pdcp_test_event_t> events,
srsran::pdcp_t_reordering_t::ms500, srsran::pdcp_t_reordering_t::ms500,
srsran::pdcp_discard_timer_t::infinity, srsran::pdcp_discard_timer_t::infinity,
false, false,
srsran::srsran_rat_t::nr}; srsran::srsran_rat_t::nr},
sec_cfg,
logger),
pdcp_rx(pdcp_hlp_rx.pdcp),
gw_rx(pdcp_hlp_rx.gw),
stack(pdcp_hlp_rx.stack),
logger(logger)
{}
int test_rx(std::vector<pdcp_test_event_t> events,
const pdcp_initial_state& init_state,
uint32_t n_sdus_exp,
const srsran::unique_byte_buffer_t& sdu_exp)
pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, logger); {
srsran::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp;
gw_dummy* gw_rx = &pdcp_hlp_rx.gw;
srsue::stack_test_dummy* stack = &pdcp_hlp_rx.stack;
pdcp_hlp_rx.set_pdcp_initial_state(init_state); pdcp_hlp_rx.set_pdcp_initial_state(init_state);
// Generate test message and encript/decript SDU. // Generate test message and encript/decript SDU.
for (pdcp_test_event_t& event : events) { for (pdcp_test_event_t& event : events) {
// Decript and integrity check the PDU // Decript and integrity check the PDU
pdcp_rx->write_pdu(std::move(event.pkt)); pdcp_rx.write_pdu(std::move(event.pkt));
for (uint32_t i = 0; i < event.ticks; ++i) { for (uint32_t i = 0; i < event.ticks; ++i) {
stack->run_tti(); stack.run_tti();
} }
} }
// Test if the number of RX packets // Test if the number of RX packets
TESTASSERT_EQ(gw_rx->rx_count, n_sdus_exp); TESTASSERT_EQ(gw_rx.rx_count, n_sdus_exp);
srsran::unique_byte_buffer_t sdu_act = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t sdu_act = srsran::make_byte_buffer();
gw_rx->get_last_pdu(sdu_act); gw_rx.get_last_pdu(sdu_act);
TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0); TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0);
return 0; return 0;
} }
};
/* /*
* RX Test: PDCP Entity with SN LEN = 12 and 18. * RX Test: PDCP Entity with SN LEN = 12 and 18.
@ -76,12 +88,13 @@ int test_rx_all(srslog::basic_logger& logger)
{ {
auto& test_logger = srslog::fetch_basic_logger("TESTER "); auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX COUNT [4095,4096], 12 bit SN"); srsran::test_delimit_logger delimiter("RX COUNT [4095,4096], 12 bit SN");
test_rx_helper rx_helper(srsran::PDCP_SN_LEN_12, logger);
std::vector<uint32_t> test1_counts(2); // Test two packets std::vector<uint32_t> test1_counts(2); // Test two packets
std::iota(test1_counts.begin(), test1_counts.end(), 4095); // Starting at COUNT 4095 std::iota(test1_counts.begin(), test1_counts.end(), 4095); // Starting at COUNT 4095
std::vector<pdcp_test_event_t> test1_pdus = std::vector<pdcp_test_event_t> test1_pdus =
gen_expected_pdus_vector(tst_sdu1, test1_counts, srsran::PDCP_SN_LEN_12, sec_cfg, logger); gen_expected_pdus_vector(tst_sdu1, test1_counts, srsran::PDCP_SN_LEN_12, sec_cfg, logger);
pdcp_initial_state test1_init_state = {.tx_next = 4095, .rx_next = 4095, .rx_deliv = 4095, .rx_reord = 0}; pdcp_initial_state test1_init_state = {.tx_next = 4095, .rx_next = 4095, .rx_deliv = 4095, .rx_reord = 0};
TESTASSERT(test_rx(std::move(test1_pdus), test1_init_state, srsran::PDCP_SN_LEN_12, 2, tst_sdu1, logger) == 0); TESTASSERT(rx_helper.test_rx(std::move(test1_pdus), test1_init_state, 2, tst_sdu1) == 0);
} }
/* /*
* RX Test 2: PDCP Entity with SN LEN = 12 * RX Test 2: PDCP Entity with SN LEN = 12
@ -92,13 +105,14 @@ int test_rx_all(srslog::basic_logger& logger)
{ {
auto& test_logger = srslog::fetch_basic_logger("TESTER "); auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX COUNT [4294967295,0], 12 bit SN"); srsran::test_delimit_logger delimiter("RX COUNT [4294967295,0], 12 bit SN");
test_rx_helper rx_helper(srsran::PDCP_SN_LEN_12, logger);
std::vector<uint32_t> test2_counts(2); // Test two packets std::vector<uint32_t> test2_counts(2); // Test two packets
std::iota(test2_counts.begin(), test2_counts.end(), 4294967295); // Starting at COUNT 4294967295 std::iota(test2_counts.begin(), test2_counts.end(), 4294967295); // Starting at COUNT 4294967295
std::vector<pdcp_test_event_t> test2_pdus = std::vector<pdcp_test_event_t> test2_pdus =
gen_expected_pdus_vector(tst_sdu1, test2_counts, srsran::PDCP_SN_LEN_12, sec_cfg, logger); gen_expected_pdus_vector(tst_sdu1, test2_counts, srsran::PDCP_SN_LEN_12, sec_cfg, logger);
pdcp_initial_state test2_init_state = { pdcp_initial_state test2_init_state = {
.tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0};
TESTASSERT(test_rx(std::move(test2_pdus), test2_init_state, srsran::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0); TESTASSERT(rx_helper.test_rx(std::move(test2_pdus), test2_init_state, 1, tst_sdu1) == 0);
} }
/* /*
* RX Test 3: PDCP Entity with SN LEN = 18 * RX Test 3: PDCP Entity with SN LEN = 18
@ -108,12 +122,13 @@ int test_rx_all(srslog::basic_logger& logger)
{ {
auto& test_logger = srslog::fetch_basic_logger("TESTER "); auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX COUNT [262144,262145], 12 bit SN"); srsran::test_delimit_logger delimiter("RX COUNT [262144,262145], 12 bit SN");
test_rx_helper rx_helper(srsran::PDCP_SN_LEN_18, logger);
std::vector<uint32_t> test3_counts(2); // Test two packets std::vector<uint32_t> test3_counts(2); // Test two packets
std::iota(test3_counts.begin(), test3_counts.end(), 262144); // Starting at COUNT 262144 std::iota(test3_counts.begin(), test3_counts.end(), 262144); // Starting at COUNT 262144
std::vector<pdcp_test_event_t> test3_pdus = std::vector<pdcp_test_event_t> test3_pdus =
gen_expected_pdus_vector(tst_sdu1, test3_counts, srsran::PDCP_SN_LEN_18, sec_cfg, logger); gen_expected_pdus_vector(tst_sdu1, test3_counts, srsran::PDCP_SN_LEN_18, sec_cfg, logger);
pdcp_initial_state test3_init_state = {.tx_next = 262144, .rx_next = 262144, .rx_deliv = 262144, .rx_reord = 0}; pdcp_initial_state test3_init_state = {.tx_next = 262144, .rx_next = 262144, .rx_deliv = 262144, .rx_reord = 0};
TESTASSERT(test_rx(std::move(test3_pdus), test3_init_state, srsran::PDCP_SN_LEN_18, 2, tst_sdu1, logger) == 0); TESTASSERT(rx_helper.test_rx(std::move(test3_pdus), test3_init_state, 2, tst_sdu1) == 0);
} }
/* /*
@ -124,22 +139,25 @@ int test_rx_all(srslog::basic_logger& logger)
{ {
auto& test_logger = srslog::fetch_basic_logger("TESTER "); auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX COUNT [4294967295,4294967296], 18 bit SN"); srsran::test_delimit_logger delimiter("RX COUNT [4294967295,4294967296], 18 bit SN");
test_rx_helper rx_helper(srsran::PDCP_SN_LEN_18, logger);
std::vector<uint32_t> test4_counts(2); // Test two packets std::vector<uint32_t> test4_counts(2); // Test two packets
std::iota(test4_counts.begin(), test4_counts.end(), 4294967295); // Starting at COUNT 4294967295 std::iota(test4_counts.begin(), test4_counts.end(), 4294967295); // Starting at COUNT 4294967295
std::vector<pdcp_test_event_t> test4_pdus = std::vector<pdcp_test_event_t> test4_pdus =
gen_expected_pdus_vector(tst_sdu1, test4_counts, srsran::PDCP_SN_LEN_18, sec_cfg, logger); gen_expected_pdus_vector(tst_sdu1, test4_counts, srsran::PDCP_SN_LEN_18, sec_cfg, logger);
pdcp_initial_state test4_init_state = { pdcp_initial_state test4_init_state = {
.tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0};
TESTASSERT(test_rx(std::move(test4_pdus), test4_init_state, srsran::PDCP_SN_LEN_18, 1, tst_sdu1, logger) == 0); TESTASSERT(rx_helper.test_rx(std::move(test4_pdus), test4_init_state, 1, tst_sdu1) == 0);
} }
/* /*
* RX Test 5: PDCP Entity with SN LEN = 12 * RX Test 5: PDCP Entity with SN LEN = 12
* Test reception of two out-of-order packets, starting at COUNT 0. * Test reception of two out-of-order packets, starting at COUNT 0.
* Both packets are received and delivered before t-Reordering expires.
*/ */
{ {
auto& test_logger = srslog::fetch_basic_logger("TESTER "); auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX out-of-order COUNT [1,0], 12 bit SN"); srsran::test_delimit_logger delimiter("RX out-of-order COUNT [1,0], 12 bit SN");
test_rx_helper rx_helper(srsran::PDCP_SN_LEN_12, logger);
std::vector<pdcp_test_event_t> test5_pdus; std::vector<pdcp_test_event_t> test5_pdus;
pdcp_initial_state test5_init_state = {}; pdcp_initial_state test5_init_state = {};
@ -156,16 +174,21 @@ int test_rx_all(srslog::basic_logger& logger)
// Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after)
test5_pdus.push_back(std::move(event_pdu2)); test5_pdus.push_back(std::move(event_pdu2));
test5_pdus.push_back(std::move(event_pdu1)); test5_pdus.push_back(std::move(event_pdu1));
TESTASSERT(test_rx(std::move(test5_pdus), test5_init_state, srsran::PDCP_SN_LEN_12, 2, tst_sdu2, logger) == 0); TESTASSERT(rx_helper.test_rx(std::move(test5_pdus), test5_init_state, 2, tst_sdu2) == 0);
TESTASSERT(rx_helper.pdcp_rx.is_reordering_timer_running() == false);
TESTASSERT(rx_helper.pdcp_rx.get_rx_deliv() == 2);
TESTASSERT(rx_helper.pdcp_rx.get_rx_reord() == 2);
} }
/* /*
* RX Test 6: PDCP Entity with SN LEN = 18 * RX Test 6: PDCP Entity with SN LEN = 18
* Test reception of two out-of-order packets, starting at COUNT 0. * Test reception of two out-of-order packets, starting at COUNT 0.
* Both packets are received and delivered before t-Reordering expires.
*/ */
{ {
auto& test_logger = srslog::fetch_basic_logger("TESTER "); auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX out-of-order COUNT [1,0], 18 bit SN"); srsran::test_delimit_logger delimiter("RX out-of-order COUNT [1,0], 18 bit SN");
test_rx_helper rx_helper(srsran::PDCP_SN_LEN_18, logger);
std::vector<pdcp_test_event_t> test6_pdus; std::vector<pdcp_test_event_t> test6_pdus;
pdcp_initial_state test6_init_state = {}; pdcp_initial_state test6_init_state = {};
@ -182,7 +205,10 @@ int test_rx_all(srslog::basic_logger& logger)
// Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after)
test6_pdus.push_back(std::move(event_pdu2)); test6_pdus.push_back(std::move(event_pdu2));
test6_pdus.push_back(std::move(event_pdu1)); test6_pdus.push_back(std::move(event_pdu1));
TESTASSERT(test_rx(std::move(test6_pdus), test6_init_state, srsran::PDCP_SN_LEN_18, 2, tst_sdu2, logger) == 0); TESTASSERT(rx_helper.test_rx(std::move(test6_pdus), test6_init_state, 2, tst_sdu2) == 0);
TESTASSERT(rx_helper.pdcp_rx.is_reordering_timer_running() == false);
TESTASSERT(rx_helper.pdcp_rx.get_rx_deliv() == 2);
TESTASSERT(rx_helper.pdcp_rx.get_rx_reord() == 2);
} }
/* /*
@ -192,6 +218,7 @@ int test_rx_all(srslog::basic_logger& logger)
{ {
auto& test_logger = srslog::fetch_basic_logger("TESTER "); auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX out-of-order COUNT [1,0] t_reordering expired, 12 bit SN"); srsran::test_delimit_logger delimiter("RX out-of-order COUNT [1,0] t_reordering expired, 12 bit SN");
test_rx_helper rx_helper(srsran::PDCP_SN_LEN_12, logger);
std::vector<pdcp_test_event_t> test7_pdus; std::vector<pdcp_test_event_t> test7_pdus;
pdcp_initial_state test7_init_state = {}; pdcp_initial_state test7_init_state = {};
@ -203,7 +230,10 @@ int test_rx_all(srslog::basic_logger& logger)
// Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after)
test7_pdus.push_back(std::move(event_pdu1)); test7_pdus.push_back(std::move(event_pdu1));
TESTASSERT(test_rx(std::move(test7_pdus), test7_init_state, srsran::PDCP_SN_LEN_12, 1, tst_sdu2, logger) == 0); TESTASSERT(rx_helper.test_rx(std::move(test7_pdus), test7_init_state, 1, tst_sdu2) == 0);
TESTASSERT(rx_helper.pdcp_rx.is_reordering_timer_running() == false);
TESTASSERT(rx_helper.pdcp_rx.get_rx_deliv() == 2);
TESTASSERT(rx_helper.pdcp_rx.get_rx_reord() == 2);
} }
/* /*
@ -212,6 +242,7 @@ int test_rx_all(srslog::basic_logger& logger)
*/ */
{ {
srsran::test_delimit_logger delimiter("RX duplicate COUNTs [0,0], 12 bit SN"); srsran::test_delimit_logger delimiter("RX duplicate COUNTs [0,0], 12 bit SN");
test_rx_helper rx_helper(srsran::PDCP_SN_LEN_12, logger);
std::vector<pdcp_test_event_t> test8_pdus; std::vector<pdcp_test_event_t> test8_pdus;
pdcp_initial_state test8_init_state = {}; pdcp_initial_state test8_init_state = {};
@ -228,7 +259,7 @@ int test_rx_all(srslog::basic_logger& logger)
// Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after)
test8_pdus.push_back(std::move(event_pdu1)); test8_pdus.push_back(std::move(event_pdu1));
test8_pdus.push_back(std::move(event_pdu2)); test8_pdus.push_back(std::move(event_pdu2));
TESTASSERT(test_rx(std::move(test8_pdus), test8_init_state, srsran::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0); TESTASSERT(rx_helper.test_rx(std::move(test8_pdus), test8_init_state, 1, tst_sdu1) == 0);
} }
return 0; return 0;
} }

Loading…
Cancel
Save