root / slirp / tcp_var.h @ cbeb0857
History | View | Annotate | Download (10.5 kB)
1 | f0cbd3ec | bellard | /*
|
---|---|---|---|
2 | f0cbd3ec | bellard | * Copyright (c) 1982, 1986, 1993, 1994
|
3 | f0cbd3ec | bellard | * The Regents of the University of California. All rights reserved.
|
4 | f0cbd3ec | bellard | *
|
5 | f0cbd3ec | bellard | * Redistribution and use in source and binary forms, with or without
|
6 | f0cbd3ec | bellard | * modification, are permitted provided that the following conditions
|
7 | f0cbd3ec | bellard | * are met:
|
8 | f0cbd3ec | bellard | * 1. Redistributions of source code must retain the above copyright
|
9 | f0cbd3ec | bellard | * notice, this list of conditions and the following disclaimer.
|
10 | f0cbd3ec | bellard | * 2. Redistributions in binary form must reproduce the above copyright
|
11 | f0cbd3ec | bellard | * notice, this list of conditions and the following disclaimer in the
|
12 | f0cbd3ec | bellard | * documentation and/or other materials provided with the distribution.
|
13 | f0cbd3ec | bellard | * 3. All advertising materials mentioning features or use of this software
|
14 | f0cbd3ec | bellard | * must display the following acknowledgement:
|
15 | f0cbd3ec | bellard | * This product includes software developed by the University of
|
16 | f0cbd3ec | bellard | * California, Berkeley and its contributors.
|
17 | f0cbd3ec | bellard | * 4. Neither the name of the University nor the names of its contributors
|
18 | f0cbd3ec | bellard | * may be used to endorse or promote products derived from this software
|
19 | f0cbd3ec | bellard | * without specific prior written permission.
|
20 | f0cbd3ec | bellard | *
|
21 | f0cbd3ec | bellard | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
22 | f0cbd3ec | bellard | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23 | f0cbd3ec | bellard | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
24 | f0cbd3ec | bellard | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
25 | f0cbd3ec | bellard | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
26 | f0cbd3ec | bellard | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
27 | f0cbd3ec | bellard | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
28 | f0cbd3ec | bellard | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
29 | f0cbd3ec | bellard | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
30 | f0cbd3ec | bellard | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
31 | f0cbd3ec | bellard | * SUCH DAMAGE.
|
32 | f0cbd3ec | bellard | *
|
33 | f0cbd3ec | bellard | * @(#)tcp_var.h 8.3 (Berkeley) 4/10/94
|
34 | f0cbd3ec | bellard | * tcp_var.h,v 1.3 1994/08/21 05:27:39 paul Exp
|
35 | f0cbd3ec | bellard | */
|
36 | f0cbd3ec | bellard | |
37 | f0cbd3ec | bellard | #ifndef _TCP_VAR_H_
|
38 | f0cbd3ec | bellard | #define _TCP_VAR_H_
|
39 | f0cbd3ec | bellard | |
40 | f0cbd3ec | bellard | #include "tcpip.h" |
41 | f0cbd3ec | bellard | #include "tcp_timer.h" |
42 | f0cbd3ec | bellard | |
43 | f0cbd3ec | bellard | #if SIZEOF_CHAR_P == 4 |
44 | f0cbd3ec | bellard | typedef struct tcpiphdr *tcpiphdrp_32; |
45 | f0cbd3ec | bellard | #else
|
46 | f0cbd3ec | bellard | typedef u_int32_t tcpiphdrp_32;
|
47 | f0cbd3ec | bellard | #endif
|
48 | f0cbd3ec | bellard | |
49 | f0cbd3ec | bellard | /*
|
50 | f0cbd3ec | bellard | * Tcp control block, one per tcp; fields:
|
51 | f0cbd3ec | bellard | */
|
52 | f0cbd3ec | bellard | struct tcpcb {
|
53 | f0cbd3ec | bellard | tcpiphdrp_32 seg_next; /* sequencing queue */
|
54 | f0cbd3ec | bellard | tcpiphdrp_32 seg_prev; |
55 | f0cbd3ec | bellard | short t_state; /* state of this connection */ |
56 | f0cbd3ec | bellard | short t_timer[TCPT_NTIMERS]; /* tcp timers */ |
57 | f0cbd3ec | bellard | short t_rxtshift; /* log(2) of rexmt exp. backoff */ |
58 | f0cbd3ec | bellard | short t_rxtcur; /* current retransmit value */ |
59 | f0cbd3ec | bellard | short t_dupacks; /* consecutive dup acks recd */ |
60 | f0cbd3ec | bellard | u_short t_maxseg; /* maximum segment size */
|
61 | f0cbd3ec | bellard | char t_force; /* 1 if forcing out a byte */ |
62 | f0cbd3ec | bellard | u_short t_flags; |
63 | f0cbd3ec | bellard | #define TF_ACKNOW 0x0001 /* ack peer immediately */ |
64 | f0cbd3ec | bellard | #define TF_DELACK 0x0002 /* ack, but try to delay it */ |
65 | f0cbd3ec | bellard | #define TF_NODELAY 0x0004 /* don't delay packets to coalesce */ |
66 | f0cbd3ec | bellard | #define TF_NOOPT 0x0008 /* don't use tcp options */ |
67 | f0cbd3ec | bellard | #define TF_SENTFIN 0x0010 /* have sent FIN */ |
68 | f0cbd3ec | bellard | #define TF_REQ_SCALE 0x0020 /* have/will request window scaling */ |
69 | f0cbd3ec | bellard | #define TF_RCVD_SCALE 0x0040 /* other side has requested scaling */ |
70 | f0cbd3ec | bellard | #define TF_REQ_TSTMP 0x0080 /* have/will request timestamps */ |
71 | f0cbd3ec | bellard | #define TF_RCVD_TSTMP 0x0100 /* a timestamp was received in SYN */ |
72 | f0cbd3ec | bellard | #define TF_SACK_PERMIT 0x0200 /* other side said I could SACK */ |
73 | f0cbd3ec | bellard | |
74 | f0cbd3ec | bellard | /* Make it static for now */
|
75 | f0cbd3ec | bellard | /* struct tcpiphdr *t_template; / * skeletal packet for transmit */
|
76 | f0cbd3ec | bellard | struct tcpiphdr t_template;
|
77 | f0cbd3ec | bellard | |
78 | f0cbd3ec | bellard | struct socket *t_socket; /* back pointer to socket */ |
79 | f0cbd3ec | bellard | /*
|
80 | f0cbd3ec | bellard | * The following fields are used as in the protocol specification.
|
81 | f0cbd3ec | bellard | * See RFC783, Dec. 1981, page 21.
|
82 | f0cbd3ec | bellard | */
|
83 | f0cbd3ec | bellard | /* send sequence variables */
|
84 | f0cbd3ec | bellard | tcp_seq snd_una; /* send unacknowledged */
|
85 | f0cbd3ec | bellard | tcp_seq snd_nxt; /* send next */
|
86 | f0cbd3ec | bellard | tcp_seq snd_up; /* send urgent pointer */
|
87 | f0cbd3ec | bellard | tcp_seq snd_wl1; /* window update seg seq number */
|
88 | f0cbd3ec | bellard | tcp_seq snd_wl2; /* window update seg ack number */
|
89 | f0cbd3ec | bellard | tcp_seq iss; /* initial send sequence number */
|
90 | f0cbd3ec | bellard | u_int32_t snd_wnd; /* send window */
|
91 | f0cbd3ec | bellard | /* receive sequence variables */
|
92 | f0cbd3ec | bellard | u_int32_t rcv_wnd; /* receive window */
|
93 | f0cbd3ec | bellard | tcp_seq rcv_nxt; /* receive next */
|
94 | f0cbd3ec | bellard | tcp_seq rcv_up; /* receive urgent pointer */
|
95 | f0cbd3ec | bellard | tcp_seq irs; /* initial receive sequence number */
|
96 | f0cbd3ec | bellard | /*
|
97 | f0cbd3ec | bellard | * Additional variables for this implementation.
|
98 | f0cbd3ec | bellard | */
|
99 | f0cbd3ec | bellard | /* receive variables */
|
100 | f0cbd3ec | bellard | tcp_seq rcv_adv; /* advertised window */
|
101 | f0cbd3ec | bellard | /* retransmit variables */
|
102 | f0cbd3ec | bellard | tcp_seq snd_max; /* highest sequence number sent;
|
103 | f0cbd3ec | bellard | * used to recognize retransmits
|
104 | f0cbd3ec | bellard | */
|
105 | f0cbd3ec | bellard | /* congestion control (for slow start, source quench, retransmit after loss) */
|
106 | f0cbd3ec | bellard | u_int32_t snd_cwnd; /* congestion-controlled window */
|
107 | f0cbd3ec | bellard | u_int32_t snd_ssthresh; /* snd_cwnd size threshold for
|
108 | f0cbd3ec | bellard | * for slow start exponential to
|
109 | f0cbd3ec | bellard | * linear switch
|
110 | f0cbd3ec | bellard | */
|
111 | f0cbd3ec | bellard | /*
|
112 | f0cbd3ec | bellard | * transmit timing stuff. See below for scale of srtt and rttvar.
|
113 | f0cbd3ec | bellard | * "Variance" is actually smoothed difference.
|
114 | f0cbd3ec | bellard | */
|
115 | f0cbd3ec | bellard | short t_idle; /* inactivity time */ |
116 | f0cbd3ec | bellard | short t_rtt; /* round trip time */ |
117 | f0cbd3ec | bellard | tcp_seq t_rtseq; /* sequence number being timed */
|
118 | f0cbd3ec | bellard | short t_srtt; /* smoothed round-trip time */ |
119 | f0cbd3ec | bellard | short t_rttvar; /* variance in round-trip time */ |
120 | f0cbd3ec | bellard | u_short t_rttmin; /* minimum rtt allowed */
|
121 | f0cbd3ec | bellard | u_int32_t max_sndwnd; /* largest window peer has offered */
|
122 | f0cbd3ec | bellard | |
123 | f0cbd3ec | bellard | /* out-of-band data */
|
124 | f0cbd3ec | bellard | char t_oobflags; /* have some */ |
125 | f0cbd3ec | bellard | char t_iobc; /* input character */ |
126 | f0cbd3ec | bellard | #define TCPOOB_HAVEDATA 0x01 |
127 | f0cbd3ec | bellard | #define TCPOOB_HADDATA 0x02 |
128 | f0cbd3ec | bellard | short t_softerror; /* possible error not yet reported */ |
129 | f0cbd3ec | bellard | |
130 | f0cbd3ec | bellard | /* RFC 1323 variables */
|
131 | f0cbd3ec | bellard | u_char snd_scale; /* window scaling for send window */
|
132 | f0cbd3ec | bellard | u_char rcv_scale; /* window scaling for recv window */
|
133 | f0cbd3ec | bellard | u_char request_r_scale; /* pending window scaling */
|
134 | f0cbd3ec | bellard | u_char requested_s_scale; |
135 | f0cbd3ec | bellard | u_int32_t ts_recent; /* timestamp echo data */
|
136 | f0cbd3ec | bellard | u_int32_t ts_recent_age; /* when last updated */
|
137 | f0cbd3ec | bellard | tcp_seq last_ack_sent; |
138 | f0cbd3ec | bellard | |
139 | f0cbd3ec | bellard | }; |
140 | f0cbd3ec | bellard | |
141 | f0cbd3ec | bellard | #define sototcpcb(so) ((so)->so_tcpcb)
|
142 | f0cbd3ec | bellard | |
143 | f0cbd3ec | bellard | /*
|
144 | f0cbd3ec | bellard | * The smoothed round-trip time and estimated variance
|
145 | f0cbd3ec | bellard | * are stored as fixed point numbers scaled by the values below.
|
146 | f0cbd3ec | bellard | * For convenience, these scales are also used in smoothing the average
|
147 | f0cbd3ec | bellard | * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
|
148 | f0cbd3ec | bellard | * With these scales, srtt has 3 bits to the right of the binary point,
|
149 | f0cbd3ec | bellard | * and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the
|
150 | f0cbd3ec | bellard | * binary point, and is smoothed with an ALPHA of 0.75.
|
151 | f0cbd3ec | bellard | */
|
152 | f0cbd3ec | bellard | #define TCP_RTT_SCALE 8 /* multiplier for srtt; 3 bits frac. */ |
153 | f0cbd3ec | bellard | #define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */ |
154 | f0cbd3ec | bellard | #define TCP_RTTVAR_SCALE 4 /* multiplier for rttvar; 2 bits */ |
155 | f0cbd3ec | bellard | #define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */ |
156 | f0cbd3ec | bellard | |
157 | f0cbd3ec | bellard | /*
|
158 | f0cbd3ec | bellard | * The initial retransmission should happen at rtt + 4 * rttvar.
|
159 | f0cbd3ec | bellard | * Because of the way we do the smoothing, srtt and rttvar
|
160 | f0cbd3ec | bellard | * will each average +1/2 tick of bias. When we compute
|
161 | f0cbd3ec | bellard | * the retransmit timer, we want 1/2 tick of rounding and
|
162 | f0cbd3ec | bellard | * 1 extra tick because of +-1/2 tick uncertainty in the
|
163 | f0cbd3ec | bellard | * firing of the timer. The bias will give us exactly the
|
164 | f0cbd3ec | bellard | * 1.5 tick we need. But, because the bias is
|
165 | f0cbd3ec | bellard | * statistical, we have to test that we don't drop below
|
166 | f0cbd3ec | bellard | * the minimum feasible timer (which is 2 ticks).
|
167 | f0cbd3ec | bellard | * This macro assumes that the value of TCP_RTTVAR_SCALE
|
168 | f0cbd3ec | bellard | * is the same as the multiplier for rttvar.
|
169 | f0cbd3ec | bellard | */
|
170 | f0cbd3ec | bellard | #define TCP_REXMTVAL(tp) \
|
171 | f0cbd3ec | bellard | (((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) |
172 | f0cbd3ec | bellard | |
173 | f0cbd3ec | bellard | /* XXX
|
174 | f0cbd3ec | bellard | * We want to avoid doing m_pullup on incoming packets but that
|
175 | f0cbd3ec | bellard | * means avoiding dtom on the tcp reassembly code. That in turn means
|
176 | f0cbd3ec | bellard | * keeping an mbuf pointer in the reassembly queue (since we might
|
177 | f0cbd3ec | bellard | * have a cluster). As a quick hack, the source & destination
|
178 | f0cbd3ec | bellard | * port numbers (which are no longer needed once we've located the
|
179 | f0cbd3ec | bellard | * tcpcb) are overlayed with an mbuf pointer.
|
180 | f0cbd3ec | bellard | */
|
181 | f0cbd3ec | bellard | #if SIZEOF_CHAR_P == 4 |
182 | f0cbd3ec | bellard | typedef struct mbuf *mbufp_32; |
183 | f0cbd3ec | bellard | #else
|
184 | f0cbd3ec | bellard | typedef u_int32_t mbufp_32;
|
185 | f0cbd3ec | bellard | #endif
|
186 | f0cbd3ec | bellard | #define REASS_MBUF(ti) (*(mbufp_32 *)&((ti)->ti_t))
|
187 | f0cbd3ec | bellard | |
188 | f0cbd3ec | bellard | /*
|
189 | f0cbd3ec | bellard | * TCP statistics.
|
190 | f0cbd3ec | bellard | * Many of these should be kept per connection,
|
191 | f0cbd3ec | bellard | * but that's inconvenient at the moment.
|
192 | f0cbd3ec | bellard | */
|
193 | f0cbd3ec | bellard | struct tcpstat {
|
194 | f0cbd3ec | bellard | u_long tcps_connattempt; /* connections initiated */
|
195 | f0cbd3ec | bellard | u_long tcps_accepts; /* connections accepted */
|
196 | f0cbd3ec | bellard | u_long tcps_connects; /* connections established */
|
197 | f0cbd3ec | bellard | u_long tcps_drops; /* connections dropped */
|
198 | f0cbd3ec | bellard | u_long tcps_conndrops; /* embryonic connections dropped */
|
199 | f0cbd3ec | bellard | u_long tcps_closed; /* conn. closed (includes drops) */
|
200 | f0cbd3ec | bellard | u_long tcps_segstimed; /* segs where we tried to get rtt */
|
201 | f0cbd3ec | bellard | u_long tcps_rttupdated; /* times we succeeded */
|
202 | f0cbd3ec | bellard | u_long tcps_delack; /* delayed acks sent */
|
203 | f0cbd3ec | bellard | u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */
|
204 | f0cbd3ec | bellard | u_long tcps_rexmttimeo; /* retransmit timeouts */
|
205 | f0cbd3ec | bellard | u_long tcps_persisttimeo; /* persist timeouts */
|
206 | f0cbd3ec | bellard | u_long tcps_keeptimeo; /* keepalive timeouts */
|
207 | f0cbd3ec | bellard | u_long tcps_keepprobe; /* keepalive probes sent */
|
208 | f0cbd3ec | bellard | u_long tcps_keepdrops; /* connections dropped in keepalive */
|
209 | f0cbd3ec | bellard | |
210 | f0cbd3ec | bellard | u_long tcps_sndtotal; /* total packets sent */
|
211 | f0cbd3ec | bellard | u_long tcps_sndpack; /* data packets sent */
|
212 | f0cbd3ec | bellard | u_long tcps_sndbyte; /* data bytes sent */
|
213 | f0cbd3ec | bellard | u_long tcps_sndrexmitpack; /* data packets retransmitted */
|
214 | f0cbd3ec | bellard | u_long tcps_sndrexmitbyte; /* data bytes retransmitted */
|
215 | f0cbd3ec | bellard | u_long tcps_sndacks; /* ack-only packets sent */
|
216 | f0cbd3ec | bellard | u_long tcps_sndprobe; /* window probes sent */
|
217 | f0cbd3ec | bellard | u_long tcps_sndurg; /* packets sent with URG only */
|
218 | f0cbd3ec | bellard | u_long tcps_sndwinup; /* window update-only packets sent */
|
219 | f0cbd3ec | bellard | u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */
|
220 | f0cbd3ec | bellard | |
221 | f0cbd3ec | bellard | u_long tcps_rcvtotal; /* total packets received */
|
222 | f0cbd3ec | bellard | u_long tcps_rcvpack; /* packets received in sequence */
|
223 | f0cbd3ec | bellard | u_long tcps_rcvbyte; /* bytes received in sequence */
|
224 | f0cbd3ec | bellard | u_long tcps_rcvbadsum; /* packets received with ccksum errs */
|
225 | f0cbd3ec | bellard | u_long tcps_rcvbadoff; /* packets received with bad offset */
|
226 | f0cbd3ec | bellard | /* u_long tcps_rcvshort; */ /* packets received too short */ |
227 | f0cbd3ec | bellard | u_long tcps_rcvduppack; /* duplicate-only packets received */
|
228 | f0cbd3ec | bellard | u_long tcps_rcvdupbyte; /* duplicate-only bytes received */
|
229 | f0cbd3ec | bellard | u_long tcps_rcvpartduppack; /* packets with some duplicate data */
|
230 | f0cbd3ec | bellard | u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */
|
231 | f0cbd3ec | bellard | u_long tcps_rcvoopack; /* out-of-order packets received */
|
232 | f0cbd3ec | bellard | u_long tcps_rcvoobyte; /* out-of-order bytes received */
|
233 | f0cbd3ec | bellard | u_long tcps_rcvpackafterwin; /* packets with data after window */
|
234 | f0cbd3ec | bellard | u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */
|
235 | f0cbd3ec | bellard | u_long tcps_rcvafterclose; /* packets rcvd after "close" */
|
236 | f0cbd3ec | bellard | u_long tcps_rcvwinprobe; /* rcvd window probe packets */
|
237 | f0cbd3ec | bellard | u_long tcps_rcvdupack; /* rcvd duplicate acks */
|
238 | f0cbd3ec | bellard | u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */
|
239 | f0cbd3ec | bellard | u_long tcps_rcvackpack; /* rcvd ack packets */
|
240 | f0cbd3ec | bellard | u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */
|
241 | f0cbd3ec | bellard | u_long tcps_rcvwinupd; /* rcvd window update packets */
|
242 | f0cbd3ec | bellard | /* u_long tcps_pawsdrop; */ /* segments dropped due to PAWS */ |
243 | f0cbd3ec | bellard | u_long tcps_predack; /* times hdr predict ok for acks */
|
244 | f0cbd3ec | bellard | u_long tcps_preddat; /* times hdr predict ok for data pkts */
|
245 | f0cbd3ec | bellard | u_long tcps_socachemiss; /* tcp_last_so misses */
|
246 | f0cbd3ec | bellard | u_long tcps_didnuttin; /* Times tcp_output didn't do anything XXX */
|
247 | f0cbd3ec | bellard | }; |
248 | f0cbd3ec | bellard | |
249 | f0cbd3ec | bellard | extern struct tcpstat tcpstat; /* tcp statistics */ |
250 | f0cbd3ec | bellard | extern u_int32_t tcp_now; /* for RFC 1323 timestamps */ |
251 | f0cbd3ec | bellard | |
252 | f0cbd3ec | bellard | #endif |