From 15c47fab567c5ee624171ff55e7da2c0cc882f69 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 26 Mar 2020 21:54:29 +0100 Subject: [PATCH] nas: adding t3402 to restart attach after initial attach attempt counter expired --- srsue/hdr/stack/upper/nas.h | 2 ++ srsue/src/stack/upper/nas.cc | 27 +++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index 86bc9099a..1a36101d5 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -133,12 +133,14 @@ private: // timers srsue::task_handler_interface_lte* task_handler = nullptr; + srslte::timer_handler::unique_timer t3402; // started when attach attempt counter reached 5 srslte::timer_handler::unique_timer t3410; // started when attach request is sent, on expiry, start t3411 srslte::timer_handler::unique_timer t3411; // started when attach failed srslte::timer_handler::unique_timer t3421; // started when detach request is sent srslte::timer_handler::unique_timer reattach_timer; // started to trigger delayed re-attach // Values according to TS 24.301 Sec 10.2 + const uint32_t t3402_duration_ms = 12 * 60 * 1000; // 12m const uint32_t t3410_duration_ms = 15 * 1000; // 15s const uint32_t t3411_duration_ms = 10 * 1000; // 10s const uint32_t t3421_duration_ms = 15 * 1000; // 15s diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 437bb6977..1cd256cd0 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -240,6 +240,7 @@ nas::nas(srsue::stack_interface_nas* task_handler_) : plmn_searcher(this), rrc_connector(this), task_handler(task_handler_), + t3402(task_handler_->get_unique_timer()), t3410(task_handler_->get_unique_timer()), t3411(task_handler_->get_unique_timer()), t3421(task_handler_->get_unique_timer()), @@ -297,6 +298,7 @@ void nas::init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_ } // Configure timers + t3402.set(t3402_duration_ms, [this](uint32_t tid) { timer_expired(tid); }); t3410.set(t3410_duration_ms, [this](uint32_t tid) { timer_expired(tid); }); t3411.set(t3411_duration_ms, [this](uint32_t tid) { timer_expired(tid); }); t3421.set(t3421_duration_ms, [this](uint32_t tid) { timer_expired(tid); }); @@ -333,19 +335,24 @@ void nas::run_tti() void nas::timer_expired(uint32_t timeout_id) { - if (timeout_id == t3410.id()) { + if (timeout_id == t3402.id()) { + nas_log->info("Timer T3402 expired: trying to attach again\n"); + start_attach_request(nullptr, srslte::establishment_cause_t::mo_sig); + } else if (timeout_id == t3410.id()) { // Section 5.5.1.2.6 case c) attach_attempt_counter++; - nas_log->info("Timer T3410 expired: starting T3411 (attempt %d/%d)\n", attach_attempt_counter, max_attach_attempts); + nas_log->info("Timer T3410 expired after attach attempt %d/%d: starting T3411)\n", + attach_attempt_counter, + max_attach_attempts); if (attach_attempt_counter < max_attach_attempts) { // start T3411, ToDo: EMM-DEREGISTERED.ATTEMPTING-TO-ATTACH isn't fully implemented yet t3411.run(); } else { - // maximum attach attempts reached, cleanup current state and try again + // maximum attach attempts reached enter_emm_deregistered(); - start_attach_request(nullptr, srslte::establishment_cause_t::mo_sig); + t3402.run(); } } else if (timeout_id == t3411.id()) { nas_log->info("Timer T3411 expired: trying to attach again\n"); @@ -386,7 +393,10 @@ void nas::start_attach_request(srslte::proc_state_t* result, srslte::establishme t3411.stop(); } - // Todo: stop T3402 + // stop T3402 + if (t3402.is_running()) { + t3402.stop(); + } // Search PLMN is not selected if (!plmn_is_selected) { @@ -455,17 +465,14 @@ void nas::plmn_search_completed(const rrc_interface_nas::found_plmn_t found_plmn bool nas::detach_request(const bool switch_off) { switch (state) { - case EMM_STATE_DEREGISTERED: - // do nothing .. - break; case EMM_STATE_REGISTERED: // send detach request send_detach_request(switch_off); break; + case EMM_STATE_DEREGISTERED: case EMM_STATE_DEREGISTERED_INITIATED: - // do nothing .. - break; default: + nas_log->debug("Received request to detach in state %s\n", emm_state_text[state]); break; } return false;