diff --git a/srsue/hdr/stack/upper/nas_5g.h b/srsue/hdr/stack/upper/nas_5g.h index 138ade151..3d916bdc1 100644 --- a/srsue/hdr/stack/upper/nas_5g.h +++ b/srsue/hdr/stack/upper/nas_5g.h @@ -71,6 +71,9 @@ public: int disable_data(); int start_service_request(); + // Metrics getter + void get_metrics(nas_5g_metrics_t& metrics); + private: rrc_nr_interface_nas_5g* rrc_nr = nullptr; usim_interface_nas* usim = nullptr; @@ -179,6 +182,7 @@ private: bool unestablished_pdu_sessions(); int get_unestablished_pdu_session(uint16_t& pdu_session_id, pdu_session_cfg_t& pdu_session_cfg); int reset_pdu_sessions(); + uint32_t num_of_est_pdu_sessions(); struct pdu_session_t { bool configured; diff --git a/srsue/hdr/stack/upper/nas_5g_metrics.h b/srsue/hdr/stack/upper/nas_5g_metrics.h index 3dc7b425b..79cd049a3 100644 --- a/srsue/hdr/stack/upper/nas_5g_metrics.h +++ b/srsue/hdr/stack/upper/nas_5g_metrics.h @@ -18,7 +18,7 @@ namespace srsue { struct nas_5g_metrics_t { - uint32_t nof_active_5g_bearers; + uint32_t nof_active_pdu_sessions; mm5g_state_t::state_t state; }; diff --git a/srsue/src/stack/upper/nas_5g.cc b/srsue/src/stack/upper/nas_5g.cc index 8d594c783..8253a57db 100644 --- a/srsue/src/stack/upper/nas_5g.cc +++ b/srsue/src/stack/upper/nas_5g.cc @@ -1018,10 +1018,15 @@ int nas_5g::reset_pdu_sessions() pdu_session.established = false; pdu_session.pdu_session_id = 0; } - return SRSRAN_SUCCESS; } +void nas_5g::get_metrics(nas_5g_metrics_t& metrics) +{ + metrics.nof_active_pdu_sessions = num_of_est_pdu_sessions(); + metrics.state = state.get_state(); +} + /******************************************************************************* * Helpers ******************************************************************************/ @@ -1135,6 +1140,17 @@ int nas_5g::init_pdu_sessions(std::vector pdu_session_cfgs) return SRSRAN_SUCCESS; } +uint32_t nas_5g::num_of_est_pdu_sessions() +{ + uint32_t i = 0; + for (auto pdu_session : pdu_sessions) { + if (pdu_session.established == true) { + i++; + } + } + return i; +} + int nas_5g::configure_pdu_session(uint16_t pdu_session_id) { for (auto pdu_session : pdu_sessions) {