From 668f8df3be7f644056d16ea4a7fd7929429da0b4 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 21 Sep 2015 11:18:06 +0200 Subject: audio/rsl: Include statistics for one call Use the new libosmo-abis API to query the session for the statistics and then send it as a TLV element to the BSC. This can be used to do post processing about the call. E.g to figure out if no audio arrived at all. --- src/common/rsl.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/common/rsl.c b/src/common/rsl.c index f31b2e35..9f1cf29b 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -1191,6 +1191,37 @@ static int rsl_rx_sacch_inf_mod(struct msgb *msg) /* * ip.access related messages */ +static void rsl_add_rtp_stats(struct gsm_lchan *lchan, struct msgb *msg) +{ + struct ipa_stats { + uint32_t packets_sent; + uint32_t octets_sent; + uint32_t packets_recv; + uint32_t octets_recv; + uint32_t packets_lost; + uint32_t arrival_jitter; + uint32_t avg_tx_delay; + } __attribute__((packed)); + + struct ipa_stats stats; + + + memset(&stats, 0, sizeof(stats)); + + + osmo_rtp_socket_stats(lchan->abis_ip.rtp_socket, + &stats.packets_sent, &stats.octets_sent, + &stats.packets_recv, &stats.octets_recv, + &stats.packets_lost, &stats.arrival_jitter); + /* convert to network byte order */ + stats.packets_sent = htonl(stats.packets_sent); + stats.octets_sent = htonl(stats.octets_sent); + stats.packets_recv = htonl(stats.packets_recv); + stats.octets_recv = htonl(stats.octets_recv); + stats.packets_lost = htonl(stats.packets_lost); + + msgb_tlv_put(msg, RSL_IE_IPAC_CONN_STAT, sizeof(stats), (uint8_t *) &stats); +} int rsl_tx_ipac_dlcx_ind(struct gsm_lchan *lchan, uint8_t cause) { @@ -1204,6 +1235,7 @@ int rsl_tx_ipac_dlcx_ind(struct gsm_lchan *lchan, uint8_t cause) return -ENOMEM; msgb_tv16_put(nmsg, RSL_IE_IPAC_CONN_ID, htons(lchan->abis_ip.conn_id)); + rsl_add_rtp_stats(lchan, nmsg); msgb_tlv_put(nmsg, RSL_IE_CAUSE, 1, &cause); rsl_ipa_push_hdr(nmsg, RSL_MT_IPAC_DLCX_IND, gsm_lchan2chan_nr(lchan)); @@ -1275,8 +1307,10 @@ static int rsl_tx_ipac_dlcx_ack(struct gsm_lchan *lchan, int inc_conn_id) if (!msg) return -ENOMEM; - if (inc_conn_id) + if (inc_conn_id) { msgb_tv_put(msg, RSL_IE_IPAC_CONN_ID, lchan->abis_ip.conn_id); + rsl_add_rtp_stats(lchan, msg); + } rsl_ipa_push_hdr(msg, RSL_MT_IPAC_DLCX_ACK, chan_nr); msg->trx = lchan->ts->trx; @@ -1555,11 +1589,11 @@ static int rsl_rx_ipac_dlcx(struct msgb *msg) if (TLVP_PRESENT(&tp, RSL_IE_IPAC_CONN_ID)) inc_conn_id = 1; + rc = rsl_tx_ipac_dlcx_ack(lchan, inc_conn_id); osmo_rtp_socket_free(lchan->abis_ip.rtp_socket); lchan->abis_ip.rtp_socket = NULL; msgb_queue_flush(&lchan->dl_tch_queue); - - return rsl_tx_ipac_dlcx_ack(lchan, inc_conn_id); + return rc; } /* -- cgit v1.2.3