From 72cc4e0ca5135a1d6a84af1250aebd8e7922516d Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 26 Aug 2020 19:39:40 +0200 Subject: [PATCH] Stop ContentionResolutionTimer on RA error. Updated test --- srsue/src/stack/mac/proc_ra.cc | 3 ++- srsue/test/mac_test.cc | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/srsue/src/stack/mac/proc_ra.cc b/srsue/src/stack/mac/proc_ra.cc index c28c9b3aa..a1e835c83 100644 --- a/srsue/src/stack/mac/proc_ra.cc +++ b/srsue/src/stack/mac/proc_ra.cc @@ -500,6 +500,7 @@ void ra_proc::response_error() { rntis->temp_rnti = 0; preambleTransmissionCounter++; + contention_resolution_timer.stop(); if (preambleTransmissionCounter >= rach_cfg.preambleTransMax + 1) { rError("Maximum number of transmissions reached (%d)\n", rach_cfg.preambleTransMax); rrc->ra_problem(); @@ -518,7 +519,7 @@ void ra_proc::response_error() rDebug("Backoff wait interval %d\n", backoff_interval); state = BACKOFF_WAIT; } else { - rDebug("Transmitting immediately (%d/%d)\n", preambleTransmissionCounter, rach_cfg.preambleTransMax); + rInfo("Transmitting new preamble immediately (%d/%d)\n", preambleTransmissionCounter, rach_cfg.preambleTransMax); resource_selection(); } } diff --git a/srsue/test/mac_test.cc b/srsue/test/mac_test.cc index e5142ffe2..5061bc428 100644 --- a/srsue/test/mac_test.cc +++ b/srsue/test/mac_test.cc @@ -1108,6 +1108,7 @@ int mac_ul_sch_pdu_three_byte_test() } struct ra_test { + int rar_offset; uint32_t nof_prachs; uint32_t rar_nof_rapid; // set to zero to don't transmit RAR uint32_t rar_nof_invalid_rapid; @@ -1162,7 +1163,7 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti // TODO: Test power ramping // Check MAC does not schedule RA-RNTI before window starts - for (uint32_t i = 0; i < phy->prach_delay + 3 - 1; i++) { + for (uint32_t i = 0; i < phy->prach_delay + 3 - 1 + test.rar_offset; i++) { stack->run_tti(tti); TESTASSERT(!SRSLTE_RNTI_ISRAR(mac->get_dl_sched_rnti(tti))); tti++; @@ -1370,7 +1371,7 @@ int mac_random_access_test() my_test.rar_nof_invalid_rapid = rach_cfg.ra_supervision_info.ra_resp_win_size.to_number(); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &stack)); - // Test 3: RAR received but no matching RAPID. Test Msg3 retransmissions + // Test 3: RAR with valid RAPID. Test Msg3 retransmissions // On each HARQ retx, contention resolution timer must be restarted (5.1.5) // When max-HARQ-msg3-retx, contention not successful mac_log->info("\n=========== Test %d =============\n", test_id++); @@ -1378,12 +1379,22 @@ int mac_random_access_test() my_test.nof_msg3_retx = rach_cfg.max_harq_msg3_tx; TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &stack)); + // Make sure ContentionResolutionTimer is stopped after the failure + phy.reset(); + for (int i = 0; i < 8; i++) { + stack.run_tti(tti++); + TESTASSERT(!phy.is_prach_transmitted()); + } + + mac.reset(); + mac.set_contention_id(contention_id); + rlc.write_sdu(0, 6); // UL-CCCH with Msg3 + rlc.write_sdu(3, 100); // DRB data on other LCG my_test.nof_msg3_retx = 0; + // Test 4: RAR with valid RAPID. Msg3 transmitted, Msg4 received but invalid ConRes // Contention resolution is defined in 5.1.5. If ConResID does not match, the ConRes is considered // not successful and tries again mac_log->info("\n=========== Test %d =============\n", test_id++); - phy.reset(); - my_test.nof_msg3_retx = 0; my_test.msg4_enable = true; TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &stack)); @@ -1393,7 +1404,10 @@ int mac_random_access_test() my_test.msg4_valid_conres = true; my_test.check_ra_successful = true; my_test.assume_prach_transmitted = 0; + my_test.rar_offset = 1; + my_test.nof_msg3_retx = 1; TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &stack)); + my_test.rar_offset = 0; // Test 6: RA with existing C-RNTI (Sends C-RNTI MAC CE) // The transmission of C-RNTI MAC CE is only done if no CCCH is present (5.1.4).