4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 013d3692 was
09be643,
checked in by Josef Vodanovich <jjv4@…>, 15 years ago
|
removed unnecessary loops
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | #include <netdb.h> |
---|
2 | #include <inttypes.h> |
---|
3 | #include <lt_inttypes.h> |
---|
4 | #include <stdio.h> |
---|
5 | #include "libtrace.h" |
---|
6 | #include "tracereport.h" |
---|
7 | |
---|
8 | static stat_t ttl_stat[4][256] = {{{0,0}}} ; |
---|
9 | static bool suppress[4] = {true,true,true,true}; |
---|
10 | |
---|
11 | void ttl_per_packet(struct libtrace_packet_t *packet) |
---|
12 | { |
---|
13 | struct libtrace_ip *ip = trace_get_ip(packet); |
---|
14 | if (!ip) |
---|
15 | return; |
---|
16 | int dir = trace_get_direction(packet); |
---|
17 | if(dir < 0 || dir > 1) |
---|
18 | dir = 2; |
---|
19 | ttl_stat[dir][ip->ip_ttl].count++; |
---|
20 | ttl_stat[dir][ip->ip_ttl].bytes+=trace_get_wire_length(packet); |
---|
21 | suppress[dir] = false; |
---|
22 | } |
---|
23 | |
---|
24 | void ttl_suppress() |
---|
25 | { |
---|
26 | int i; |
---|
27 | printf("%-20s","Direction:"); |
---|
28 | for(i=0;i<4;i++){ |
---|
29 | if(!suppress[i]){ |
---|
30 | switch(i){ |
---|
31 | case 0: |
---|
32 | printf("\t%24s", "Outbound "); |
---|
33 | break; |
---|
34 | case 1: |
---|
35 | printf("\t%24s", "Inbound "); |
---|
36 | break; |
---|
37 | case 2: |
---|
38 | printf("\t%24s", "Undefined "); |
---|
39 | break; |
---|
40 | default: |
---|
41 | break; |
---|
42 | } |
---|
43 | } |
---|
44 | } |
---|
45 | printf("\n"); |
---|
46 | printf("%-20s","TTL"); |
---|
47 | for(i=0;i<4;i++){ |
---|
48 | if(!suppress[i]){ |
---|
49 | printf("\t%12s\t%12s", "bytes","packets"); |
---|
50 | } |
---|
51 | } |
---|
52 | printf("\n"); |
---|
53 | } |
---|
54 | |
---|
55 | void ttl_report(void) |
---|
56 | { |
---|
57 | int i,j; |
---|
58 | printf("# TTL breakdown:\n"); |
---|
59 | ttl_suppress(); |
---|
60 | for(i=0;i<256;++i) { |
---|
61 | if (ttl_stat[0][i].count==0 && |
---|
62 | ttl_stat[1][i].count==0 && ttl_stat[2][i].count==0) |
---|
63 | continue; |
---|
64 | printf("%20i:",i); |
---|
65 | for(j=0;j<4;j++){ |
---|
66 | if (ttl_stat[j][i].count==0){ |
---|
67 | if(!suppress[j]) |
---|
68 | printf("\t%24s"," "); |
---|
69 | continue; |
---|
70 | } |
---|
71 | printf("\t%12" PRIu64 "\t%12" PRIu64, |
---|
72 | ttl_stat[j][i].bytes, |
---|
73 | ttl_stat[j][i].count); |
---|
74 | } |
---|
75 | printf("\n"); |
---|
76 | } |
---|
77 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.