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/.
dexter gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/7396 stats: use libosmocore counter for in/out_stream.err_ts_counter The two counters: in_stream.err_ts_counter and out_stream.err_ts_counter are still handcoded. To make them better accessible they should be replaced with libosmocore counters. - replace state.in_stream.err_ts_counter with libosmocore counter - replace state.in_stream.err_ts_counter with libosmocore counter Change-Id: I3ff73cac521e66729eac4ea65054de7df338dab5 Related: OS#2517 --- M include/osmocom/mgcp/mgcp_internal.h M src/libosmo-mgcp/mgcp_conn.c M src/libosmo-mgcp/mgcp_network.c M src/libosmo-mgcp/mgcp_stat.c M src/libosmo-mgcp/mgcp_vty.c M tests/mgcp/mgcp_test.c 6 files changed, 39 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/96/7396/1 diff --git a/include/osmocom/mgcp/mgcp_internal.h b/include/osmocom/mgcp/mgcp_internal.h index 0da2c56..e0a20bf 100644 --- a/include/osmocom/mgcp/mgcp_internal.h +++ b/include/osmocom/mgcp/mgcp_internal.h @@ -45,7 +45,7 @@ uint32_t ssrc; uint16_t last_seq; uint32_t last_timestamp; - uint32_t err_ts_counter; + struct osmo_counter *err_ts_ctr; int32_t last_tsdelta; uint32_t last_arrival_time; }; diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c index 998dbc5..a2bc35f 100644 --- a/src/libosmo-mgcp/mgcp_conn.c +++ b/src/libosmo-mgcp/mgcp_conn.c @@ -26,6 +26,7 @@ #include <osmocom/mgcp/mgcp_common.h> #include <osmocom/mgcp/mgcp_endp.h> #include <osmocom/gsm/gsm_utils.h> +#include <osmocom/core/counter.h> #include <ctype.h> /* Allocate a new connection identifier. According to RFC3435, they must @@ -87,6 +88,7 @@ static void mgcp_rtp_conn_init(struct mgcp_conn_rtp *conn_rtp, struct mgcp_conn *conn) { struct mgcp_rtp_end *end = &conn_rtp->end; + char *counter_name; conn_rtp->type = MGCP_RTP_DEFAULT; conn_rtp->osmux.allocated_cid = -1; @@ -108,11 +110,24 @@ mgcp_rtp_codec_init(&end->codec); mgcp_rtp_codec_init(&end->alt_codec); + + /* Allocate counters */ + counter_name = + talloc_asprintf(conn, "conn_%s_stream_in_err_ts_ctr", conn->id); + conn_rtp->state.in_stream.err_ts_ctr = osmo_counter_alloc(counter_name); + counter_name = + talloc_asprintf(conn, "conn_%s_stream_out_err_ts_ctr", conn->id); + conn_rtp->state.out_stream.err_ts_ctr = + osmo_counter_alloc(counter_name); } /* Cleanup rtp connection struct */ static void mgcp_rtp_conn_cleanup(struct mgcp_conn_rtp *conn_rtp) { + /* Remove counters */ + osmo_counter_free(conn_rtp->state.in_stream.err_ts_ctr); + osmo_counter_free(conn_rtp->state.out_stream.err_ts_ctr); + osmux_disable_conn(conn_rtp); osmux_release_cid(conn_rtp); mgcp_free_rtp_port(&conn_rtp->end); diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c index 6923b97..64c7ef2 100644 --- a/src/libosmo-mgcp/mgcp_network.c +++ b/src/libosmo-mgcp/mgcp_network.c @@ -222,7 +222,7 @@ if (seq == sstate->last_seq) { if (timestamp != sstate->last_timestamp) { - sstate->err_ts_counter += 1; + osmo_counter_inc(sstate->err_ts_ctr); LOGP(DRTP, LOGL_ERROR, "The %s timestamp delta is != 0 but the sequence " "number %d is the same, " @@ -272,7 +272,7 @@ ts_alignment_error(sstate, state->packet_duration, timestamp); if (timestamp_error) { - sstate->err_ts_counter += 1; + osmo_counter_inc(sstate->err_ts_ctr); LOGP(DRTP, LOGL_NOTICE, "The %s timestamp has an alignment error of %d " "on 0x%x SSRC: %u " @@ -505,13 +505,16 @@ mgcp_rtp_annex_count(endp, state, seq, transit, ssrc); if (!state->initialized) { + /* FIXME: Move this initialization to mgcp.conn.c */ state->initialized = 1; state->in_stream.last_seq = seq - 1; state->in_stream.ssrc = state->patch.orig_ssrc = ssrc; state->in_stream.last_tsdelta = 0; state->packet_duration = mgcp_rtp_packet_duration(endp, rtp_end); - state->out_stream = state->in_stream; + state->out_stream.last_seq = seq - 1; + state->out_stream.ssrc = state->patch.orig_ssrc = ssrc; + state->out_stream.last_tsdelta = 0; state->out_stream.last_timestamp = timestamp; state->out_stream.ssrc = ssrc - 1; /* force output SSRC change */ LOGP(DRTP, LOGL_INFO, diff --git a/src/libosmo-mgcp/mgcp_stat.c b/src/libosmo-mgcp/mgcp_stat.c index 581130c..85c4155 100644 --- a/src/libosmo-mgcp/mgcp_stat.c +++ b/src/libosmo-mgcp/mgcp_stat.c @@ -87,9 +87,9 @@ if (conn->conn->endp->cfg->osmux != OSMUX_USAGE_OFF) { /* Error Counter */ nchars = snprintf(str, str_len, - "\r\nX-Osmo-CP: EC TI=%u, TO=%u", - conn->state.in_stream.err_ts_counter, - conn->state.out_stream.err_ts_counter); + "\r\nX-Osmo-CP: EC TI=%lu, TO=%lu", + osmo_counter_get(conn->state.in_stream.err_ts_ctr), + osmo_counter_get(conn->state.out_stream.err_ts_ctr)); if (nchars < 0 || nchars >= str_len) goto truncate; diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c index 14ecd17..bedb67b 100644 --- a/src/libosmo-mgcp/mgcp_vty.c +++ b/src/libosmo-mgcp/mgcp_vty.c @@ -160,15 +160,16 @@ struct mgcp_rtp_codec *codec = &end->codec; vty_out(vty, - " Timestamp Errs: %d->%d%s" + " Timestamp Errs: %lu->%lu%s" " Dropped Packets: %d%s" " Payload Type: %d Rate: %u Channels: %d %s" " Frame Duration: %u Frame Denominator: %u%s" " FPP: %d Packet Duration: %u%s" " FMTP-Extra: %s Audio-Name: %s Sub-Type: %s%s" " Output-Enabled: %d Force-PTIME: %d%s", - state->in_stream.err_ts_counter, - state->out_stream.err_ts_counter, VTY_NEWLINE, + osmo_counter_get(state->in_stream.err_ts_ctr), + osmo_counter_get(state->out_stream.err_ts_ctr), + VTY_NEWLINE, end->stats.dropped_packets, VTY_NEWLINE, codec->payload_type, codec->rate, codec->channels, VTY_NEWLINE, codec->frame_duration_num, codec->frame_duration_den, diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c index e1e6290..ef3b807 100644 --- a/tests/mgcp/mgcp_test.c +++ b/tests/mgcp/mgcp_test.c @@ -1142,6 +1142,9 @@ memset(&endp, 0, sizeof(endp)); memset(&state, 0, sizeof(state)); + state.in_stream.err_ts_ctr = osmo_counter_alloc("test-counter-in"); + state.out_stream.err_ts_ctr = osmo_counter_alloc("test-counter-out"); + endp.type = &ep_typeset.rtp; trunk.vty_number_endpoints = 1; @@ -1186,18 +1189,20 @@ state.in_stream.last_tsdelta, state.in_stream.last_seq); printf("Out TS change: %d, dTS: %d, Seq change: %d, " - "TS Err change: in %+d, out %+d\n", + "TS Err change: in +%lu, out +%lu\n", state.out_stream.last_timestamp - last_timestamp, state.out_stream.last_tsdelta, state.out_stream.last_seq - last_seqno, - state.in_stream.err_ts_counter - last_in_ts_err_cnt, - state.out_stream.err_ts_counter - last_out_ts_err_cnt); + osmo_counter_get(state.in_stream.err_ts_ctr) - + last_in_ts_err_cnt, + osmo_counter_get(state.out_stream.err_ts_ctr) - + last_out_ts_err_cnt); printf("Stats: Jitter = %u, Transit = %d\n", calc_jitter(&state), state.stats.transit); - last_in_ts_err_cnt = state.in_stream.err_ts_counter; - last_out_ts_err_cnt = state.out_stream.err_ts_counter; + last_in_ts_err_cnt = osmo_counter_get(state.in_stream.err_ts_ctr); + last_out_ts_err_cnt = osmo_counter_get(state.out_stream.err_ts_ctr); last_timestamp = state.out_stream.last_timestamp; last_seqno = state.out_stream.last_seq; } -- To view, visit https://gerrit.osmocom.org/7396 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3ff73cac521e66729eac4ea65054de7df338dab5 Gerrit-PatchSet: 1 Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Owner: dexter <pmaier at sysmocom.de>