diff options
author | cmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-01-14 17:06:53 +0000 |
---|---|---|
committer | cmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-01-14 17:06:53 +0000 |
commit | 18355cb1bd45c07c3bb8db529960e1a741a57571 (patch) | |
tree | 43972250d0a84d0d32d6d8d700d0d18bf1986e58 /tap-rpcstat.c | |
parent | da17a7a4471347887db02503dbb5221e0bccce33 (diff) |
From Cal Turney via bug 4964: Round & display 6 decimal places in tshark SRTs.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35537 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'tap-rpcstat.c')
-rw-r--r-- | tap-rpcstat.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/tap-rpcstat.c b/tap-rpcstat.c index ccc2045f7c..b61e09333f 100644 --- a/tap-rpcstat.c +++ b/tap-rpcstat.c @@ -22,7 +22,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* This module provides rpc call/reply RTT statistics to tshark. +/* This module provides rpc call/reply SRT statistics to tshark. * It is only used by tshark and not wireshark * * It serves as an example on how to use the tap api. @@ -44,6 +44,9 @@ #include <epan/stat_cmd_args.h> #include <epan/dissectors/packet-rpc.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 { const char *proc; @@ -175,8 +178,8 @@ rpcstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, const voi 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++; } @@ -203,29 +206,27 @@ rpcstat_draw(void *prs) guint32 i; guint64 td; printf("\n"); - printf("===================================================================\n"); - printf("%s Version %d RTT Statistics:\n", rs->prog, rs->version); + printf("=======================================================\n"); + printf("%s Version %d SRT Statistics:\n", rs->prog, rs->version); 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.*/ - td=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; + 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("%-15s %6d %3d.%05d %3d.%05d %3" G_GINT64_MODIFIER "u.%05" G_GINT64_MODIFIER "u\n", + printf("%-15s %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"); } static guint32 rpc_program=0; |