/* tap-comparestat.c
* Compare two capture files
* Copyright 2008 Vincenzo Condoleo, Christophe Dirac, Reto Ruoss
- * supported by HSR (Hochschule Rapperswil)
+ * supported by HSR (Hochschule Rapperswil)
*
* $Id$
*
* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <epan/timestamp.h>
#include <epan/stat_cmd_args.h>
#include <epan/dissectors/packet-ip.h>
-#include "register.h"
#include "timestats.h"
frame_info *fInfo;
vec_t cksum_vec[3];
guint16 computed_cksum=0;
-
+
/* so this get filled, usually with the first frame */
if(cs->eth_dst.len==0) {
cs->eth_dst=pinfo->dl_dst;
packet_info *pinfo=(packet_info*)ep_alloc(sizeof(packet_info));
pinfo->fd=(frame_data*)ep_alloc(sizeof(frame_data));
pinfo->fd->num = fInfo->num;
-
+
fInfoTemp=se_tree_lookup32(cs->ip_id_tree, fInfo->id);
if(fInfoTemp==NULL){
/* Detect ongoing package loss */
cs->zebra_time.nsecs++;
se_tree_insert32(cs->nr_tree, fInfo->id, fInfo);
fInfo->zebra_time=cs->zebra_time;
- cs->zebra_time.nsecs=cs->zebra_time.nsecs++;
+ cs->zebra_time.nsecs++;
}
} else {
if((g_array_index(cs->ip_ttl_list, guint8, 0)==fInfo->ip_ttl) || (g_array_index(cs->ip_ttl_list, guint8, 1)==fInfo->ip_ttl)){
cs->zebra_time.nsecs++;
se_tree_insert32(cs->nr_tree, fInfo->id, fInfo);
fInfo->zebra_time=cs->zebra_time;
- cs->zebra_time.nsecs=cs->zebra_time.nsecs++;
+ cs->zebra_time.nsecs++;
}
-
+
}
} else {
if(TTL_method==FALSE){
} else {
fInfo->zebra_time.nsecs=fInfoTemp->zebra_time.nsecs+1;
}
- }
+ }
}
-
+
/* count packets of file */
if(fmod(fInfo->zebra_time.nsecs, MERGED_FILES)){
cs->first_file_amount++;
if(!nstime_is_unset(&cs->current_time)){
fInfo->fp->predecessor_time.nsecs=cs->current_time.nsecs;
}
-
+
cs->current_time.nsecs=fInfo->zebra_time.nsecs;
return FALSE;
fInfoTemp=se_tree_lookup32(cs->packet_tree, cs->start_packet_nr_first);
if(fInfoTemp==NULL){
printf("ERROR: start number not set correctly\n");
+ return FALSE;
}
if(fmod(fInfoTemp->zebra_time.nsecs, 2)){
/*first file*/
}
if(fInfo->fp->count > MERGED_FILES){
printf("Packet id :%i, count:%i Problem:", fInfo->id, fInfo->fp->count);
- printf("More than two packets\n");
+ printf("More than two packets\n");
if(fInfo->fp->cksum == WRONG_CHKSUM){
printf("Checksum error over IP header\n");
}
} else if((nstime_cmp(&fInfo->fp->predecessor_time, &fInfo->zebra_time)>0||nstime_cmp(&fInfo->fp->partner->fp->predecessor_time, &fInfo->fp->partner->zebra_time)>0) && fInfo->zebra_time.nsecs != MERGED_FILES && ON_method){
printf("Packet id :%i, count:%i Problem:", fInfo->id, fInfo->fp->count);
printf("Not correct order\n");
- }
+ }
}
}
return FALSE;
* stdout.
* TShark will only call this callback once, which is when tshark has
* finished reading all packets and exists.
- * If used with wireshark this may be called any time, perhaps once every 3
+ * If used with wireshark this may be called any time, perhaps once every 3
* seconds or so.
* This function may even be called in parallell with (*reset) or (*draw)
* so make sure there are no races. The data in the rpcstat_t can thus change
cs->stats.variance=compare_variance;
/* add statistic string */
- statis_string=g_strdup_printf("Compare Statistics: \nNumber of packets total:%i 1st file:%i, 2nd file:%i\nScopes:\t start:%i stop:%i\nand:\t start:%i stop:%i\nEqual packets: %i \nAllowed variation: %f \nAverage time difference: %f\n", (first_file_amount+second_file_amount), first_file_amount, second_file_amount, cs->start_packet_nr_first, cs->stop_packet_nr_first, cs->start_packet_nr_second, cs->stop_packet_nr_second, cs->stats.num, cs->stats.variance, fabs(get_average(&cs->stats.tot, cs->stats.num)));
+ statis_string=g_strdup_printf("Compare Statistics: \nFilter: %s\nNumber of packets total:%i 1st file:%i, 2nd file:%i\nScopes:\t start:%i stop:%i\nand:\t start:%i stop:%i\nEqual packets: %i \nAllowed variation: %f \nAverage time difference: %f\n", cs->filter ? cs->filter : "", (first_file_amount+second_file_amount), first_file_amount, second_file_amount, cs->start_packet_nr_first, cs->stop_packet_nr_first, cs->start_packet_nr_second, cs->stop_packet_nr_second, cs->stats.num, cs->stats.variance, fabs(get_average(&cs->stats.tot, cs->stats.num)));
printf("\n");
printf("===================================================================\n");
gint start, stop,ttl, order, pos=0;
gdouble variance;
- if(sscanf(optarg,"compare,%d,%d,%d,%d,%lf,%n",&start, &stop, &ttl, &order, &variance, &pos)==5){
+ if(sscanf(optarg,"compare,%d,%d,%d,%d,%lf%n",&start, &stop, &ttl, &order, &variance, &pos)==5){
if(pos){
- filter=optarg+pos;
+ if(*(optarg+pos)==',')
+ filter=optarg+pos+1;
+ else
+ filter=optarg+pos;
} else {
filter=NULL;
}
} else {
cs->filter=NULL;
}
-
+
/* create a Hash to count the packets with the same ip.id */
cs->packet_tree=se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "Packet_info_tree");
- error_string=register_tap_listener("ip", cs, filter, comparestat_reset, comparestat_packet, comparestat_draw);
+ error_string=register_tap_listener("ip", cs, filter, 0, comparestat_reset, comparestat_packet, comparestat_draw);
if(error_string){
/* error, we failed to attach to the tap. clean up */
g_free(cs->filter);