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
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 #include <wiretap/wtap.h>
36 #include <epan/epan.h>
37 #include <epan/packet.h>
38 #include <epan/packet_info.h>
39 #include <epan/value_string.h>
41 #include <epan/asn1.h>
42 #include <epan/dissectors/packet-gsm_map.h>
44 #include "../stat_menu.h"
45 #include "../globals.h"
47 #include "../summary.h"
49 #include "ui/gtk/gui_stat_menu.h"
50 #include "ui/gtk/dlg_utils.h"
51 #include "ui/gtk/gui_utils.h"
52 #include "ui/gtk/gsm_map_stat.h"
55 #define SUM_STR_MAX 1024
59 add_string_to_box(gchar *str, GtkWidget *box)
62 lb = gtk_label_new(str);
63 gtk_misc_set_alignment(GTK_MISC(lb), 0.0f, 0.5f);
64 gtk_box_pack_start(GTK_BOX(box), lb,FALSE,FALSE, 0);
68 void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
70 summary_tally summary;
71 GtkWidget *sum_open_w,
72 *main_vb, *file_fr, *data_fr, *file_box,
73 *data_box, *bbox, *close_bt,
74 *invoke_fr, *invoke_box,
78 gchar string_buff[SUM_STR_MAX];
81 int tot_invokes, tot_rr;
82 double tot_invokes_size, tot_rr_size;
84 /* initialize the tally */
85 summary_fill_in(&cfile, &summary);
87 /* initial computations */
88 seconds = summary.stop_time - summary.start_time;
90 sum_open_w = dlg_window_new("GSM MAP Statistics: Summary"); /* transient_for top_level */
91 gtk_window_set_destroy_with_parent (GTK_WINDOW(sum_open_w), TRUE);
93 /* Container for each row of widgets */
94 main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
95 gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
96 gtk_container_add(GTK_CONTAINER(sum_open_w), main_vb);
97 gtk_widget_show(main_vb);
100 file_fr = gtk_frame_new("File");
101 gtk_box_pack_start(GTK_BOX (main_vb), file_fr, TRUE, TRUE, 0);
102 gtk_widget_show(file_fr);
104 file_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
105 gtk_container_add(GTK_CONTAINER(file_fr), file_box);
106 gtk_widget_show(file_box);
109 g_snprintf(string_buff, SUM_STR_MAX, "Name: %s", ((summary.filename) ? summary.filename : "None"));
110 add_string_to_box(string_buff, file_box);
113 g_snprintf(string_buff, SUM_STR_MAX, "Length: %" G_GINT64_MODIFIER "d", summary.file_length);
114 add_string_to_box(string_buff, file_box);
117 g_snprintf(string_buff, SUM_STR_MAX, "Format: %s", wtap_file_type_string(summary.file_type));
118 add_string_to_box(string_buff, file_box);
120 if (summary.has_snap) {
121 /* snapshot length */
122 g_snprintf(string_buff, SUM_STR_MAX, "Snapshot length: %u", summary.snap);
123 add_string_to_box(string_buff, file_box);
127 data_fr = gtk_frame_new("Data");
128 gtk_box_pack_start(GTK_BOX (main_vb), data_fr, TRUE, TRUE, 0);
129 gtk_widget_show(data_fr);
131 data_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
132 gtk_container_add(GTK_CONTAINER(data_fr), data_box);
133 gtk_widget_show(data_box);
136 * We must have no un-time-stamped packets (i.e., the number of
137 * time-stamped packets must be the same as the number of packets),
138 * and at least two time-stamped packets, in order for the elapsed
141 if (summary.packet_count_ts == summary.packet_count &&
142 summary.packet_count_ts >= 2) {
144 g_snprintf(string_buff, SUM_STR_MAX, "Elapsed time: %.3f seconds", summary.elapsed_time);
145 add_string_to_box(string_buff, data_box);
147 g_snprintf(string_buff, SUM_STR_MAX, "Between first and last packet: %.3f seconds", seconds);
148 add_string_to_box(string_buff, data_box);
152 g_snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", summary.packet_count);
153 add_string_to_box(string_buff, data_box);
156 tot_invokes_size = 0;
157 for (i=0; i < GSM_MAP_MAX_NUM_OPR_CODES; i++)
159 tot_invokes += gsm_map_stat.opr_code[i];
160 tot_invokes_size += gsm_map_stat.size[i];
165 for (i=0; i < GSM_MAP_MAX_NUM_OPR_CODES; i++)
167 tot_rr += gsm_map_stat.opr_code_rr[i];
168 tot_rr_size += gsm_map_stat.size_rr[i];
172 invoke_fr = gtk_frame_new("Invokes");
173 gtk_box_pack_start(GTK_BOX (main_vb), invoke_fr, TRUE, TRUE, 0);
174 gtk_widget_show(invoke_fr);
176 invoke_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
177 gtk_container_add(GTK_CONTAINER(invoke_fr), invoke_box);
178 gtk_widget_show(invoke_box);
180 /* Total number of invokes */
181 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes: %u", tot_invokes);
182 add_string_to_box(string_buff, invoke_box);
185 * We must have no un-time-stamped packets (i.e., the number of
186 * time-stamped packets must be the same as the number of packets),
187 * and at least two time-stamped packets, in order for the elapsed
190 if (summary.packet_count_ts == summary.packet_count &&
191 summary.packet_count_ts >= 2) {
192 /* Total number of invokes per second */
194 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: %.2f", tot_invokes/seconds);
196 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: N/A");
197 add_string_to_box(string_buff, invoke_box);
200 /* Total size of invokes */
201 g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Invokes: %.0f", tot_invokes_size);
202 add_string_to_box(string_buff, invoke_box);
204 /* Average size of invokes */
206 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: %.2f", tot_invokes_size/tot_invokes);
208 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: N/A");
209 add_string_to_box(string_buff, invoke_box);
212 * We must have no un-time-stamped packets (i.e., the number of
213 * time-stamped packets must be the same as the number of packets),
214 * and at least two time-stamped packets, in order for the elapsed
217 if (summary.packet_count_ts == summary.packet_count &&
218 summary.packet_count_ts >= 2) {
219 /* Average size of invokes per second */
221 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_invokes_size/seconds);
223 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
224 add_string_to_box(string_buff, invoke_box);
227 /* Return Results frame */
228 rr_fr = gtk_frame_new("Return Results");
229 gtk_box_pack_start(GTK_BOX (main_vb), rr_fr, TRUE, TRUE, 0);
230 gtk_widget_show(rr_fr);
232 rr_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
233 gtk_container_add(GTK_CONTAINER(rr_fr), rr_box);
234 gtk_widget_show(rr_box);
236 /* Total number of return results */
237 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results: %u", tot_rr);
238 add_string_to_box(string_buff, rr_box);
241 * We must have no un-time-stamped packets (i.e., the number of
242 * time-stamped packets must be the same as the number of packets),
243 * and at least two time-stamped packets, in order for the elapsed
246 if (summary.packet_count_ts == summary.packet_count &&
247 summary.packet_count_ts >= 2) {
248 /* Total number of return results per second */
250 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: %.2f", tot_rr/seconds);
252 g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: N/A");
253 add_string_to_box(string_buff, rr_box);
256 /* Total size of return results */
257 g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Return Results: %.0f", tot_rr_size);
258 add_string_to_box(string_buff, rr_box);
260 /* Average size of return results */
262 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: %.2f", tot_rr_size/tot_rr);
264 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: N/A");
265 add_string_to_box(string_buff, rr_box);
268 * We must have no un-time-stamped packets (i.e., the number of
269 * time-stamped packets must be the same as the number of packets),
270 * and at least two time-stamped packets, in order for the elapsed
273 if (summary.packet_count_ts == summary.packet_count &&
274 summary.packet_count_ts >= 2) {
275 /* Average size of return results per second */
277 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_rr_size/seconds);
279 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
280 add_string_to_box(string_buff, rr_box);
284 tot_fr = gtk_frame_new("Totals");
285 gtk_box_pack_start(GTK_BOX (main_vb), tot_fr, TRUE, TRUE, 0);
286 gtk_widget_show(tot_fr);
288 tot_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
289 gtk_container_add(GTK_CONTAINER(tot_fr), tot_box);
290 gtk_widget_show(tot_box);
292 /* Total number of return results */
293 g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages: %u", tot_invokes + tot_rr);
294 add_string_to_box(string_buff, tot_box);
297 * We must have no un-time-stamped packets (i.e., the number of
298 * time-stamped packets must be the same as the number of packets),
299 * and at least two time-stamped packets, in order for the elapsed
302 if (summary.packet_count_ts == summary.packet_count &&
303 summary.packet_count_ts >= 2) {
305 g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: %.2f",
306 (tot_invokes + tot_rr)/seconds);
308 g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: N/A");
309 add_string_to_box(string_buff, tot_box);
312 g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for GSM MAP messages: %.0f", tot_invokes_size + tot_rr_size);
313 add_string_to_box(string_buff, tot_box);
315 if (tot_invokes + tot_rr)
316 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: %.2f",
317 (tot_invokes_size + tot_rr_size)/(tot_invokes + tot_rr));
319 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: N/A");
320 add_string_to_box(string_buff, tot_box);
323 * We must have no un-time-stamped packets (i.e., the number of
324 * time-stamped packets must be the same as the number of packets),
325 * and at least two time-stamped packets, in order for the elapsed
328 if (summary.packet_count_ts == summary.packet_count &&
329 summary.packet_count_ts >= 2) {
331 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: %.2f",
332 (tot_invokes_size + tot_rr_size)/seconds);
334 g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: N/A");
335 add_string_to_box(string_buff, tot_box);
339 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
340 gtk_box_pack_start(GTK_BOX(main_vb), bbox, TRUE, TRUE, 0);
341 gtk_widget_show(bbox);
343 close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
344 window_set_cancel_button(sum_open_w, close_bt, window_cancel_button_cb);
346 g_signal_connect(sum_open_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
348 gtk_widget_show(sum_open_w);
349 window_present(sum_open_w);
354 register_tap_listener_gtkgsm_map_summary(void)