laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/36205?usp=email )
Change subject: Introduce counter for per-hnb cumulative active CS RAB duration ...................................................................... Introduce counter for per-hnb cumulative active CS RAB duration This counter can be used to determine the traffic in Erlangs per HNB. Change-Id: Iffb6a3f38239094551a12c872cd8474d02a5ad56 --- M include/osmocom/hnbgw/hnbgw.h M include/osmocom/hnbgw/mgw_fsm.h M src/osmo-hnbgw/hnbgw.c M src/osmo-hnbgw/mgw_fsm.c 4 files changed, 95 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h index 23c1239..f2982de 100644 --- a/include/osmocom/hnbgw/hnbgw.h +++ b/include/osmocom/hnbgw/hnbgw.h @@ -19,6 +19,7 @@ #include <osmocom/mgcp_client/mgcp_client_pool.h> #define STORE_UPTIME_INTERVAL 10 /* seconds */ +#define HNB_STORE_RAB_DURATIONS_INTERVAL 1 /* seconds */ enum { DMAIN, @@ -96,6 +97,8 @@ HNB_CTR_RUA_UDT_UL, HNB_CTR_RUA_UDT_DL, + + HNB_CTR_RAB_ACTIVE_MILLISECONDS_TOTAL, }; enum hnb_stat { @@ -385,6 +388,8 @@ struct osmo_pfcp_endpoint *ep; struct osmo_pfcp_cp_peer *cp_peer; } pfcp; + + struct osmo_timer_list hnb_store_rab_durations_timer; }; extern struct hnbgw *g_hnbgw; diff --git a/include/osmocom/hnbgw/mgw_fsm.h b/include/osmocom/hnbgw/mgw_fsm.h index 2c919e5..d662fcc 100644 --- a/include/osmocom/hnbgw/mgw_fsm.h +++ b/include/osmocom/hnbgw/mgw_fsm.h @@ -5,3 +5,5 @@ int handle_cs_rab_ass_req(struct hnbgw_context_map *map, struct msgb *ranap_msg, ranap_message *message); int mgw_fsm_handle_cs_rab_ass_resp(struct hnbgw_context_map *map, struct msgb *ranap_msg, ranap_message *message); int mgw_fsm_release(struct hnbgw_context_map *map); + +uint64_t mgw_fsm_get_elapsed_ms(struct hnbgw_context_map *map, const struct timespec *now); diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c index c2d86e8..055b438 100644 --- a/src/osmo-hnbgw/hnbgw.c +++ b/src/osmo-hnbgw/hnbgw.c @@ -42,6 +42,7 @@ #include <osmocom/hnbgw/hnbgw_rua.h> #include <osmocom/hnbgw/hnbgw_cn.h> #include <osmocom/hnbgw/context_map.h> +#include <osmocom/hnbgw/mgw_fsm.h> struct hnbgw *g_hnbgw = NULL; @@ -51,6 +52,41 @@ {} }; +/* update the active RAB duration rate_ctr for given HNB */ +static void hnb_store_rab_durations(struct hnb_context *hnb) +{ + struct hnbgw_context_map *map; + struct timespec now; + uint64_t elapsed_cs_rab_ms = 0; + + osmo_clock_gettime(CLOCK_MONOTONIC, &now); + + /* iterate over all context_maps (subscribers) */ + llist_for_each_entry(map, &hnb->map_list, hnb_list) { + /* skip any PS maps, we care about CS RABs only here */ + if (map->is_ps) + continue; + elapsed_cs_rab_ms += mgw_fsm_get_elapsed_ms(map, &now); + } + + /* Export to rate countes. */ + rate_ctr_add(HNBP_CTR(hnb->persistent, HNB_CTR_RAB_ACTIVE_MILLISECONDS_TOTAL), elapsed_cs_rab_ms); +} + +static void hnbgw_store_hnb_rab_durations(void *data) +{ + struct hnb_context *hnb; + + llist_for_each_entry(hnb, &g_hnbgw->hnb_list, list) { + if (!hnb->persistent) + continue; + hnb_store_rab_durations(hnb); + } + + /* Keep this timer ticking */ + osmo_timer_schedule(&g_hnbgw->hnb_store_rab_durations_timer, HNB_STORE_RAB_DURATIONS_INTERVAL, 0); +} + /*********************************************************************** * UE Context @@ -358,6 +394,9 @@ "rua:unit_data:ul", "Received RUA UnitData (UDT) in uplink" }, [HNB_CTR_RUA_UDT_DL] = { "rua:unit_data:dl", "Transmitted RUA UnitData (UDT) in downlink" }, + + [HNB_CTR_RAB_ACTIVE_MILLISECONDS_TOTAL] = { + "rab:cs:active_milliseconds:total", "Cumulative number of milliseconds of CS RAB activity" }, }; const struct rate_ctr_group_desc hnb_ctrg_desc = { @@ -821,4 +860,7 @@ osmo_timer_setup(&g_hnbgw->store_uptime_timer, hnbgw_store_hnb_uptime, g_hnbgw); osmo_timer_schedule(&g_hnbgw->store_uptime_timer, STORE_UPTIME_INTERVAL, 0); + + osmo_timer_setup(&g_hnbgw->hnb_store_rab_durations_timer, hnbgw_store_hnb_rab_durations, g_hnbgw); + osmo_timer_schedule(&g_hnbgw->hnb_store_rab_durations_timer, HNB_STORE_RAB_DURATIONS_INTERVAL, 0); } diff --git a/src/osmo-hnbgw/mgw_fsm.c b/src/osmo-hnbgw/mgw_fsm.c index d405d85..6d23790 100644 --- a/src/osmo-hnbgw/mgw_fsm.c +++ b/src/osmo-hnbgw/mgw_fsm.c @@ -1,4 +1,4 @@ -/* (C) 2021 by sysmocom s.f.m.c. GmbH <i...@sysmocom.de> +/* (C) 2021-2024 by sysmocom s.f.m.c. GmbH <i...@sysmocom.de> * All Rights Reserved * * Author: Philipp Maier @@ -123,6 +123,10 @@ struct osmo_sockaddr ci_hnb_crcx_ack_addr; char msc_rtp_addr[INET6_ADDRSTRLEN]; uint16_t msc_rtp_port; + + /* Timestamps to track active duration */ + struct timespec active_start; + struct timespec active_stored; }; struct osmo_tdef_state_timeout mgw_fsm_timeouts[32] = { @@ -554,6 +558,9 @@ } LOGPFSML(fi, LOGL_DEBUG, "HNB and MSC side call-legs completed!\n"); + + osmo_clock_gettime(CLOCK_MONOTONIC, &mgw_fsm_priv->active_start); + mgw_fsm_priv->active_stored = mgw_fsm_priv->active_start; } static void mgw_fsm_release_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) @@ -915,3 +922,30 @@ osmo_fsm_inst_dispatch(map->mgw_fi, MGW_EV_RELEASE, NULL); return 0; } + +/* determine the number of elapsed active RAB milli-seconds since last call */ +uint64_t mgw_fsm_get_elapsed_ms(struct hnbgw_context_map *map, const struct timespec *now) +{ + struct mgw_fsm_priv *mgw_fsm_priv; + struct timespec elapsed; + uint64_t elapsed_ms; + + if (!map->mgw_fi) + return 0; + + OSMO_ASSERT(map->mgw_fi->fsm == &mgw_fsm); + mgw_fsm_priv = map->mgw_fi->priv; + + /* Ignore RABs whose activation timestamps are not yet set. */ + if (!timespecisset(&mgw_fsm_priv->active_stored)) + return 0; + + /* Calculate elapsed time since last storage */ + timespecsub(now, &mgw_fsm_priv->active_stored, &elapsed); + elapsed_ms = elapsed.tv_sec * 1000 + elapsed.tv_nsec / 1000000; + + /* Update storage time */ + mgw_fsm_priv->active_stored = *now; + + return elapsed_ms; +} -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36205?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Iffb6a3f38239094551a12c872cd8474d02a5ad56 Gerrit-Change-Number: 36205 Gerrit-PatchSet: 5 Gerrit-Owner: laforge <lafo...@osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: osmith <osm...@sysmocom.de> Gerrit-Reviewer: pespin <pes...@sysmocom.de> Gerrit-MessageType: merged