laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36788?usp=email )

Change subject: KPI: Add initial set of DTAP message type rate counters
......................................................................

KPI: Add initial set of DTAP message type rate counters

From an operational perspective, it may be interesting to know how many
LU/RAU/Attach attempts, rejects and accepts are happening in a given
hNodeB.  Let's add some common infrastructure for DTAP related
statistics as well as some initial counters.

Related: SYS#6885
Depends: osmo-iuh.git Change-Id I7dea74102da8b610ff2a310c5814f5c89f08e7a6
Change-Id: I3e1ad7a2aa71674a22a27c31512600f2de139032
---
M TODO-RELEASE
M include/osmocom/hnbgw/hnbgw.h
M include/osmocom/hnbgw/kpi.h
M src/osmo-hnbgw/Makefile.am
M src/osmo-hnbgw/context_map_rua.c
M src/osmo-hnbgw/hnbgw.c
A src/osmo-hnbgw/kpi_dtap.c
M src/osmo-hnbgw/kpi_ranap.c
8 files changed, 197 insertions(+), 3 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/TODO-RELEASE b/TODO-RELEASE
index a80e188..b0ad6a0 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -11,3 +11,4 @@

 MGW    MGCP CRCX       osmo-hnbgw used to CRCX in loopback mode, to trigger a 
legacy IuUP hack. CRCX is no
                        longer in loopback mode now, so older osmo-mgw may fail 
to respond to IuUP Initialization.
+osmo-iuh >1.5.1        decoding of more RANAP procedures in ranap_common 
required for DTAP rate_counters
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index 8daf713..dc046a0 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -136,6 +136,18 @@
        HNB_CTR_CS_PAGING_ATTEMPTED,

        HNB_CTR_RAB_ACTIVE_MILLISECONDS_TOTAL,
+
+       HNB_CTR_DTAP_CS_LU_REQ,
+       HNB_CTR_DTAP_CS_LU_ACC,
+       HNB_CTR_DTAP_CS_LU_REJ,
+
+       HNB_CTR_DTAP_PS_ATT_REQ,
+       HNB_CTR_DTAP_PS_ATT_ACK,
+       HNB_CTR_DTAP_PS_ATT_REJ,
+
+       HNB_CTR_DTAP_PS_RAU_REQ,
+       HNB_CTR_DTAP_PS_RAU_ACK,
+       HNB_CTR_DTAP_PS_RAU_REJ,
 };

 enum hnb_stat {
diff --git a/include/osmocom/hnbgw/kpi.h b/include/osmocom/hnbgw/kpi.h
index 63f3477..2a13972 100644
--- a/include/osmocom/hnbgw/kpi.h
+++ b/include/osmocom/hnbgw/kpi.h
@@ -6,3 +6,6 @@

 void kpi_ranap_process_ul(struct hnbgw_context_map *map, ranap_message *ranap);
 void kpi_ranap_process_dl(struct hnbgw_context_map *map, ranap_message *ranap);
+
+void kpi_dtap_process_ul(struct hnbgw_context_map *map, const uint8_t *buf, 
unsigned int len, uint8_t sapi);
+void kpi_dtap_process_dl(struct hnbgw_context_map *map, const uint8_t *buf, 
unsigned int len, uint8_t sapi);
diff --git a/src/osmo-hnbgw/Makefile.am b/src/osmo-hnbgw/Makefile.am
index 0727f30..9dffabf 100644
--- a/src/osmo-hnbgw/Makefile.am
+++ b/src/osmo-hnbgw/Makefile.am
@@ -44,6 +44,7 @@
        cnlink.c \
        ranap_rab_ass.c \
        mgw_fsm.c \
+       kpi_dtap.c \
        kpi_ranap.c \
        tdefs.c \
        $(NULL)
diff --git a/src/osmo-hnbgw/context_map_rua.c b/src/osmo-hnbgw/context_map_rua.c
index f37ded8..d5b2cb7 100644
--- a/src/osmo-hnbgw/context_map_rua.c
+++ b/src/osmo-hnbgw/context_map_rua.c
@@ -220,10 +220,9 @@
        switch (event) {

        case MAP_RUA_EV_RX_CONNECT:
+               /* not needed for RAB assignment scanning, but for KPI scanning 
*/
+               handle_rx_rua(fi, ranap_msg);
                map_rua_fsm_state_chg(MAP_RUA_ST_CONNECTED);
-               /* The Connect will never be a RAB Assignment response, so no 
need for handle_rx_rua() (which decodes
-                * the RANAP message to detect a RAB Assignment response). Just 
forward to SCCP as is. */
-               map_sccp_dispatch(map, MAP_SCCP_EV_TX_DATA_REQUEST, ranap_msg);
                return;

        case MAP_RUA_EV_RX_DISCONNECT:
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index fe29c29..24d11a5 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -464,6 +464,18 @@

        [HNB_CTR_RAB_ACTIVE_MILLISECONDS_TOTAL] = {
                "rab:cs:active_milliseconds:total", "Cumulative number of 
milliseconds of CS RAB activity" },
+
+       [HNB_CTR_DTAP_CS_LU_REQ] = { "dtap:cs:location_update:req", "CS 
Location Update Requests" },
+       [HNB_CTR_DTAP_CS_LU_ACC] = { "dtap:cs:location_update:accept", "CS 
Location Update Accepts" },
+       [HNB_CTR_DTAP_CS_LU_REJ] = { "dtap:cs:location_update:reject", "CS 
Location Update Rejects" },
+
+       [HNB_CTR_DTAP_PS_ATT_REQ] = { "dtap:ps:attach:req", "PS Attach 
Requests" },
+       [HNB_CTR_DTAP_PS_ATT_ACK] = { "dtap:ps:attach:accept", "PS Attach 
Accepts" },
+       [HNB_CTR_DTAP_PS_ATT_REJ] = { "dtap:ps:attach:reject", "PS Attach 
Rejects" },
+
+       [HNB_CTR_DTAP_PS_RAU_REQ] = { "dtap:ps:routing_area_update:req", "PS 
Routing Area Update Requests" },
+       [HNB_CTR_DTAP_PS_RAU_ACK] = { "dtap:ps:routing_area_update:accept", "PS 
Routing Area Update Accepts" },
+       [HNB_CTR_DTAP_PS_RAU_REJ] = { "dtap:ps:routing_area_update:reject", "PS 
Routing Area Update Rejects" },
 };

 const struct rate_ctr_group_desc hnb_ctrg_desc = {
diff --git a/src/osmo-hnbgw/kpi_dtap.c b/src/osmo-hnbgw/kpi_dtap.c
new file mode 100644
index 0000000..8d47208
--- /dev/null
+++ b/src/osmo-hnbgw/kpi_dtap.c
@@ -0,0 +1,111 @@
+/* KPI (statistics, counters) at DTAP level */
+/* (C) 2024 by Harald Welte <lafo...@osmocom.org>
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: AGPL-3.0+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <osmocom/core/utils.h>
+
+#include <osmocom/ranap/ranap_common_ran.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
+
+#include <osmocom/hnbgw/hnbgw.h>
+#include <osmocom/hnbgw/context_map.h>
+#include <osmocom/hnbgw/kpi.h>
+
+/***********************************************************************
+ * DOWNLINK messages
+ ***********************************************************************/
+
+void kpi_dtap_process_dl(struct hnbgw_context_map *map, const uint8_t *buf, 
unsigned int len,
+                        uint8_t sapi)
+{
+       struct hnb_persistent *hnbp = map->hnb_ctx->persistent;
+       const struct gsm48_hdr *gh = (const struct gsm48_hdr *)buf;
+       if (len < sizeof(*gh))
+               return;
+
+       /* if you make use of any data beyond the fixed-size gsm48_hdr, you 
must make sure the underlying
+        * buffer length is actually long enough! */
+
+       if (map->is_ps) {
+               /* Packet Switched Domain (from SGSN) */
+               switch (gsm48_hdr_msg_type(gh)) {
+               case GSM48_MT_GMM_ATTACH_ACK:
+                       HNBP_CTR_INC(hnbp, HNB_CTR_DTAP_PS_ATT_ACK);
+                       break;
+               case GSM48_MT_GMM_ATTACH_REJ:
+                       HNBP_CTR_INC(hnbp, HNB_CTR_DTAP_PS_ATT_REJ);
+                       break;
+               case GSM48_MT_GMM_RA_UPD_ACK:
+                       HNBP_CTR_INC(hnbp, HNB_CTR_DTAP_PS_RAU_ACK);
+                       break;
+               case GSM48_MT_GMM_RA_UPD_REJ:
+                       HNBP_CTR_INC(hnbp, HNB_CTR_DTAP_PS_RAU_REJ);
+                       break;
+               }
+       } else {
+               /* Circuit Switched Domain (from MSC) */
+               switch (gsm48_hdr_msg_type(gh)) {
+               case GSM48_MT_MM_LOC_UPD_ACCEPT:
+                       /* FIXME: many LU are acknwoeldged implicitly with TMSI 
allocation */
+                       HNBP_CTR_INC(hnbp, HNB_CTR_DTAP_CS_LU_ACC);
+                       break;
+               case GSM48_MT_MM_LOC_UPD_REJECT:
+                       HNBP_CTR_INC(hnbp, HNB_CTR_DTAP_CS_LU_REJ);
+                       break;
+               }
+       }
+}
+
+/***********************************************************************
+ * UPLINK messages
+ ***********************************************************************/
+
+void kpi_dtap_process_ul(struct hnbgw_context_map *map, const uint8_t *buf, 
unsigned int len,
+                        uint8_t sapi)
+{
+       struct hnb_persistent *hnbp = map->hnb_ctx->persistent;
+       const struct gsm48_hdr *gh = (const struct gsm48_hdr *)buf;
+       if (len < sizeof(*gh))
+               return;
+
+       /* if you make use of any data beyond the fixed-size gsm48_hdr, you 
must make sure the underlying
+        * buffer length is actually long enough! */
+
+       if (map->is_ps) {
+               /* Packet Switched Domain (to SGSN) */
+               switch (gsm48_hdr_msg_type(gh)) {
+               case GSM48_MT_GMM_ATTACH_REQ:
+                       HNBP_CTR_INC(hnbp, HNB_CTR_DTAP_PS_ATT_REQ);
+                       break;
+               case GSM48_MT_GMM_RA_UPD_REQ:
+                       HNBP_CTR_INC(hnbp, HNB_CTR_DTAP_PS_RAU_REQ);
+                       break;
+               }
+       } else {
+               /* Circuit Switched Domain (to MSC) */
+               switch (gsm48_hdr_msg_type(gh)) {
+               case GSM48_MT_MM_LOC_UPD_REQUEST:
+                       HNBP_CTR_INC(hnbp, HNB_CTR_DTAP_CS_LU_REQ);
+                       break;
+               }
+       }
+}
diff --git a/src/osmo-hnbgw/kpi_ranap.c b/src/osmo-hnbgw/kpi_ranap.c
index c4460ff..59631cf 100644
--- a/src/osmo-hnbgw/kpi_ranap.c
+++ b/src/osmo-hnbgw/kpi_ranap.c
@@ -165,6 +165,18 @@
        }
 }

+static void kpi_ranap_process_dl_direct_transfer(struct hnbgw_context_map 
*map, ranap_message *ranap)
+{
+       const RANAP_DirectTransferIEs_t *dt_ies = &ranap->msg.directTransferIEs;
+       uint8_t sapi = 0;
+
+       if (dt_ies->presenceMask & DIRECTTRANSFERIES_RANAP_SAPI_PRESENT) {
+               if (dt_ies->sapi == RANAP_SAPI_sapi_3)
+                       sapi = 3;
+       }
+       kpi_dtap_process_dl(map, dt_ies->nas_pdu.buf, dt_ies->nas_pdu.size, 
sapi);
+}
+
 void kpi_ranap_process_dl(struct hnbgw_context_map *map, ranap_message *ranap)
 {
        switch (ranap->procedureCode) {
@@ -174,6 +186,9 @@
        case RANAP_ProcedureCode_id_Iu_Release:
                kpi_ranap_process_dl_iu_rel_cmd(map, ranap);            /* IU 
RELEASE CMD (8.5) */
                break;
+       case RANAP_ProcedureCode_id_DirectTransfer:
+               kpi_ranap_process_dl_direct_transfer(map, ranap);
+               break;
        default:
                break;
        }
@@ -370,6 +385,24 @@
        }
 }

+static void kpi_ranap_process_ul_initial_ue(struct hnbgw_context_map *map, 
ranap_message *ranap)
+{
+       const RANAP_InitialUE_MessageIEs_t *iue_ies = 
&ranap->msg.initialUE_MessageIEs;
+       kpi_dtap_process_ul(map, iue_ies->nas_pdu.buf, iue_ies->nas_pdu.size, 
0);
+}
+
+static void kpi_ranap_process_ul_direct_transfer(struct hnbgw_context_map 
*map, ranap_message *ranap)
+{
+       const RANAP_DirectTransferIEs_t *dt_ies = &ranap->msg.directTransferIEs;
+       uint8_t sapi = 0;
+
+       if (dt_ies->presenceMask & DIRECTTRANSFERIES_RANAP_SAPI_PRESENT) {
+               if (dt_ies->sapi == RANAP_SAPI_sapi_3)
+                       sapi = 3;
+       }
+       kpi_dtap_process_ul(map, dt_ies->nas_pdu.buf, dt_ies->nas_pdu.size, 
sapi);
+}
+
 void kpi_ranap_process_ul(struct hnbgw_context_map *map, ranap_message *ranap)
 {
        switch (ranap->procedureCode) {
@@ -382,6 +415,12 @@
                 * processing of the downlink Iu Release Command.  It's not 
like the RNC/HNB has any way to
                 * refuse the release anyway. */
                break;
+       case RANAP_ProcedureCode_id_InitialUE_Message:
+               kpi_ranap_process_ul_initial_ue(map, ranap);
+               break;
+       case RANAP_ProcedureCode_id_DirectTransfer:
+               kpi_ranap_process_ul_direct_transfer(map, ranap);
+               break;
        default:
                break;
        }

--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36788?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: I3e1ad7a2aa71674a22a27c31512600f2de139032
Gerrit-Change-Number: 36788
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

Reply via email to