mirror of https://github.com/PentHertz/srsLTE.git
Added function to generate vector of PDUs
This commit is contained in:
parent
ed24544a63
commit
eb1470621a
|
@ -19,6 +19,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "pdcp_nr_test.h"
|
#include "pdcp_nr_test.h"
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
// Encryption and Integrity Keys
|
// Encryption and Integrity Keys
|
||||||
uint8_t k_int[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
|
uint8_t k_int[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
|
||||||
|
@ -424,60 +425,69 @@ 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)
|
||||||
{
|
{
|
||||||
|
// Test SDUs
|
||||||
|
srslte::unique_byte_buffer_t tst_sdu1 = allocate_unique_buffer(*pool); // SDU 1
|
||||||
|
tst_sdu1->append_bytes(sdu1, sizeof(sdu1));
|
||||||
|
srslte::unique_byte_buffer_t tst_sdu2 = allocate_unique_buffer(*pool); // SDU 2
|
||||||
|
tst_sdu2->append_bytes(sdu2, sizeof(sdu2));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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 (SN LEN 12)
|
* This tests correct handling of HFN in the case of SN wraparound (SN LEN 12)
|
||||||
*/
|
*/
|
||||||
TESTASSERT(test_rx_in_sequence(4096, normal_init_state, srslte::PDCP_SN_LEN_12, 4097, pool, log) == 0);
|
std::vector<uint32_t> test1_counts(2); // Test two packets
|
||||||
|
std::iota(test1_counts.begin(), test1_counts.end(), 4095); // Starting at COUNT 4095
|
||||||
|
std::vector<srslte::unique_byte_buffer_t> test1_exp_pdus = gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_12, sec_cfg, pool, log);
|
||||||
|
pdcp_initial_state test1_init_state = {.tx_next = 4095, .rx_next = 4095, .rx_deliv = 4095, .rx_reord = 0};
|
||||||
|
TESTASSERT(test_rx_in_sequence(4096, test1_init_state, srslte::PDCP_SN_LEN_12, 2, 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
|
||||||
* Packet that wraparound should be dropped, so only one packet should be received at the GW.
|
* Packet that wraparound should be dropped, so only one packet should be received at the GW.
|
||||||
*/
|
*/
|
||||||
TESTASSERT(test_rx_in_sequence(4294967296, near_wraparound_init_state, srslte::PDCP_SN_LEN_12, 1, pool, log) == 0);
|
TESTASSERT(test_rx_in_sequence(4294967296, near_wraparound_init_state, srslte::PDCP_SN_LEN_12, 1, 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 (SN LEN 18)
|
* This tests correct handling of HFN in the case of SN wraparound (SN LEN 18)
|
||||||
*/
|
*/
|
||||||
TESTASSERT(test_rx_in_sequence(262144, normal_init_state, srslte::PDCP_SN_LEN_18, 262146, pool, log) == 0);
|
TESTASSERT(test_rx_in_sequence(262144, normal_init_state, srslte::PDCP_SN_LEN_18, 262146, pool, log) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RX Test 4: PDCP Entity with SN LEN = 18
|
* RX Test 4: PDCP Entity with SN LEN = 18
|
||||||
* 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(4294967296, near_wraparound_init_state, srslte::PDCP_SN_LEN_18, 2, pool, log) == 0);
|
TESTASSERT(test_rx_in_sequence(4294967296, near_wraparound_init_state, srslte::PDCP_SN_LEN_18, 2, pool, log) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RX Test 5: PDCP Entity with SN LEN = 12
|
* RX Test 5: 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(normal_init_state, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
TESTASSERT(test_rx_out_of_order(normal_init_state, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RX Test 6: PDCP Entity with SN LEN = 12
|
* RX Test 6: PDCP Entity with SN LEN = 12
|
||||||
* Test Reception of one out-of-order packet at COUNT wraparound.
|
* Test Reception of one out-of-order packet at COUNT wraparound.
|
||||||
*/
|
*/
|
||||||
TESTASSERT(test_rx_out_of_order(near_wraparound_init_state, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
TESTASSERT(test_rx_out_of_order(near_wraparound_init_state, 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
|
||||||
* 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(4294967297, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
// TESTASSERT(test_rx_out_of_order(4294967297, srslte::PDCP_SN_LEN_12, pool, log) == 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup all tests
|
// Setup all tests
|
||||||
|
|
|
@ -173,14 +173,21 @@ public:
|
||||||
srslte::timers timers;
|
srslte::timers timers;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper function to generate PDUs
|
// Helper function to generate PDUs
|
||||||
void gen_expected_pdu(srslte::unique_byte_buffer_t in_sdu,
|
srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t& in_sdu,
|
||||||
uint32_t count,
|
uint32_t count,
|
||||||
srslte::pdcp_config_t cfg,
|
uint8_t pdcp_sn_len,
|
||||||
pdcp_security_cfg sec_cfg,
|
pdcp_security_cfg sec_cfg,
|
||||||
srslte::log* log,
|
srslte::byte_buffer_pool* pool,
|
||||||
srslte::byte_buffer_pool* pool)
|
srslte::log* log)
|
||||||
{
|
{
|
||||||
|
srslte::pdcp_config_t cfg = {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(cfg, sec_cfg, log);
|
pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log);
|
||||||
srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp;
|
srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp;
|
||||||
rlc_dummy* rlc = &pdcp_hlp.rlc;
|
rlc_dummy* rlc = &pdcp_hlp.rlc;
|
||||||
|
@ -189,25 +196,28 @@ void gen_expected_pdu(srslte::unique_byte_buffer_t in_sdu,
|
||||||
init_state.tx_next = count;
|
init_state.tx_next = count;
|
||||||
pdcp_hlp.set_pdcp_initial_state(init_state);
|
pdcp_hlp.set_pdcp_initial_state(init_state);
|
||||||
|
|
||||||
// for (uint32_t i = 0; i <= count; ++i) {
|
|
||||||
srslte::unique_byte_buffer_t sdu = srslte::allocate_unique_buffer(*pool);
|
srslte::unique_byte_buffer_t sdu = srslte::allocate_unique_buffer(*pool);
|
||||||
*sdu = *in_sdu;
|
*sdu = *in_sdu;
|
||||||
pdcp->write_sdu(std::move(sdu), true);
|
pdcp->write_sdu(std::move(sdu), true);
|
||||||
//}
|
|
||||||
srslte::unique_byte_buffer_t out_pdu = srslte::allocate_unique_buffer(*pool);
|
srslte::unique_byte_buffer_t out_pdu = srslte::allocate_unique_buffer(*pool);
|
||||||
rlc->get_last_sdu(out_pdu);
|
rlc->get_last_sdu(out_pdu);
|
||||||
print_packet_array(out_pdu);
|
|
||||||
|
return std::move(out_pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to generate vector of PDU from a vector of TX_NEXTs for generating expected pdus
|
// Helper function to generate vector of PDU from a vector of TX_NEXTs for generating expected pdus
|
||||||
void gen_expected_pdus_vector(const std::vector<uint32_t>& tx_nexts,
|
std::vector<srslte::unique_byte_buffer_t> gen_expected_pdus_vector(const srslte::unique_byte_buffer_t& in_sdu,
|
||||||
std::vector<srslte::unique_byte_buffer_t>& pdu_vec,
|
const std::vector<uint32_t>& tx_nexts,
|
||||||
srslte::byte_buffer_pool* pool)
|
uint8_t pdcp_sn_len,
|
||||||
|
pdcp_security_cfg sec_cfg,
|
||||||
|
srslte::byte_buffer_pool* pool,
|
||||||
|
srslte::log* log)
|
||||||
{
|
{
|
||||||
|
std::vector<srslte::unique_byte_buffer_t> pdu_vec;
|
||||||
for (uint32_t tx_next : tx_nexts) {
|
for (uint32_t tx_next : tx_nexts) {
|
||||||
srslte::unique_byte_byffer_t pdu = srslte::allocate_byte_buffer(*pool);
|
srslte::unique_byte_buffer_t pdu = gen_expected_pdu(in_sdu, tx_next, pdcp_sn_len, sec_cfg, pool, log);
|
||||||
gen_expected_pdu(tx_next, pdu);
|
pdu_vec.push_back(std::move(pdu));
|
||||||
pdu_vec.push_back(pdu);
|
|
||||||
}
|
}
|
||||||
|
return pdu_vec;
|
||||||
}
|
}
|
||||||
#endif // SRSLTE_PDCP_NR_TEST_H
|
#endif // SRSLTE_PDCP_NR_TEST_H
|
||||||
|
|
Loading…
Reference in New Issue