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,13 +425,22 @@ 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
|
||||||
|
|
|
@ -174,13 +174,20 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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