|
|
|
@ -145,117 +145,6 @@ int test_rx(std::vector<pdcp_test_event_t> events,
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Genric function to test reception of a single out-of-order packet
|
|
|
|
|
*/
|
|
|
|
|
int test_rx_out_of_order(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_RB_IS_DRB,
|
|
|
|
|
srslte::SECURITY_DIRECTION_UPLINK,
|
|
|
|
|
srslte::SECURITY_DIRECTION_DOWNLINK,
|
|
|
|
|
pdcp_sn_len,
|
|
|
|
|
srslte::pdcp_t_reordering_t::ms500};
|
|
|
|
|
|
|
|
|
|
srslte::pdcp_config_t cfg_rx = {1,
|
|
|
|
|
srslte::PDCP_RB_IS_DRB,
|
|
|
|
|
srslte::SECURITY_DIRECTION_DOWNLINK,
|
|
|
|
|
srslte::SECURITY_DIRECTION_UPLINK,
|
|
|
|
|
pdcp_sn_len,
|
|
|
|
|
srslte::pdcp_t_reordering_t::ms500};
|
|
|
|
|
|
|
|
|
|
pdcp_nr_test_helper pdcp_hlp_tx(cfg_tx, sec_cfg, log);
|
|
|
|
|
srslte::pdcp_entity_nr* pdcp_tx = &pdcp_hlp_tx.pdcp;
|
|
|
|
|
rlc_dummy* rlc_tx = &pdcp_hlp_tx.rlc;
|
|
|
|
|
|
|
|
|
|
pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, log);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// Allocate buffers for later comparison.
|
|
|
|
|
srslte::unique_byte_buffer_t sdu_act = allocate_unique_buffer(*pool);
|
|
|
|
|
srslte::unique_byte_buffer_t sdu_exp = allocate_unique_buffer(*pool);
|
|
|
|
|
|
|
|
|
|
// Write PDUs into tx entity to get expected PDUs
|
|
|
|
|
srslte::unique_byte_buffer_t tx_sdu_out1 = allocate_unique_buffer(*pool);
|
|
|
|
|
tx_sdu_out1->append_bytes(sdu1, sizeof(sdu1));
|
|
|
|
|
pdcp_tx->write_sdu(std::move(tx_sdu_out1), true);
|
|
|
|
|
|
|
|
|
|
srslte::unique_byte_buffer_t tx_pdu_out1 = allocate_unique_buffer(*pool);
|
|
|
|
|
rlc_tx->get_last_sdu(tx_pdu_out1);
|
|
|
|
|
|
|
|
|
|
srslte::unique_byte_buffer_t tx_sdu_out2 = allocate_unique_buffer(*pool);
|
|
|
|
|
tx_sdu_out2->append_bytes(sdu2, sizeof(sdu2));
|
|
|
|
|
*sdu_exp = *tx_sdu_out2; // save expected SDU
|
|
|
|
|
pdcp_tx->write_sdu(std::move(tx_sdu_out2), true);
|
|
|
|
|
|
|
|
|
|
srslte::unique_byte_buffer_t tx_pdu_out2 = allocate_unique_buffer(*pool);
|
|
|
|
|
rlc_tx->get_last_sdu(tx_pdu_out2);
|
|
|
|
|
|
|
|
|
|
// Write PDUs out-of-order into rx entity to see if re-ordering is OK.
|
|
|
|
|
pdcp_rx->write_pdu(std::move(tx_pdu_out2));
|
|
|
|
|
pdcp_rx->write_pdu(std::move(tx_pdu_out1));
|
|
|
|
|
|
|
|
|
|
// Test actual reception
|
|
|
|
|
TESTASSERT(gw_rx->rx_count == 2);
|
|
|
|
|
gw_rx->get_last_pdu(sdu_act);
|
|
|
|
|
|
|
|
|
|
log->info_hex(sdu_act->msg, sdu_act->N_bytes, "SDU act");
|
|
|
|
|
TESTASSERT(compare_two_packets(sdu_act, sdu_exp) == 0);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* RX Test: PDCP Entity with packtes received out of order
|
|
|
|
|
* PDCP entity configured with EIA2 and EEA2
|
|
|
|
|
*/
|
|
|
|
|
int test_rx_out_of_order_timeout(uint8_t pdcp_sn_len, srslte::byte_buffer_pool* pool, srslte::log* log)
|
|
|
|
|
{
|
|
|
|
|
srslte::pdcp_config_t cfg_rx = {1,
|
|
|
|
|
srslte::PDCP_RB_IS_DRB,
|
|
|
|
|
srslte::SECURITY_DIRECTION_DOWNLINK,
|
|
|
|
|
srslte::SECURITY_DIRECTION_UPLINK,
|
|
|
|
|
pdcp_sn_len,
|
|
|
|
|
srslte::pdcp_t_reordering_t::ms500};
|
|
|
|
|
|
|
|
|
|
pdcp_nr_test_helper pdcp_rx_hlp(cfg_rx, sec_cfg, log);
|
|
|
|
|
srslte::pdcp_entity_nr* pdcp_rx = &pdcp_rx_hlp.pdcp;
|
|
|
|
|
gw_dummy* gw_rx = &pdcp_rx_hlp.gw;
|
|
|
|
|
srslte::timers* timers = &pdcp_rx_hlp.timers;
|
|
|
|
|
|
|
|
|
|
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(sdu2, sizeof(sdu2));
|
|
|
|
|
|
|
|
|
|
// Generate encripted and integrity protected PDUs
|
|
|
|
|
srslte::unique_byte_buffer_t rx_pdu7 = allocate_unique_buffer(*pool);
|
|
|
|
|
rx_pdu7->append_bytes(pdu2_count1_snlen12, sizeof(pdu2_count1_snlen12));
|
|
|
|
|
|
|
|
|
|
// decript and check matching SDUs (out of order)
|
|
|
|
|
pdcp_rx->write_pdu(std::move(rx_pdu7));
|
|
|
|
|
|
|
|
|
|
// Make sure out of order is not received until time out
|
|
|
|
|
TESTASSERT(gw_rx->rx_count == 0);
|
|
|
|
|
|
|
|
|
|
// Trigger timer
|
|
|
|
|
for (uint16_t i = 0; i < 500; ++i) {
|
|
|
|
|
timers->step_all();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure timout delivered PDU to GW
|
|
|
|
|
TESTASSERT(gw_rx->rx_count == 1);
|
|
|
|
|
gw_rx->get_last_pdu(sdu_act);
|
|
|
|
|
TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* TX Test: PDCP Entity with SN LEN = 12 and 18.
|
|
|
|
|
* PDCP entity configured with EIA2 and EEA2
|
|
|
|
@ -430,59 +319,64 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
|
|
|
|
|
* This tests correct handling of COUNT in the case of [HFN|SN] wraparound
|
|
|
|
|
* Packet that wraparound should be dropped, so only one packet should be received at the GW.
|
|
|
|
|
*/
|
|
|
|
|
/*{
|
|
|
|
|
{
|
|
|
|
|
std::vector<uint32_t> test2_counts(2); // Test two packets
|
|
|
|
|
std::iota(test2_counts.begin(), test2_counts.end(), 4294967295); // Starting at COUNT 4294967295
|
|
|
|
|
std::vector<srslte::unique_byte_buffer_t> test2_pdus =
|
|
|
|
|
std::vector<pdcp_test_event_t> test2_pdus =
|
|
|
|
|
gen_expected_pdus_vector(tst_sdu1, test2_counts, srslte::PDCP_SN_LEN_12, sec_cfg, pool, log);
|
|
|
|
|
pdcp_initial_state test2_init_state = {
|
|
|
|
|
.tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0};
|
|
|
|
|
TESTASSERT(test_rx(std::move(test2_pdus), test2_init_state, srslte::PDCP_SN_LEN_12, 1, pool, log) == 0);
|
|
|
|
|
}*/
|
|
|
|
|
TESTASSERT(test_rx(std::move(test2_pdus), test2_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, 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 (SN LEN 18)
|
|
|
|
|
*/
|
|
|
|
|
/*{
|
|
|
|
|
{
|
|
|
|
|
std::vector<uint32_t> test3_counts(2); // Test two packets
|
|
|
|
|
std::iota(test3_counts.begin(), test3_counts.end(), 262144); // Starting at COUNT 262144
|
|
|
|
|
std::vector<srslte::unique_byte_buffer_t> test3_pdus =
|
|
|
|
|
std::vector<pdcp_test_event_t> test3_pdus =
|
|
|
|
|
gen_expected_pdus_vector(tst_sdu1, test3_counts, srslte::PDCP_SN_LEN_18, sec_cfg, pool, log);
|
|
|
|
|
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, srslte::PDCP_SN_LEN_18, 2, pool, log) == 0);
|
|
|
|
|
}*/
|
|
|
|
|
TESTASSERT(test_rx(std::move(test3_pdus), test3_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu1, pool, log) == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* RX Test 4: PDCP Entity with SN LEN = 18
|
|
|
|
|
* Test in-sequence reception of 4294967297 packets.
|
|
|
|
|
* This tests correct handling of COUNT in the case of [HFN|SN] wraparound
|
|
|
|
|
*/
|
|
|
|
|
/*{
|
|
|
|
|
{
|
|
|
|
|
std::vector<uint32_t> test4_counts(2); // Test two packets
|
|
|
|
|
std::iota(test4_counts.begin(), test4_counts.end(), 4294967295); // Starting at COUNT 4294967295
|
|
|
|
|
std::vector<srslte::unique_byte_buffer_t> test4_pdus =
|
|
|
|
|
std::vector<pdcp_test_event_t> test4_pdus =
|
|
|
|
|
gen_expected_pdus_vector(tst_sdu1, test4_counts, srslte::PDCP_SN_LEN_18, sec_cfg, pool, log);
|
|
|
|
|
pdcp_initial_state test4_init_state = {
|
|
|
|
|
.tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0};
|
|
|
|
|
TESTASSERT(test_rx(std::move(test4_pdus), test4_init_state, srslte::PDCP_SN_LEN_18, 1, pool, log) == 0);
|
|
|
|
|
}*/
|
|
|
|
|
TESTASSERT(test_rx(std::move(test4_pdus), test4_init_state, srslte::PDCP_SN_LEN_18, 1, tst_sdu1, pool, log) == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* RX Test 5: PDCP Entity with SN LEN = 12
|
|
|
|
|
* Test reception of two out-of-order packets, starting at COUNT 0.
|
|
|
|
|
*/
|
|
|
|
|
/*{
|
|
|
|
|
std::vector<srslte::unique_byte_buffer_t> test5_pdus;
|
|
|
|
|
{
|
|
|
|
|
std::vector<pdcp_test_event_t> test5_pdus;
|
|
|
|
|
pdcp_initial_state test5_init_state = {};
|
|
|
|
|
srslte::unique_byte_buffer_t pdu1 = srslte::allocate_unique_buffer(*pool);
|
|
|
|
|
srslte::unique_byte_buffer_t pdu2 = srslte::allocate_unique_buffer(*pool);
|
|
|
|
|
pdu1->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12));
|
|
|
|
|
pdu2->append_bytes(pdu2_count1_snlen12, sizeof(pdu2_count1_snlen12));
|
|
|
|
|
test5_pdus.push_back(std::move(pdu2));
|
|
|
|
|
test5_pdus.push_back(std::move(pdu1));
|
|
|
|
|
TESTASSERT(test_rx(std::move(test5_pdus), test5_init_state, srslte::PDCP_SN_LEN_12, 2, pool, log) == 0);
|
|
|
|
|
}*/
|
|
|
|
|
pdcp_test_event_t event_pdu1;
|
|
|
|
|
event_pdu1.pkt = srslte::allocate_unique_buffer(*pool);
|
|
|
|
|
event_pdu1.pkt->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12));
|
|
|
|
|
|
|
|
|
|
pdcp_test_event_t event_pdu2;
|
|
|
|
|
event_pdu2.pkt = srslte::allocate_unique_buffer(*pool);
|
|
|
|
|
event_pdu2.pkt->append_bytes(pdu2_count1_snlen12, sizeof(pdu2_count1_snlen12));
|
|
|
|
|
|
|
|
|
|
// 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_pdu1));
|
|
|
|
|
TESTASSERT(test_rx(std::move(test5_pdus), test5_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu2, pool, log) == 0);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* RX Test 5: PDCP Entity with SN LEN = 12
|
|
|
|
|
* Test Reception of one out-of-order packet.
|
|
|
|
|