* 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-rpc.h>
-#include "register.h"
+
+#define MICROSECS_PER_SEC 1000000
+#define NANOSECS_PER_SEC 1000000000
/* used to keep track of statistics for a specific program/version */
typedef struct _rpc_program_t {
}
}
-
+
/* we are only interested in reply packets */
if(ri->request || !rp){
return 0;
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++;
}
rp->num++;
char str[64];
printf("\n");
- printf("===================================================================\n");
+ printf("==========================================================\n");
printf("ONC-RPC Program Statistics:\n");
- printf("Program Version Calls Min SRT Max SRT Avg SRT\n");
+ printf("Program Version Calls Min SRT Max SRT Avg SRT\n");
for(rp=prog_list;rp;rp=rp->next){
- /* scale it to units of 10us.*/
- td=rp->tot.secs;
- td=td*100000+(int)rp->tot.nsecs/10000;
- if(rp->num){
- td/=rp->num;
- } else {
- td=0;
+ /* Only display procs with non-zero calls */
+ if(rp->num==0){
+ continue;
}
+ /* Scale the average SRT in units of 1us and round to the nearest us. */
+ td = ((guint64)(rp->tot.secs)) * NANOSECS_PER_SEC + rp->tot.nsecs;
+ td = ((td / rp->num) + 500) / 1000;
g_snprintf(str, sizeof(str), "%s(%d)",rpc_prog_name(rp->program),rp->program);
- printf("%-15s %2d %6d %3d.%05d %3d.%05d %3" G_GINT64_MODIFIER "u.%05" G_GINT64_MODIFIER "u\n",
+ printf("%-15s %2d %6d %3d.%06d %3d.%06d %3" G_GINT64_MODIFIER "u.%06" G_GINT64_MODIFIER "u\n",
str,
rp->version,
rp->num,
- (int)rp->min.secs,rp->min.nsecs/10000,
- (int)rp->max.secs,rp->max.nsecs/10000,
- td/100000, td%100000
+ (int)(rp->min.secs),(rp->min.nsecs+500)/1000,
+ (int)(rp->max.secs),(rp->max.nsecs+500)/1000,
+ td/MICROSECS_PER_SEC, td%MICROSECS_PER_SEC
);
}
printf("===================================================================\n");