root / slirp / debug.c @ 0d62c4cf
History | View | Annotate | Download (6.3 kB)
1 |
/*
|
---|---|
2 |
* Copyright (c) 1995 Danny Gasparovski.
|
3 |
* Portions copyright (c) 2000 Kelly Price.
|
4 |
*
|
5 |
* Please read the file COPYRIGHT for the
|
6 |
* terms and conditions of the copyright.
|
7 |
*/
|
8 |
|
9 |
#include <slirp.h> |
10 |
|
11 |
FILE *dfd = NULL;
|
12 |
int slirp_debug = 0; |
13 |
|
14 |
#ifdef LOG_ENABLED
|
15 |
static void |
16 |
ipstats(void)
|
17 |
{ |
18 |
lprint(" \r\n");
|
19 |
|
20 |
lprint("IP stats:\r\n");
|
21 |
lprint(" %6d total packets received (%d were unaligned)\r\n",
|
22 |
ipstat.ips_total, ipstat.ips_unaligned); |
23 |
lprint(" %6d with incorrect version\r\n", ipstat.ips_badvers);
|
24 |
lprint(" %6d with bad header checksum\r\n", ipstat.ips_badsum);
|
25 |
lprint(" %6d with length too short (len < sizeof(iphdr))\r\n", ipstat.ips_tooshort);
|
26 |
lprint(" %6d with length too small (len < ip->len)\r\n", ipstat.ips_toosmall);
|
27 |
lprint(" %6d with bad header length\r\n", ipstat.ips_badhlen);
|
28 |
lprint(" %6d with bad packet length\r\n", ipstat.ips_badlen);
|
29 |
lprint(" %6d fragments received\r\n", ipstat.ips_fragments);
|
30 |
lprint(" %6d fragments dropped\r\n", ipstat.ips_fragdropped);
|
31 |
lprint(" %6d fragments timed out\r\n", ipstat.ips_fragtimeout);
|
32 |
lprint(" %6d packets reassembled ok\r\n", ipstat.ips_reassembled);
|
33 |
lprint(" %6d outgoing packets fragmented\r\n", ipstat.ips_fragmented);
|
34 |
lprint(" %6d total outgoing fragments\r\n", ipstat.ips_ofragments);
|
35 |
lprint(" %6d with bad protocol field\r\n", ipstat.ips_noproto);
|
36 |
lprint(" %6d total packets delivered\r\n", ipstat.ips_delivered);
|
37 |
} |
38 |
|
39 |
static void |
40 |
tcpstats(void)
|
41 |
{ |
42 |
lprint(" \r\n");
|
43 |
|
44 |
lprint("TCP stats:\r\n");
|
45 |
|
46 |
lprint(" %6d packets sent\r\n", tcpstat.tcps_sndtotal);
|
47 |
lprint(" %6d data packets (%d bytes)\r\n",
|
48 |
tcpstat.tcps_sndpack, tcpstat.tcps_sndbyte); |
49 |
lprint(" %6d data packets retransmitted (%d bytes)\r\n",
|
50 |
tcpstat.tcps_sndrexmitpack, tcpstat.tcps_sndrexmitbyte); |
51 |
lprint(" %6d ack-only packets (%d delayed)\r\n",
|
52 |
tcpstat.tcps_sndacks, tcpstat.tcps_delack); |
53 |
lprint(" %6d URG only packets\r\n", tcpstat.tcps_sndurg);
|
54 |
lprint(" %6d window probe packets\r\n", tcpstat.tcps_sndprobe);
|
55 |
lprint(" %6d window update packets\r\n", tcpstat.tcps_sndwinup);
|
56 |
lprint(" %6d control (SYN/FIN/RST) packets\r\n", tcpstat.tcps_sndctrl);
|
57 |
lprint(" %6d times tcp_output did nothing\r\n", tcpstat.tcps_didnuttin);
|
58 |
|
59 |
lprint(" %6d packets received\r\n", tcpstat.tcps_rcvtotal);
|
60 |
lprint(" %6d acks (for %d bytes)\r\n",
|
61 |
tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte); |
62 |
lprint(" %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack);
|
63 |
lprint(" %6d acks for unsent data\r\n", tcpstat.tcps_rcvacktoomuch);
|
64 |
lprint(" %6d packets received in sequence (%d bytes)\r\n",
|
65 |
tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte); |
66 |
lprint(" %6d completely duplicate packets (%d bytes)\r\n",
|
67 |
tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte); |
68 |
|
69 |
lprint(" %6d packets with some duplicate data (%d bytes duped)\r\n",
|
70 |
tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte); |
71 |
lprint(" %6d out-of-order packets (%d bytes)\r\n",
|
72 |
tcpstat.tcps_rcvoopack, tcpstat.tcps_rcvoobyte); |
73 |
lprint(" %6d packets of data after window (%d bytes)\r\n",
|
74 |
tcpstat.tcps_rcvpackafterwin, tcpstat.tcps_rcvbyteafterwin); |
75 |
lprint(" %6d window probes\r\n", tcpstat.tcps_rcvwinprobe);
|
76 |
lprint(" %6d window update packets\r\n", tcpstat.tcps_rcvwinupd);
|
77 |
lprint(" %6d packets received after close\r\n", tcpstat.tcps_rcvafterclose);
|
78 |
lprint(" %6d discarded for bad checksums\r\n", tcpstat.tcps_rcvbadsum);
|
79 |
lprint(" %6d discarded for bad header offset fields\r\n",
|
80 |
tcpstat.tcps_rcvbadoff); |
81 |
|
82 |
lprint(" %6d connection requests\r\n", tcpstat.tcps_connattempt);
|
83 |
lprint(" %6d connection accepts\r\n", tcpstat.tcps_accepts);
|
84 |
lprint(" %6d connections established (including accepts)\r\n", tcpstat.tcps_connects);
|
85 |
lprint(" %6d connections closed (including %d drop)\r\n",
|
86 |
tcpstat.tcps_closed, tcpstat.tcps_drops); |
87 |
lprint(" %6d embryonic connections dropped\r\n", tcpstat.tcps_conndrops);
|
88 |
lprint(" %6d segments we tried to get rtt (%d succeeded)\r\n",
|
89 |
tcpstat.tcps_segstimed, tcpstat.tcps_rttupdated); |
90 |
lprint(" %6d retransmit timeouts\r\n", tcpstat.tcps_rexmttimeo);
|
91 |
lprint(" %6d connections dropped by rxmt timeout\r\n",
|
92 |
tcpstat.tcps_timeoutdrop); |
93 |
lprint(" %6d persist timeouts\r\n", tcpstat.tcps_persisttimeo);
|
94 |
lprint(" %6d keepalive timeouts\r\n", tcpstat.tcps_keeptimeo);
|
95 |
lprint(" %6d keepalive probes sent\r\n", tcpstat.tcps_keepprobe);
|
96 |
lprint(" %6d connections dropped by keepalive\r\n", tcpstat.tcps_keepdrops);
|
97 |
lprint(" %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
|
98 |
lprint(" %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
|
99 |
lprint(" %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
|
100 |
} |
101 |
|
102 |
static void |
103 |
udpstats(void)
|
104 |
{ |
105 |
lprint(" \r\n");
|
106 |
|
107 |
lprint("UDP stats:\r\n");
|
108 |
lprint(" %6d datagrams received\r\n", udpstat.udps_ipackets);
|
109 |
lprint(" %6d with packets shorter than header\r\n", udpstat.udps_hdrops);
|
110 |
lprint(" %6d with bad checksums\r\n", udpstat.udps_badsum);
|
111 |
lprint(" %6d with data length larger than packet\r\n", udpstat.udps_badlen);
|
112 |
lprint(" %6d UDP socket cache misses\r\n", udpstat.udpps_pcbcachemiss);
|
113 |
lprint(" %6d datagrams sent\r\n", udpstat.udps_opackets);
|
114 |
} |
115 |
|
116 |
static void |
117 |
icmpstats(void)
|
118 |
{ |
119 |
lprint(" \r\n");
|
120 |
lprint("ICMP stats:\r\n");
|
121 |
lprint(" %6d ICMP packets received\r\n", icmpstat.icps_received);
|
122 |
lprint(" %6d were too short\r\n", icmpstat.icps_tooshort);
|
123 |
lprint(" %6d with bad checksums\r\n", icmpstat.icps_checksum);
|
124 |
lprint(" %6d with type not supported\r\n", icmpstat.icps_notsupp);
|
125 |
lprint(" %6d with bad type feilds\r\n", icmpstat.icps_badtype);
|
126 |
lprint(" %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect);
|
127 |
} |
128 |
|
129 |
static void |
130 |
mbufstats(void)
|
131 |
{ |
132 |
struct mbuf *m;
|
133 |
int i;
|
134 |
|
135 |
lprint(" \r\n");
|
136 |
|
137 |
lprint("Mbuf stats:\r\n");
|
138 |
|
139 |
lprint(" %6d mbufs allocated (%d max)\r\n", mbuf_alloced, mbuf_max);
|
140 |
|
141 |
i = 0;
|
142 |
for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next)
|
143 |
i++; |
144 |
lprint(" %6d mbufs on free list\r\n", i);
|
145 |
|
146 |
i = 0;
|
147 |
for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
|
148 |
i++; |
149 |
lprint(" %6d mbufs on used list\r\n", i);
|
150 |
lprint(" %6d mbufs queued as packets\r\n\r\n", if_queued);
|
151 |
} |
152 |
#endif
|
153 |
|
154 |
void
|
155 |
slirp_stats(void)
|
156 |
{ |
157 |
#ifdef LOG_ENABLED
|
158 |
ipstats(); |
159 |
tcpstats(); |
160 |
udpstats(); |
161 |
icmpstats(); |
162 |
mbufstats(); |
163 |
#else
|
164 |
lprint("SLIRP statistics code not compiled.\n");
|
165 |
#endif
|
166 |
} |