From e68956bcf605fe885c669284a713005c704477a7 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 26 Nov 2019 14:01:16 +0000 Subject: [PATCH] Adding discard timer timeout to PDCP config. --- lib/include/srslte/common/interfaces_common.h | 6 +- lib/include/srslte/upper/pdcp_entity_base.h | 3 +- lib/test/upper/pdcp_nr_test.cc | 61 ++++++++++++++++--- lib/test/upper/pdcp_nr_test.h | 3 +- srsenb/src/stack/rrc/rrc.cc | 18 ++++-- srsue/src/stack/rrc/rrc.cc | 26 ++++---- srsue/test/ttcn3/hdr/ttcn3_sys_interface.h | 5 +- 7 files changed, 88 insertions(+), 34 deletions(-) diff --git a/lib/include/srslte/common/interfaces_common.h b/lib/include/srslte/common/interfaces_common.h index ad3d18050..d6c8fad5e 100644 --- a/lib/include/srslte/common/interfaces_common.h +++ b/lib/include/srslte/common/interfaces_common.h @@ -144,13 +144,15 @@ public: security_direction_t tx_direction_, security_direction_t rx_direction_, uint8_t sn_len_, - pdcp_t_reordering_t t_reordering_) : + pdcp_t_reordering_t t_reordering_, + pdcp_discard_timer_t discard_timer_) : bearer_id(bearer_id_), rb_type(rb_type_), tx_direction(tx_direction_), rx_direction(rx_direction_), sn_len(sn_len_), - t_reordering(t_reordering_) + t_reordering(t_reordering_), + discard_timer(discard_timer_) { hdr_len_bytes = ceil((float)sn_len / 8); } diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srslte/upper/pdcp_entity_base.h index 03398c9f6..b4c222026 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srslte/upper/pdcp_entity_base.h @@ -103,7 +103,8 @@ protected: SECURITY_DIRECTION_DOWNLINK, SECURITY_DIRECTION_UPLINK, PDCP_SN_LEN_12, - pdcp_t_reordering_t::ms500}; + pdcp_t_reordering_t::ms500, + pdcp_discard_timer_t::infinity}; std::mutex mutex; diff --git a/lib/test/upper/pdcp_nr_test.cc b/lib/test/upper/pdcp_nr_test.cc index 48e037923..e8ee1524c 100644 --- a/lib/test/upper/pdcp_nr_test.cc +++ b/lib/test/upper/pdcp_nr_test.cc @@ -79,7 +79,8 @@ int test_tx(uint32_t n_packets, srslte::SECURITY_DIRECTION_UPLINK, srslte::SECURITY_DIRECTION_DOWNLINK, pdcp_sn_len, - srslte::pdcp_t_reordering_t::ms500}; + srslte::pdcp_t_reordering_t::ms500, + srslte::pdcp_discard_timer_t::infinity}; pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; @@ -121,7 +122,8 @@ int test_rx(std::vector events, srslte::SECURITY_DIRECTION_DOWNLINK, srslte::SECURITY_DIRECTION_UPLINK, pdcp_sn_len, - srslte::pdcp_t_reordering_t::ms500}; + srslte::pdcp_t_reordering_t::ms500, + srslte::pdcp_discard_timer_t::infinity}; pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, log); srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp; @@ -147,6 +149,47 @@ int test_rx(std::vector events, return 0; } +/* + * Genric function to test transmission of in-sequence packets + */ +int test_tx_sdu_discard(uint32_t n_packets, + const pdcp_initial_state& init_state, + uint8_t pdcp_sn_len, + uint64_t n_pdus_exp, + srslte::unique_byte_buffer_t pdu_exp, + srslte::byte_buffer_pool* pool, + srslte::log* log) +{ + srslte::pdcp_config_t cfg = {1, + srslte::PDCP_RB_IS_DRB, + srslte::SECURITY_DIRECTION_UPLINK, + srslte::SECURITY_DIRECTION_DOWNLINK, + pdcp_sn_len, + srslte::pdcp_t_reordering_t::ms500, + srslte::pdcp_discard_timer_t::ms50}; + + pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); + srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; + rlc_dummy* rlc = &pdcp_hlp.rlc; + + pdcp_hlp.set_pdcp_initial_state(init_state); + + // Run test + for (uint32_t i = 0; i < n_packets; ++i) { + // Test SDU + srslte::unique_byte_buffer_t sdu = allocate_unique_buffer(*pool); + sdu->append_bytes(sdu1, sizeof(sdu1)); + pdcp->write_sdu(std::move(sdu), true); + } + + srslte::unique_byte_buffer_t pdu_act = allocate_unique_buffer(*pool); + rlc->get_last_sdu(pdu_act); + + TESTASSERT(rlc->rx_count == n_pdus_exp); + TESTASSERT(compare_two_packets(pdu_act, pdu_exp) == 0); + return 0; +} + /* * TX Test: PDCP Entity with SN LEN = 12 and 18. * PDCP entity configured with EIA2 and EEA2 @@ -287,6 +330,11 @@ int test_tx_all(srslte::byte_buffer_pool* pool, srslte::log* log) std::move(pdu_exp_count4294967295_len18), pool, log) == 0); + + /* + * TX Test 9: PDCP Entity with SN LEN = 12 + * Test TX PDU discard. + */ return 0; } @@ -462,17 +510,10 @@ int run_all_tests(srslte::byte_buffer_pool* pool) TESTASSERT(test_tx_all(pool, &log) == 0); TESTASSERT(test_rx_all(pool, &log) == 0); - - // Helpers for generating expected PDUs - // srslte::unique_byte_buffer_t sdu = srslte::allocate_unique_buffer(*pool); - // sdu->append_bytes(sdu2, sizeof(sdu2)); - // uint32_t tx_next = 1; - // srslte::unique_byte_buffer_t pdu = gen_expected_pdu(std::move(sdu), tx_next, srslte::PDCP_SN_LEN_18, sec_cfg, pool, - // &log); print_packet_array(pdu); return 0; } -int main(int argc, char** argv) +int main() { if (run_all_tests(srslte::byte_buffer_pool::get_instance()) != SRSLTE_SUCCESS) { fprintf(stderr, "pdcp_nr_tests() failed\n"); diff --git a/lib/test/upper/pdcp_nr_test.h b/lib/test/upper/pdcp_nr_test.h index 74a6d5ef5..058da2ff4 100644 --- a/lib/test/upper/pdcp_nr_test.h +++ b/lib/test/upper/pdcp_nr_test.h @@ -192,7 +192,8 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t srslte::SECURITY_DIRECTION_UPLINK, srslte::SECURITY_DIRECTION_DOWNLINK, pdcp_sn_len, - srslte::pdcp_t_reordering_t::ms500}; + srslte::pdcp_t_reordering_t::ms500, + srslte::pdcp_discard_timer_t::infinity}; pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 9fca74067..1e9549cc6 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -219,8 +219,10 @@ void rrc::add_user(uint16_t rnti) srslte::SECURITY_DIRECTION_DOWNLINK, srslte::SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500}; - uint32_t teid_in = 1; + srslte::pdcp_t_reordering_t::ms500, + srslte::pdcp_discard_timer_t::infinity}; + + uint32_t teid_in = 1; for (auto& mbms_item : mcch.msg.c1().mbsfn_area_cfg_r9().pmch_info_list_r9[0].mbms_session_info_list_r9) { uint32_t lcid = mbms_item.lc_ch_id_r9; @@ -1642,7 +1644,8 @@ void rrc::ue::send_connection_setup(bool is_setup) srslte::SECURITY_DIRECTION_DOWNLINK, srslte::SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_5, - srslte::pdcp_t_reordering_t::ms500}; + srslte::pdcp_t_reordering_t::ms500, + srslte::pdcp_discard_timer_t::infinity}; parent->pdcp->add_bearer(rnti, 1, pdcp_cnfg); @@ -1859,7 +1862,8 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) srslte::SECURITY_DIRECTION_DOWNLINK, srslte::SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_5, - srslte::pdcp_t_reordering_t::ms500}; + srslte::pdcp_t_reordering_t::ms500, + srslte::pdcp_discard_timer_t::infinity}; parent->pdcp->add_bearer(rnti, 2, pdcp_cnfg_srb); parent->pdcp->config_security(rnti, 2, k_rrc_enc, k_rrc_int, k_up_enc, cipher_algo, integ_algo); @@ -1875,7 +1879,8 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) srslte::SECURITY_DIRECTION_DOWNLINK, srslte::SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500}; + srslte::pdcp_t_reordering_t::ms500, + srslte::pdcp_discard_timer_t::infinity}; if (conn_reconf->rr_cfg_ded.drb_to_add_mod_list[0].pdcp_cfg.rlc_um_present) { if (conn_reconf->rr_cfg_ded.drb_to_add_mod_list[0].pdcp_cfg.rlc_um.pdcp_sn_size.value == @@ -1952,7 +1957,8 @@ void rrc::ue::send_connection_reconf_new_bearer(LIBLTE_S1AP_E_RABTOBESETUPLISTBE srslte::SECURITY_DIRECTION_DOWNLINK, srslte::SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_12, - srslte::pdcp_t_reordering_t::ms500}; + srslte::pdcp_t_reordering_t::ms500, + srslte::pdcp_discard_timer_t::infinity}; parent->pdcp->add_bearer(rnti, lcid, pdcp_config); diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index b4cad6b9e..3c7952a91 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -2565,12 +2565,13 @@ void rrc::handle_con_reest(rrc_conn_reest_s* setup) void rrc::add_srb(srb_to_add_mod_s* srb_cnfg) { // Setup PDCP - pdcp_config_t pdcp_cfg = {.bearer_id = srb_cnfg->srb_id, - .rb_type = PDCP_RB_IS_SRB, - .tx_direction = SECURITY_DIRECTION_UPLINK, - .rx_direction = SECURITY_DIRECTION_DOWNLINK, - .sn_len = PDCP_SN_LEN_5, - .t_reordering = pdcp_t_reordering_t::ms500}; + pdcp_config_t pdcp_cfg = {.bearer_id = srb_cnfg->srb_id, + .rb_type = PDCP_RB_IS_SRB, + .tx_direction = SECURITY_DIRECTION_UPLINK, + .rx_direction = SECURITY_DIRECTION_DOWNLINK, + .sn_len = PDCP_SN_LEN_5, + .t_reordering = pdcp_t_reordering_t::ms500, + .discard_timer = pdcp_discard_timer_t::infinity}; pdcp->add_bearer(srb_cnfg->srb_id, pdcp_cfg); if (RB_ID_SRB2 == srb_cnfg->srb_id) { @@ -2644,12 +2645,13 @@ void rrc::add_drb(drb_to_add_mod_s* drb_cnfg) } // Setup PDCP - pdcp_config_t pdcp_cfg = {.bearer_id = drb_cnfg->drb_id, - .rb_type = PDCP_RB_IS_DRB, - .tx_direction = SECURITY_DIRECTION_UPLINK, - .rx_direction = SECURITY_DIRECTION_DOWNLINK, - .sn_len = PDCP_SN_LEN_12, - .t_reordering = pdcp_t_reordering_t::ms500}; + pdcp_config_t pdcp_cfg = {.bearer_id = drb_cnfg->drb_id, + .rb_type = PDCP_RB_IS_DRB, + .tx_direction = SECURITY_DIRECTION_UPLINK, + .rx_direction = SECURITY_DIRECTION_DOWNLINK, + .sn_len = PDCP_SN_LEN_12, + .t_reordering = pdcp_t_reordering_t::ms500, + .discard_timer = pdcp_discard_timer_t::infinity}; if (drb_cnfg->pdcp_cfg.rlc_um_present) { if (drb_cnfg->pdcp_cfg.rlc_um.pdcp_sn_size == pdcp_cfg_s::rlc_um_s_::pdcp_sn_size_e_::len7bits) { diff --git a/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h b/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h index 52643827c..37d4b9fdf 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_sys_interface.h @@ -221,7 +221,8 @@ private: .tx_direction = SECURITY_DIRECTION_DOWNLINK, .rx_direction = SECURITY_DIRECTION_UPLINK, .sn_len = PDCP_SN_LEN_5, - .t_reorderding = srslte::pdcp_t_reordering_t::ms500}; + .t_reorderding = srslte::pdcp_t_reordering_t::ms500, + .discard_timer = srslte::pdcp_discard_timer_t::infinity}; syssim->add_srb(lcid, pdcp_cfg); } } else if (config.HasMember("Release")) { @@ -601,4 +602,4 @@ private: byte_buffer_pool* pool = nullptr; }; -#endif // SRSUE_TTCN3_SYS_INTERFACE_H \ No newline at end of file +#endif // SRSUE_TTCN3_SYS_INTERFACE_H