From 0558cfbc053ab0d3d837441223461281cf454959 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 4 Jul 2022 12:47:26 -0400 Subject: [PATCH] TT#178400 collect and report RTP sequencing metrics Change-Id: I037b1dff876eece1d3c8d4eda715587f294c1cd6 --- daemon/codec.c | 7 ++ daemon/statistics.c | 15 ++++ include/counter_stats_fields.inc | 4 + lib/codeclib.c | 1 + t/test-stats.c | 140 +++++++++++++++++++++++++++++++ 5 files changed, 167 insertions(+) diff --git a/daemon/codec.c b/daemon/codec.c index 58a793248..9e1d950c8 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -1629,9 +1629,15 @@ static int __handler_func_sequencer(struct media_packet *mp, struct transcode_pa if (func_ret != 1) __transcode_packet_free(packet); ssrc_in_p->duplicates++; + RTPE_STATS_INC(rtp_duplicates); goto out; } + if (seq_ret == 1) + RTPE_STATS_INC(rtp_seq_resets); + else if (seq_ret == 2) + RTPE_STATS_INC(rtp_reordered); + // got a new packet, run decoder while (1) { @@ -1659,6 +1665,7 @@ static int __handler_func_sequencer(struct media_packet *mp, struct transcode_pa break; ilogs(transcoding, LOG_DEBUG, "Timestamp difference too large (%llu ms) after lost packet, " "forcing next packet", ts_diff_us / 1000); + RTPE_STATS_INC(rtp_skips); } else break; diff --git a/daemon/statistics.c b/daemon/statistics.c index 12c72231c..39bc98808 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -558,6 +558,21 @@ GQueue *statistics_gather_metrics(void) { STAT_GET_PRINT(rtt_dsct, "discrete round-trip time", 1.0); STAT_GET_PRINT(packetloss, "packet loss", 1.0); STAT_GET_PRINT(jitter_measured, "jitter (measured)", 1.0); + METRIC("packets_lost", "Packets lost", UINT64F, UINT64F, + atomic64_get(&rtpe_stats_cumulative.packets_lost)); + PROM("packets_lost", "counter"); + METRIC("rtp_duplicates", "Duplicate RTP packets", UINT64F, UINT64F, + atomic64_get(&rtpe_stats_cumulative.rtp_duplicates)); + PROM("rtp_duplicates", "counter"); + METRIC("rtp_skips", "RTP sequence skips", UINT64F, UINT64F, + atomic64_get(&rtpe_stats_cumulative.rtp_skips)); + PROM("rtp_skips", "counter"); + METRIC("rtp_seq_resets", "RTP sequence resets", UINT64F, UINT64F, + atomic64_get(&rtpe_stats_cumulative.rtp_seq_resets)); + PROM("rtp_seq_resets", "counter"); + METRIC("rtp_reordered", "Out-of-order RTP packets", UINT64F, UINT64F, + atomic64_get(&rtpe_stats_cumulative.rtp_reordered)); + PROM("rtp_reordered", "counter"); HEADER(NULL, ""); HEADER("}", ""); diff --git a/include/counter_stats_fields.inc b/include/counter_stats_fields.inc index f442a9356..fd9197473 100644 --- a/include/counter_stats_fields.inc +++ b/include/counter_stats_fields.inc @@ -20,3 +20,7 @@ F(call_duration) F(call_duration2) F(total_calls_duration_intv) F(packets_lost) +F(rtp_duplicates) +F(rtp_skips) +F(rtp_seq_resets) +F(rtp_reordered) diff --git a/lib/codeclib.c b/lib/codeclib.c index 997f30159..591c1b802 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -1228,6 +1228,7 @@ int packet_sequencer_insert(packet_sequencer_t *ps, seq_packet_t *p) { seq_ok: if (g_tree_lookup(ps->packets, GINT_TO_POINTER(p->seq))) return -1; + ret = g_tree_nnodes(ps->packets) == 0 ? ret : 2; // indicates an out-of-order packet g_tree_insert(ps->packets, GINT_TO_POINTER(p->seq), p); return ret; diff --git a/t/test-stats.c b/t/test-stats.c index 44395c037..d30c9dd66 100644 --- a/t/test-stats.c +++ b/t/test-stats.c @@ -1004,6 +1004,26 @@ int main(void) { "jitter_measured_stddev\n" "0.000000\n" "0.000000\n" + "Packets lost\n" + "packets_lost\n" + "0\n" + "0\n" + "Duplicate RTP packets\n" + "rtp_duplicates\n" + "0\n" + "0\n" + "RTP sequence skips\n" + "rtp_skips\n" + "0\n" + "0\n" + "RTP sequence resets\n" + "rtp_seq_resets\n" + "0\n" + "0\n" + "Out-of-order RTP packets\n" + "rtp_reordered\n" + "0\n" + "0\n" "\n" "\n" "}\n" @@ -2012,6 +2032,26 @@ int main(void) { "jitter_measured_stddev\n" "0.000000\n" "0.000000\n" + "Packets lost\n" + "packets_lost\n" + "0\n" + "0\n" + "Duplicate RTP packets\n" + "rtp_duplicates\n" + "0\n" + "0\n" + "RTP sequence skips\n" + "rtp_skips\n" + "0\n" + "0\n" + "RTP sequence resets\n" + "rtp_seq_resets\n" + "0\n" + "0\n" + "Out-of-order RTP packets\n" + "rtp_reordered\n" + "0\n" + "0\n" "\n" "\n" "}\n" @@ -3017,6 +3057,26 @@ int main(void) { "jitter_measured_stddev\n" "0.000000\n" "0.000000\n" + "Packets lost\n" + "packets_lost\n" + "0\n" + "0\n" + "Duplicate RTP packets\n" + "rtp_duplicates\n" + "0\n" + "0\n" + "RTP sequence skips\n" + "rtp_skips\n" + "0\n" + "0\n" + "RTP sequence resets\n" + "rtp_seq_resets\n" + "0\n" + "0\n" + "Out-of-order RTP packets\n" + "rtp_reordered\n" + "0\n" + "0\n" "\n" "\n" "}\n" @@ -4035,6 +4095,26 @@ int main(void) { "jitter_measured_stddev\n" "0.000000\n" "0.000000\n" + "Packets lost\n" + "packets_lost\n" + "0\n" + "0\n" + "Duplicate RTP packets\n" + "rtp_duplicates\n" + "0\n" + "0\n" + "RTP sequence skips\n" + "rtp_skips\n" + "0\n" + "0\n" + "RTP sequence resets\n" + "rtp_seq_resets\n" + "0\n" + "0\n" + "Out-of-order RTP packets\n" + "rtp_reordered\n" + "0\n" + "0\n" "\n" "\n" "}\n" @@ -5048,6 +5128,26 @@ int main(void) { "jitter_measured_stddev\n" "0.000000\n" "0.000000\n" + "Packets lost\n" + "packets_lost\n" + "0\n" + "0\n" + "Duplicate RTP packets\n" + "rtp_duplicates\n" + "0\n" + "0\n" + "RTP sequence skips\n" + "rtp_skips\n" + "0\n" + "0\n" + "RTP sequence resets\n" + "rtp_seq_resets\n" + "0\n" + "0\n" + "Out-of-order RTP packets\n" + "rtp_reordered\n" + "0\n" + "0\n" "\n" "\n" "}\n" @@ -6056,6 +6156,26 @@ int main(void) { "jitter_measured_stddev\n" "0.000000\n" "0.000000\n" + "Packets lost\n" + "packets_lost\n" + "0\n" + "0\n" + "Duplicate RTP packets\n" + "rtp_duplicates\n" + "0\n" + "0\n" + "RTP sequence skips\n" + "rtp_skips\n" + "0\n" + "0\n" + "RTP sequence resets\n" + "rtp_seq_resets\n" + "0\n" + "0\n" + "Out-of-order RTP packets\n" + "rtp_reordered\n" + "0\n" + "0\n" "\n" "\n" "}\n" @@ -7066,6 +7186,26 @@ int main(void) { "jitter_measured_stddev\n" "0.000000\n" "0.000000\n" + "Packets lost\n" + "packets_lost\n" + "0\n" + "0\n" + "Duplicate RTP packets\n" + "rtp_duplicates\n" + "0\n" + "0\n" + "RTP sequence skips\n" + "rtp_skips\n" + "0\n" + "0\n" + "RTP sequence resets\n" + "rtp_seq_resets\n" + "0\n" + "0\n" + "Out-of-order RTP packets\n" + "rtp_reordered\n" + "0\n" + "0\n" "\n" "\n" "}\n"