lib,pdcp_nr: fix rx unit tests

master
Pedro Alvarez 3 years ago
parent 904dbff471
commit 7f98101f30

@ -176,10 +176,16 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
srsran_direction_text[integrity_direction],
srsran_direction_text[encryption_direction]);
if (rx_overflow) {
logger.warning("Rx PDCP COUNTs have overflowed. Discarding SDU.");
return;
}
// Sanity check
if (pdu->N_bytes <= cfg.hdr_len_bytes) {
return;
}
logger.debug("Rx PDCP state - RX_NEXT=%u, RX_DELIV=%u, RX_REORD=%u", rx_next, rx_deliv, rx_reord);
// Extract RCVD_SN from header
uint32_t rcvd_sn = read_data_header(pdu);
@ -195,7 +201,7 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
}
rcvd_count = COUNT(rcvd_hfn, rcvd_sn);
logger.debug("RCVD_HFN=%u, RCVD_SN=%u, RCVD_COUNT=%u", rcvd_hfn, rcvd_sn, rcvd_count);
logger.debug("Estimated RCVD_HFN=%u, RCVD_SN=%u, RCVD_COUNT=%u", rcvd_hfn, rcvd_sn, rcvd_count);
// TS 38.323, section 5.8: Deciphering
// The data unit that is ciphered is the MAC-I and the
@ -265,6 +271,7 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
rx_reord = rx_next;
reordering_timer.run();
}
logger.debug("Rx PDCP state - RX_NEXT=%u, RX_DELIV=%u, RX_REORD=%u", rx_next, rx_deliv, rx_reord);
}
// Notification of delivery/failure

@ -67,8 +67,8 @@ uint8_t pdu1_count262144_snlen18[] = {0x80, 0x00, 0x00, 0xc2, 0x47, 0xc2, 0x
uint8_t pdu1_count4294967295_snlen18[] = {0x83, 0xff, 0xff, 0x1e, 0x47, 0x78, 0xb8, 0x7a, 0x9f};
// Test PDUs for rx (generated from SDU2)
uint8_t pdu2_count1_snlen12[] = {0x80, 0x01, 0x5e, 0x3d, 0x64, 0xaf, 0xac, 0x7c};
uint8_t pdu2_count1_snlen18[] = {0x80, 0x00, 0x01, 0x5e, 0x3d, 0x64, 0xaf, 0xac, 0x7c};
uint8_t pdu2_count1_snlen12[] = {0x80, 0x01, 0x5e, 0x3d, 0x70, 0x6a, 0xa4, 0x90};
uint8_t pdu2_count1_snlen18[] = {0x80, 0x00, 0x01, 0x5e, 0x3d, 0x93, 0xfe, 0xcc, 0x2e};
// This is the normal initial state. All state variables are set to zero
pdcp_initial_state normal_init_state = {};

@ -49,7 +49,7 @@ int test_rx(std::vector<pdcp_test_event_t> events,
}
// Test if the number of RX packets
TESTASSERT(gw_rx->rx_count == n_sdus_exp);
TESTASSERT_EQ(gw_rx->rx_count, n_sdus_exp);
srsran::unique_byte_buffer_t sdu_act = srsran::make_byte_buffer();
gw_rx->get_last_pdu(sdu_act);
TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0);
@ -74,6 +74,8 @@ int test_rx_all(srslog::basic_logger& logger)
* This tests correct handling of HFN in the case of SN wraparound (SN LEN 12)
*/
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX COUNT [4095,4096], 12 bit SN");
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 =
@ -88,6 +90,8 @@ int test_rx_all(srslog::basic_logger& logger)
* Packet that wraparound should be dropped, so only one packet should be received at the GW.
*/
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX COUNT [4294967295,0], 12 bit SN");
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<pdcp_test_event_t> test2_pdus =
@ -102,6 +106,8 @@ int test_rx_all(srslog::basic_logger& logger)
* This tests correct handling of HFN in the case of SN wraparound (SN LEN 18)
*/
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX COUNT [262144,262145], 12 bit SN");
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<pdcp_test_event_t> test3_pdus =
@ -116,6 +122,8 @@ int test_rx_all(srslog::basic_logger& logger)
* This tests correct handling of COUNT in the case of [HFN|SN] wraparound
*/
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX COUNT [4294967295,4294967296], 18 bit SN");
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<pdcp_test_event_t> test4_pdus =
@ -130,6 +138,8 @@ int test_rx_all(srslog::basic_logger& logger)
* Test reception of two out-of-order packets, starting at COUNT 0.
*/
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX out-of-order COUNT [1,0], 12 bit SN");
std::vector<pdcp_test_event_t> test5_pdus;
pdcp_initial_state test5_init_state = {};
@ -154,6 +164,8 @@ int test_rx_all(srslog::basic_logger& logger)
* Test reception of two out-of-order packets, starting at COUNT 0.
*/
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX out-of-order COUNT [1,0], 18 bit SN");
std::vector<pdcp_test_event_t> test6_pdus;
pdcp_initial_state test6_init_state = {};
@ -178,6 +190,8 @@ int test_rx_all(srslog::basic_logger& logger)
* Test Reception of one out-of-order packet.
*/
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("RX out-of-order COUNT [1,0] t_reordering expired, 12 bit SN");
std::vector<pdcp_test_event_t> test7_pdus;
pdcp_initial_state test7_init_state = {};
@ -197,6 +211,7 @@ int test_rx_all(srslog::basic_logger& logger)
* Test reception of two duplicate PDUs, with COUNT 0.
*/
{
srsran::test_delimit_logger delimiter("RX duplicate COUNTs [0,0], 12 bit SN");
std::vector<pdcp_test_event_t> test8_pdus;
pdcp_initial_state test8_init_state = {};

Loading…
Cancel
Save