Improved speed of tests for COUNT wraparound, by setting the PDCP initial state.

master
Pedro Alvarez 5 years ago committed by Andre Puschmann
parent ffc26a702d
commit 1d56fa6308

@ -114,6 +114,9 @@ private:
pdcp_entity_nr* parent; pdcp_entity_nr* parent;
}; };
/*
* Helpers
*/
inline void pdcp_entity_nr::pass_to_upper_layers(unique_byte_buffer_t sdu) inline void pdcp_entity_nr::pass_to_upper_layers(unique_byte_buffer_t sdu)
{ {
if (is_srb()) { if (is_srb()) {

@ -86,7 +86,7 @@ void pdcp_entity_base::integrity_generate(uint8_t* msg, uint32_t msg_len, uint32
break; break;
} }
log->debug("Integrity gen input: COUNT %d, Bearer ID %d, Direction %s\n", log->debug("Integrity gen input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s\n",
count, count,
cfg.bearer_id, cfg.bearer_id,
(cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink")); (cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"));
@ -123,7 +123,7 @@ bool pdcp_entity_base::integrity_verify(uint8_t* msg, uint32_t msg_len, uint32_t
break; break;
} }
log->debug("Integrity check input: COUNT %d, Bearer ID %d, Direction %s\n", log->debug("Integrity check input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s\n",
count, count,
cfg.bearer_id, cfg.bearer_id,
cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"); cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink");
@ -158,7 +158,7 @@ void pdcp_entity_base::cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t c
k_enc = k_up_enc; k_enc = k_up_enc;
} }
log->debug("Cipher encrypt input: COUNT: %d, Bearer ID: %d, Direction %s\n", log->debug("Cipher encrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s\n",
count, count,
cfg.bearer_id, cfg.bearer_id,
cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"); cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink");
@ -197,7 +197,7 @@ void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t cou
k_enc = k_up_enc; k_enc = k_up_enc;
} }
log->debug("Cipher decrypt input: COUNT: %d, Bearer ID: %d, Direction %s\n", log->debug("Cipher decrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s\n",
count, count,
cfg.bearer_id, cfg.bearer_id,
(cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK) ? "Downlink" : "Uplink"); (cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK) ? "Downlink" : "Uplink");

@ -140,7 +140,7 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
} }
rcvd_count = COUNT(rcvd_hfn, rcvd_sn); rcvd_count = COUNT(rcvd_hfn, rcvd_sn);
log->debug("RCVD_SN %d, RCVD_COUNT %d\n", rcvd_sn, rcvd_count); log->debug("RCVD_SN %" PRIu32 ", RCVD_COUNT %" PRIu32 "\n", rcvd_sn, rcvd_count);
// Decripting // Decripting
cipher_decrypt(pdu->msg, pdu->N_bytes, rcvd_count, pdu->msg); cipher_decrypt(pdu->msg, pdu->N_bytes, rcvd_count, pdu->msg);
@ -285,7 +285,7 @@ void pdcp_entity_nr::deliver_all_consecutive_counts()
it != reorder_queue.end() && it->first == rx_deliv; it != reorder_queue.end() && it->first == rx_deliv;
reorder_queue.erase(it++)) reorder_queue.erase(it++))
{ {
log->debug("Delivering SDU with RCVD_COUNT %d\n", it->first); log->debug("Delivering SDU with RCVD_COUNT %" PRIu32 "\n", it->first);
// Pass PDCP SDU to the next layers // Pass PDCP SDU to the next layers
pass_to_upper_layers(std::move(it->second)); pass_to_upper_layers(std::move(it->second));

@ -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, 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}; 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 = { pdcp_security_cfg sec_cfg = {
k_int, k_int,
k_enc, k_enc,
@ -98,7 +99,7 @@ int test_tx(uint32_t n_packets,
/* /*
* Genric function to test reception of in-sequence 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, 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; srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp;
gw_dummy* gw_rx = &pdcp_hlp_rx.gw; 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_act = allocate_unique_buffer(*pool);
srslte::unique_byte_buffer_t sdu_exp = allocate_unique_buffer(*pool); srslte::unique_byte_buffer_t sdu_exp = allocate_unique_buffer(*pool);
sdu_exp->append_bytes(sdu1, sizeof(sdu1)); sdu_exp->append_bytes(sdu1, sizeof(sdu1));
// Generate test message and encript/decript SDU. Check match with original SDU // 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 sdu = allocate_unique_buffer(*pool);
srslte::unique_byte_buffer_t pdu = allocate_unique_buffer(*pool); srslte::unique_byte_buffer_t pdu = allocate_unique_buffer(*pool);
sdu->append_bytes(sdu_exp->msg, sdu_exp->N_bytes); 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) 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 * RX Test 1: PDCP Entity with SN LEN = 12
* Test in-sequence reception of 4097 packets. * Test in-sequence reception of 4097 packets.
* This tests correct handling of HFN in the case of SN wraparound * 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 * RX Test 2: PDCP Entity with SN LEN = 12
* Test in-sequence reception of 4294967297 packets. * Test in-sequence reception of 4294967297 packets.
* This tests correct handling of COUNT in the case of [HFN|SN] wraparound * 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 * RX Test 3: PDCP Entity with SN LEN = 18
* Test In-sequence reception of 262145 packets. * Test In-sequence reception of 262145 packets.
* This tests correct handling of HFN in the case of SN wraparound * 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 * RX Test 4: PDCP Entity with SN LEN = 12
* Test Reception of one out-of-order packet. * 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(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 * RX Test 5: PDCP Entity with SN LEN = 12
* Test timeout of t-Reordering when one packet is lost. * 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 * 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); log.set_hex_limit(128);
// Helpers for generating expected PDUs // Helpers for generating expected PDUs
srslte::unique_byte_buffer_t sdu = srslte::allocate_unique_buffer(*pool); // srslte::unique_byte_buffer_t sdu = srslte::allocate_unique_buffer(*pool);
sdu->append_bytes(sdu1, sizeof(sdu1)); // sdu->append_bytes(sdu1, sizeof(sdu1));
srslte::pdcp_config_t cfg_tx = {1, // srslte::pdcp_config_t cfg_tx = {1,
srslte::PDCP_RB_IS_DRB, // srslte::PDCP_RB_IS_DRB,
srslte::SECURITY_DIRECTION_UPLINK, // srslte::SECURITY_DIRECTION_UPLINK,
srslte::SECURITY_DIRECTION_DOWNLINK, // srslte::SECURITY_DIRECTION_DOWNLINK,
srslte::PDCP_SN_LEN_18, // srslte::PDCP_SN_LEN_18,
srslte::pdcp_t_reordering_t::ms500}; // srslte::pdcp_t_reordering_t::ms500};
gen_expected_pdu(std::move(sdu), 0, cfg_tx, sec_cfg, &log, pool); //gen_expected_pdu(std::move(sdu), 0, cfg_tx, sec_cfg, &log, pool);
//TESTASSERT(test_tx_all(pool, &log) == 0); //TESTASSERT(test_tx_all(pool, &log) == 0);
//TESTASSERT(test_rx_all(pool, &log) == 0); TESTASSERT(test_rx_all(pool, &log) == 0);
return 0; return 0;
} }

@ -62,6 +62,13 @@ struct pdcp_security_cfg {
srslte::CIPHERING_ALGORITHM_ID_ENUM enc_algo; srslte::CIPHERING_ALGORITHM_ID_ENUM enc_algo;
}; };
struct pdcp_initial_state {
uint32_t tx_next;
uint32_t rx_next;
uint32_t rx_deliv;
uint32_t rx_reord;
};
// dummy classes // dummy classes
class rlc_dummy : public srsue::rlc_interface_pdcp class rlc_dummy : public srsue::rlc_interface_pdcp
{ {
@ -149,6 +156,13 @@ public:
pdcp.enable_encryption(); pdcp.enable_encryption();
} }
void set_pdcp_initial_state(pdcp_initial_state init_state) {
pdcp.set_tx_next(init_state.tx_next);
pdcp.set_rx_next(init_state.rx_next);
pdcp.set_rx_deliv(init_state.rx_deliv);
pdcp.set_rx_reord(init_state.rx_reord);
}
srslte::pdcp_entity_nr pdcp; srslte::pdcp_entity_nr pdcp;
rlc_dummy rlc; rlc_dummy rlc;
rrc_dummy rrc; rrc_dummy rrc;

Loading…
Cancel
Save