2 * H.225 RAS Service Response Time statistics for Wireshar
3 * Copyright 2003 Lars Roland
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
38 #include <epan/packet.h>
39 #include <epan/packet_info.h>
40 #include <epan/epan.h>
41 #include <epan/value_string.h>
43 #include <epan/dissectors/packet-h225.h>
45 #include "../register.h"
46 #include "../timestats.h"
47 #include "../simple_dialog.h"
49 #include "../globals.h"
50 #include "../stat_menu.h"
52 #include "gtk/gui_stat_util.h"
53 #include "gtk/dlg_utils.h"
54 #include "gtk/tap_dfilter_dlg.h"
55 #include "gtk/gui_utils.h"
59 static void gtk_h225rassrt_init(const char *optarg, void *userdata);
61 static tap_dfilter_dlg h225_rassrt_dlg = {
62 "H.225 RAS Service Response Time",
68 /* following values represent the size of their valuestring arrays */
69 #define NUM_RAS_STATS 7
71 static const value_string ras_message_category[] = {
73 { 1, "Registration "},
74 { 2, "UnRegistration"},
82 typedef enum _ras_type {
89 typedef enum _ras_category {
100 /* Summary of response-time calculations*/
101 typedef struct _h225_rtd_t {
102 guint32 open_req_num;
103 guint32 disc_rsp_num;
109 /* used to keep track of the statistics for an entire program interface */
110 typedef struct _h225rassrt_t {
114 GtkWidget *scrolled_window;
116 h225_rtd_t ras_rtd[NUM_RAS_STATS];
121 h225rassrt_reset(void *phs)
123 h225rassrt_t *hs=(h225rassrt_t *)phs;
126 for(i=0;i<NUM_RAS_STATS;i++) {
127 hs->ras_rtd[i].stats.num = 0;
128 hs->ras_rtd[i].stats.min_num = 0;
129 hs->ras_rtd[i].stats.max_num = 0;
130 hs->ras_rtd[i].stats.min.secs = 0;
131 hs->ras_rtd[i].stats.min.nsecs = 0;
132 hs->ras_rtd[i].stats.max.secs = 0;
133 hs->ras_rtd[i].stats.max.nsecs = 0;
134 hs->ras_rtd[i].stats.tot.secs = 0;
135 hs->ras_rtd[i].stats.tot.nsecs = 0;
136 hs->ras_rtd[i].open_req_num = 0;
137 hs->ras_rtd[i].disc_rsp_num = 0;
138 hs->ras_rtd[i].req_dup_num = 0;
139 hs->ras_rtd[i].rsp_dup_num = 0;
146 h225rassrt_packet(void *phs, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *phi)
148 h225rassrt_t *hs=(h225rassrt_t *)phs;
149 const h225_packet_info *pi=phi;
151 ras_type rasmsg_type = RAS_OTHER;
152 ras_category rascategory = RAS_OTHERS;
154 if (pi->msg_type != H225_RAS || pi->msg_tag == -1) {
155 /* No RAS Message or uninitialized msg_tag -> return */
159 if (pi->msg_tag < 21) {
161 rascategory = pi->msg_tag / 3;
162 rasmsg_type = pi->msg_tag % 3;
165 /* No SRT yet (ToDo) */
169 switch(rasmsg_type) {
172 if(pi->is_duplicate){
173 hs->ras_rtd[rascategory].req_dup_num++;
176 hs->ras_rtd[rascategory].open_req_num++;
181 /* no break - delay stats are identical for Confirm and Reject */
183 if(pi->is_duplicate){
184 /* Duplicate is ignored */
185 hs->ras_rtd[rascategory].rsp_dup_num++;
187 else if (!pi->request_available) {
188 /* no request was seen, ignore response */
189 hs->ras_rtd[rascategory].disc_rsp_num++;
192 hs->ras_rtd[rascategory].open_req_num--;
193 time_stat_update(&(hs->ras_rtd[rascategory].stats),&(pi->delta_time), pinfo);
204 h225rassrt_draw(void *phs)
206 h225rassrt_t *hs=(h225rassrt_t *)phs;
211 str[i]=g_malloc(sizeof(char[256]));
213 /* Now print Message and Reason Counter Table */
214 /* clear list before printing */
215 gtk_clist_clear(hs->table);
217 for(i=0;i<NUM_RAS_STATS;i++) {
218 /* nothing seen, nothing to do */
219 if(hs->ras_rtd[i].stats.num==0){
223 g_snprintf(str[0], sizeof(char[256]),
224 "%s", val_to_str(i,ras_message_category,"Other"));
225 g_snprintf(str[1], sizeof(char[256]),
226 "%7d", hs->ras_rtd[i].stats.num);
227 g_snprintf(str[2], sizeof(char[256]),
228 "%8.2f msec", nstime_to_msec(&(hs->ras_rtd[i].stats.min)));
229 g_snprintf(str[3], sizeof(char[256]),
230 "%8.2f msec", nstime_to_msec(&(hs->ras_rtd[i].stats.max)));;
231 g_snprintf(str[4], sizeof(char[256]),
232 "%8.2f msec", get_average(&(hs->ras_rtd[i].stats.tot), hs->ras_rtd[i].stats.num));
233 g_snprintf(str[5], sizeof(char[256]),
234 "%6u", hs->ras_rtd[i].stats.min_num);
235 g_snprintf(str[6], sizeof(char[256]),
236 "%6u", hs->ras_rtd[i].stats.max_num);
237 g_snprintf(str[7], sizeof(char[256]),
238 "%4u", hs->ras_rtd[i].open_req_num);
239 g_snprintf(str[8], sizeof(char[256]),
240 "%4u", hs->ras_rtd[i].disc_rsp_num);
241 g_snprintf(str[9], sizeof(char[256]),
242 "%4u", hs->ras_rtd[i].req_dup_num);
243 g_snprintf(str[10], sizeof(char[256]),
244 "%4u", hs->ras_rtd[i].rsp_dup_num);
245 gtk_clist_append(GTK_CLIST(hs->table), str);
248 gtk_widget_show(GTK_WIDGET(hs->table));
253 win_destroy_cb(GtkWindow *win _U_, gpointer data)
255 h225rassrt_t *hs=(h225rassrt_t *)data;
257 protect_thread_critical_region();
258 remove_tap_listener(hs);
259 unprotect_thread_critical_region();
269 static const gchar *titles[]={
278 "Discarded Responses",
280 "Repeated Responses" };
283 gtk_h225rassrt_init(const char *optarg, void *userdata _U_)
286 const char *filter=NULL;
287 GString *error_string;
291 if(strncmp(optarg,"h225,srt,",9) == 0){
297 hs=g_malloc(sizeof(h225rassrt_t));
298 hs->filter=g_strdup(filter);
300 h225rassrt_reset(hs);
302 hs->win=window_new(GTK_WINDOW_TOPLEVEL, "h225-ras-srt");
303 gtk_window_set_default_size(GTK_WINDOW(hs->win), 600, 300);
305 hs->vbox=gtk_vbox_new(FALSE, 3);
306 gtk_container_set_border_width(GTK_CONTAINER(hs->vbox), 12);
308 init_main_stat_window(hs->win, hs->vbox, "H.225 RAS Service Response Time", filter);
310 /* init a scrolled window*/
311 hs->scrolled_window = scrolled_window_new(NULL, NULL);
313 hs->table = create_stat_table(hs->scrolled_window, hs->vbox, 11, titles);
315 error_string=register_tap_listener("h225", hs, filter, h225rassrt_reset, h225rassrt_packet, h225rassrt_draw);
317 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
318 g_string_free(error_string, TRUE);
325 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
326 gtk_box_pack_end(GTK_BOX(hs->vbox), bbox, FALSE, FALSE, 0);
328 close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
329 window_set_cancel_button(hs->win, close_bt, window_cancel_button_cb);
331 g_signal_connect(hs->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
332 g_signal_connect(hs->win, "destroy", G_CALLBACK(win_destroy_cb), hs);
334 gtk_widget_show_all(hs->win);
335 window_present(hs->win);
337 cf_retap_packets(&cfile, FALSE);
338 gdk_window_raise(hs->win->window);
342 register_tap_listener_gtk_h225rassrt(void)
344 register_dfilter_stat(&h225_rassrt_dlg, "H.225 RAS",
345 REGISTER_STAT_GROUP_RESPONSE_TIME);