diff options
-rw-r--r-- | tap-dcerpcstat.c | 37 | ||||
-rw-r--r-- | tap-rpcprogs.c | 32 | ||||
-rw-r--r-- | tap-rpcstat.c | 37 | ||||
-rw-r--r-- | tap-smbstat.c | 74 |
4 files changed, 87 insertions, 93 deletions
diff --git a/tap-dcerpcstat.c b/tap-dcerpcstat.c index 1ed0ce6eb2..d02236dfdf 100644 --- a/tap-dcerpcstat.c +++ b/tap-dcerpcstat.c @@ -38,6 +38,9 @@ #include <epan/stat_cmd_args.h> #include <epan/dissectors/packet-dcerpc.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; @@ -131,8 +134,8 @@ dcerpcstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, const 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++; } @@ -148,29 +151,29 @@ dcerpcstat_draw(void *prs) guint32 i; guint64 td; 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.*/ - 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; + /* 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 %3" G_GINT64_MODIFIER "u.%05" G_GINT64_MODIFIER "u\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"); } diff --git a/tap-rpcprogs.c b/tap-rpcprogs.c index 295932bec0..accc64c00d 100644 --- a/tap-rpcprogs.c +++ b/tap-rpcprogs.c @@ -42,6 +42,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 program/version */ typedef struct _rpc_program_t { struct _rpc_program_t *next; @@ -164,8 +167,8 @@ rpcprogs_packet(void *dummy1 _U_, packet_info *pinfo, epan_dissect_t *edt _U_, c 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++; @@ -182,27 +185,26 @@ rpcprogs_draw(void *dummy _U_) 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"); 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; diff --git a/tap-smbstat.c b/tap-smbstat.c index a2d0d66cf1..ac7d4f019f 100644 --- a/tap-smbstat.c +++ b/tap-smbstat.c @@ -40,6 +40,9 @@ #include <epan/dissectors/packet-smb.h> #include "timestats.h" +#define MICROSECS_PER_SEC 1000000 +#define NANOSECS_PER_SEC 1000000000 + /* used to keep track of the statistics for an entire program interface */ typedef struct _smbstat_t { char *filter; @@ -103,10 +106,10 @@ smbstat_draw(void *pss) guint32 i; guint64 td; printf("\n"); - printf("===================================================================\n"); - printf("SMB RTT Statistics:\n"); + printf("=================================================================\n"); + printf("SMB SRT Statistics:\n"); printf("Filter: %s\n",ss->filter?ss->filter:""); - printf("Commands Calls Min RTT Max RTT Avg RTT\n"); + printf("Commands Calls Min SRT Max SRT Avg SRT\n"); for(i=0;i<256;i++){ /* nothing seen, nothing to do */ if(ss->proc[i].num==0){ @@ -123,77 +126,62 @@ smbstat_draw(void *pss) continue; } - /* scale it to units of 10us.*/ - td=ss->proc[i].tot.secs; - td=td*100000+(int)ss->proc[i].tot.nsecs/10000; - if(ss->proc[i].num){ - td/=ss->proc[i].num; - } else { - td=0; - } + /* Scale the average SRT in units of 1us and round to the nearest us. */ + td = ((guint64)(ss->proc[i].tot.secs)) * NANOSECS_PER_SEC + ss->proc[i].tot.nsecs; + + td = ((td / ss->proc[i].num) + 500) / 1000; - printf("%-25s %6d %3d.%05d %3d.%05d %3" G_GINT64_MODIFIER "u.%05" G_GINT64_MODIFIER "u\n", + printf("%-25s %6d %3d.%06d %3d.%06d %3" G_GINT64_MODIFIER "u.%06" G_GINT64_MODIFIER "u\n", val_to_str_ext(i, &smb_cmd_vals_ext, "Unknown (0x%02x)"), ss->proc[i].num, - (int)ss->proc[i].min.secs,ss->proc[i].min.nsecs/10000, - (int)ss->proc[i].max.secs,ss->proc[i].max.nsecs/10000, - td/100000, td%100000 + (int)(ss->proc[i].min.secs),(ss->proc[i].min.nsecs+500)/1000, + (int)(ss->proc[i].max.secs),(ss->proc[i].max.nsecs+500)/1000, + td/MICROSECS_PER_SEC, td%MICROSECS_PER_SEC ); } printf("\n"); - printf("Transaction2 Commands Calls Min RTT Max RTT Avg RTT\n"); + printf("Transaction2 Commands Calls Min SRT Max SRT Avg SRT\n"); for(i=0;i<256;i++){ /* nothing seen, nothing to do */ if(ss->trans2[i].num==0){ continue; } - /* scale it to units of 10us.*/ - td=ss->trans2[i].tot.secs; - td=td*100000+(int)ss->trans2[i].tot.nsecs/10000; - if(ss->trans2[i].num){ - td/=ss->trans2[i].num; - } else { - td=0; - } + /* Scale the average SRT in units of 1us and round to the nearest us. */ + td = ((guint64)(ss->trans2[i].tot.secs)) * NANOSECS_PER_SEC + ss->trans2[i].tot.nsecs; + td = ((td / ss->trans2[i].num) + 500) / 1000; - printf("%-25s %6d %3d.%05d %3d.%05d %3" G_GINT64_MODIFIER "u.%05" G_GINT64_MODIFIER "u\n", + printf("%-25s %6d %3d.%06d %3d.%06d %3" G_GINT64_MODIFIER "u.%06" G_GINT64_MODIFIER "u\n", val_to_str_ext(i, &trans2_cmd_vals_ext, "Unknown (0x%02x)"), ss->trans2[i].num, - (int)ss->trans2[i].min.secs,ss->trans2[i].min.nsecs/10000, - (int)ss->trans2[i].max.secs,ss->trans2[i].max.nsecs/10000, - td/100000, td%100000 + (int)(ss->trans2[i].min.secs),(ss->trans2[i].min.nsecs+500)/1000, + (int)(ss->trans2[i].max.secs),(ss->trans2[i].max.nsecs+500)/1000, + td/MICROSECS_PER_SEC, td%MICROSECS_PER_SEC ); } printf("\n"); - printf("NT Transaction Commands Calls Min RTT Max RTT Avg RTT\n"); + printf("NT Transaction Commands Calls Min SRT Max SRT Avg SRT\n"); for(i=0;i<256;i++){ /* nothing seen, nothing to do */ if(ss->nt_trans[i].num==0){ continue; } + /* Scale the average SRT in units of 1us and round to the nearest us. */ + td = ((guint64)(ss->nt_trans[i].tot.secs)) * NANOSECS_PER_SEC + ss->nt_trans[i].tot.nsecs; + td = ((td / ss->nt_trans[i].num) + 500) / 1000; - /* scale it to units of 10us.*/ - td=ss->nt_trans[i].tot.secs; - td=td*100000+(int)ss->nt_trans[i].tot.nsecs/10000; - if(ss->nt_trans[i].num){ - td/=ss->nt_trans[i].num; - } else { - td=0; - } - - printf("%-25s %6d %3d.%05d %3d.%05d %3" G_GINT64_MODIFIER "u.%05" G_GINT64_MODIFIER "u\n", + printf("%-25s %6d %3d.%06d %3d.%06d %3" G_GINT64_MODIFIER "u.%06" G_GINT64_MODIFIER "u\n", val_to_str_ext(i, &nt_cmd_vals_ext, "Unknown (0x%02x)"), ss->nt_trans[i].num, - (int)ss->nt_trans[i].min.secs,ss->nt_trans[i].min.nsecs/10000, - (int)ss->nt_trans[i].max.secs,ss->nt_trans[i].max.nsecs/10000, - td/100000, td%100000 + (int)(ss->nt_trans[i].min.secs),(ss->nt_trans[i].min.nsecs+500)/1000, + (int)(ss->nt_trans[i].max.secs),(ss->nt_trans[i].max.nsecs+500)/1000, + td/MICROSECS_PER_SEC, td%MICROSECS_PER_SEC ); } - printf("===================================================================\n"); + printf("=================================================================\n"); } |