4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 09be643 was
09be643,
checked in by Josef Vodanovich <jjv4@…>, 15 years ago
|
removed unnecessary loops
|
-
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 | for(i=0;i<4;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","ECN"); |
---|
50 | for(i=0;i<4;i++){ |
---|
51 | if(!suppress[i]){ |
---|
52 | printf("\t%12s\t%12s", "bytes","packets"); |
---|
53 | } |
---|
54 | } |
---|
55 | printf("\n"); |
---|
56 | } |
---|
57 | |
---|
58 | void ecn_report(void) |
---|
59 | { |
---|
60 | int i,j; |
---|
61 | printf("# ECN breakdown:\n"); |
---|
62 | ecn_suppress(); |
---|
63 | for(i=0;i<4;++i) { |
---|
64 | if (ecn_stat[0][i].count==0 && |
---|
65 | ecn_stat[1][i].count==0 && ecn_stat[2][i].count==0) |
---|
66 | continue; |
---|
67 | printf("%20i:",i); |
---|
68 | for(j=0;j<4;j++){ |
---|
69 | if (ecn_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 | ecn_stat[j][i].bytes, |
---|
76 | ecn_stat[j][i].count); |
---|
77 | } |
---|
78 | printf("\n"); |
---|
79 | } |
---|
80 | |
---|
81 | int total = 0; |
---|
82 | for(i=0;i<4;i++){ |
---|
83 | for(j=1;j<4;j++) |
---|
84 | total += ecn_stat[i][j].count; |
---|
85 | } |
---|
86 | printf("%s: %i\n", "Total ECN", total); |
---|
87 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.