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 tos_stat[4][256] = {{{0,0}}} ; |
---|
9 | static bool suppress[4] = {true,true,true,true}; |
---|
10 | |
---|
11 | void tos_per_packet(struct libtrace_packet_t *packet) |
---|
12 | { |
---|
13 | struct libtrace_ip *ip = trace_get_ip(packet); |
---|
14 | |
---|
15 | if (!ip) |
---|
16 | return; |
---|
17 | int dir = trace_get_direction(packet); |
---|
18 | if(dir < 0 || dir > 1) |
---|
19 | dir = 2; |
---|
20 | tos_stat[dir][ip->ip_tos].count++; |
---|
21 | tos_stat[dir][ip->ip_tos].bytes+=trace_get_wire_length(packet); |
---|
22 | suppress[dir] = false; |
---|
23 | } |
---|
24 | |
---|
25 | void tos_suppress() |
---|
26 | { |
---|
27 | int i; |
---|
28 | printf("%-20s","Direction:"); |
---|
29 | //printf("%20s", " "); |
---|
30 | for(i=0;i<4;i++){ |
---|
31 | if(!suppress[i]){ |
---|
32 | switch(i){ |
---|
33 | case 0: |
---|
34 | printf("\t%24s", "Outbound "); |
---|
35 | break; |
---|
36 | case 1: |
---|
37 | printf("\t%24s", "Inbound "); |
---|
38 | break; |
---|
39 | case 2: |
---|
40 | printf("\t%24s", "Undefined "); |
---|
41 | break; |
---|
42 | default: |
---|
43 | break; |
---|
44 | } |
---|
45 | } |
---|
46 | } |
---|
47 | printf("\n"); |
---|
48 | printf("%-20s","ToS"); |
---|
49 | for(i=0;i<4;i++){ |
---|
50 | if(!suppress[i]){ |
---|
51 | printf("\t%12s\t%12s", "bytes","packets"); |
---|
52 | } |
---|
53 | } |
---|
54 | printf("\n"); |
---|
55 | } |
---|
56 | |
---|
57 | void tos_report(void) |
---|
58 | { |
---|
59 | int i,j; |
---|
60 | printf("# TOS breakdown:\n"); |
---|
61 | tos_suppress(); |
---|
62 | for(i=0;i<256;++i) { |
---|
63 | if (tos_stat[0][i].count==0 && |
---|
64 | tos_stat[1][i].count==0 && tos_stat[2][i].count==0) |
---|
65 | continue; |
---|
66 | printf("%20i:",i); |
---|
67 | for(j=0;j<4;j++){ |
---|
68 | if (tos_stat[j][i].count==0){ |
---|
69 | if(!suppress[j]) |
---|
70 | printf("\t%24s"," "); |
---|
71 | continue; |
---|
72 | } |
---|
73 | printf("\t%12" PRIu64 "\t%12" PRIu64, |
---|
74 | tos_stat[j][i].bytes, |
---|
75 | tos_stat[j][i].count); |
---|
76 | } |
---|
77 | printf("\n"); |
---|
78 | } |
---|
79 | |
---|
80 | int total; |
---|
81 | for(i=0;i<4;i++){ |
---|
82 | total = 0; |
---|
83 | for(j=0;j<256;j++) |
---|
84 | total += tos_stat[i][j].count; |
---|
85 | //printf("%s: %i\n", "Total", total); |
---|
86 | } |
---|
87 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.