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.9 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 nlp_stat[4][65536] = {{{0,0}}} ; |
---|
9 | static bool suppress[4] = {true,true,true,true}; |
---|
10 | |
---|
11 | void nlp_per_packet(struct libtrace_packet_t *packet) |
---|
12 | { |
---|
13 | unsigned char *p=trace_get_link(packet); |
---|
14 | uint16_t a; |
---|
15 | |
---|
16 | p += 12; |
---|
17 | a = *p; |
---|
18 | a *= 256; |
---|
19 | a += p[1]; |
---|
20 | int dir = trace_get_direction(packet); |
---|
21 | if(dir < 0 || dir > 1) |
---|
22 | dir = 2; |
---|
23 | |
---|
24 | nlp_stat[dir][a].count++; |
---|
25 | nlp_stat[dir][a].bytes+=trace_get_wire_length(packet); |
---|
26 | suppress[dir] = false; |
---|
27 | } |
---|
28 | |
---|
29 | void nlp_suppress() |
---|
30 | { |
---|
31 | int i; |
---|
32 | printf("%-20s","Direction:"); |
---|
33 | //printf("%20s", " "); |
---|
34 | for(i=0;i<4;i++){ |
---|
35 | if(!suppress[i]){ |
---|
36 | switch(i){ |
---|
37 | case 0: |
---|
38 | printf("\t%24s", "Outbound "); |
---|
39 | break; |
---|
40 | case 1: |
---|
41 | printf("\t%24s", "Inbound "); |
---|
42 | break; |
---|
43 | case 2: |
---|
44 | printf("\t%24s", "Undefined "); |
---|
45 | break; |
---|
46 | default: |
---|
47 | break; |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | printf("\n"); |
---|
52 | printf("%-20s","NLP"); |
---|
53 | for(i=0;i<4;i++){ |
---|
54 | if(!suppress[i]){ |
---|
55 | printf("\t%12s\t%12s", "bytes","packets"); |
---|
56 | } |
---|
57 | } |
---|
58 | printf("\n"); |
---|
59 | } |
---|
60 | |
---|
61 | void nlp_report(void){ |
---|
62 | printf("# Network Layer Protocol breakdown:\n"); |
---|
63 | nlp_suppress(); |
---|
64 | int i,j; |
---|
65 | |
---|
66 | for(i = 0; i < 65536; i++){ |
---|
67 | if (nlp_stat[0][i].count==0 && |
---|
68 | nlp_stat[1][i].count==0 && nlp_stat[2][i].count==0) |
---|
69 | continue; |
---|
70 | switch(i){ |
---|
71 | case 0x0800: |
---|
72 | printf("%20s", "IPv4"); |
---|
73 | break; |
---|
74 | case 0x0806: |
---|
75 | printf("%20s", "ARP"); |
---|
76 | break; |
---|
77 | case 0x8137: |
---|
78 | printf("%20s", "IPX"); |
---|
79 | break; |
---|
80 | case 0x814C: |
---|
81 | printf("%20s", "SNMP"); |
---|
82 | break; |
---|
83 | case 0x86DD: |
---|
84 | printf("%20s", "IPv6"); |
---|
85 | break; |
---|
86 | case 0x880B: |
---|
87 | printf("%20s", "PPP"); |
---|
88 | break; |
---|
89 | default: |
---|
90 | printf("%20i:",i); |
---|
91 | } |
---|
92 | for(j=0;j<4;j++){ |
---|
93 | if (nlp_stat[j][i].count==0){ |
---|
94 | if(!suppress[j]) |
---|
95 | printf("\t%24s"," "); |
---|
96 | continue; |
---|
97 | } |
---|
98 | printf("\t%12" PRIu64 "\t%12" PRIu64, |
---|
99 | nlp_stat[j][i].bytes, |
---|
100 | nlp_stat[j][i].count); |
---|
101 | } |
---|
102 | printf("\n"); |
---|
103 | } |
---|
104 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.