2008-10-06 20:11:44 +00:00
|
|
|
/* gtp_stat.c
|
|
|
|
* gtp_stat 2008 Kari Tiirikainen
|
|
|
|
* Largely based on ldap_stat by Ronnie Sahlberg, all mistakes added by KTi
|
|
|
|
*
|
|
|
|
* 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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-10-06 20:11:44 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 01:48:30 +00:00
|
|
|
#include "config.h"
|
2008-10-06 20:11:44 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <epan/packet_info.h>
|
|
|
|
#include <epan/value_string.h>
|
|
|
|
#include <epan/tap.h>
|
|
|
|
#include <epan/dissectors/packet-gtp.h>
|
|
|
|
|
2012-01-16 01:07:52 +00:00
|
|
|
#include "ui/simple_dialog.h"
|
2008-10-06 20:11:44 +00:00
|
|
|
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/gui_utils.h"
|
|
|
|
#include "ui/gtk/dlg_utils.h"
|
|
|
|
#include "ui/gtk/service_response_time_table.h"
|
|
|
|
#include "ui/gtk/tap_param_dlg.h"
|
|
|
|
#include "ui/gtk/main.h"
|
2008-10-06 20:11:44 +00:00
|
|
|
|
2011-07-21 20:12:08 +00:00
|
|
|
|
2014-01-17 19:21:41 +00:00
|
|
|
void register_tap_listener_gtkgtpstat(void);
|
|
|
|
|
2008-10-06 20:11:44 +00:00
|
|
|
/* used to keep track of the statistics for an entire program interface */
|
|
|
|
typedef struct _gtpstat_t {
|
|
|
|
GtkWidget *win;
|
|
|
|
srt_stat_table gtp_srt_table;
|
|
|
|
} gtpstat_t;
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtpstat_set_title(gtpstat_t *gtp)
|
|
|
|
{
|
2012-06-03 22:03:05 +00:00
|
|
|
set_window_title(gtp->win, "GTP Control Plane Response Time statistics");
|
2008-10-06 20:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtpstat_reset(void *pgtp)
|
|
|
|
{
|
|
|
|
gtpstat_t *gtp=(gtpstat_t *)pgtp;
|
|
|
|
|
|
|
|
reset_srt_table_data(>p->gtp_srt_table);
|
|
|
|
gtpstat_set_title(gtp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gtpstat_packet(void *pgtp, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi)
|
|
|
|
{
|
2013-12-08 23:16:06 +00:00
|
|
|
const gtp_msg_hash_t *gtp=(const gtp_msg_hash_t *)psi;
|
2008-10-06 20:11:44 +00:00
|
|
|
gtpstat_t *fs=(gtpstat_t *)pgtp;
|
2010-01-29 23:17:32 +00:00
|
|
|
int idx=0;
|
2008-10-06 20:11:44 +00:00
|
|
|
|
|
|
|
/* we are only interested in reply packets */
|
|
|
|
if(gtp->is_request){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* if we have not seen the request, just ignore it */
|
|
|
|
if(!gtp->req_frame){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only use the commands we know how to handle, this is not a comprehensive list */
|
2010-01-29 23:17:32 +00:00
|
|
|
/* Redoing the message indexing is bit reduntant, */
|
|
|
|
/* but using message type as such would yield a long gtp_srt_table. */
|
|
|
|
/* Only a fraction of the messages are matchable req/resp pairs, */
|
|
|
|
/* it just doesn't feel feasible. */
|
2008-10-06 20:11:44 +00:00
|
|
|
|
|
|
|
switch(gtp->msgtype){
|
2010-01-29 23:17:32 +00:00
|
|
|
case GTP_MSG_ECHO_REQ: idx=0;
|
2010-08-30 16:10:01 +00:00
|
|
|
break;
|
2010-01-29 23:17:32 +00:00
|
|
|
case GTP_MSG_CREATE_PDP_REQ: idx=1;
|
|
|
|
break;
|
|
|
|
case GTP_MSG_UPDATE_PDP_REQ: idx=2;
|
|
|
|
break;
|
|
|
|
case GTP_MSG_DELETE_PDP_REQ: idx=3;
|
|
|
|
break;
|
2008-10-06 20:11:44 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-29 23:17:32 +00:00
|
|
|
add_srt_table_data(&fs->gtp_srt_table, idx, >p->req_time, pinfo);
|
2008-10-06 20:11:44 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtpstat_draw(void *pgtp)
|
|
|
|
{
|
|
|
|
gtpstat_t *gtp=(gtpstat_t *)pgtp;
|
|
|
|
|
|
|
|
draw_srt_table_data(>p->gtp_srt_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
|
|
|
{
|
|
|
|
gtpstat_t *gtp=(gtpstat_t *)data;
|
|
|
|
|
|
|
|
remove_tap_listener(gtp);
|
|
|
|
|
|
|
|
free_srt_table_data(>p->gtp_srt_table);
|
|
|
|
g_free(gtp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2012-12-05 15:56:36 +00:00
|
|
|
gtk_gtpstat_init(const char *opt_arg, void *userdata _U_)
|
2008-10-06 20:11:44 +00:00
|
|
|
{
|
|
|
|
gtpstat_t *gtp;
|
|
|
|
const char *filter=NULL;
|
|
|
|
GtkWidget *label;
|
|
|
|
char *filter_string;
|
|
|
|
GString *error_string;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *close_bt;
|
|
|
|
|
2012-12-05 15:56:36 +00:00
|
|
|
if(!strncmp(opt_arg,"gtp,",4)){
|
|
|
|
filter=opt_arg+4;
|
2008-10-06 20:11:44 +00:00
|
|
|
} else {
|
|
|
|
filter="gtp"; /*NULL doesn't work here like in LDAP. Too little time/lazy to find out why ?*/
|
|
|
|
}
|
|
|
|
|
2013-03-21 02:58:59 +00:00
|
|
|
gtp=(gtpstat_t *)g_malloc(sizeof(gtpstat_t));
|
2008-10-06 20:11:44 +00:00
|
|
|
|
2009-06-21 20:42:07 +00:00
|
|
|
gtp->win = dlg_window_new("gtp-stat"); /* transient_for top_level */
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(gtp->win), TRUE);
|
|
|
|
|
Add a "Sum" column to the Service Response Time (SRT) window.
The Service Response Time (SRT) window currently provides the
columns: Index, Procedure, Calls, Min SRT, Max SRT, and Avg SRT.
A Sum column has been found useful in some customer situations
to understand the total time spent doing a set of procedures.
For example, in one case we were trying to isolate whether most
time was being spent on a client thread or in the act of making
outbound calls. We knew the start and end time of the client call,
so with the "Sum" of time spent in that period, we could isolate
a particular set of procedures driving the slow down.
Additional changes made in this patch:
* Add " (s)" to Min, Max, Avg, and Sum columns to make it clear
that times are in seconds.
* Refactor out width and height constants used in calls to
gtk_window_set_default_size in most of the SRT users into
#define SRT_PREFERRED_WIDTH and SRT_PREFERRED_HEIGHT. Also
increase the common width of 550 to 650 to account for the
additional column.
Change-Id: I20f152eecbcd0bbf69f71c6c6b9f9463e8867e23
Reviewed-on: https://code.wireshark.org/review/7047
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-10 01:20:38 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(gtp->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT);
|
2008-10-06 20:11:44 +00:00
|
|
|
gtpstat_set_title(gtp);
|
|
|
|
|
2012-04-21 16:40:14 +00:00
|
|
|
vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
2008-10-06 20:11:44 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(gtp->win), vbox);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
|
|
|
|
|
|
|
label=gtk_label_new("GTP Service Response Time statistics");
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
|
|
|
|
label=gtk_label_new(filter_string);
|
|
|
|
g_free(filter_string);
|
|
|
|
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
label=gtk_label_new("GTP Requests");
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* We must display TOP LEVEL Widget before calling init_srt_table() */
|
|
|
|
gtk_widget_show_all(gtp->win);
|
|
|
|
|
|
|
|
init_srt_table(>p->gtp_srt_table, 4, vbox, NULL);
|
|
|
|
init_srt_table_row(>p->gtp_srt_table, 0, "Echo");
|
|
|
|
init_srt_table_row(>p->gtp_srt_table, 1, "Create PDP context");
|
|
|
|
init_srt_table_row(>p->gtp_srt_table, 2, "Update PDP context");
|
|
|
|
init_srt_table_row(>p->gtp_srt_table, 3, "Delete PDP context");
|
|
|
|
|
2009-06-05 22:42:47 +00:00
|
|
|
error_string=register_tap_listener("gtp", gtp, filter, 0, gtpstat_reset, gtpstat_packet, gtpstat_draw);
|
2008-10-06 20:11:44 +00:00
|
|
|
if(error_string){
|
2008-10-31 09:53:56 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
|
2008-10-06 20:11:44 +00:00
|
|
|
g_string_free(error_string, TRUE);
|
|
|
|
g_free(gtp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Button row. */
|
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
|
|
|
|
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
|
|
|
2013-03-21 02:58:59 +00:00
|
|
|
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
2008-10-06 20:11:44 +00:00
|
|
|
window_set_cancel_button(gtp->win, close_bt, window_cancel_button_cb);
|
|
|
|
|
|
|
|
g_signal_connect(gtp->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(gtp->win, "destroy", G_CALLBACK(win_destroy_cb), gtp);
|
|
|
|
|
|
|
|
gtk_widget_show_all(gtp->win);
|
|
|
|
window_present(gtp->win);
|
|
|
|
|
2009-06-05 22:42:47 +00:00
|
|
|
cf_retap_packets(&cfile);
|
2011-07-21 20:12:08 +00:00
|
|
|
gdk_window_raise(gtk_widget_get_window(gtp->win));
|
2008-10-06 20:11:44 +00:00
|
|
|
}
|
|
|
|
|
2011-06-05 22:39:23 +00:00
|
|
|
static tap_param gtp_stat_params[] = {
|
2014-11-14 20:21:12 +00:00
|
|
|
{ PARAM_FILTER, "filter", "Filter", NULL, TRUE }
|
2011-06-05 22:39:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static tap_param_dlg gtp_stat_dlg = {
|
2008-10-06 20:11:44 +00:00
|
|
|
"GTP Control Plane Response Time Statistics",
|
|
|
|
"gtp",
|
|
|
|
gtk_gtpstat_init,
|
2011-06-05 22:39:23 +00:00
|
|
|
-1,
|
|
|
|
G_N_ELEMENTS(gtp_stat_params),
|
|
|
|
gtp_stat_params
|
2008-10-06 20:11:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
register_tap_listener_gtkgtpstat(void)
|
|
|
|
{
|
2013-05-24 01:10:16 +00:00
|
|
|
register_param_stat(>p_stat_dlg, "GTP",
|
2008-10-06 20:11:44 +00:00
|
|
|
REGISTER_STAT_GROUP_RESPONSE_TIME);
|
|
|
|
}
|
2015-02-15 18:58:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|