4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 33dff53 was
b5dc60d,
checked in by Josef Vodanovich <jjv4@…>, 15 years ago
|
Lots of minor changes to the reports to make it look a bit nicer and tcp ss should be working.
|
-
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[3][256] = {{{0,0}}} ; |
---|
9 | static bool suppress[3] = {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 | libtrace_direction_t dir = trace_get_direction(packet); |
---|
15 | |
---|
16 | if (!ip) |
---|
17 | return; |
---|
18 | |
---|
19 | if (dir != TRACE_DIR_INCOMING && dir != TRACE_DIR_OUTGOING) |
---|
20 | dir = TRACE_DIR_OTHER; |
---|
21 | |
---|
22 | ttl_stat[dir][ip->ip_ttl].count++; |
---|
23 | ttl_stat[dir][ip->ip_ttl].bytes+=trace_get_wire_length(packet); |
---|
24 | suppress[dir] = false; |
---|
25 | } |
---|
26 | |
---|
27 | void ttl_suppress() |
---|
28 | { |
---|
29 | int i; |
---|
30 | printf("%-20s","Direction:"); |
---|
31 | for(i=0;i<3;i++){ |
---|
32 | if(!suppress[i]){ |
---|
33 | switch(i){ |
---|
34 | case 0: |
---|
35 | printf("\t%24s", "Outbound "); |
---|
36 | break; |
---|
37 | case 1: |
---|
38 | printf("\t%24s", "Inbound "); |
---|
39 | break; |
---|
40 | case 2: |
---|
41 | printf("\t%24s", "Undefined "); |
---|
42 | break; |
---|
43 | default: |
---|
44 | break; |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|
48 | printf("\n"); |
---|
49 | printf("%-20s","TTL"); |
---|
50 | for(i=0;i<3;i++){ |
---|
51 | if(!suppress[i]){ |
---|
52 | printf("\t%12s\t%12s", "bytes","packets"); |
---|
53 | } |
---|
54 | } |
---|
55 | printf("\n"); |
---|
56 | } |
---|
57 | |
---|
58 | void ttl_report(void) |
---|
59 | { |
---|
60 | int i,j; |
---|
61 | printf("# TTL breakdown:\n"); |
---|
62 | ttl_suppress(); |
---|
63 | for(i=0;i<256;++i) { |
---|
64 | if (ttl_stat[0][i].count==0 && |
---|
65 | ttl_stat[1][i].count==0 && ttl_stat[2][i].count==0) |
---|
66 | continue; |
---|
67 | printf("%20i:",i); |
---|
68 | for(j=0;j<3;j++){ |
---|
69 | if (ttl_stat[j][i].count==0){ |
---|
70 | if(!suppress[j]) |
---|
71 | printf("\t%24s"," "); |
---|
72 | continue; |
---|
73 | } |
---|
74 | printf("\t%12" PRIu64 "\t%12" PRIu64, |
---|
75 | ttl_stat[j][i].bytes, |
---|
76 | ttl_stat[j][i].count); |
---|
77 | } |
---|
78 | printf("\n"); |
---|
79 | } |
---|
80 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.