4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since a8f2692 was
a8f2692,
checked in by Perry Lorier <perry@…>, 11 years ago
|
Tidy up a bazillion tiny warnings
|
-
Property mode set to
100644
|
File size:
2.0 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 | #include "report.h" |
---|
8 | |
---|
9 | static stat_t tcpseg_stat[3][2048] = {{{0,0}}} ; |
---|
10 | static bool suppress[3] = {true,true,true}; |
---|
11 | |
---|
12 | void tcpseg_per_packet(struct libtrace_packet_t *packet) |
---|
13 | { |
---|
14 | struct libtrace_tcp *tcp = trace_get_tcp(packet); |
---|
15 | libtrace_ip_t *ip = trace_get_ip(packet); |
---|
16 | libtrace_direction_t dir = trace_get_direction(packet); |
---|
17 | int ss; |
---|
18 | uint16_t ip_len ; |
---|
19 | |
---|
20 | if (!tcp || !ip) |
---|
21 | return; |
---|
22 | |
---|
23 | if (dir != TRACE_DIR_INCOMING && dir != TRACE_DIR_OUTGOING) |
---|
24 | dir = TRACE_DIR_OTHER; |
---|
25 | |
---|
26 | ip_len = ntohs(ip->ip_len); |
---|
27 | ss = ip_len - (ip->ip_hl * 4); |
---|
28 | |
---|
29 | tcpseg_stat[dir][ss].count++; |
---|
30 | tcpseg_stat[dir][ss].bytes+=trace_get_wire_length(packet); |
---|
31 | suppress[dir] = false; |
---|
32 | } |
---|
33 | |
---|
34 | void tcpseg_report(void) |
---|
35 | { |
---|
36 | int i,j; |
---|
37 | FILE *out = fopen("tcpseg.rpt", "w"); |
---|
38 | if (!out) { |
---|
39 | perror("fopen"); |
---|
40 | return; |
---|
41 | } |
---|
42 | fprintf(out, "%-16s\t%10s\t%16s %16s\n", |
---|
43 | "SEGMENT SIZE", |
---|
44 | "DIRECTION", |
---|
45 | "BYTES", |
---|
46 | "PACKETS"); |
---|
47 | |
---|
48 | for(i=0;i<2048;++i) { |
---|
49 | bool indent_needed; |
---|
50 | if (tcpseg_stat[0][i].count==0 && |
---|
51 | tcpseg_stat[1][i].count==0 && tcpseg_stat[2][i].count==0) |
---|
52 | continue; |
---|
53 | fprintf(out, "%16i:",i); |
---|
54 | indent_needed=false; |
---|
55 | for(j=0;j<3;j++){ |
---|
56 | if (indent_needed) { |
---|
57 | fprintf(out, "%16s", " "); |
---|
58 | } |
---|
59 | if (suppress[j]) |
---|
60 | continue; |
---|
61 | switch (j) { |
---|
62 | case 0: |
---|
63 | fprintf(out, "\t%10s", "Outbound"); |
---|
64 | break; |
---|
65 | case 1: |
---|
66 | fprintf(out, "\t%10s", "Inbound"); |
---|
67 | break; |
---|
68 | case 2: |
---|
69 | fprintf(out, "\t%10s", "Unknown"); |
---|
70 | break; |
---|
71 | } |
---|
72 | fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", |
---|
73 | tcpseg_stat[j][i].bytes, |
---|
74 | tcpseg_stat[j][i].count); |
---|
75 | indent_needed=true; |
---|
76 | } |
---|
77 | } |
---|
78 | fclose(out); |
---|
79 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.