diff options
author | Balint Reczey <balint.reczey@ericsson.com> | 2008-12-31 17:47:36 +0000 |
---|---|---|
committer | Balint Reczey <balint.reczey@ericsson.com> | 2008-12-31 17:47:36 +0000 |
commit | ae5112393998f99710c97f4dd58b5c16fd2b1335 (patch) | |
tree | e7635763be0c96dbad8b8cfc7630d26c21758a14 /tap-megacostat.c | |
parent | 0e26b510ea39be15ed8a760fc4b2ef7b1badcf1a (diff) |
Service response time statistics for MEGACO (CLI part).
Refactored GUI part to avoid code duplication.
svn path=/trunk/; revision=27143
Diffstat (limited to 'tap-megacostat.c')
-rw-r--r-- | tap-megacostat.c | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/tap-megacostat.c b/tap-megacostat.c new file mode 100644 index 0000000000..efd431ab4f --- /dev/null +++ b/tap-megacostat.c @@ -0,0 +1,136 @@ +/* tap-megacostat.c + * mgcpstat 2003 Lars Roland + * Copyright 2008, Ericsson AB + * By Balint Reczey <balint.reczey@ericsson.com> + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#include <string.h> +#include "epan/packet_info.h" +#include <epan/tap.h> +#include <epan/stat_cmd_args.h> +#include "epan/value_string.h" +#include "register.h" +#include "epan/gcp.h" +#include "timestats.h" + +#include "tap-megaco-common.h" + + + +static void +megacostat_draw(void *pms) +{ + megacostat_t *ms=(megacostat_t *)pms; + int i; + + /* printing results */ + printf("\n"); + printf("=====================================================================================================\n"); + printf("MEGACO Response Time Delay (RTD) Statistics:\n"); + printf("Filter for statistics: %s\n",ms->filter?ms->filter:""); + printf("Duplicate requests: %u\n",ms->req_dup_num); + printf("Duplicate responses: %u\n",ms->rsp_dup_num); + printf("Open requests: %u\n",ms->open_req_num); + printf("Discarded responses: %u\n",ms->disc_rsp_num); + printf(" Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame |\n"); + for(i=0;i<NUM_TIMESTATS;i++) { + if(ms->rtd[i].num) { + printf("%5s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u |\n", + val_to_str(i,megaco_message_type,"Other"),ms->rtd[i].num, + nstime_to_msec(&(ms->rtd[i].min)), nstime_to_msec(&(ms->rtd[i].max)), + get_average(&(ms->rtd[i].tot), ms->rtd[i].num), + ms->rtd[i].min_num, ms->rtd[i].max_num + ); + } + } + printf("=====================================================================================================\n"); +} + + +static void +megacostat_init(const char *optarg, void* userdata _U_) +{ + megacostat_t *ms; + int i; + const char *filter=NULL; + GString *error_string; + + if(!strncmp(optarg,"megaco,rtd,",11)){ + filter=optarg+11; + } else { + filter=""; + } + + ms=g_malloc(sizeof(megacostat_t)); + ms->filter=g_strdup(filter); + + for(i=0;i<NUM_TIMESTATS;i++) { + ms->rtd[i].num=0; + ms->rtd[i].min_num=0; + ms->rtd[i].max_num=0; + ms->rtd[i].min.secs=0; + ms->rtd[i].min.nsecs=0; + ms->rtd[i].max.secs=0; + ms->rtd[i].max.nsecs=0; + ms->rtd[i].tot.secs=0; + ms->rtd[i].tot.nsecs=0; + } + + ms->open_req_num=0; + ms->disc_rsp_num=0; + ms->req_dup_num=0; + ms->rsp_dup_num=0; + + error_string=register_tap_listener("megaco", ms, filter, NULL, megacostat_packet, megacostat_draw); + if(error_string){ + /* error, we failed to attach to the tap. clean up */ + g_free(ms->filter); + g_free(ms); + + fprintf(stderr, "tshark: Couldn't register megaco,rtd tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); + exit(1); + } +} + + +void +register_tap_listener_megacostat(void) +{ + /* We don't register this tap, if we don't have the megaco plugin loaded.*/ + if (find_tap_id("megaco")) { + register_stat_cmd_arg("megaco,rtd", megacostat_init, NULL); + } +} + |