From 38bbc55631831983d1b51ed02a443b10e855bb8a Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 22 Jul 2019 14:23:57 +0100 Subject: [PATCH] Added tests for PDCP NR Rx with SN Len = 18. In-sequence reception seems to work. --- lib/src/upper/pdcp_entity_nr.cc | 5 +++-- lib/test/upper/pdcp_nr_test.cc | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/src/upper/pdcp_entity_nr.cc b/lib/src/upper/pdcp_entity_nr.cc index 4dde859b7..3644ff677 100644 --- a/lib/src/upper/pdcp_entity_nr.cc +++ b/lib/src/upper/pdcp_entity_nr.cc @@ -187,10 +187,11 @@ void pdcp_entity_nr::read_data_header(const unique_byte_buffer_t& pdu, uint32_t switch (cfg.sn_len) { case PDCP_SN_LEN_12: srslte::uint8_to_uint16(pdu->msg, &rcvd_sn_16); - (*rcvd_sn) = 0x0FFF & rcvd_sn_16; + (*rcvd_sn) = SN(rcvd_sn_16); break; case PDCP_SN_LEN_18: - // srslte::uint8_to_uint24((uint16_t*)sdu->msg, rcvd_sn); + srslte::uint8_to_uint24(pdu->msg, rcvd_sn); + (*rcvd_sn) = SN(*rcvd_sn); break; default: log->error("Cannot extract RCVD_SN, invalid SN length configured: %d\n", cfg.sn_len); diff --git a/lib/test/upper/pdcp_nr_test.cc b/lib/test/upper/pdcp_nr_test.cc index 3d0e23b17..1401a8c6f 100644 --- a/lib/test/upper/pdcp_nr_test.cc +++ b/lib/test/upper/pdcp_nr_test.cc @@ -222,7 +222,7 @@ int test_tx_all(srslte::byte_buffer_pool* pool, srslte::log* log) srslte::unique_byte_buffer_t pdu_exp_sn0_len18 = allocate_unique_buffer(*pool); memcpy(pdu_exp_sn0_len18->msg, pdu4, PDU4_LEN); pdu_exp_sn0_len18->N_bytes = PDU4_LEN; - //TESTASSERT(test_tx(1, srslte::PDCP_SN_LEN_18, std::move(pdu_exp_sn0_len18), pool, log) == 0); + TESTASSERT(test_tx(1, srslte::PDCP_SN_LEN_18, std::move(pdu_exp_sn0_len18), pool, log) == 0); /* * TX Test 5: PDCP Entity with SN LEN = 18 @@ -254,14 +254,14 @@ int test_tx_all(srslte::byte_buffer_pool* pool, srslte::log* log) * RX Test: PDCP Entity with SN LEN = 12 and 18. Tested 4097 packets received without losses. * PDCP entity configured with EIA2 and EEA2 */ -int test_rx_in_sequence(uint32_t n_packets, srslte::byte_buffer_pool* pool, srslte::log* log) +int test_rx_in_sequence(uint32_t n_packets, uint8_t pdcp_sn_len, srslte::byte_buffer_pool* pool, srslte::log* log) { srslte::pdcp_entity_nr pdcp_tx; srslte::pdcp_entity_nr pdcp_rx; srslte::srslte_pdcp_config_t cfg_tx = { - 1, srslte::PDCP_RB_IS_DRB, SECURITY_DIRECTION_UPLINK, SECURITY_DIRECTION_DOWNLINK, srslte::PDCP_SN_LEN_12}; + 1, srslte::PDCP_RB_IS_DRB, SECURITY_DIRECTION_UPLINK, SECURITY_DIRECTION_DOWNLINK, pdcp_sn_len}; srslte::srslte_pdcp_config_t cfg_rx = { - 1, srslte::PDCP_RB_IS_DRB, SECURITY_DIRECTION_DOWNLINK, SECURITY_DIRECTION_UPLINK, srslte::PDCP_SN_LEN_12}; + 1, srslte::PDCP_RB_IS_DRB, SECURITY_DIRECTION_DOWNLINK, SECURITY_DIRECTION_UPLINK, pdcp_sn_len}; rlc_dummy rlc_tx(log); rrc_dummy rrc_tx(log); @@ -319,7 +319,8 @@ int run_all_tests(srslte::byte_buffer_pool* pool) log.set_hex_limit(128); TESTASSERT(test_tx_all(pool, &log) == 0); - TESTASSERT(test_rx_in_sequence(4097, pool, &log) == 0); + TESTASSERT(test_rx_in_sequence(4097, srslte::PDCP_SN_LEN_12, pool, &log) == 0); + TESTASSERT(test_rx_in_sequence(262145, srslte::PDCP_SN_LEN_18, pool, &log) == 0); return 0; }