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.
575 lines
26 KiB
C++
575 lines
26 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
|
*
|
||
|
*/
|
||
|
|
||
5 years ago
|
#include "srsenb/hdr/enb.h"
|
||
5 years ago
|
#include "srsenb/hdr/stack/rrc/rrc_mobility.h"
|
||
5 years ago
|
#include "srsenb/test/common/dummy_classes.h"
|
||
4 years ago
|
#include "srsran/asn1/rrc_utils.h"
|
||
|
#include "srsran/common/test_common.h"
|
||
5 years ago
|
#include "test_helpers.h"
|
||
5 years ago
|
#include <iostream>
|
||
|
|
||
4 years ago
|
using namespace asn1::rrc;
|
||
|
|
||
4 years ago
|
enum class test_event {
|
||
|
success,
|
||
|
wrong_measreport,
|
||
|
concurrent_ho,
|
||
|
ho_prep_failure,
|
||
|
duplicate_crnti_ce,
|
||
|
recover,
|
||
|
wrong_target_cell,
|
||
|
unknown_qci,
|
||
5 years ago
|
};
|
||
|
|
||
4 years ago
|
const char* to_string(test_event event)
|
||
|
{
|
||
|
switch (event) {
|
||
|
case test_event::success:
|
||
|
return "success";
|
||
|
case test_event::wrong_measreport:
|
||
|
return "wrong measreport";
|
||
|
case test_event::concurrent_ho:
|
||
|
return "measreport while in handover";
|
||
|
case test_event::ho_prep_failure:
|
||
|
return "ho preparation failure";
|
||
|
case test_event::recover:
|
||
|
return "fail and success";
|
||
|
case test_event::duplicate_crnti_ce:
|
||
|
return "duplicate CRNTI CE";
|
||
|
case test_event::wrong_target_cell:
|
||
|
return "wrong target cell";
|
||
|
case test_event::unknown_qci:
|
||
|
return "invalid QoS";
|
||
|
default:
|
||
|
return "none";
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
struct mobility_tester {
|
||
4 years ago
|
explicit mobility_tester(const test_event& args_) :
|
||
4 years ago
|
args(args_), logger(srslog::fetch_basic_logger("RRC")), rrc(&task_sched)
|
||
5 years ago
|
{
|
||
4 years ago
|
logger.set_level(srslog::basic_levels::info);
|
||
|
logger.set_hex_dump_max_size(1024);
|
||
5 years ago
|
}
|
||
|
virtual int generate_rrc_cfg() = 0;
|
||
|
virtual int setup_rrc() { return setup_rrc_common(); }
|
||
|
int run_preamble()
|
||
|
{
|
||
4 years ago
|
// mute all the startup log
|
||
|
logger.set_level(srslog::basic_levels::none);
|
||
|
|
||
4 years ago
|
// add user
|
||
|
sched_interface::ue_cfg_t ue_cfg{};
|
||
|
ue_cfg.supported_cc_list.resize(1);
|
||
|
ue_cfg.supported_cc_list[0].enb_cc_idx = 0;
|
||
|
ue_cfg.supported_cc_list[0].active = true;
|
||
|
rrc.add_user(rnti, ue_cfg);
|
||
|
|
||
5 years ago
|
// Do all the handshaking until the first RRC Connection Reconf
|
||
4 years ago
|
test_helpers::bring_rrc_to_reconf_state(rrc, *task_sched.get_timer_handler(), rnti);
|
||
4 years ago
|
logger.set_level(srslog::basic_levels::info);
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
test_event args;
|
||
4 years ago
|
srslog::basic_logger& logger;
|
||
4 years ago
|
srsran::task_scheduler task_sched;
|
||
4 years ago
|
rrc_cfg_t cfg;
|
||
5 years ago
|
|
||
|
srsenb::rrc rrc;
|
||
5 years ago
|
test_dummies::mac_mobility_dummy mac;
|
||
|
test_dummies::rlc_mobility_dummy rlc;
|
||
5 years ago
|
test_dummies::pdcp_mobility_dummy pdcp;
|
||
4 years ago
|
test_dummies::phy_mobility_dummy phy;
|
||
5 years ago
|
test_dummies::s1ap_mobility_dummy s1ap;
|
||
|
gtpu_dummy gtpu;
|
||
|
|
||
5 years ago
|
void tic()
|
||
|
{
|
||
4 years ago
|
task_sched.tic();
|
||
5 years ago
|
rrc.tti_clock();
|
||
4 years ago
|
task_sched.run_pending_tasks();
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
const uint16_t rnti = 0x46;
|
||
|
|
||
|
protected:
|
||
|
int generate_rrc_cfg_common()
|
||
|
{
|
||
|
srsenb::all_args_t all_args;
|
||
4 years ago
|
TESTASSERT(test_helpers::parse_default_cfg(&cfg, all_args) == SRSRAN_SUCCESS);
|
||
5 years ago
|
cfg.meas_cfg_present = true;
|
||
|
report_cfg_eutra_s rep = generate_rep1();
|
||
|
cfg.cell_list[0].meas_cfg.meas_reports.push_back(rep);
|
||
|
cfg.cell_list[0].meas_cfg.meas_cells.resize(1);
|
||
|
cfg.cell_list[0].meas_cfg.meas_cells[0] = generate_cell1();
|
||
|
cfg.cell_list[0].meas_cfg.meas_cells[0].pci = 2;
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
int setup_rrc_common()
|
||
|
{
|
||
4 years ago
|
rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, >pu);
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
};
|
||
|
|
||
|
struct s1ap_mobility_tester : public mobility_tester {
|
||
4 years ago
|
explicit s1ap_mobility_tester(const test_event& args_) : mobility_tester(args_) {}
|
||
5 years ago
|
int generate_rrc_cfg() final
|
||
|
{
|
||
4 years ago
|
TESTASSERT(generate_rrc_cfg_common() == SRSRAN_SUCCESS);
|
||
4 years ago
|
cfg.cell_list[0].meas_cfg.meas_cells[0].eci = 0x19C02;
|
||
|
cfg.cell_list[0].meas_cfg.meas_cells[0].earfcn = 2850;
|
||
|
cfg.cell_list[0].meas_cfg.meas_gap_period = 40;
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
};
|
||
|
|
||
|
struct intraenb_mobility_tester : public mobility_tester {
|
||
4 years ago
|
explicit intraenb_mobility_tester(const test_event& args_) : mobility_tester(args_) {}
|
||
5 years ago
|
int generate_rrc_cfg() final
|
||
|
{
|
||
4 years ago
|
TESTASSERT(generate_rrc_cfg_common() == SRSRAN_SUCCESS);
|
||
4 years ago
|
cfg.cell_list[0].meas_cfg.meas_cells[0].eci = 0x19B02;
|
||
|
cfg.cell_list[0].meas_cfg.meas_gap_period = 40;
|
||
|
cfg.cell_list[0].meas_cfg.meas_cells[0].earfcn = 2850;
|
||
|
|
||
|
cell_cfg_t cell2 = cfg.cell_list[0];
|
||
|
cell2.pci = 2;
|
||
|
cell2.cell_id = 2;
|
||
|
cell2.dl_earfcn = 2850;
|
||
|
cell2.meas_cfg.meas_cells[0].pci = 1;
|
||
|
cell2.meas_cfg.meas_cells[0].earfcn = 3400;
|
||
|
cell2.meas_cfg.meas_cells[0].eci = 0x19B01;
|
||
|
cell2.meas_cfg.meas_gap_period = 80;
|
||
5 years ago
|
cfg.cell_list.push_back(cell2);
|
||
5 years ago
|
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
};
|
||
5 years ago
|
|
||
4 years ago
|
int test_s1ap_mobility(srsran::log_sink_spy& spy, test_event test_params)
|
||
5 years ago
|
{
|
||
4 years ago
|
printf("\n===== TEST: test_s1ap_mobility() for event %s =====\n", to_string(test_params));
|
||
4 years ago
|
s1ap_mobility_tester tester{test_params};
|
||
|
spy.reset_counters();
|
||
4 years ago
|
srsran::unique_byte_buffer_t pdu;
|
||
5 years ago
|
|
||
4 years ago
|
TESTASSERT(tester.generate_rrc_cfg() == SRSRAN_SUCCESS);
|
||
|
TESTASSERT(tester.setup_rrc() == SRSRAN_SUCCESS);
|
||
|
TESTASSERT(tester.run_preamble() == SRSRAN_SUCCESS);
|
||
5 years ago
|
test_dummies::s1ap_mobility_dummy& s1ap = tester.s1ap;
|
||
5 years ago
|
|
||
4 years ago
|
/* Receive correct measConfig */
|
||
|
dl_dcch_msg_s dl_dcch_msg;
|
||
4 years ago
|
TESTASSERT(test_helpers::unpack_asn1(dl_dcch_msg, srsran::make_span(tester.pdcp.last_sdu.sdu)));
|
||
4 years ago
|
rrc_conn_recfg_r8_ies_s& recfg_r8 = dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8();
|
||
|
TESTASSERT(recfg_r8.meas_cfg_present and recfg_r8.meas_cfg.meas_gap_cfg_present);
|
||
|
TESTASSERT(recfg_r8.meas_cfg.meas_gap_cfg.type().value == setup_opts::setup);
|
||
|
TESTASSERT((1 + recfg_r8.meas_cfg.meas_gap_cfg.setup().gap_offset.type().value) * 40u ==
|
||
|
tester.cfg.cell_list[0].meas_cfg.meas_gap_period);
|
||
|
|
||
5 years ago
|
/* Receive MeasReport from UE (correct if PCI=2) */
|
||
4 years ago
|
if (test_params == test_event::wrong_measreport) {
|
||
5 years ago
|
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x0D, 0xBC, 0x80}; // PCI == 3
|
||
4 years ago
|
test_helpers::copy_msg_to_buffer(pdu, meas_report);
|
||
5 years ago
|
} else {
|
||
|
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x09, 0xBC, 0x80}; // PCI == 2
|
||
4 years ago
|
test_helpers::copy_msg_to_buffer(pdu, meas_report);
|
||
5 years ago
|
}
|
||
5 years ago
|
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
|
||
|
tester.tic();
|
||
5 years ago
|
|
||
5 years ago
|
/* Test Case: the MeasReport is not valid */
|
||
4 years ago
|
if (test_params == test_event::wrong_measreport) {
|
||
5 years ago
|
TESTASSERT(s1ap.last_ho_required.rrc_container == nullptr);
|
||
4 years ago
|
TESTASSERT(spy.get_warning_counter() == 1);
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
5 years ago
|
TESTASSERT(s1ap.last_ho_required.rrc_container != nullptr);
|
||
5 years ago
|
|
||
5 years ago
|
/* Test Case: Multiple concurrent MeasReports arrived. Only one HO procedure should be running */
|
||
4 years ago
|
if (test_params == test_event::concurrent_ho) {
|
||
5 years ago
|
s1ap.last_ho_required = {};
|
||
|
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x09, 0xBC, 0x80}; // PCI == 2
|
||
4 years ago
|
test_helpers::copy_msg_to_buffer(pdu, meas_report);
|
||
5 years ago
|
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
|
||
|
tester.tic();
|
||
5 years ago
|
TESTASSERT(s1ap.last_ho_required.rrc_container == nullptr);
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
/* Test Case: Check HO Required was sent to S1AP */
|
||
5 years ago
|
TESTASSERT(s1ap.last_ho_required.rnti == tester.rnti);
|
||
|
TESTASSERT(s1ap.last_ho_required.target_eci == tester.cfg.cell_list[0].meas_cfg.meas_cells[0].eci);
|
||
5 years ago
|
TESTASSERT(s1ap.last_ho_required.target_plmn.to_string() == "00101");
|
||
|
{
|
||
5 years ago
|
asn1::cbit_ref bref(s1ap.last_ho_required.rrc_container->msg, s1ap.last_ho_required.rrc_container->N_bytes);
|
||
5 years ago
|
asn1::rrc::ho_prep_info_s hoprep;
|
||
|
TESTASSERT(hoprep.unpack(bref) == asn1::SRSASN_SUCCESS);
|
||
|
ho_prep_info_r8_ies_s& hoprepr8 = hoprep.crit_exts.c1().ho_prep_info_r8();
|
||
|
TESTASSERT(hoprepr8.as_cfg_present);
|
||
|
// Check if RRC sends the current active bearers
|
||
4 years ago
|
TESTASSERT(hoprepr8.as_cfg.source_rr_cfg.srb_to_add_mod_list_present);
|
||
|
TESTASSERT(hoprepr8.as_cfg.source_rr_cfg.srb_to_add_mod_list[0].srb_id == 1);
|
||
|
TESTASSERT(hoprepr8.as_cfg.source_rr_cfg.srb_to_add_mod_list[1].srb_id == 2);
|
||
5 years ago
|
TESTASSERT(hoprepr8.as_cfg.source_rr_cfg.drb_to_add_mod_list_present);
|
||
|
TESTASSERT(hoprepr8.as_cfg.source_rr_cfg.drb_to_add_mod_list[0].drb_id == 1);
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
/* Test Case: HandoverPreparation has failed */
|
||
4 years ago
|
if (test_params == test_event::ho_prep_failure) {
|
||
4 years ago
|
tester.rrc.ho_preparation_complete(tester.rnti, rrc::ho_prep_result::failure, {}, nullptr);
|
||
4 years ago
|
// TESTASSERT(spy.get_error_counter() == 1);
|
||
5 years ago
|
TESTASSERT(not s1ap.last_enb_status.status_present);
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
|
||
|
/* MME returns back an HandoverCommand, S1AP unwraps the RRC container */
|
||
|
uint8_t ho_cmd_rrc_container[] = {0x01, 0xa9, 0x00, 0xd9, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x22, 0x04, 0x00, 0x00,
|
||
|
0x01, 0x48, 0x04, 0xbc, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0xa0, 0x07, 0xa0,
|
||
|
0x10, 0x00, 0x01, 0x00, 0x05, 0x00, 0xa7, 0xd0, 0xc1, 0xf6, 0xaf, 0x3e, 0x12, 0xcc,
|
||
|
0x86, 0x0d, 0x30, 0x00, 0x0b, 0x5a, 0x02, 0x17, 0x86, 0x00, 0x05, 0xa0, 0x20};
|
||
4 years ago
|
test_helpers::copy_msg_to_buffer(pdu, ho_cmd_rrc_container);
|
||
5 years ago
|
TESTASSERT(s1ap.last_enb_status.rnti != tester.rnti);
|
||
4 years ago
|
tester.rrc.ho_preparation_complete(tester.rnti, rrc::ho_prep_result::success, asn1::s1ap::ho_cmd_s{}, std::move(pdu));
|
||
5 years ago
|
TESTASSERT(s1ap.last_enb_status.status_present);
|
||
4 years ago
|
TESTASSERT(spy.get_error_counter() == 0);
|
||
5 years ago
|
asn1::rrc::dl_dcch_msg_s ho_cmd;
|
||
4 years ago
|
TESTASSERT(test_helpers::unpack_asn1(ho_cmd, srsran::make_span(tester.pdcp.last_sdu.sdu)));
|
||
4 years ago
|
recfg_r8 = ho_cmd.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8();
|
||
5 years ago
|
TESTASSERT(recfg_r8.mob_ctrl_info_present);
|
||
|
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
int test_s1ap_tenb_mobility(test_event test_params)
|
||
4 years ago
|
{
|
||
4 years ago
|
printf("\n===== TEST: test_s1ap_tenb_mobility() for event %s =====\n", to_string(test_params));
|
||
4 years ago
|
s1ap_mobility_tester tester{test_params};
|
||
4 years ago
|
srsran::unique_byte_buffer_t pdu;
|
||
4 years ago
|
|
||
4 years ago
|
TESTASSERT(tester.generate_rrc_cfg() == SRSRAN_SUCCESS);
|
||
4 years ago
|
tester.cfg.cell_list[0].meas_cfg.meas_cells[0].eci = 0x19B01;
|
||
|
tester.cfg.enb_id = 0x19C;
|
||
|
tester.cfg.cell.id = 0x02;
|
||
|
tester.cfg.cell_list[0].cell_id = 0x02;
|
||
|
tester.cfg.cell_list[0].pci = 2;
|
||
4 years ago
|
TESTASSERT(tester.setup_rrc() == SRSRAN_SUCCESS);
|
||
4 years ago
|
security_cfg_handler sec_cfg{tester.cfg};
|
||
4 years ago
|
|
||
4 years ago
|
/* TeNB receives S1AP Handover Request */
|
||
4 years ago
|
asn1::s1ap::ho_request_s ho_req;
|
||
|
ho_req.protocol_ies.erab_to_be_setup_list_ho_req.value.resize(1);
|
||
|
auto& erab = ho_req.protocol_ies.erab_to_be_setup_list_ho_req.value[0].value.erab_to_be_setup_item_ho_req();
|
||
|
erab.erab_id = 5;
|
||
|
erab.erab_level_qos_params.qci = 9;
|
||
4 years ago
|
if (test_params == test_event::unknown_qci) {
|
||
4 years ago
|
erab.erab_level_qos_params.qci = 10;
|
||
|
}
|
||
4 years ago
|
ho_req.protocol_ies.ue_security_cap.value.integrity_protection_algorithms.set(14, true);
|
||
4 years ago
|
asn1::s1ap::sourceenb_to_targetenb_transparent_container_s container;
|
||
4 years ago
|
container.target_cell_id.cell_id.from_number(0x19C02);
|
||
4 years ago
|
if (test_params == test_event::wrong_target_cell) {
|
||
4 years ago
|
container.target_cell_id.cell_id.from_number(0x19C03);
|
||
|
}
|
||
4 years ago
|
container.erab_info_list_present = true;
|
||
|
container.erab_info_list.resize(1);
|
||
|
container.erab_info_list[0].load_info_obj(ASN1_S1AP_ID_ERAB_INFO_LIST_ITEM);
|
||
|
container.erab_info_list[0].value.erab_info_list_item().erab_id = 5;
|
||
|
container.erab_info_list[0].value.erab_info_list_item().dl_forwarding_present = true;
|
||
|
container.erab_info_list[0].value.erab_info_list_item().dl_forwarding.value =
|
||
|
asn1::s1ap::dl_forwarding_opts::dl_forwarding_proposed;
|
||
4 years ago
|
uint8_t ho_prep_container[] = {
|
||
|
0x0a, 0x10, 0x0b, 0x81, 0x80, 0x00, 0x01, 0x80, 0x00, 0xf3, 0x02, 0x08, 0x00, 0x00, 0x15, 0x80, 0x00, 0x14,
|
||
|
0x06, 0xa4, 0x02, 0xf0, 0x04, 0x04, 0xf0, 0x00, 0x14, 0x80, 0x4a, 0x00, 0x00, 0x00, 0x02, 0x12, 0x31, 0xb6,
|
||
|
0xf8, 0x3e, 0xa0, 0x6f, 0x05, 0xe4, 0x65, 0x14, 0x1d, 0x39, 0xd0, 0x54, 0x4c, 0x00, 0x02, 0x54, 0x00, 0x20,
|
||
|
0x04, 0x60, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x04, 0x14,
|
||
|
0x00, 0x67, 0x0d, 0xfb, 0xc4, 0x66, 0x06, 0x50, 0x0f, 0x00, 0x08, 0x00, 0x20, 0x80, 0x0c, 0x14, 0xca, 0x2d,
|
||
|
0x5c, 0xe1, 0x86, 0x35, 0x39, 0x80, 0x0e, 0x06, 0xa4, 0x40, 0x0f, 0x22, 0x78};
|
||
|
// 0a100b818000018000f3020800001580001406a402f00404f00014804a000000021231b6f83ea06f05e465141d39d0544c00025400200460000000100100c000000000020500041400670dfbc46606500f00080020800c14ca2d5ce1863539800e06a4400f2278
|
||
|
container.rrc_container.resize(sizeof(ho_prep_container));
|
||
|
memcpy(container.rrc_container.data(), ho_prep_container, sizeof(ho_prep_container));
|
||
4 years ago
|
asn1::s1ap::cause_c cause;
|
||
|
int rnti = tester.rrc.start_ho_ue_resource_alloc(ho_req, container, cause);
|
||
4 years ago
|
if (test_params == test_event::wrong_target_cell) {
|
||
4 years ago
|
TESTASSERT(rnti == SRSRAN_INVALID_RNTI);
|
||
4 years ago
|
TESTASSERT(cause.type().value == asn1::s1ap::cause_c::types_opts::radio_network);
|
||
|
TESTASSERT(cause.radio_network().value == asn1::s1ap::cause_radio_network_opts::ho_target_not_allowed);
|
||
|
TESTASSERT(tester.rrc.get_nof_users() == 0);
|
||
|
return SRSRAN_SUCCESS;
|
||
|
}
|
||
4 years ago
|
if (test_params == test_event::unknown_qci) {
|
||
4 years ago
|
TESTASSERT(rnti == SRSRAN_INVALID_RNTI);
|
||
|
TESTASSERT(cause.type().value == asn1::s1ap::cause_c::types_opts::radio_network);
|
||
4 years ago
|
TESTASSERT(cause.radio_network().value == asn1::s1ap::cause_radio_network_opts::not_supported_qci_value);
|
||
4 years ago
|
TESTASSERT(tester.rrc.get_nof_users() == 0);
|
||
|
return SRSRAN_SUCCESS;
|
||
|
}
|
||
4 years ago
|
tester.tic();
|
||
|
TESTASSERT(tester.rrc.get_nof_users() == 1);
|
||
|
TESTASSERT(tester.mac.ue_db.count(0x46));
|
||
|
auto& mac_ue = tester.mac.ue_db[0x46];
|
||
|
TESTASSERT(mac_ue.supported_cc_list[0].active);
|
||
|
TESTASSERT(mac_ue.supported_cc_list[0].enb_cc_idx == 0);
|
||
4 years ago
|
TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction == sched_interface::ue_bearer_cfg_t::BOTH);
|
||
4 years ago
|
// Check Security Configuration
|
||
|
TESTASSERT(tester.pdcp.bearers.count(0x46));
|
||
4 years ago
|
TESTASSERT(tester.pdcp.bearers[0x46].count(srb_to_lcid(lte_srb::srb1)) and
|
||
|
tester.pdcp.bearers[0x46].count(srb_to_lcid(lte_srb::srb2)));
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].enable_encryption);
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].enable_integrity);
|
||
4 years ago
|
sec_cfg.set_security_capabilities(ho_req.protocol_ies.ue_security_cap.value);
|
||
|
sec_cfg.set_security_key(ho_req.protocol_ies.security_context.value.next_hop_param);
|
||
|
sec_cfg.regenerate_keys_handover(tester.cfg.cell_list[0].pci, tester.cfg.cell_list[0].dl_earfcn);
|
||
4 years ago
|
srsran::as_security_config_t as_sec_cfg = sec_cfg.get_as_sec_cfg();
|
||
4 years ago
|
TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.k_rrc_int == as_sec_cfg.k_rrc_int);
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.k_rrc_enc == as_sec_cfg.k_rrc_enc);
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.k_up_int == as_sec_cfg.k_up_int);
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.cipher_algo == as_sec_cfg.cipher_algo);
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.integ_algo == as_sec_cfg.integ_algo);
|
||
4 years ago
|
|
||
4 years ago
|
// Check if S1AP Handover Request ACK send is called
|
||
|
TESTASSERT(tester.s1ap.last_ho_req_ack.rnti == 0x46);
|
||
|
TESTASSERT(tester.s1ap.last_ho_req_ack.ho_cmd_pdu != nullptr);
|
||
|
TESTASSERT(tester.s1ap.last_ho_req_ack.admitted_bearers.size() ==
|
||
|
ho_req.protocol_ies.erab_to_be_setup_list_ho_req.value.size());
|
||
4 years ago
|
ho_cmd_s ho_cmd;
|
||
4 years ago
|
asn1::cbit_ref bref{tester.s1ap.last_ho_req_ack.ho_cmd_pdu->msg, tester.s1ap.last_ho_req_ack.ho_cmd_pdu->N_bytes};
|
||
4 years ago
|
TESTASSERT(ho_cmd.unpack(bref) == asn1::SRSASN_SUCCESS);
|
||
|
bref = asn1::cbit_ref{ho_cmd.crit_exts.c1().ho_cmd_r8().ho_cmd_msg.data(),
|
||
|
ho_cmd.crit_exts.c1().ho_cmd_r8().ho_cmd_msg.size()};
|
||
|
dl_dcch_msg_s dl_dcch_msg;
|
||
|
TESTASSERT(dl_dcch_msg.unpack(bref) == asn1::SRSASN_SUCCESS);
|
||
4 years ago
|
TESTASSERT(dl_dcch_msg.msg.type().value == dl_dcch_msg_type_c::types_opts::c1);
|
||
|
TESTASSERT(dl_dcch_msg.msg.c1().type().value == dl_dcch_msg_type_c::c1_c_::types_opts::rrc_conn_recfg);
|
||
4 years ago
|
auto& recfg_r8 = dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8();
|
||
|
|
||
4 years ago
|
// Receives MMEStatusTransfer
|
||
|
asn1::s1ap::bearers_subject_to_status_transfer_list_l bearers;
|
||
|
bearers.resize(1);
|
||
|
bearers[0].value.bearers_subject_to_status_transfer_item().erab_id = 5;
|
||
|
bearers[0].value.bearers_subject_to_status_transfer_item().dl_coun_tvalue.pdcp_sn = 100;
|
||
|
bearers[0].value.bearers_subject_to_status_transfer_item().dl_coun_tvalue.hfn = 3;
|
||
|
bearers[0].value.bearers_subject_to_status_transfer_item().ul_coun_tvalue.pdcp_sn = 120;
|
||
|
bearers[0].value.bearers_subject_to_status_transfer_item().ul_coun_tvalue.hfn = 4;
|
||
|
tester.rrc.set_erab_status(0x46, bearers);
|
||
4 years ago
|
TESTASSERT(tester.pdcp.bearers.count(0x46));
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46].count(3));
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][3].state.next_pdcp_tx_sn == 100);
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][3].state.tx_hfn == 3);
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][3].state.next_pdcp_rx_sn == 120);
|
||
|
TESTASSERT(tester.pdcp.bearers[0x46][3].state.rx_hfn == 4);
|
||
4 years ago
|
|
||
4 years ago
|
// user PRACHs and sends C-RNTI CE
|
||
|
sched_interface::ue_cfg_t ue_cfg{};
|
||
|
ue_cfg.supported_cc_list.resize(1);
|
||
|
ue_cfg.supported_cc_list[0].enb_cc_idx = 0;
|
||
|
ue_cfg.supported_cc_list[0].active = true;
|
||
|
tester.rrc.add_user(0x47, ue_cfg);
|
||
|
tester.rrc.upd_user(0x47, 0x46);
|
||
|
|
||
|
uint8_t recfg_complete[] = {0x10, 0x00};
|
||
|
test_helpers::copy_msg_to_buffer(pdu, recfg_complete);
|
||
4 years ago
|
tester.rrc.write_pdu(0x46, srb_to_lcid(lte_srb::srb1), std::move(pdu));
|
||
4 years ago
|
tester.tic();
|
||
4 years ago
|
TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction == sched_interface::ue_bearer_cfg_t::BOTH);
|
||
|
TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction == sched_interface::ue_bearer_cfg_t::BOTH);
|
||
|
TESTASSERT(mac_ue.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction == sched_interface::ue_bearer_cfg_t::BOTH);
|
||
4 years ago
|
TESTASSERT(mac_ue.pucch_cfg.I_sr == recfg_r8.rr_cfg_ded.phys_cfg_ded.sched_request_cfg.setup().sr_cfg_idx);
|
||
|
TESTASSERT(mac_ue.pucch_cfg.n_pucch_sr ==
|
||
|
recfg_r8.rr_cfg_ded.phys_cfg_ded.sched_request_cfg.setup().sr_pucch_res_idx);
|
||
|
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
int test_intraenb_mobility(srsran::log_sink_spy& spy, test_event test_params)
|
||
5 years ago
|
{
|
||
4 years ago
|
printf("\n===== TEST: test_intraenb_mobility() for event %s =====\n", to_string(test_params));
|
||
4 years ago
|
intraenb_mobility_tester tester{test_params};
|
||
|
spy.reset_counters();
|
||
4 years ago
|
srsran::unique_byte_buffer_t pdu;
|
||
5 years ago
|
|
||
4 years ago
|
TESTASSERT(tester.generate_rrc_cfg() == SRSRAN_SUCCESS);
|
||
|
TESTASSERT(tester.setup_rrc() == SRSRAN_SUCCESS);
|
||
|
TESTASSERT(tester.run_preamble() == SRSRAN_SUCCESS);
|
||
4 years ago
|
|
||
|
/* Receive correct measConfig */
|
||
|
dl_dcch_msg_s dl_dcch_msg;
|
||
4 years ago
|
TESTASSERT(test_helpers::unpack_asn1(dl_dcch_msg, srsran::make_span(tester.pdcp.last_sdu.sdu)));
|
||
4 years ago
|
rrc_conn_recfg_r8_ies_s& recfg_r8 = dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8();
|
||
|
TESTASSERT(recfg_r8.meas_cfg_present and recfg_r8.meas_cfg.meas_gap_cfg_present);
|
||
|
TESTASSERT(recfg_r8.meas_cfg.meas_gap_cfg.type().value == setup_opts::setup);
|
||
|
TESTASSERT((1 + recfg_r8.meas_cfg.meas_gap_cfg.setup().gap_offset.type().value) * 40u ==
|
||
|
tester.cfg.cell_list[0].meas_cfg.meas_gap_period);
|
||
|
|
||
5 years ago
|
tester.pdcp.last_sdu.sdu = nullptr;
|
||
5 years ago
|
tester.rlc.test_reset_all();
|
||
4 years ago
|
tester.phy.phy_cfg_set = false;
|
||
5 years ago
|
|
||
|
/* Receive MeasReport from UE (correct if PCI=2) */
|
||
4 years ago
|
if (test_params == test_event::wrong_measreport) {
|
||
5 years ago
|
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x0D, 0xBC, 0x80}; // PCI == 3
|
||
4 years ago
|
test_helpers::copy_msg_to_buffer(pdu, meas_report);
|
||
5 years ago
|
} else {
|
||
|
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x09, 0xBC, 0x80}; // PCI == 2
|
||
4 years ago
|
test_helpers::copy_msg_to_buffer(pdu, meas_report);
|
||
5 years ago
|
}
|
||
|
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
|
||
|
tester.tic();
|
||
|
TESTASSERT(tester.s1ap.last_ho_required.rrc_container == nullptr);
|
||
|
|
||
|
/* Test Case: the MeasReport is not valid */
|
||
4 years ago
|
if (test_params == test_event::wrong_measreport) {
|
||
4 years ago
|
TESTASSERT(spy.get_warning_counter() == 1);
|
||
5 years ago
|
TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr);
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
TESTASSERT(tester.pdcp.last_sdu.sdu != nullptr);
|
||
|
TESTASSERT(tester.s1ap.last_ho_required.rrc_container == nullptr);
|
||
|
TESTASSERT(not tester.s1ap.last_enb_status.status_present);
|
||
|
|
||
|
/* Test Case: Multiple concurrent MeasReports arrived. Only one HO procedure should be running */
|
||
4 years ago
|
if (test_params == test_event::concurrent_ho) {
|
||
5 years ago
|
tester.pdcp.last_sdu = {};
|
||
|
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x09, 0xBC, 0x80}; // PCI == 2
|
||
4 years ago
|
test_helpers::copy_msg_to_buffer(pdu, meas_report);
|
||
5 years ago
|
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
|
||
|
tester.tic();
|
||
|
TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr);
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
|
||
|
/* Test Case: the HandoverCommand was sent to the lower layers */
|
||
4 years ago
|
TESTASSERT(spy.get_error_counter() == 0);
|
||
5 years ago
|
TESTASSERT(tester.pdcp.last_sdu.rnti == tester.rnti);
|
||
|
TESTASSERT(tester.pdcp.last_sdu.lcid == 1); // SRB1
|
||
|
asn1::rrc::dl_dcch_msg_s ho_cmd;
|
||
4 years ago
|
TESTASSERT(test_helpers::unpack_asn1(ho_cmd, srsran::make_span(tester.pdcp.last_sdu.sdu)));
|
||
4 years ago
|
recfg_r8 = ho_cmd.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8();
|
||
5 years ago
|
TESTASSERT(recfg_r8.mob_ctrl_info_present);
|
||
|
TESTASSERT(recfg_r8.mob_ctrl_info.new_ue_id.to_number() == tester.rnti);
|
||
|
TESTASSERT(recfg_r8.mob_ctrl_info.target_pci == 2);
|
||
5 years ago
|
TESTASSERT(recfg_r8.rr_cfg_ded_present);
|
||
|
TESTASSERT(recfg_r8.rr_cfg_ded.phys_cfg_ded_present);
|
||
|
const asn1::rrc::phys_cfg_ded_s& phy_cfg_ded = recfg_r8.rr_cfg_ded.phys_cfg_ded;
|
||
|
TESTASSERT(phy_cfg_ded.sched_request_cfg_present);
|
||
|
TESTASSERT(phy_cfg_ded.cqi_report_cfg_present);
|
||
4 years ago
|
// PHY should not be updated until the UE handovers to the new cell
|
||
|
TESTASSERT(not tester.phy.phy_cfg_set);
|
||
4 years ago
|
// Correct measConfig
|
||
|
TESTASSERT(recfg_r8.meas_cfg_present and recfg_r8.meas_cfg.meas_gap_cfg_present);
|
||
|
TESTASSERT(recfg_r8.meas_cfg.meas_gap_cfg.type().value == setup_opts::setup);
|
||
|
TESTASSERT((1 + recfg_r8.meas_cfg.meas_gap_cfg.setup().gap_offset.type().value) * 40u ==
|
||
|
tester.cfg.cell_list[1].meas_cfg.meas_gap_period);
|
||
5 years ago
|
|
||
4 years ago
|
/* Test Case: The UE sends a C-RNTI CE. Bearers are reestablished, PHY is configured */
|
||
5 years ago
|
tester.pdcp.last_sdu.sdu = nullptr;
|
||
|
tester.rrc.upd_user(tester.rnti + 1, tester.rnti);
|
||
|
TESTASSERT(tester.rlc.ue_db[tester.rnti].reest_sdu_counter == 0);
|
||
|
TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr);
|
||
4 years ago
|
TESTASSERT(tester.phy.phy_cfg_set);
|
||
4 years ago
|
TESTASSERT(tester.phy.last_cfg.size() == 1 and tester.mac.ue_db[tester.rnti].supported_cc_list.size() == 1);
|
||
|
TESTASSERT(tester.phy.last_cfg[0].enb_cc_idx == tester.mac.ue_db[tester.rnti].supported_cc_list[0].enb_cc_idx);
|
||
5 years ago
|
|
||
|
/* Test Case: The UE receives a duplicate C-RNTI CE. Nothing should happen */
|
||
4 years ago
|
if (test_params == test_event::duplicate_crnti_ce) {
|
||
5 years ago
|
TESTASSERT(tester.rlc.ue_db[tester.rnti].reest_sdu_counter == 0);
|
||
|
tester.rrc.upd_user(tester.rnti + 2, tester.rnti);
|
||
|
TESTASSERT(tester.rlc.ue_db[tester.rnti].reest_sdu_counter == 0);
|
||
|
TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr);
|
||
|
TESTASSERT(tester.rlc.ue_db[tester.rnti].last_sdu == nullptr); // No Reject sent
|
||
|
}
|
||
|
|
||
|
/* Test Case: Terminate first Handover. No extra messages should be sent DL. SR/CQI resources match recfg message */
|
||
|
uint8_t recfg_complete[] = {0x10, 0x00};
|
||
4 years ago
|
test_helpers::copy_msg_to_buffer(pdu, recfg_complete);
|
||
4 years ago
|
tester.rrc.write_pdu(tester.rnti, srb_to_lcid(lte_srb::srb2), std::move(pdu));
|
||
5 years ago
|
TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr);
|
||
|
sched_interface::ue_cfg_t& ue_cfg = tester.mac.ue_db[tester.rnti];
|
||
|
TESTASSERT(ue_cfg.pucch_cfg.sr_configured);
|
||
|
TESTASSERT(ue_cfg.pucch_cfg.n_pucch_sr == phy_cfg_ded.sched_request_cfg.setup().sr_pucch_res_idx);
|
||
|
TESTASSERT(ue_cfg.pucch_cfg.I_sr == phy_cfg_ded.sched_request_cfg.setup().sr_cfg_idx);
|
||
4 years ago
|
TESTASSERT(ue_cfg.supported_cc_list[0].dl_cfg.cqi_report.pmi_idx ==
|
||
5 years ago
|
phy_cfg_ded.cqi_report_cfg.cqi_report_periodic.setup().cqi_pmi_cfg_idx);
|
||
|
TESTASSERT(ue_cfg.pucch_cfg.n_pucch == phy_cfg_ded.cqi_report_cfg.cqi_report_periodic.setup().cqi_pucch_res_idx);
|
||
|
|
||
|
/* Test Case: The RRC should be able to start a new handover */
|
||
|
uint8_t meas_report[] = {0x08, 0x10, 0x38, 0x74, 0x00, 0x05, 0xBC, 0x80}; // PCI == 1
|
||
4 years ago
|
test_helpers::copy_msg_to_buffer(pdu, meas_report);
|
||
5 years ago
|
tester.rrc.write_pdu(tester.rnti, 1, std::move(pdu));
|
||
|
tester.tic();
|
||
|
TESTASSERT(tester.s1ap.last_ho_required.rrc_container == nullptr);
|
||
|
TESTASSERT(tester.pdcp.last_sdu.sdu != nullptr);
|
||
|
TESTASSERT(tester.s1ap.last_ho_required.rrc_container == nullptr);
|
||
|
TESTASSERT(not tester.s1ap.last_enb_status.status_present);
|
||
4 years ago
|
TESTASSERT(test_helpers::unpack_asn1(ho_cmd, srsran::make_span(tester.pdcp.last_sdu.sdu)));
|
||
5 years ago
|
recfg_r8 = ho_cmd.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8();
|
||
|
TESTASSERT(recfg_r8.mob_ctrl_info_present);
|
||
|
TESTASSERT(recfg_r8.mob_ctrl_info.new_ue_id.to_number() == tester.rnti);
|
||
|
TESTASSERT(recfg_r8.mob_ctrl_info.target_pci == 1);
|
||
5 years ago
|
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
int main(int argc, char** argv)
|
||
5 years ago
|
{
|
||
4 years ago
|
// Setup the log spy to intercept error and warning log entries.
|
||
|
if (!srslog::install_custom_sink(
|
||
4 years ago
|
srsran::log_sink_spy::name(),
|
||
|
std::unique_ptr<srsran::log_sink_spy>(new srsran::log_sink_spy(srslog::get_default_log_formatter())))) {
|
||
|
return SRSRAN_ERROR;
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
auto* spy = static_cast<srsran::log_sink_spy*>(srslog::find_sink(srsran::log_sink_spy::name()));
|
||
4 years ago
|
if (!spy) {
|
||
4 years ago
|
return SRSRAN_ERROR;
|
||
4 years ago
|
}
|
||
|
srslog::set_default_sink(*spy);
|
||
|
|
||
|
auto& logger = srslog::fetch_basic_logger("RRC", false);
|
||
|
logger.set_level(srslog::basic_levels::info);
|
||
|
logger.set_hex_dump_max_size(1024);
|
||
|
|
||
4 years ago
|
srslog::init();
|
||
|
|
||
5 years ago
|
if (argc < 3) {
|
||
|
argparse::usage(argv[0]);
|
||
|
return -1;
|
||
|
}
|
||
|
argparse::parse_args(argc, argv);
|
||
5 years ago
|
|
||
4 years ago
|
// Source ENB - S1 Handover
|
||
4 years ago
|
TESTASSERT(test_s1ap_mobility(*spy, test_event::wrong_measreport) == 0);
|
||
|
TESTASSERT(test_s1ap_mobility(*spy, test_event::concurrent_ho) == 0);
|
||
|
TESTASSERT(test_s1ap_mobility(*spy, test_event::ho_prep_failure) == 0);
|
||
|
TESTASSERT(test_s1ap_mobility(*spy, test_event::success) == 0);
|
||
5 years ago
|
|
||
4 years ago
|
TESTASSERT(test_s1ap_tenb_mobility(test_event::wrong_target_cell) == 0);
|
||
|
TESTASSERT(test_s1ap_tenb_mobility(test_event::unknown_qci) == 0);
|
||
|
TESTASSERT(test_s1ap_tenb_mobility(test_event::success) == 0);
|
||
4 years ago
|
|
||
5 years ago
|
// intraeNB Handover
|
||
4 years ago
|
TESTASSERT(test_intraenb_mobility(*spy, test_event::wrong_measreport) == 0);
|
||
|
TESTASSERT(test_intraenb_mobility(*spy, test_event::concurrent_ho) == 0);
|
||
|
TESTASSERT(test_intraenb_mobility(*spy, test_event::duplicate_crnti_ce) == 0);
|
||
|
TESTASSERT(test_intraenb_mobility(*spy, test_event::success) == 0);
|
||
4 years ago
|
|
||
|
srslog::flush();
|
||
5 years ago
|
|
||
5 years ago
|
printf("\nSuccess\n");
|
||
5 years ago
|
|
||
4 years ago
|
return SRSRAN_SUCCESS;
|
||
5 years ago
|
}
|