6 * Copyright 2008, Ericsson AB
7 * By Balint Reczey <balint.reczey@ericsson.com>
9 * based on gtk/rtp_stream_dlg.c
10 * Copyright 2003, Alcatel Business Systems
11 * By Lars Ruoff <lars.ruoff@gmx.net>
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs <gerald@wireshark.org>
15 * Copyright 1998 Gerald Combs
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version 2
20 * of the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 * This TAP provides statistics for RTP streams
42 #ifdef HAVE_SYS_TYPES_H
43 # include <sys/types.h>
48 #include "epan/packet_info.h"
49 #include "epan/value_string.h"
51 #include <epan/rtp_pt.h>
52 #include <epan/stat_cmd_args.h>
53 #include <epan/addr_resolv.h>
55 #include "tap-rtp-common.h"
57 /* The one and only global rtpstream_tapinfo_t structure for tshark and wireshark.
59 static rtpstream_tapinfo_t the_tapinfo_struct =
60 {0, NULL, 0, TAP_ANALYSE, NULL, NULL, NULL, 0, FALSE};
63 rtp_streams_stat_draw(void *arg _U_)
68 rtp_stream_info_t* strinfo;
75 printf("========================= RTP Streams ========================\n");
76 printf("%15s %5s %15s %5s %10s %16s %5s %12s %15s %15s %15s %s\n","Src IP addr", "Port", "Dest IP addr", "Port", "SSRC", "Payload", "Pkts", "Lost", "Max Delta(ms)", "Max Jitter(ms)", "Mean Jitter(ms)", "Problems?");
78 /* save the current locale */
79 savelocale = setlocale(LC_NUMERIC, NULL);
80 /* switch to "C" locale to avoid problems with localized decimal separators
81 in g_snprintf("%f") functions */
82 setlocale(LC_NUMERIC, "C");
84 list = the_tapinfo_struct.strinfo_list;
86 list = g_list_first(list);
89 strinfo = (rtp_stream_info_t*)(list->data);
93 if(strinfo->info_payload_type_str != NULL){
94 payload_type = g_strdup(strinfo->info_payload_type_str);
96 payload_type = g_strdup_printf("Unknown(%u)",strinfo->pt);
100 payload_type = g_strdup(val_to_str(strinfo->pt, rtp_payload_type_vals,
104 /* packet count, lost packets */
105 expected = (strinfo->rtp_stats.stop_seq_nr + strinfo->rtp_stats.cycles*65536)
106 - strinfo->rtp_stats.start_seq_nr + 1;
107 lost = expected - strinfo->rtp_stats.total_nr;
109 perc = (double)(lost*100)/(double)expected;
114 printf("%15s %5u %15s %5u 0x%08X %16s %5u %5d (%.1f%%) %15.2f %15.2f %15.2f %s\n",
115 get_addr_name(&(strinfo->src_addr)),
117 get_addr_name(&(strinfo->dest_addr)),
123 strinfo->rtp_stats.max_delta,
124 strinfo->rtp_stats.max_jitter,
125 strinfo->rtp_stats.mean_jitter,
126 (strinfo->problem)?"X":"");
128 list = g_list_next(list);
133 printf("==============================================================\n");
134 /* restore previous locale setting */
135 setlocale(LC_NUMERIC, savelocale);
140 rtp_streams_stat_init(const char *optarg _U_, void* userdata _U_)
145 register_tap_listener("rtp", &the_tapinfo_struct, NULL, 0,
148 rtp_streams_stat_draw);
152 g_string_free(err_p, TRUE);
160 register_tap_listener_rtp_streams(void)
162 register_stat_cmd_arg("rtp,streams", rtp_streams_stat_init,NULL);