4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 734dfb1 was
d3ff1fb,
checked in by Perry Lorier <perry@…>, 17 years ago
|
Add trace summary
|
-
Property mode set to
100644
|
File size:
942 bytes
|
Line | |
---|
1 | #include <netdb.h> |
---|
2 | #include <inttypes.h> |
---|
3 | #include <stdio.h> |
---|
4 | #include "libtrace.h" |
---|
5 | #include "tracereport.h" |
---|
6 | #include "report.h" |
---|
7 | |
---|
8 | static stat_t prot_stat[256] = { {0,0} } ; |
---|
9 | |
---|
10 | void protocol_per_packet(struct libtrace_packet_t *packet) |
---|
11 | { |
---|
12 | struct libtrace_ip *ip = trace_get_ip(packet); |
---|
13 | if (!ip) |
---|
14 | return; |
---|
15 | |
---|
16 | prot_stat[ip->ip_p].count++; |
---|
17 | prot_stat[ip->ip_p].bytes+=trace_get_wire_length(packet); |
---|
18 | } |
---|
19 | |
---|
20 | void protocol_report(void) |
---|
21 | { |
---|
22 | int i; |
---|
23 | printf("# Protocol breakdown:\n"); |
---|
24 | printf("%-20s \t%12s\t%12s\n","Protocol","bytes","packets"); |
---|
25 | setprotoent(1); |
---|
26 | for(i=0;i<256;++i) { |
---|
27 | struct protoent *prot; |
---|
28 | if (prot_stat[i].count==0) |
---|
29 | continue; |
---|
30 | prot = getprotobynumber(i); |
---|
31 | if (prot) { |
---|
32 | printf("%20s:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
33 | prot->p_name, |
---|
34 | prot_stat[i].bytes, |
---|
35 | prot_stat[i].count); |
---|
36 | } |
---|
37 | else { |
---|
38 | printf("%20i:\t%12" PRIu64 "\t%12" PRIu64 "\n", |
---|
39 | i, |
---|
40 | prot_stat[i].bytes, |
---|
41 | prot_stat[i].count); |
---|
42 | |
---|
43 | } |
---|
44 | } |
---|
45 | setprotoent(0); |
---|
46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.