From Andrew Feren (bug 2462):
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 14 Apr 2008 20:02:45 +0000 (20:02 +0000)
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 14 Apr 2008 20:02:45 +0000 (20:02 +0000)
Patch to print packet rate.

From me:
Document -x option in man page.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@25024 f5534014-38df-0310-8fa8-9805f1628bb7

capinfos.c
doc/capinfos.pod

index d9be5194d129444eacbc19fb01ece3152f065e24..f6cf17baeb98ef2f48b28e3a6eb56bf43b8ee90f 100644 (file)
@@ -67,6 +67,7 @@ static gboolean cap_end_time = FALSE;
 static gboolean cap_data_rate_byte = FALSE;
 static gboolean cap_data_rate_bit = FALSE;
 static gboolean cap_packet_size = FALSE;
+static gboolean cap_packet_rate = FALSE;
 
 
 typedef struct _capture_info {
@@ -119,6 +120,7 @@ print_stats(capture_info *cf_info)
   if (cap_data_rate_byte) printf("Data rate: %.2f bytes/s\n", cf_info->data_rate);
   if (cap_data_rate_bit) printf("Data rate: %.2f bits/s\n", cf_info->data_rate*8);
   if (cap_packet_size) printf("Average packet size: %.2f bytes\n", cf_info->packet_size);
+  if (cap_packet_rate) printf("Average packet rate: %.2f packets/s\n", cf_info->packet_rate);
 }
 
 static int
@@ -200,10 +202,12 @@ process_cap_file(wtap *wth, const char *filename)
 
   if (packet > 0) {
     cf_info.data_rate   = (double)bytes / (stop_time-start_time);  /* Data rate per second */
+    cf_info.packet_rate = (double)packet / (stop_time-start_time); /* packet rate per second */
     cf_info.packet_size = (double)bytes / packet;                  /* Avg packet size      */
   }
   else {
     cf_info.data_rate   = 0.0;
+    cf_info.packet_rate = 0.0;
     cf_info.packet_size = 0.0;
   }
 
@@ -254,6 +258,7 @@ usage(gboolean is_error)
   fprintf(output, "  -y display average data rate (in bytes/s)\n");
   fprintf(output, "  -i display average data rate (in bits/s)\n");
   fprintf(output, "  -z display average packet size (in bytes)\n");
+  fprintf(output, "  -x display average packet rate (in packets/s)\n");
   fprintf(output, "\n");
   fprintf(output, "Miscellaneous:\n");
   fprintf(output, "  -h display this help and exit\n");
@@ -306,7 +311,7 @@ main(int argc, char *argv[])
 
   /* Process the options */
 
-  while ((opt = getopt(argc, argv, "tEcsduaeyizvh")) !=-1) {
+  while ((opt = getopt(argc, argv, "tEcsduaeyizvhx")) !=-1) {
 
     switch (opt) {
 
@@ -354,6 +359,10 @@ main(int argc, char *argv[])
       cap_packet_size = TRUE;
       break;
 
+    case 'x':
+      cap_packet_rate = TRUE;
+      break;
+
     case 'h':
       usage(FALSE);
       exit(1);
@@ -381,6 +390,7 @@ main(int argc, char *argv[])
     cap_data_rate_byte = TRUE;
     cap_data_rate_bit = TRUE;
     cap_packet_size = TRUE;
+    cap_packet_rate = TRUE;
   }
 
   if ((argc - optind) < 1) {
index 19de7aef48ce78654a52287dedb8e43db3ffa6a7..d0283cd0ab0bbbb472a9d32649a7c65d2c8f6176 100644 (file)
@@ -17,6 +17,7 @@ S<[ B<-e> ]>
 S<[ B<-y> ]>
 S<[ B<-i> ]>
 S<[ B<-z> ]>
+S<[ B<-x> ]>
 S<[ B<-h> ]>
 E<lt>I<infile>E<gt>
 I<...>
@@ -104,6 +105,10 @@ Displays the average data rate, in bits
 
 displays the average packet size, in bytes
 
+=item -x
+
+displays the average packet rate, in packets
+
 =item -h
 
 Prints the help listing and exits.