Changeset 4dd7363 for examples/count
- Timestamp:
- 10/13/05 14:09:18 (17 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- d2cc963
- Parents:
- 3aed3ed
- Location:
- examples/count
- Files:
-
- 3 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
examples/count/Makefile
r18478c1 r4dd7363 9 9 LDLIBS = $(libdir) -ltrace 10 10 11 BINS = count11 BINS = tracestats 12 12 .PHONY: all clean distclean install depend 13 13 -
examples/count/tracestats.c
r18478c1 r4dd7363 30 30 31 31 // 32 // This program takes a trace and outputs every packet that it sees to standard 33 // out, decoding source/dest IP's, protocol type, and the timestamp of this 34 // packet. 32 // This program takes a series of traces and bpf filters and outputs how many 33 // bytes/packets 35 34 36 35 #include <stdio.h> … … 63 62 } *filters = NULL; 64 63 int filter_count=0; 65 uint64_t count;66 uint64_t bytes;64 uint64_t totcount; 65 uint64_t totbytes; 67 66 68 67 /* Process a trace, counting packets that match filter(s) */ … … 71 70 struct libtrace_packet_t packet; 72 71 int i; 72 uint64_t count = 0; 73 uint64_t bytes = 0; 73 74 74 75 fprintf(stderr,"%s:\n",uri); … … 94 95 95 96 for(i=0;i<filter_count;++i) { 96 printf("% s\t%8"PRIu64"\t%8"PRIu64"\t%5.02f\n",filters[i].expr,filters[i].count,filters[i].bytes,filters[i].count*100.0/count);97 printf("%30s:\t%12"PRIu64"\t%12"PRIu64"\t%7.03f\n",filters[i].expr,filters[i].count,filters[i].bytes,filters[i].count*100.0/count); 97 98 filters[i].bytes=0; 98 99 filters[i].count=0; 99 100 } 100 printf(" Total:\t%8"PRIu64"\t%8" PRIu64 "\n",count,bytes);101 count=0;102 bytes=0;101 printf("%30s:\t%12"PRIu64"\t%12" PRIu64 "\n","Total",count,bytes); 102 totcount+=count; 103 totbytes+=bytes; 103 104 104 105 trace_destroy(trace); … … 143 144 } 144 145 145 printf(" filter\tcount \tbytes \t%%\n");146 printf("%-30s\t%12s\t%12s\t%7s\n","filter","count","bytes","%"); 146 147 for(i=optind;i<argc;++i) { 147 148 run_trace(argv[i]); 149 } 150 if (optind+1<argc) { 151 printf("Grand total:\n"); 152 printf("%30s:\t%12"PRIu64"\t%12" PRIu64 "\n","Total",totcount,totbytes); 148 153 } 149 154
Note: See TracChangeset
for help on using the changeset viewer.