From 0e778d686799ee3a87372442954c13cb5908827f Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 29 Mar 2019 09:51:00 +0100 Subject: [PATCH] rtp: log additional statistics --- include/villas/stats.h | 9 +++++++++ lib/nodes/rtp.cpp | 12 +++++++++++- lib/stats.c | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/villas/stats.h b/include/villas/stats.h index ec2fdcc16..c8e40e73b 100644 --- a/include/villas/stats.h +++ b/include/villas/stats.h @@ -49,9 +49,18 @@ enum stats_metric { STATS_METRIC_SMPS_SKIPPED, /**< Counter for skipped samples due to hooks. */ STATS_METRIC_SMPS_REORDERED, /**< Counter for reordered samples. */ + + /* Timings */ STATS_METRIC_GAP_SAMPLE, /**< Histogram for inter sample timestamps (as sent by remote). */ STATS_METRIC_GAP_RECEIVED, /**< Histogram for inter sample arrival time (as seen by this instance). */ STATS_METRIC_OWD, /**< Histogram for one-way-delay (OWD) of received samples. */ + + /* RTP metrics */ + STATS_METRIC_RTP_LOSS_FRACTION, /**< Fraction lost since last RTP SR/RR. */ + STATS_METRIC_RTP_PKTS_LOST, /**< Cumul. no. pkts lost. */ + STATS_METRIC_RTP_JITTER, /**< Interarrival jitter. */ + + /* Always last */ STATS_METRIC_COUNT /**< Just here to have an updated number of statistics. */ }; diff --git a/lib/nodes/rtp.cpp b/lib/nodes/rtp.cpp index a3250b08f..5641965a9 100644 --- a/lib/nodes/rtp.cpp +++ b/lib/nodes/rtp.cpp @@ -42,6 +42,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -342,7 +343,16 @@ static void rtcp_handler(const struct sa *src, struct rtcp_msg *msg, void *arg) if (msg->hdr.count > 0) { const struct rtcp_rr *rr = &msg->r.sr.rrv[0]; debug(5, "RTP: fraction lost = %d", rr->fraction); - rtp_aimd(n, (double) rr->fraction / 256); + + double loss = (double) rr->fraction / 256; + + rtp_aimd(n, loss); + + if (n->stats) { + stats_update(n->stats, STATS_METRIC_RTP_PKTS_LOST, rr->lost); + stats_update(n->stats, STATS_METRIC_RTP_LOSS_FRACTION, loss); + stats_update(n->stats, STATS_METRIC_RTP_JITTER, rr->jitter); + } } else debug(5, "RTCP: Received sender report with zero reception reports"); diff --git a/lib/stats.c b/lib/stats.c index 88ef632f6..04609c663 100644 --- a/lib/stats.c +++ b/lib/stats.c @@ -37,6 +37,9 @@ struct stats_metric_description stats_metrics[] = { { "gap_sent", STATS_METRIC_GAP_SAMPLE, "seconds", "Inter-message timestamps (as sent by remote)", 25 }, { "gap_received", STATS_METRIC_GAP_RECEIVED, "seconds", "Inter-message arrival time (as received by this instance)", 25 }, { "owd", STATS_METRIC_OWD, "seconds", "One-way-delay (OWD) of received messages", 25 }, + { "rtp.loss_fraction", STATS_METRIC_RTP_LOSS_FRACTION, "percent", "Fraction lost since last RTP SR/RR.", 25 }, + { "rtp.pkts_lost", STATS_METRIC_RTP_PKTS_LOST, "packets", "Cumulative number of packtes lost", 25 }, + { "rtp.jitter", STATS_METRIC_RTP_JITTER, "seconds", "Interarrival jitter", 25 }, }; struct stats_type_description stats_types[] = {