|
|
|
@ -26,6 +26,7 @@ uint8_t k_int[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0
|
|
|
|
|
uint8_t k_enc[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
|
|
|
|
|
0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31};
|
|
|
|
|
|
|
|
|
|
// Security Configuration, common to all tests.
|
|
|
|
|
pdcp_security_cfg sec_cfg = {
|
|
|
|
|
k_int,
|
|
|
|
|
k_enc,
|
|
|
|
@ -98,7 +99,7 @@ int test_tx(uint32_t n_packets,
|
|
|
|
|
/*
|
|
|
|
|
* Genric function to test reception of in-sequence packets
|
|
|
|
|
*/
|
|
|
|
|
int test_rx_in_sequence(uint64_t n_packets, uint8_t pdcp_sn_len, srslte::byte_buffer_pool* pool, srslte::log* log)
|
|
|
|
|
int test_rx_in_sequence(uint64_t tx_next_max, const pdcp_initial_state &init_state, uint8_t pdcp_sn_len, srslte::byte_buffer_pool* pool, srslte::log* log)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
srslte::pdcp_config_t cfg_tx = {1,
|
|
|
|
@ -123,12 +124,15 @@ int test_rx_in_sequence(uint64_t n_packets, uint8_t pdcp_sn_len, srslte::byte_bu
|
|
|
|
|
srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp;
|
|
|
|
|
gw_dummy* gw_rx = &pdcp_hlp_rx.gw;
|
|
|
|
|
|
|
|
|
|
pdcp_hlp_tx.set_pdcp_initial_state(init_state);
|
|
|
|
|
pdcp_hlp_rx.set_pdcp_initial_state(init_state);
|
|
|
|
|
|
|
|
|
|
srslte::unique_byte_buffer_t sdu_act = allocate_unique_buffer(*pool);
|
|
|
|
|
srslte::unique_byte_buffer_t sdu_exp = allocate_unique_buffer(*pool);
|
|
|
|
|
sdu_exp->append_bytes(sdu1, sizeof(sdu1));
|
|
|
|
|
|
|
|
|
|
// Generate test message and encript/decript SDU. Check match with original SDU
|
|
|
|
|
for (uint64_t i = 0; i < n_packets; ++i) {
|
|
|
|
|
for (uint64_t i = init_state.tx_next; i <= tx_next_max; ++i) {
|
|
|
|
|
srslte::unique_byte_buffer_t sdu = allocate_unique_buffer(*pool);
|
|
|
|
|
srslte::unique_byte_buffer_t pdu = allocate_unique_buffer(*pool);
|
|
|
|
|
sdu->append_bytes(sdu_exp->msg, sdu_exp->N_bytes);
|
|
|
|
@ -466,39 +470,49 @@ int test_tx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
|
|
|
|
|
*/
|
|
|
|
|
int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
|
|
|
|
|
{
|
|
|
|
|
// This is the normal initial state. All state variables are set to zero
|
|
|
|
|
pdcp_initial_state normal_init_state = {};
|
|
|
|
|
|
|
|
|
|
// Some tests regarding COUNT wraparound take really long.
|
|
|
|
|
// This puts the PCDC state closer to wraparound quickly.
|
|
|
|
|
pdcp_initial_state near_wraparound_init_state = {
|
|
|
|
|
.tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* RX Test 1: PDCP Entity with SN LEN = 12
|
|
|
|
|
* Test in-sequence reception of 4097 packets.
|
|
|
|
|
* This tests correct handling of HFN in the case of SN wraparound
|
|
|
|
|
*/
|
|
|
|
|
TESTASSERT(test_rx_in_sequence(4097, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
|
|
|
|
//TESTASSERT(test_rx_in_sequence(4096, normal_init_state, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* RX Test 2: PDCP Entity with SN LEN = 12
|
|
|
|
|
* Test in-sequence reception of 4294967297 packets.
|
|
|
|
|
* This tests correct handling of COUNT in the case of [HFN|SN] wraparound
|
|
|
|
|
*/
|
|
|
|
|
// // TESTASSERT(test_rx_in_sequence(4294967297, srslte::PDCP_SN_LEN_12, pool, &log) == 0);
|
|
|
|
|
//pdcp_initial_state test2_init_state = {};
|
|
|
|
|
TESTASSERT(test_rx_in_sequence(4294967296, near_wraparound_init_state, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* RX Test 3: PDCP Entity with SN LEN = 18
|
|
|
|
|
* Test In-sequence reception of 262145 packets.
|
|
|
|
|
* This tests correct handling of HFN in the case of SN wraparound
|
|
|
|
|
*/
|
|
|
|
|
TESTASSERT(test_rx_in_sequence(262145, srslte::PDCP_SN_LEN_18, pool, log) == 0);
|
|
|
|
|
pdcp_initial_state test3_init_state = {};
|
|
|
|
|
//TESTASSERT(test_rx_in_sequence(262145, normal_init_state, srslte::PDCP_SN_LEN_18, pool, log) == 0);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* RX Test 4: PDCP Entity with SN LEN = 12
|
|
|
|
|
* Test Reception of one out-of-order packet.
|
|
|
|
|
*/
|
|
|
|
|
//TESTASSERT(test_rx_out_of_order(srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
|
|
|
|
TESTASSERT(test_rx_out_of_order(2, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
|
|
|
|
//TESTASSERT(test_rx_out_of_order(2, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* RX Test 5: PDCP Entity with SN LEN = 12
|
|
|
|
|
* Test timeout of t-Reordering when one packet is lost.
|
|
|
|
|
*/
|
|
|
|
|
TESTASSERT(test_rx_out_of_order_timeout(srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
|
|
|
|
//TESTASSERT(test_rx_out_of_order_timeout(srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* RX Test 5: PDCP Entity with SN LEN = 12
|
|
|
|
@ -516,17 +530,17 @@ int run_all_tests(srslte::byte_buffer_pool* pool)
|
|
|
|
|
log.set_hex_limit(128);
|
|
|
|
|
|
|
|
|
|
// Helpers for generating expected PDUs
|
|
|
|
|
srslte::unique_byte_buffer_t sdu = srslte::allocate_unique_buffer(*pool);
|
|
|
|
|
sdu->append_bytes(sdu1, sizeof(sdu1));
|
|
|
|
|
srslte::pdcp_config_t cfg_tx = {1,
|
|
|
|
|
srslte::PDCP_RB_IS_DRB,
|
|
|
|
|
srslte::SECURITY_DIRECTION_UPLINK,
|
|
|
|
|
srslte::SECURITY_DIRECTION_DOWNLINK,
|
|
|
|
|
srslte::PDCP_SN_LEN_18,
|
|
|
|
|
srslte::pdcp_t_reordering_t::ms500};
|
|
|
|
|
gen_expected_pdu(std::move(sdu), 0, cfg_tx, sec_cfg, &log, pool);
|
|
|
|
|
// srslte::unique_byte_buffer_t sdu = srslte::allocate_unique_buffer(*pool);
|
|
|
|
|
// sdu->append_bytes(sdu1, sizeof(sdu1));
|
|
|
|
|
// srslte::pdcp_config_t cfg_tx = {1,
|
|
|
|
|
// srslte::PDCP_RB_IS_DRB,
|
|
|
|
|
// srslte::SECURITY_DIRECTION_UPLINK,
|
|
|
|
|
// srslte::SECURITY_DIRECTION_DOWNLINK,
|
|
|
|
|
// srslte::PDCP_SN_LEN_18,
|
|
|
|
|
// srslte::pdcp_t_reordering_t::ms500};
|
|
|
|
|
//gen_expected_pdu(std::move(sdu), 0, cfg_tx, sec_cfg, &log, pool);
|
|
|
|
|
//TESTASSERT(test_tx_all(pool, &log) == 0);
|
|
|
|
|
//TESTASSERT(test_rx_all(pool, &log) == 0);
|
|
|
|
|
TESTASSERT(test_rx_all(pool, &log) == 0);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|