Suppress invalid or non-meaningful statistics - for example, without

time stamps on all packets in a set, you can't determine the start and
end time of the packets in the set (even one timestampless packet throws
the determination off - was that packet before the first time-stamped or
after the last time-stamped packet, or between them?).

svn path=/trunk/; revision=41187
This commit is contained in:
Guy Harris 2012-02-26 08:02:02 +00:00
parent 08d7ff268b
commit 30b86b7817
5 changed files with 291 additions and 150 deletions

View File

@ -43,17 +43,37 @@ tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
{
double cur_time;
sum_tally->bytes += cur_frame->pkt_len;
if (cur_frame->flags.passed_dfilter){
sum_tally->filtered_count++;
sum_tally->filtered_bytes += cur_frame->pkt_len;
}
if (cur_frame->flags.marked){
sum_tally->marked_count++;
sum_tally->marked_bytes += cur_frame->pkt_len;
}
if (cur_frame->flags.ignored){
sum_tally->ignored_count++;
}
if (cur_frame->flags.has_ts) {
/* This packet has a time stamp. */
cur_time = nstime_to_sec(&cur_frame->abs_ts);
sum_tally->packet_count_ts++;
if (cur_time < sum_tally->start_time) {
sum_tally->start_time = cur_time;
}
if (cur_time > sum_tally->stop_time){
sum_tally->stop_time = cur_time;
}
sum_tally->bytes += cur_frame->pkt_len;
if (cur_frame->flags.passed_dfilter){
if (sum_tally->filtered_count==0){
sum_tally->filtered_count_ts++;
/*
* If we've seen one filtered packet, this is the first
* one.
*/
if (sum_tally->filtered_count == 1){
sum_tally->filtered_start= cur_time;
sum_tally->filtered_stop = cur_time;
} else {
@ -64,11 +84,14 @@ tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
sum_tally->filtered_stop = cur_time;
}
}
sum_tally->filtered_count++;
sum_tally->filtered_bytes += cur_frame->pkt_len ;
}
if (cur_frame->flags.marked){
if (sum_tally->marked_count==0){
sum_tally->marked_count_ts++;
/*
* If we've seen one marked packet, this is the first
* one.
*/
if (sum_tally->marked_count == 1){
sum_tally->marked_start= cur_time;
sum_tally->marked_stop = cur_time;
} else {
@ -79,11 +102,7 @@ tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
sum_tally->marked_stop = cur_time;
}
}
sum_tally->marked_count++;
sum_tally->marked_bytes += cur_frame->pkt_len ;
}
if (cur_frame->flags.ignored){
sum_tally->ignored_count++;
}
}
@ -95,14 +114,17 @@ summary_fill_in(capture_file *cf, summary_tally *st)
guint32 framenum;
wtapng_section_t* shb_inf;
st->packet_count_ts = 0;
st->start_time = 0;
st->stop_time = 0;
st->bytes = 0;
st->filtered_count = 0;
st->filtered_count_ts = 0;
st->filtered_start = 0;
st->filtered_stop = 0;
st->filtered_bytes = 0;
st->marked_count = 0;
st->marked_count_ts = 0;
st->marked_start = 0;
st->marked_stop = 0;
st->marked_bytes = 0;

View File

@ -47,13 +47,16 @@ typedef struct _summary_tally {
double elapsed_time; /**< seconds, with msec resolution,
includes time before first packet
and after last packet */
int marked_count; /**< number of marked packets */
guint32 marked_count; /**< number of marked packets */
guint32 marked_count_ts; /**< number of time-stamped marked packets */
guint64 marked_bytes; /**< total bytes in the marked packets */
double marked_start; /**< time in seconds, with msec resolution */
double marked_stop; /**< time in seconds, with msec resolution */
int ignored_count; /**< number of ignored packets */
int packet_count; /**< total number of packets in trace */
int filtered_count; /**< number of filtered packets */
guint32 ignored_count; /**< number of ignored packets */
guint32 packet_count; /**< total number of packets in trace */
guint32 packet_count_ts; /**< total number of time-stamped packets in trace */
guint32 filtered_count; /**< number of filtered packets */
guint32 filtered_count_ts; /**< number of time-stamped filtered packets */
guint64 filtered_bytes; /**< total bytes in the filtered packets */
double filtered_start; /**< time in seconds, with msec resolution */
double filtered_stop; /**< time in seconds, with msec resolution */

View File

@ -90,7 +90,7 @@ void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
/* initialize the tally */
summary_fill_in(&cfile, &summary);
/* initial compututations */
/* initial computations */
seconds = summary.stop_time - summary.start_time;
sum_open_w = dlg_window_new("GSM MAP Statistics: Summary"); /* transient_for top_level */
@ -138,12 +138,21 @@ void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
gtk_container_add(GTK_CONTAINER(data_fr), data_box);
gtk_widget_show(data_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* seconds */
g_snprintf(string_buff, SUM_STR_MAX, "Elapsed time: %.3f seconds", summary.elapsed_time);
add_string_to_box(string_buff, data_box);
g_snprintf(string_buff, SUM_STR_MAX, "Between first and last packet: %.3f seconds", seconds);
add_string_to_box(string_buff, data_box);
}
/* Packet count */
g_snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", summary.packet_count);
@ -178,12 +187,21 @@ void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes: %u", tot_invokes);
add_string_to_box(string_buff, invoke_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* Total number of invokes per second */
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: %.2f", tot_invokes/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: N/A");
add_string_to_box(string_buff, invoke_box);
}
/* Total size of invokes */
g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Invokes: %.0f", tot_invokes_size);
@ -196,12 +214,21 @@ void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: N/A");
add_string_to_box(string_buff, invoke_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* Average size of invokes per second */
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_invokes_size/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
add_string_to_box(string_buff, invoke_box);
}
/* Return Results frame */
rr_fr = gtk_frame_new("Return Results");
@ -216,12 +243,21 @@ void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results: %u", tot_rr);
add_string_to_box(string_buff, rr_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* Total number of return results per second */
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: %.2f", tot_rr/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: N/A");
add_string_to_box(string_buff, rr_box);
}
/* Total size of return results */
g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Return Results: %.0f", tot_rr_size);
@ -234,12 +270,21 @@ void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: N/A");
add_string_to_box(string_buff, rr_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* Average size of return results per second */
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_rr_size/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
add_string_to_box(string_buff, rr_box);
}
/* Totals frame */
tot_fr = gtk_frame_new("Totals");
@ -254,12 +299,21 @@ void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages: %u", tot_invokes + tot_rr);
add_string_to_box(string_buff, tot_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: %.2f",
(tot_invokes + tot_rr)/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: N/A");
add_string_to_box(string_buff, tot_box);
}
g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for GSM MAP messages: %.0f", tot_invokes_size + tot_rr_size);
add_string_to_box(string_buff, tot_box);
@ -271,13 +325,21 @@ void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: N/A");
add_string_to_box(string_buff, tot_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: %.2f",
(tot_invokes_size + tot_rr_size)/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: N/A");
add_string_to_box(string_buff, tot_box);
}
/* Button row. */
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);

View File

@ -286,7 +286,7 @@ void mtp3_sum_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
/* initialize the tally */
summary_fill_in(&cfile, &summary);
/* initial compututations */
/* initial computations */
seconds = summary.stop_time - summary.start_time;
sum_open_w = dlg_window_new("MTP3 Statistics: Summary"); /* transient_for top_level */
@ -335,12 +335,21 @@ void mtp3_sum_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
gtk_container_add(GTK_CONTAINER(data_fr), data_box);
gtk_widget_show(data_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* seconds */
g_snprintf(string_buff, SUM_STR_MAX, "Elapsed time: %.3f seconds", summary.elapsed_time);
add_string_to_box(string_buff, data_box);
g_snprintf(string_buff, SUM_STR_MAX, "Between first and last packet: %.3f seconds", seconds);
add_string_to_box(string_buff, data_box);
}
/* Packet count */
g_snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", summary.packet_count);
@ -371,6 +380,14 @@ void mtp3_sum_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
g_snprintf(string_buff, SUM_STR_MAX, "Total MSUs: %u", tot_num_msus);
add_string_to_box(string_buff, tot_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
if (seconds) {
g_snprintf(string_buff, SUM_STR_MAX, "MSUs/second: %.2f", tot_num_msus/seconds);
}
@ -378,6 +395,7 @@ void mtp3_sum_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
g_snprintf(string_buff, SUM_STR_MAX, "MSUs/second: N/A");
}
add_string_to_box(string_buff, tot_box);
}
g_snprintf(string_buff, SUM_STR_MAX, "Total Bytes: %.0f", tot_num_bytes);
add_string_to_box(string_buff, tot_box);
@ -390,6 +408,14 @@ void mtp3_sum_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
}
add_string_to_box(string_buff, tot_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
if (seconds) {
g_snprintf(string_buff, SUM_STR_MAX, "Bytes/second: %.2f", tot_num_bytes/seconds);
}
@ -397,6 +423,7 @@ void mtp3_sum_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
g_snprintf(string_buff, SUM_STR_MAX, "Bytes/second: N/A");
}
add_string_to_box(string_buff, tot_box);
}
/* Button row. */
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);

View File

@ -170,6 +170,14 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
#ifdef HAVE_LIBPCAP
summary_fill_in_capture(&cfile, &global_capture_opts, &summary);
#endif
/*
* Note: the start and stop times are initialized to 0, so if we
* have zero or one packets of the type in question that have
* time stamps, the elapsed times will be zero, just as if we
* have both start and stop time stamps but they're the same.
* That means we can avoid some checks for whether we have more
* than one packet of the type in question with time stamps.
*/
seconds = summary.stop_time - summary.start_time;
disp_seconds = summary.filtered_stop - summary.filtered_start;
marked_seconds = summary.marked_stop - summary.marked_start;
@ -214,7 +222,14 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
add_string_to_table(table, &row, "Packet size limit:", string_buff);
}
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least one time-stamped packet, in order for the start
* and stop times to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count >= 1) {
/* Time */
add_string_to_table(table, &row, "", "");
add_string_to_table(table, &row, "Time", "");
@ -227,6 +242,11 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
time_to_string(string_buff, SUM_STR_MAX, (time_t)summary.stop_time);
add_string_to_table(table, &row, "Last packet:", string_buff);
/*
* We must have at least two time-stamped packets for the elapsed time
* to be valid.
*/
if (summary.packet_count_ts >= 2) {
/* elapsed seconds */
elapsed_time = (unsigned int)summary.elapsed_time;
if(elapsed_time/86400) {
@ -237,7 +257,8 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
}
add_string_to_table(table, &row, "Elapsed:", string_buff);
}
}
/* Capture */
add_string_to_table(table, &row, "", "");
@ -395,6 +416,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
} else {
string_buff3[0] = '\0';
}
if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
add_string_to_list(list, "Between first and last packet", string_buff, string_buff2, string_buff3);
/* Packets per second */
@ -413,6 +435,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
} else {
string_buff3[0] = '\0';
}
if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
add_string_to_list(list, "Avg. packets/sec", string_buff, string_buff2, string_buff3);
/* Packet size */
@ -437,6 +460,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
} else {
string_buff3[0] = '\0';
}
if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
add_string_to_list(list, "Avg. packet size", string_buff, string_buff2, string_buff3);
/* Byte count */
@ -451,6 +475,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
} else {
string_buff3[0] = '\0';
}
if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
add_string_to_list(list, "Bytes", string_buff, string_buff2, string_buff3);
/* Bytes per second */
@ -472,6 +497,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
} else {
string_buff3[0] = '\0';
}
if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
add_string_to_list(list, "Avg. bytes/sec", string_buff, string_buff2, string_buff3);
/* MBit per second */
@ -496,6 +522,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
} else {
string_buff3[0] = '\0';
}
if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
add_string_to_list(list, "Avg. MBit/sec", string_buff, string_buff2, string_buff3);