2 * Routines for GSM MAP Statictics summary window
4 * Copyright 2004, Michael Lum <mlum [AT] telostech.com>
5 * In association with Telos Technology Inc.
7 * Modified from summary_dlg.c
9 * $Id: gsm_map_summary.c,v 1.1 2004/04/21 17:57:31 guy Exp $
11 * Ethereal - Network traffic analyzer
12 * By Gerald Combs <gerald@ethereal.com>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include "epan/packet_info.h"
39 #include "epan/epan.h"
40 #include "epan/value_string.h"
43 #include "dlg_utils.h"
45 #include "compat_macros.h"
48 #include "packet-gsm_map.h"
49 #include "gsm_map_stat.h"
51 #define SUM_STR_MAX 1024
55 add_string_to_box(gchar *str, GtkWidget *box)
58 lb = gtk_label_new(str);
59 gtk_misc_set_alignment(GTK_MISC(lb), 0.0, 0.5);
60 gtk_box_pack_start(GTK_BOX(box), lb,FALSE,FALSE, 0);
66 gsm_map_stat_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_)
68 summary_tally summary;
69 GtkWidget *sum_open_w,
70 *main_vb, *file_fr, *data_fr, *file_box,
71 *data_box, *bbox, *close_bt,
72 *invoke_fr, *invoke_box,
76 gchar string_buff[SUM_STR_MAX];
79 int tot_invokes, tot_rr;
80 double tot_invokes_size, tot_rr_size;
82 /* initialize the tally */
83 summary_fill_in(&summary);
85 /* initial compututations */
86 seconds = summary.stop_time - summary.start_time;
88 sum_open_w = window_new(GTK_WINDOW_TOPLEVEL, "GSM MAP Statistics: Summary");
90 /* Container for each row of widgets */
91 main_vb = gtk_vbox_new(FALSE, 3);
92 gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
93 gtk_container_add(GTK_CONTAINER(sum_open_w), main_vb);
94 gtk_widget_show(main_vb);
97 file_fr = gtk_frame_new("File");
98 gtk_container_add(GTK_CONTAINER(main_vb), file_fr);
99 gtk_widget_show(file_fr);
101 file_box = gtk_vbox_new(FALSE, 3);
102 gtk_container_add(GTK_CONTAINER(file_fr), file_box);
103 gtk_widget_show(file_box);
106 g_snprintf(string_buff, SUM_STR_MAX, "Name: %s", summary.filename);
107 add_string_to_box(string_buff, file_box);
110 g_snprintf(string_buff, SUM_STR_MAX, "Length: %lu", summary.file_length);
111 add_string_to_box(string_buff, file_box);
114 g_snprintf(string_buff, SUM_STR_MAX, "Format: %s", wtap_file_type_string(summary.encap_type));
115 add_string_to_box(string_buff, file_box);
117 if (summary.has_snap) {
118 /* snapshot length */
119 g_snprintf(string_buff, SUM_STR_MAX, "Snapshot length: %u", summary.snap);
120 add_string_to_box(string_buff, file_box);
124 data_fr = gtk_frame_new("Data");
125 gtk_container_add(GTK_CONTAINER(main_vb), data_fr);
126 gtk_widget_show(data_fr);
128 data_box = gtk_vbox_new(FALSE, 3);
129 gtk_container_add(GTK_CONTAINER(data_fr), data_box);
130 gtk_widget_show(data_box);
133 g_snprintf(string_buff, SUM_STR_MAX, "Elapsed time: %.3f seconds", summary.elapsed_time);
134 add_string_to_box(string_buff, data_box);
136 g_snprintf(string_buff, SUM_STR_MAX, "Between first and last packet: %.3f seconds", seconds);
137 add_string_to_box(string_buff, data_box);
140 g_snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", summary.packet_count);
141 add_string_to_box(string_buff, data_box);
144 tot_invokes_size = 0;
145 for (i=0; i < GSM_MAP_MAX_NUM_OPR_CODES; i++)
147 tot_invokes += gsm_map_stat.opr_code[i];
148 tot_invokes_size += gsm_map_stat.size[i];
153 for (i=0; i < GSM_MAP_MAX_NUM_OPR_CODES; i++)
155 tot_rr += gsm_map_stat.opr_code_rr[i];
156 tot_rr_size += gsm_map_stat.size_rr[i];
160 invoke_fr = gtk_frame_new("Invokes");
161 gtk_container_add(GTK_CONTAINER(main_vb), invoke_fr);
162 gtk_widget_show(invoke_fr);
164 invoke_box = gtk_vbox_new(FALSE, 3);
165 gtk_container_add(GTK_CONTAINER(invoke_fr), invoke_box);
166 gtk_widget_show(invoke_box);
168 /* Total number of invokes */
169 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes: %u", tot_invokes);
170 add_string_to_box(string_buff, invoke_box);
172 /* Total number of invokes per second */
173 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: %.2f", tot_invokes/seconds);
174 add_string_to_box(string_buff, invoke_box);
176 /* Total size of invokes */
177 g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Invokes: %.0f", tot_invokes_size);
178 add_string_to_box(string_buff, invoke_box);
180 /* Average size of invokes */
181 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: %.2f", tot_invokes_size/tot_invokes);
182 add_string_to_box(string_buff, invoke_box);
184 /* Average size of invokes per second */
185 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_invokes_size/seconds);
186 add_string_to_box(string_buff, invoke_box);
188 /* Return Results frame */
189 rr_fr = gtk_frame_new("Return Results");
190 gtk_container_add(GTK_CONTAINER(main_vb), rr_fr);
191 gtk_widget_show(rr_fr);
193 rr_box = gtk_vbox_new(FALSE, 3);
194 gtk_container_add(GTK_CONTAINER(rr_fr), rr_box);
195 gtk_widget_show(rr_box);
197 /* Total number of return results */
198 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results: %u", tot_rr);
199 add_string_to_box(string_buff, rr_box);
201 /* Total number of return results per second */
202 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: %.2f", tot_rr/seconds);
203 add_string_to_box(string_buff, rr_box);
205 /* Total size of return results */
206 g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Return Results: %.0f", tot_rr_size);
207 add_string_to_box(string_buff, rr_box);
209 /* Average size of return results */
210 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: %.2f", tot_rr_size/tot_rr);
211 add_string_to_box(string_buff, rr_box);
213 /* Average size of return results per second */
214 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_rr_size/seconds);
215 add_string_to_box(string_buff, rr_box);
218 tot_fr = gtk_frame_new("Totals");
219 gtk_container_add(GTK_CONTAINER(main_vb), tot_fr);
220 gtk_widget_show(tot_fr);
222 tot_box = gtk_vbox_new(FALSE, 3);
223 gtk_container_add(GTK_CONTAINER(tot_fr), tot_box);
224 gtk_widget_show(tot_box);
226 /* Total number of return results */
227 g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages: %u", tot_invokes + tot_rr);
228 add_string_to_box(string_buff, tot_box);
230 g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: %.2f",
231 (tot_invokes + tot_rr)/seconds);
232 add_string_to_box(string_buff, tot_box);
234 g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for GSM MAP messages: %.0f", tot_invokes_size + tot_rr_size);
235 add_string_to_box(string_buff, tot_box);
237 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: %.2f",
238 (tot_invokes_size + tot_rr_size)/(tot_invokes + tot_rr));
239 add_string_to_box(string_buff, tot_box);
241 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: %.2f",
242 (tot_invokes_size + tot_rr_size)/seconds);
243 add_string_to_box(string_buff, tot_box);
247 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
248 gtk_container_add(GTK_CONTAINER(main_vb), bbox);
249 gtk_widget_show(bbox);
251 close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
252 SIGNAL_CONNECT_OBJECT(close_bt, "clicked", gtk_widget_destroy, sum_open_w);
253 gtk_widget_grab_default(close_bt);
255 /* Catch the "key_press_event" signal in the window, so that we can catch
256 the ESC key being pressed and act as if the "Close" button had
258 dlg_set_cancel(sum_open_w, close_bt);
260 gtk_window_set_position(GTK_WINDOW(sum_open_w), GTK_WIN_POS_MOUSE);
261 gtk_widget_show(sum_open_w);
266 register_tap_listener_gtkgsm_map_summary(void)
268 register_tap_menu_item("GSM/MAP Summary", REGISTER_TAP_GROUP_NONE,
269 gsm_map_stat_gtk_sum_cb, NULL, NULL, NULL);