4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since b5dc60d was
b5dc60d,
checked in by Josef Vodanovich <jjv4@…>, 15 years ago
|
Lots of minor changes to the reports to make it look a bit nicer and tcp ss should be working.
|
-
Property mode set to
100644
|
File size:
1.7 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 tcpseg_stat[3][2048] = {{{0,0}}} ; |
---|
9 | static bool suppress[3] = {true,true,true}; |
---|
10 | |
---|
11 | void tcpseg_per_packet(struct libtrace_packet_t *packet) |
---|
12 | { |
---|
13 | struct libtrace_tcp *tcp = trace_get_tcp(packet); |
---|
14 | libtrace_direction_t dir = trace_get_direction(packet); |
---|
15 | int payload, tcplen, ss; |
---|
16 | |
---|
17 | if (!tcp) |
---|
18 | return; |
---|
19 | |
---|
20 | if (dir != TRACE_DIR_INCOMING && dir != TRACE_DIR_OUTGOING) |
---|
21 | dir = TRACE_DIR_OTHER; |
---|
22 | |
---|
23 | payload = trace_get_wire_length(packet) - trace_get_capture_length(packet); |
---|
24 | tcplen = tcp->doff * 4; |
---|
25 | ss = payload + tcplen; |
---|
26 | |
---|
27 | tcpseg_stat[dir][ss].count++; |
---|
28 | tcpseg_stat[dir][ss].bytes+=trace_get_wire_length(packet); |
---|
29 | suppress[dir] = false; |
---|
30 | } |
---|
31 | |
---|
32 | void tcpseg_suppress() |
---|
33 | { |
---|
34 | int i; |
---|
35 | printf("%-20s","Direction:"); |
---|
36 | for(i=0;i<3;i++){ |
---|
37 | if(!suppress[i]){ |
---|
38 | switch(i){ |
---|
39 | case 0: |
---|
40 | printf("\t%24s", "Outbound "); |
---|
41 | break; |
---|
42 | case 1: |
---|
43 | printf("\t%24s", "Inbound "); |
---|
44 | break; |
---|
45 | case 2: |
---|
46 | printf("\t%24s", "Undefined "); |
---|
47 | break; |
---|
48 | default: |
---|
49 | break; |
---|
50 | } |
---|
51 | } |
---|
52 | } |
---|
53 | printf("\n"); |
---|
54 | printf("%-20s","TCP SS"); |
---|
55 | for(i=0;i<3;i++){ |
---|
56 | if(!suppress[i]){ |
---|
57 | printf("\t%12s\t%12s", "bytes","packets"); |
---|
58 | } |
---|
59 | } |
---|
60 | printf("\n"); |
---|
61 | } |
---|
62 | |
---|
63 | void tcpseg_report(void) |
---|
64 | { |
---|
65 | int i,j; |
---|
66 | printf("# TCP Segment Size breakdown:\n"); |
---|
67 | tcpseg_suppress(); |
---|
68 | for(i=0;i<2048;++i) { |
---|
69 | if (tcpseg_stat[0][i].count==0 && |
---|
70 | tcpseg_stat[1][i].count==0 && tcpseg_stat[2][i].count==0) |
---|
71 | continue; |
---|
72 | printf("%20i:",i); |
---|
73 | for(j=0;j<3;j++){ |
---|
74 | if (tcpseg_stat[j][i].count==0){ |
---|
75 | if(!suppress[j]) |
---|
76 | printf("\t%24s"," "); |
---|
77 | continue; |
---|
78 | } |
---|
79 | printf("\t%12" PRIu64 "\t%12" PRIu64, |
---|
80 | tcpseg_stat[j][i].bytes, |
---|
81 | tcpseg_stat[j][i].count); |
---|
82 | } |
---|
83 | printf("\n"); |
---|
84 | } |
---|
85 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.