forked from osmocom/wireshark
From Andrew Feren (bug 2462):
Patch to print packet rate. From me: Document -x option in man page. svn path=/trunk/; revision=25024
This commit is contained in:
parent
5acf099bd2
commit
16717f3be2
12
capinfos.c
12
capinfos.c
|
@ -67,6 +67,7 @@ static gboolean cap_end_time = FALSE;
|
||||||
static gboolean cap_data_rate_byte = FALSE;
|
static gboolean cap_data_rate_byte = FALSE;
|
||||||
static gboolean cap_data_rate_bit = FALSE;
|
static gboolean cap_data_rate_bit = FALSE;
|
||||||
static gboolean cap_packet_size = FALSE;
|
static gboolean cap_packet_size = FALSE;
|
||||||
|
static gboolean cap_packet_rate = FALSE;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _capture_info {
|
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_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_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_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
|
static int
|
||||||
|
@ -200,10 +202,12 @@ process_cap_file(wtap *wth, const char *filename)
|
||||||
|
|
||||||
if (packet > 0) {
|
if (packet > 0) {
|
||||||
cf_info.data_rate = (double)bytes / (stop_time-start_time); /* Data rate per second */
|
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 */
|
cf_info.packet_size = (double)bytes / packet; /* Avg packet size */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cf_info.data_rate = 0.0;
|
cf_info.data_rate = 0.0;
|
||||||
|
cf_info.packet_rate = 0.0;
|
||||||
cf_info.packet_size = 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, " -y display average data rate (in bytes/s)\n");
|
||||||
fprintf(output, " -i display average data rate (in bits/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, " -z display average packet size (in bytes)\n");
|
||||||
|
fprintf(output, " -x display average packet rate (in packets/s)\n");
|
||||||
fprintf(output, "\n");
|
fprintf(output, "\n");
|
||||||
fprintf(output, "Miscellaneous:\n");
|
fprintf(output, "Miscellaneous:\n");
|
||||||
fprintf(output, " -h display this help and exit\n");
|
fprintf(output, " -h display this help and exit\n");
|
||||||
|
@ -306,7 +311,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Process the options */
|
/* Process the options */
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "tEcsduaeyizvh")) !=-1) {
|
while ((opt = getopt(argc, argv, "tEcsduaeyizvhx")) !=-1) {
|
||||||
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
|
||||||
|
@ -354,6 +359,10 @@ main(int argc, char *argv[])
|
||||||
cap_packet_size = TRUE;
|
cap_packet_size = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
cap_packet_rate = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(FALSE);
|
usage(FALSE);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -381,6 +390,7 @@ main(int argc, char *argv[])
|
||||||
cap_data_rate_byte = TRUE;
|
cap_data_rate_byte = TRUE;
|
||||||
cap_data_rate_bit = TRUE;
|
cap_data_rate_bit = TRUE;
|
||||||
cap_packet_size = TRUE;
|
cap_packet_size = TRUE;
|
||||||
|
cap_packet_rate = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((argc - optind) < 1) {
|
if ((argc - optind) < 1) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ S<[ B<-e> ]>
|
||||||
S<[ B<-y> ]>
|
S<[ B<-y> ]>
|
||||||
S<[ B<-i> ]>
|
S<[ B<-i> ]>
|
||||||
S<[ B<-z> ]>
|
S<[ B<-z> ]>
|
||||||
|
S<[ B<-x> ]>
|
||||||
S<[ B<-h> ]>
|
S<[ B<-h> ]>
|
||||||
E<lt>I<infile>E<gt>
|
E<lt>I<infile>E<gt>
|
||||||
I<...>
|
I<...>
|
||||||
|
@ -104,6 +105,10 @@ Displays the average data rate, in bits
|
||||||
|
|
||||||
displays the average packet size, in bytes
|
displays the average packet size, in bytes
|
||||||
|
|
||||||
|
=item -x
|
||||||
|
|
||||||
|
displays the average packet rate, in packets
|
||||||
|
|
||||||
=item -h
|
=item -h
|
||||||
|
|
||||||
Prints the help listing and exits.
|
Prints the help listing and exits.
|
||||||
|
|
Loading…
Reference in New Issue