* 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/tap.h>
#include <epan/stat_cmd_args.h>
#include <epan/dissectors/packet-dcerpc.h>
-#include "register.h"
+
+#define MICROSECS_PER_SEC 1000000
+#define NANOSECS_PER_SEC 1000000000
/* used to keep track of statistics for a specific procedure */
typedef struct _rpc_procedure_t {
rp->max.secs=delta.secs;
rp->max.nsecs=delta.nsecs;
}
-
+
rp->tot.secs += delta.secs;
rp->tot.nsecs += delta.nsecs;
- if(rp->tot.nsecs>1000000000){
- rp->tot.nsecs-=1000000000;
+ if(rp->tot.nsecs > NANOSECS_PER_SEC){
+ rp->tot.nsecs -= NANOSECS_PER_SEC;
rp->tot.secs++;
}
{
rpcstat_t *rs=prs;
guint32 i;
-#ifdef G_HAVE_UINT64
guint64 td;
-#else
- guint32 td;
-#endif
printf("\n");
- printf("===================================================================\n");
- printf("%s Major Version %u RTT Statistics:\n", rs->prog, rs->ver);
+ printf("=======================================================================\n");
+ printf("%s Major Version %u SRT Statistics:\n", rs->prog, rs->ver);
printf("Filter: %s\n",rs->filter?rs->filter:"");
- printf("Procedure Calls Min RTT Max RTT Avg RTT\n");
+ printf("Procedure Calls Min SRT Max SRT Avg SRT\n");
+
for(i=0;i<rs->num_procedures;i++){
- /* scale it to units of 10us.*/
- /* for long captures with a large tot time, this can overflow on 32bit */
- td=(int)rs->procedures[i].tot.secs;
- td=td*100000+(int)rs->procedures[i].tot.nsecs/10000;
- if(rs->procedures[i].num){
- td/=rs->procedures[i].num;
- } else {
- td=0;
+ /* Only display procs with non-zero calls */
+ if(rs->procedures[i].num==0){
+ continue;
}
+ /* Scale the average SRT in units of 1us and round to the nearest us. */
+ td = ((guint64)(rs->procedures[i].tot.secs)) * NANOSECS_PER_SEC + rs->procedures[i].tot.nsecs;
+ td = ((td / rs->procedures[i].num) + 500) / 1000;
- printf("%-25s %6d %3d.%05d %3d.%05d %3d.%05d\n",
+ printf("%-31s %6d %3d.%06d %3d.%06d %3" G_GINT64_MODIFIER "u.%06" G_GINT64_MODIFIER "u\n",
rs->procedures[i].proc,
rs->procedures[i].num,
- (int)rs->procedures[i].min.secs,rs->procedures[i].min.nsecs/10000,
- (int)rs->procedures[i].max.secs,rs->procedures[i].max.nsecs/10000,
- td/100000, td%100000
+ (int)(rs->procedures[i].min.secs),(rs->procedures[i].min.nsecs+500)/1000,
+ (int)(rs->procedures[i].max.secs),(rs->procedures[i].max.nsecs+500)/1000,
+ td/MICROSECS_PER_SEC, td%MICROSECS_PER_SEC
);
}
- printf("===================================================================\n");
+ printf("=======================================================================\n");
}
int pos=0;
const char *filter=NULL;
GString *error_string;
-
+
/*
* XXX - DCE RPC statistics are maintained only by major version,
* not by major and minor version, so the minor version number is
* and allow the minor version number to be omitted, and
* report aggregate statistics for all minor version numbers
* if it's omitted?
- *
- * XXX - should this be called "srt" rather than "rtt"? The
- * equivalent tap for Wireshark calls it "srt", for "Service
- * Response Time", rather than "rtt" for "Round-Trip Time".
*/
- if(sscanf(optarg,"dcerpc,rtt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d%n", &d1,&d2,&d3,&d40,&d41,&d42,&d43,&d44,&d45,&d46,&d47,&major,&minor,&pos)==13){
+ if(sscanf(optarg,
+ "dcerpc,srt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d%n",
+ &d1,&d2,&d3,&d40,&d41,&d42,&d43,&d44,&d45,&d46,&d47,
+ &major,&minor,&pos)==13){
uuid.Data1=d1;
uuid.Data2=d2;
uuid.Data3=d3;
filter=NULL;
}
} else {
- fprintf(stderr, "tshark: invalid \"-z dcerpc,rtt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
+ fprintf(stderr, "tshark: invalid \"-z dcerpc,srt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
exit(1);
}
if (major < 0 || major > 65535) {
rs->ver=ver;
if(filter){
- rs->filter=g_malloc(strlen(filter)+1);
- strcpy(rs->filter, filter);
+ rs->filter=g_strdup(filter);
} else {
rs->filter=NULL;
}
rs->procedures[i].proc=procs[j].name;
}
}
- rs->procedures[i].num=0;
+ rs->procedures[i].num=0;
rs->procedures[i].min.secs=0;
rs->procedures[i].min.nsecs=0;
rs->procedures[i].max.secs=0;
rs->procedures[i].tot.nsecs=0;
}
- error_string=register_tap_listener("dcerpc", rs, filter, NULL, dcerpcstat_packet, dcerpcstat_draw);
+ error_string=register_tap_listener("dcerpc", rs, filter, 0, NULL, dcerpcstat_packet, dcerpcstat_draw);
if(error_string){
/* error, we failed to attach to the tap. clean up */
g_free(rs->procedures);
g_free(rs->filter);
g_free(rs);
- fprintf(stderr, "tshark: Couldn't register dcerpc,rtt tap: %s\n",
+ fprintf(stderr, "tshark: Couldn't register dcerpc,srt tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
void
register_tap_listener_dcerpcstat(void)
{
- register_stat_cmd_arg("dcerpc,rtt,", dcerpcstat_init,NULL);
+ register_stat_cmd_arg("dcerpc,srt,", dcerpcstat_init,NULL);
}