mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
3.4 KiB
C++
116 lines
3.4 KiB
C++
4 years ago
|
/**
|
||
5 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
5 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
5 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
5 years ago
|
*
|
||
|
*/
|
||
|
#include "pdcp_nr_test.h"
|
||
|
#include <numeric>
|
||
|
|
||
|
/*
|
||
|
* Genric function to test transmission of in-sequence packets
|
||
|
*/
|
||
|
int test_tx_sdu_discard(const pdcp_initial_state& init_state,
|
||
4 years ago
|
srsran::pdcp_discard_timer_t discard_timeout,
|
||
5 years ago
|
bool imediate_notify,
|
||
4 years ago
|
srslog::basic_logger& logger)
|
||
5 years ago
|
{
|
||
4 years ago
|
srsran::pdcp_config_t cfg = {1,
|
||
|
srsran::PDCP_RB_IS_DRB,
|
||
|
srsran::SECURITY_DIRECTION_UPLINK,
|
||
|
srsran::SECURITY_DIRECTION_DOWNLINK,
|
||
|
srsran::PDCP_SN_LEN_12,
|
||
|
srsran::pdcp_t_reordering_t::ms500,
|
||
4 years ago
|
discard_timeout,
|
||
4 years ago
|
false,
|
||
|
srsran::srsran_rat_t::nr};
|
||
5 years ago
|
|
||
4 years ago
|
pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger);
|
||
4 years ago
|
srsran::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp;
|
||
4 years ago
|
rlc_dummy* rlc = &pdcp_hlp.rlc;
|
||
|
srsue::stack_test_dummy* stack = &pdcp_hlp.stack;
|
||
5 years ago
|
|
||
|
pdcp_hlp.set_pdcp_initial_state(init_state);
|
||
|
|
||
|
// Test SDU
|
||
4 years ago
|
srsran::unique_byte_buffer_t sdu = srsran::make_byte_buffer();
|
||
5 years ago
|
sdu->append_bytes(sdu1, sizeof(sdu1));
|
||
4 years ago
|
pdcp->write_sdu(std::move(sdu));
|
||
5 years ago
|
|
||
|
for (uint32_t i = 0; i < static_cast<uint32_t>(cfg.discard_timer) - 1; ++i) {
|
||
4 years ago
|
stack->run_tti();
|
||
5 years ago
|
}
|
||
|
TESTASSERT(rlc->discard_count == 0);
|
||
5 years ago
|
|
||
|
// Check if timers were started
|
||
|
if (imediate_notify) {
|
||
|
TESTASSERT(pdcp->nof_discard_timers() == 0); // RLC notified PDCP already, timer should have been disarmed
|
||
|
} else {
|
||
|
TESTASSERT(pdcp->nof_discard_timers() == 1); // One timer should be running
|
||
|
}
|
||
|
|
||
|
// Last timer step
|
||
4 years ago
|
stack->run_tti();
|
||
5 years ago
|
|
||
|
// Check if RLC was notified of SDU discard
|
||
5 years ago
|
if (imediate_notify) {
|
||
|
TESTASSERT(rlc->discard_count == 0); // RLC imediatly notified the PDCP of tx, there should be no timeouts
|
||
|
} else {
|
||
|
TESTASSERT(rlc->discard_count == 1); // RLC does not notify the the PDCP of tx, there should be a timeout
|
||
|
}
|
||
5 years ago
|
|
||
|
// Make sure there are no timers still left on the map
|
||
|
TESTASSERT(pdcp->nof_discard_timers() == 0);
|
||
|
|
||
5 years ago
|
return 0;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* TX Test: PDCP Entity with SN LEN = 12 and 18.
|
||
|
* PDCP entity configured with EIA2 and EEA2
|
||
|
*/
|
||
4 years ago
|
int test_tx_discard_all(srslog::basic_logger& logger)
|
||
5 years ago
|
{
|
||
|
/*
|
||
|
* TX Test 1: PDCP Entity with SN LEN = 12
|
||
|
* Test TX PDU discard.
|
||
|
*/
|
||
4 years ago
|
TESTASSERT(test_tx_sdu_discard(normal_init_state, srsran::pdcp_discard_timer_t::ms50, false, logger) == 0);
|
||
5 years ago
|
|
||
|
/*
|
||
|
* TX Test 2: PDCP Entity with SN LEN = 12
|
||
|
* Test TX PDU discard.
|
||
|
*/
|
||
4 years ago
|
// TESTASSERT(test_tx_sdu_discard(normal_init_state, srsran::pdcp_discard_timer_t::ms50, true, logger) == 0);
|
||
5 years ago
|
return 0;
|
||
|
}
|
||
|
|
||
|
// Setup all tests
|
||
4 years ago
|
int run_all_tests()
|
||
5 years ago
|
{
|
||
|
// Setup log
|
||
4 years ago
|
auto& logger = srslog::fetch_basic_logger("PDCP NR Test", false);
|
||
|
logger.set_level(srslog::basic_levels::debug);
|
||
|
logger.set_hex_dump_max_size(128);
|
||
5 years ago
|
|
||
4 years ago
|
TESTASSERT(test_tx_discard_all(logger) == 0);
|
||
5 years ago
|
return 0;
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
4 years ago
|
srslog::init();
|
||
|
|
||
4 years ago
|
if (run_all_tests() != SRSRAN_SUCCESS) {
|
||
5 years ago
|
fprintf(stderr, "pdcp_nr_tests() failed\n");
|
||
4 years ago
|
return SRSRAN_ERROR;
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|