4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since d4336d5 was
d4336d5,
checked in by Shane Alcock <salcock@…>, 15 years ago
|
Updated tracereport to include all the work Josef has done
|
-
Property mode set to
100644
|
File size:
1.6 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 ecn_stat[4][4] = {{{0,0}}} ; |
---|
9 | static bool suppress[4] = {true,true,true,true}; |
---|
10 | |
---|
11 | void ecn_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 | |
---|
20 | int ecn = ip->ip_tos; |
---|
21 | ecn &= 3; |
---|
22 | ecn_stat[dir][ecn].count++; |
---|
23 | ecn_stat[dir][ecn].bytes+=trace_get_wire_length(packet); |
---|
24 | suppress[dir] = false; |
---|
25 | } |
---|
26 | |
---|
27 | void ecn_suppress() |
---|
28 | { |
---|
29 | int i; |
---|
30 | printf("%-20s","Direction:"); |
---|
31 | //printf("%20s", " "); |
---|
32 | for(i=0;i<4;i++){ |
---|
33 | if(!suppress[i]){ |
---|
34 | switch(i){ |
---|
35 | case 0: |
---|
36 | printf("\t%24s", "Outbound "); |
---|
37 | break; |
---|
38 | case 1: |
---|
39 | printf("\t%24s", "Inbound "); |
---|
40 | break; |
---|
41 | case 2: |
---|
42 | printf("\t%24s", "Undefined "); |
---|
43 | break; |
---|
44 | default: |
---|
45 | break; |
---|
46 | } |
---|
47 | } |
---|
48 | } |
---|
49 | printf("\n"); |
---|
50 | printf("%-20s","ECN"); |
---|
51 | for(i=0;i<4;i++){ |
---|
52 | if(!suppress[i]){ |
---|
53 | printf("\t%12s\t%12s", "bytes","packets"); |
---|
54 | } |
---|
55 | } |
---|
56 | printf("\n"); |
---|
57 | } |
---|
58 | |
---|
59 | void ecn_report(void) |
---|
60 | { |
---|
61 | int i,j; |
---|
62 | printf("# ECN breakdown:\n"); |
---|
63 | ecn_suppress(); |
---|
64 | for(i=0;i<4;++i) { |
---|
65 | if (ecn_stat[0][i].count==0 && |
---|
66 | ecn_stat[1][i].count==0 && ecn_stat[2][i].count==0) |
---|
67 | continue; |
---|
68 | printf("%20i:",i); |
---|
69 | for(j=0;j<4;j++){ |
---|
70 | if (ecn_stat[j][i].count==0){ |
---|
71 | if(!suppress[j]) |
---|
72 | printf("\t%24s"," "); |
---|
73 | continue; |
---|
74 | } |
---|
75 | printf("\t%12" PRIu64 "\t%12" PRIu64, |
---|
76 | ecn_stat[j][i].bytes, |
---|
77 | ecn_stat[j][i].count); |
---|
78 | } |
---|
79 | printf("\n"); |
---|
80 | } |
---|
81 | |
---|
82 | int total = 0; |
---|
83 | for(i=0;i<4;i++){ |
---|
84 | for(j=1;j<4;j++) |
---|
85 | total += ecn_stat[i][j].count; |
---|
86 | } |
---|
87 | printf("%s: %i\n", "Total ECN", total); |
---|
88 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.