mac_nr_test: add PDU packing test for two SDUs from different LCs

This commit is contained in:
Andre Puschmann 2021-10-18 20:55:19 +02:00
parent d4a4da7ecc
commit 97d43eb044
1 changed files with 88 additions and 0 deletions

View File

@ -514,6 +514,92 @@ int mac_nr_ul_logical_channel_prioritization_test3()
return SRSRAN_SUCCESS;
}
// Correct packing of MAC PDU with two SDUs for different LCIDs
int mac_nr_ul_logical_channel_prioritization_test4()
{
// PDU layout (24 B in total)
const uint8_t tv[] = {0x04, 0x0a, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x05, 0x0a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05};
// dummy layers
dummy_phy phy;
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
// the actual MAC
mac_nr mac(&stack.task_sched);
const uint16_t crnti = 0x1001;
mac_nr_args_t args = {};
mac.init(args, &phy, &rlc, &rrc);
mac.set_crnti(crnti);
stack.init(&mac, &phy);
// generate config for two DRBs
std::vector<srsran::logical_channel_config_t> lcids;
srsran::logical_channel_config_t config = {};
config.lcid = 4;
config.lcg = 6;
config.PBR = 0;
config.BSD = 1000; // 1000ms
config.priority = 11;
lcids.push_back(config);
config.lcid = 5;
config.lcg = 7;
config.PBR = 0;
config.BSD = 1000; // 1000ms
config.priority = 12;
lcids.push_back(config);
// setup LCIDs in MAC
for (auto& channel : lcids) {
mac.setup_lcid(channel);
}
// write one SDU to each DRB
const uint32_t sdu_len = 10;
rlc.write_sdu(4, sdu_len);
rlc.write_sdu(5, sdu_len);
// run TTI to setup Bj, BSR should be generated
stack.run_tti(0);
usleep(100);
// create UL action and grant and read MAC PDU
{
mac_interface_phy_nr::tb_action_ul_t ul_action = {};
mac_interface_phy_nr::mac_nr_grant_ul_t mac_grant = {};
mac_grant.rnti = crnti; // make sure MAC picks it up as valid UL grant
mac_grant.pid = 0;
mac_grant.tti = 0;
mac_grant.tbs = 24;
int cc_idx = 0;
// Send grant to MAC and get action for this TB, 0x
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload->msg, mac_grant.tbs, "Generated PDU (%d B)", mac_grant.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti_nr(
ul_action.tb.payload->msg, mac_grant.tbs, mac_grant.rnti, UE_ID, mac_grant.pid, mac_grant.tti);
#endif
TESTASSERT(memcmp(ul_action.tb.payload->msg, tv, sizeof(tv)) == 0);
}
// make sure MAC PDU thread picks up before stopping
stack.run_tti(0);
mac.stop();
return SRSRAN_SUCCESS;
}
// Basic test for periodic BSR transmission
int mac_nr_ul_periodic_bsr_test()
{
@ -800,6 +886,8 @@ int main()
TESTASSERT(mac_nr_ul_logical_channel_prioritization_test1() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_ul_logical_channel_prioritization_test2() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_ul_logical_channel_prioritization_test3() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_ul_logical_channel_prioritization_test4() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_ul_periodic_bsr_test() == SRSRAN_SUCCESS);
TESTASSERT(mac_nr_dl_retx_test() == SRSRAN_SUCCESS);