Change in osmo-mgw[master]: Update per-trunk global packet/byte counters in real-time

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Mar 8 16:58:13 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/17425 )

Change subject: Update per-trunk global packet/byte counters in real-time
......................................................................

Update per-trunk global packet/byte counters in real-time

We used to update only the per-connection rx/tx packet/byte counters
on-the-fly, but not the per-trunk global counters.  The latter would
only be updated at the end of a connection.  As MGCP connections
can last quite long (think of a long phone call) this is maybe
not the best of ideas.

Note: The all_rtp:err_tstmp_in and all_rt:err_tstmp_out are still
only updated at the end of a connection.

Change-Id: Ib3866cb8149d3257fcf39733846c97c33881c4ee
Related: OS#4437
---
M src/libosmo-mgcp/mgcp_conn.c
M src/libosmo-mgcp/mgcp_network.c
2 files changed, 28 insertions(+), 10 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index 60a1700..7a86274 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -259,7 +259,6 @@
 {
 	struct rate_ctr_group *all_stats = trunk->all_rtp_conn_stats;
 	struct rate_ctr_group *conn_stats = conn_rtp->rate_ctr_group;
-	int i;
 
 	if (all_stats == NULL || conn_stats == NULL)
 		return;
@@ -269,8 +268,11 @@
 	 * All other counters in both counter groups correspond to each other. */
 	OSMO_ASSERT(conn_stats->desc->num_ctr + 1 == all_stats->desc->num_ctr);
 
-	for (i = 0; i < conn_stats->desc->num_ctr; i++)
-		rate_ctr_add(&all_stats->ctr[i], conn_stats->ctr[i].current);
+	/* all other counters are [now] updated in real-time */
+	rate_ctr_add(&all_stats->ctr[IN_STREAM_ERR_TSTMP_CTR],
+		     conn_stats->ctr[IN_STREAM_ERR_TSTMP_CTR].current);
+	rate_ctr_add(&all_stats->ctr[OUT_STREAM_ERR_TSTMP_CTR],
+		     conn_stats->ctr[OUT_STREAM_ERR_TSTMP_CTR].current);
 
 	rate_ctr_inc(&all_stats->ctr[RTP_NUM_CONNECTIONS]);
 }
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 53cdc06..cd60ce2 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -57,6 +57,22 @@
 	MGCP_PROTO_RTCP,
 };
 
+static void rtpconn_rate_ctr_add(struct mgcp_conn_rtp *conn_rtp, struct mgcp_endpoint *endp,
+				 int id, int inc)
+{
+	struct rate_ctr_group *conn_stats = conn_rtp->rate_ctr_group;
+	struct rate_ctr_group *trunk_stats = endp->tcfg->all_rtp_conn_stats;
+
+	/* add to both the per-connection and the per-trunk global stats */
+	rate_ctr_add(&conn_stats->ctr[id], inc);
+	rate_ctr_add(&trunk_stats->ctr[id], inc);
+}
+
+static void rtpconn_rate_ctr_inc(struct mgcp_conn_rtp *conn_rtp, struct mgcp_endpoint *endp, int id)
+{
+	rtpconn_rate_ctr_add(conn_rtp, endp, id, 1);
+}
+
 /*! Determine the local rtp bind IP-address.
  *  \param[out] addr caller provided memory to store the resulting IP-Address
  *  \param[in] endp mgcp endpoint, that holds a copy of the VTY parameters
@@ -845,7 +861,7 @@
 	dest_name = conn_dst->conn->name;
 
 	if (!rtp_end->output_enabled) {
-		rate_ctr_inc(&conn_dst->rate_ctr_group->ctr[RTP_DROPPED_PACKETS_CTR]);
+		rtpconn_rate_ctr_inc(conn_dst, endp, RTP_DROPPED_PACKETS_CTR);
 		LOGPENDP(endp, DRTP, LOGL_DEBUG,
 			 "output disabled, drop to %s %s "
 			 "rtp_port:%u rtcp_port:%u\n",
@@ -924,8 +940,8 @@
 			if (len <= 0)
 				return len;
 
-			rate_ctr_inc(&conn_dst->rate_ctr_group->ctr[RTP_PACKETS_TX_CTR]);
-			rate_ctr_add(&conn_dst->rate_ctr_group->ctr[RTP_OCTETS_TX_CTR], len);
+			rtpconn_rate_ctr_inc(conn_dst, endp, RTP_PACKETS_TX_CTR);
+			rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len);
 
 			nbytes += len;
 			buflen = cont;
@@ -942,8 +958,8 @@
 				    &rtp_end->addr,
 				    rtp_end->rtcp_port, buf, len);
 
-		rate_ctr_inc(&conn_dst->rate_ctr_group->ctr[RTP_PACKETS_TX_CTR]);
-		rate_ctr_add(&conn_dst->rate_ctr_group->ctr[RTP_OCTETS_TX_CTR], len);
+		rtpconn_rate_ctr_inc(conn_dst, endp, RTP_PACKETS_TX_CTR);
+		rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len);
 
 		return len;
 	}
@@ -1189,8 +1205,8 @@
 	}
 
 	/* Increment RX statistics */
-	rate_ctr_inc(&conn->rate_ctr_group->ctr[RTP_PACKETS_RX_CTR]);
-	rate_ctr_add(&conn->rate_ctr_group->ctr[RTP_OCTETS_RX_CTR], rc);
+	rtpconn_rate_ctr_inc(conn, endp, RTP_PACKETS_RX_CTR);
+	rtpconn_rate_ctr_add(conn, endp, RTP_OCTETS_RX_CTR, rc);
 
 	/* Forward a copy of the RTP data to a debug ip/port */
 	forward_data(fd->fd, &conn->tap_in, buf, rc);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/17425
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ib3866cb8149d3257fcf39733846c97c33881c4ee
Gerrit-Change-Number: 17425
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200308/e82e96e9/attachment.htm>


More information about the gerrit-log mailing list