From 604e79214d24cb1417df49bdc938bc180ff2839e Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 8 May 2020 13:37:12 +0100 Subject: [PATCH] Changed NAS is_attached interface to is_registered. --- lib/include/srslte/interfaces/ue_interfaces.h | 10 ++++---- srsenb/hdr/stack/gnb_stack_nr.h | 2 +- srsue/hdr/stack/ue_stack_lte.h | 2 +- srsue/hdr/stack/ue_stack_nr.h | 2 +- srsue/hdr/stack/upper/nas.h | 2 +- srsue/src/stack/rrc/rrc_procedures.cc | 4 ++-- srsue/src/stack/ue_stack_lte.cc | 4 ++-- srsue/src/stack/upper/gw.cc | 23 ++++++++++--------- srsue/src/stack/upper/nas.cc | 2 +- srsue/test/upper/nas_test.cc | 4 ++-- srsue/test/upper/rrc_meas_test.cc | 2 +- 11 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index bf05ef621..0c719f67c 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -224,7 +224,7 @@ public: virtual void left_rrc_connected() = 0; virtual void set_barring(srslte::barring_t barring) = 0; virtual bool paging(srslte::s_tmsi_t* ue_identity) = 0; - virtual bool is_attached() = 0; + virtual bool is_registered() = 0; virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; virtual uint32_t get_k_enb_count() = 0; virtual bool get_k_asme(uint8_t* k_asme_, uint32_t n) = 0; @@ -240,9 +240,9 @@ public: class nas_interface_stack { public: - virtual bool switch_on() = 0; - virtual bool switch_off() = 0; - virtual bool enable_data() = 0; + virtual bool switch_on() = 0; + virtual bool switch_off() = 0; + virtual bool enable_data() = 0; virtual bool disable_data() = 0; }; @@ -623,7 +623,7 @@ public: class stack_interface_gw : public pdcp_interface_gw { public: - virtual bool is_attached() = 0; + virtual bool is_registered() = 0; virtual bool start_service_request() = 0; }; diff --git a/srsenb/hdr/stack/gnb_stack_nr.h b/srsenb/hdr/stack/gnb_stack_nr.h index 252573149..cb3d7386c 100644 --- a/srsenb/hdr/stack/gnb_stack_nr.h +++ b/srsenb/hdr/stack/gnb_stack_nr.h @@ -66,7 +66,7 @@ public: bool get_metrics(srsenb::stack_metrics_t* metrics) final; // GW srsue stack_interface_gw dummy interface - bool is_attached(){return true;}; + bool is_registered(){return true;}; bool start_service_request(){return true;}; // PHY->MAC interface diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index ca601fac4..05b7a5e32 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -68,7 +68,7 @@ public: int init(const stack_args_t& args_, srslte::logger* logger_, phy_interface_stack_lte* phy_, gw_interface_stack* gw_); bool switch_on() final; bool switch_off() final; - bool is_attached() final; + bool is_registered() final; bool start_service_request() final; bool enable_data(); bool disable_data(); diff --git a/srsue/hdr/stack/ue_stack_nr.h b/srsue/hdr/stack/ue_stack_nr.h index efff83de8..ea42bba38 100644 --- a/srsue/hdr/stack/ue_stack_nr.h +++ b/srsue/hdr/stack/ue_stack_nr.h @@ -71,7 +71,7 @@ public: void stop(); // GW srsue stack_interface_gw dummy interface - bool is_attached(){return true;}; + bool is_registered(){return true;}; bool start_service_request(){return true;}; bool get_metrics(stack_metrics_t* metrics); diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index 712da530f..aa826e3b6 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -72,7 +72,7 @@ public: void start_service_request(srslte::establishment_cause_t cause_); // Stack+RRC interface - bool is_attached() override; + bool is_registered() override; // timer callback void timer_expired(uint32_t timeout_id) override; diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 1acda0076..72c6160e1 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -1175,7 +1175,7 @@ proc_outcome_t rrc::go_idle_proc::step() void rrc::go_idle_proc::then(const srslte::proc_state_t& result) { - if (rrc_ptr->nas->is_attached() and not rrc_ptr->cell_reselector.launch()) { + if (rrc_ptr->nas->is_registered() and not rrc_ptr->cell_reselector.launch()) { rrc_ptr->rrc_log->error("Failed to initiate a Cell Reselection procedure...\n"); return; } @@ -1245,7 +1245,7 @@ proc_outcome_t rrc::cell_reselection_proc::step() void rrc::cell_reselection_proc::then(const srslte::proc_state_t& result) { // Schedule cell reselection periodically, while rrc is idle - if (not rrc_ptr->is_connected() and rrc_ptr->nas->is_attached()) { + if (not rrc_ptr->is_connected() and rrc_ptr->nas->is_registered()) { if (cell_sel_result == cs_result_t::changed_cell) { // TS 36.304 5.2.4.6 - Intra-frequency and equal priority inter-frequency Cell Reselection criteria // the UE shall reselect a new cell if more than 1 second has elapsed since the UE camped diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 5ad9eddea..6b1a58699 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -262,9 +262,9 @@ void ue_stack_lte::write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) * Check whether nas is attached * @return bool wether NAS is in EMM_REGISTERED */ -bool ue_stack_lte::is_attached() +bool ue_stack_lte::is_registered() { - return nas.is_attached(); + return nas.is_registered(); } /******************** diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index 82cb95fbb..beb05d630 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -221,8 +221,8 @@ void gw::run_thread() return; } - const static uint32_t ATTACH_WAIT_TOUT = 40, SERVICE_WAIT_TOUT = 40; // 4 sec - uint32_t attach_wait = 0, service_wait = 0; + const static uint32_t REGISTER_WAIT_TOUT = 40, SERVICE_WAIT_TOUT = 40; // 4 sec + uint32_t register_wait = 0, service_wait = 0; log.info("GW IP packet receiver thread run_enable\n"); @@ -264,31 +264,32 @@ void gw::run_thread() log.info_hex(pdu->msg, pdu->N_bytes, "TX PDU"); // Make sure UE is attached - while (run_enable && !stack->is_attached() && attach_wait < ATTACH_WAIT_TOUT) { - if (!attach_wait) { - log.info("UE is not attached, waiting for NAS attach (%d/%d)\n", attach_wait, ATTACH_WAIT_TOUT); + while (run_enable && !stack->is_registered() && register_wait < REGISTER_WAIT_TOUT) { + if (!register_wait) { + log.info("UE is not attached, waiting for NAS attach (%d/%d)\n", register_wait, REGISTER_WAIT_TOUT); } usleep(100000); - attach_wait++; + register_wait++; } - attach_wait = 0; + register_wait = 0; // If we are still not attached by this stage, drop packet - if (run_enable && !stack->is_attached()) { + if (run_enable && !stack->is_registered()) { continue; } - // Wait for service request if necessary + // Wait for service request if necessary while (run_enable && !stack->is_lcid_enabled(default_lcid) && service_wait < SERVICE_WAIT_TOUT) { if (!service_wait) { - log.info("UE does not have service, waiting for NAS service request (%d/%d)\n", service_wait, SERVICE_WAIT_TOUT); + log.info( + "UE does not have service, waiting for NAS service request (%d/%d)\n", service_wait, SERVICE_WAIT_TOUT); stack->start_service_request(); } usleep(100000); service_wait++; } service_wait = 0; - + // Quit before writing packet if necessary if (!run_enable) { break; diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index bb48da8a6..fadd6520b 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -261,7 +261,7 @@ void nas::timer_expired(uint32_t timeout_id) /******************************************************************************* * UE Stack and RRC common Interface ******************************************************************************/ -bool nas::is_attached() +bool nas::is_registered() { return state.get_state() == emm_state_t::state_t::registered; } diff --git a/srsue/test/upper/nas_test.cc b/srsue/test/upper/nas_test.cc index e7ddfc152..c7f970736 100644 --- a/srsue/test/upper/nas_test.cc +++ b/srsue/test/upper/nas_test.cc @@ -158,7 +158,7 @@ public: void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) { pdcp->write_sdu(lcid, std::move(sdu)); } bool is_lcid_enabled(uint32_t lcid) { return pdcp->is_lcid_enabled(lcid); } - bool is_attached() { return true; } + bool is_registered() { return true; } bool start_service_request() { return true; } @@ -310,7 +310,7 @@ int mme_attach_request_test() gw.init(gw_args, g_logger, &stack); stack.init(&nas); - usleep(1000); // Wait for stack to initialize before stoping it. + usleep(5000); // Wait for stack to initialize before stoping it. // trigger test stack.switch_on(); stack.stop(); diff --git a/srsue/test/upper/rrc_meas_test.cc b/srsue/test/upper/rrc_meas_test.cc index 6a077bc74..55ab6370c 100644 --- a/srsue/test/upper/rrc_meas_test.cc +++ b/srsue/test/upper/rrc_meas_test.cc @@ -174,7 +174,7 @@ class nas_test : public srsue::nas { public: nas_test(srslte::task_sched_handle t) : srsue::nas(t) {} - bool is_attached() override { return false; } + bool is_registered() override { return false; } }; class pdcp_test : public srslte::pdcp