Update to the io,stat tethereal tap.

Make it possible to use subsecond granularity for the measurement intervals.

io,stat is updated to accept the interval to be specified with ms resolution.

Example

-z io,stat,0.001,smb

to generate 1ms statistics for all SMB traffic.

svn path=/trunk/; revision=7527
This commit is contained in:
Ronnie Sahlberg 2003-04-22 09:02:54 +00:00
parent 146f8ebd46
commit 729e433e37
2 changed files with 31 additions and 13 deletions

View File

@ -348,7 +348,9 @@ This option can be used multiple times on the command line.
B<-z> io,stat,I<interval>[,I<filter>][,I<filter>][,I<filter>]...
Collect frame/bytes statistics for the capture in intervals of I<interval>
seconds.
seconds. I<Intervals> can be specified either as whole or fractional seconds.
Interval can be specified in ms resolution.
If no I<filter> is specified the statistics will be calculated for all frames.
If one or more I<filters> are specified statistics will be calculated for
all filters and presented with one column of statistics for each filter.
@ -356,6 +358,12 @@ all filters and presented with one column of statistics for each filter.
This option can be used multiple times on the command line.
Example: -z io,stat,1,ip.addr==1.2.3.4 to generate 1 second statistics for
all traffic to/from host 1.2.3.4
Example: -z "io,stat,0.001,smb&&ip.addr==1.2.3.4" to generate 1ms statistics for all SMB frames to/from host 1.2.3.4.
B<-z> io,users,I<type>[,I<filter>]
Create a table that lists all conversations that could be seen in the capture.

View File

@ -1,7 +1,7 @@
/* tap-iostat.c
* iostat 2002 Ronnie Sahlberg
*
* $Id: tap-iostat.c,v 1.3 2002/11/15 10:55:15 sahlberg Exp $
* $Id: tap-iostat.c,v 1.4 2003/04/22 09:02:47 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -39,7 +39,7 @@
typedef struct _io_stat_t {
gint32 interval;
gint32 interval; /* unit is ms */
guint32 num_items;
struct _io_stat_item_t *items;
char **filters;
@ -49,7 +49,7 @@ typedef struct _io_stat_item_t {
io_stat_t *parent;
struct _io_stat_item_t *next;
struct _io_stat_item_t *prev;
gint32 time;
gint32 time; /* unit is ms since start of capture */
guint32 frames;
guint32 bytes;
} io_stat_item_t;
@ -102,25 +102,28 @@ static int
iostat_packet(io_stat_item_t *mit, packet_info *pinfo, epan_dissect_t *edt _U_, void *dummy _U_)
{
io_stat_item_t *it;
gint32 current_time;
current_time=((pinfo->fd->rel_secs*1000)+(pinfo->fd->rel_usecs/1000));
/* the prev item before the main one is always the last interval we saw packets for */
it=mit->prev;
/* XXX for the time being, just ignore all frames that are in the past.
should be fixed in the future but hopefully it is uncommon */
if(pinfo->fd->rel_secs<it->time){
if(current_time<it->time){
return FALSE;
}
/* we have moved into a new interval, we need to create a new struct */
if(pinfo->fd->rel_secs>=(it->time+mit->parent->interval)){
if(current_time>=(it->time+mit->parent->interval)){
it->next=g_malloc(sizeof(io_stat_item_t));
it->next->prev=it;
it->next->next=NULL;
it=it->next;
mit->prev=it;
it->time=(pinfo->fd->rel_secs / mit->parent->interval) * mit->parent->interval;
it->time=(current_time / mit->parent->interval) * mit->parent->interval;
it->frames=0;
it->bytes=0;
}
@ -151,12 +154,12 @@ iostat_draw(io_stat_item_t *mit)
for(i=0;i<iot->num_items;i++){
printf("Column #%d: %s\n",i,iot->filters[i]?iot->filters[i]:"");
}
printf(" ");
printf(" ");
for(i=0;i<iot->num_items;i++){
printf("| Column #%-2d ",i);
}
printf("\n");
printf("Time ");
printf("Time ");
for(i=0;i<iot->num_items;i++){
printf("|frames| bytes ");
}
@ -194,7 +197,9 @@ iostat_draw(io_stat_item_t *mit)
}
if(more_items){
printf("%5d-%5d ",t,t+iot->interval);
printf("%03d.%03d-%03d.%03d ",
t/1000,t%1000,
(t+iot->interval)/1000,(t+iot->interval)%1000);
for(i=0;i<iot->num_items;i++){
printf("%6d %9d ",frames[i],bytes[i]);
}
@ -234,11 +239,13 @@ register_io_tap(io_stat_t *io, int i, char *filter)
void
iostat_init(char *optarg)
{
int interval, pos=0;
float interval_float;
gint32 interval;
int pos=0;
io_stat_t *io;
char *filter=NULL;
if(sscanf(optarg,"io,stat,%d,%n",&interval,&pos)==1){
if(sscanf(optarg,"io,stat,%f,%n",&interval_float,&pos)==1){
if(pos){
filter=optarg+pos;
} else {
@ -249,8 +256,11 @@ iostat_init(char *optarg)
exit(1);
}
/* make interval be number of ms */
interval=interval_float*1000;
if(interval<1){
fprintf(stderr, "tethereal:iostat_init() interval must be >0 seconds\n");
fprintf(stderr, "tethereal:iostat_init() interval must be >=0.001 seconds\n");
exit(10);
}