Separating PDCP read_header function from discard_header_function. Starting to add DRB unit test.

master
Pedro Alvarez 5 years ago committed by Andre Puschmann
parent dbb5c6c06c
commit d98b888ca4

@ -124,6 +124,7 @@ protected:
// Common packing functions
uint32_t read_data_header(const unique_byte_buffer_t& pdu);
void discard_data_header(const unique_byte_buffer_t& pdu);
void write_data_header(const srslte::unique_byte_buffer_t& sdu, uint32_t count);
void extract_mac(const unique_byte_buffer_t& pdu, uint8_t* mac);
void append_mac(const unique_byte_buffer_t& sdu, uint8_t* mac);

@ -255,10 +255,13 @@ uint32_t pdcp_entity_base::read_data_header(const unique_byte_buffer_t& pdu)
log->error("Cannot extract RCVD_SN, invalid SN length configured: %d\n", cfg.sn_len);
}
// Discard header
return rcvd_sn_32;
}
void pdcp_entity_base::discard_data_header(const unique_byte_buffer_t& pdu)
{
pdu->msg += cfg.hdr_len_bytes;
pdu->N_bytes -= cfg.hdr_len_bytes;
return rcvd_sn_32;
}
void pdcp_entity_base::write_data_header(const srslte::unique_byte_buffer_t& sdu, uint32_t count)

@ -172,7 +172,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu)
log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU", rrc->get_rb_name(lcid).c_str());
// Read recvd SN from header
uint32_t sn = SN(pdu->msg[0]);
uint32_t sn = read_data_header(pdu);
log->debug("RX SRB PDU. Next_PDCP_RX_SN %d, SN %d", next_pdcp_rx_sn, sn);
@ -186,7 +186,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu)
// Perform decription
if (do_encryption) {
cipher_decrypt(&pdu->msg[1], pdu->N_bytes - 1, count, pdu->msg);
cipher_decrypt(&pdu->msg[cfg.hdr_len_bytes], pdu->N_bytes - cfg.hdr_len_bytes, count, &pdu->msg[cfg.hdr_len_bytes]);
log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU (decrypted)", rrc->get_rb_name(lcid).c_str());
}
@ -203,7 +203,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu)
}
// Discard header
pdu->msg++;
discard_data_header(pdu);
// Update state variables
if (sn < next_pdcp_rx_sn) {
@ -226,6 +226,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu)
void pdcp_entity_lte::handle_um_drb_pdu(srslte::unique_byte_buffer_t pdu)
{
uint32_t sn = read_data_header(pdu);
discard_data_header(pdu);
if (sn < next_pdcp_rx_sn) {
rx_hfn++;
@ -253,6 +254,7 @@ void pdcp_entity_lte::handle_um_drb_pdu(srslte::unique_byte_buffer_t pdu)
void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu)
{
uint32_t sn = read_data_header(pdu);
discard_data_header(pdu);
int32_t last_submit_diff_sn = last_submitted_pdcp_rx_sn - sn;
int32_t sn_diff_last_submit = sn - last_submitted_pdcp_rx_sn;

@ -114,6 +114,28 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
log) == 0);
}
/*
* RX Test 1: PDCP LTE Entity with SN LEN = 12
* Test in-sequence reception of 4096 packets.
* This tests correct handling of HFN in the case of SN wraparound (SN LEN 12)
*/
{
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<pdcp_test_event_t> test1_pdus = gen_expected_pdus_vector(
tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_SRB, sec_cfg, pool, log);
pdcp_lte_initial_state test1_init_state = {
.tx_count = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 4095, .last_submitted_pdcp_rx_sn = 4094};
TESTASSERT(test_rx(std::move(test1_pdus),
test1_init_state,
srslte::PDCP_SN_LEN_12,
srslte::PDCP_RB_IS_DRB,
2,
tst_sdu1,
pool,
log) == 0);
}
return 0;
}

Loading…
Cancel
Save