convert vm_page bit fields to flags
[unix-history] / usr / src / sys / netinet / tcp_var.h
CommitLineData
8ae0e4b4 1/*
0880b18e 2 * Copyright (c) 1982, 1986 Regents of the University of California.
2b6b6284 3 * All rights reserved.
8ae0e4b4 4 *
dbf0c423 5 * %sccs.include.redist.c%
2b6b6284 6 *
dbf0c423 7 * @(#)tcp_var.h 7.10 (Berkeley) %G%
8ae0e4b4 8 */
ad6d0022 9
9d866d2f
MK
10/*
11 * TCP configuration: This is a half-assed attempt to make TCP
12 * self-configure for a few varieties of 4.2 and 4.3-based unixes.
13 * If you don't have a) a 4.3bsd vax or b) a 3.x Sun (x<6), check
14 * this carefully (it's probably not right). Please send me mail
15 * if you run into configuration problems.
16 * - Van Jacobson (van@lbl-csam.arpa)
17 */
18
19#ifndef BSD
20#define BSD 42 /* if we're not 4.3, pretend we're 4.2 */
ac4e7106 21#define OLDSTAT /* set if we have to use old netstat binaries */
9d866d2f
MK
22#endif
23
ac4e7106
MK
24/* #define OLDSTAT /* set if we have to use old netstat binaries */
25
9d866d2f
MK
26#if sun || BSD < 43
27#define TCP_COMPAT_42 /* set if we have to interop w/4.2 systems */
28#endif
29
30#ifndef SB_MAX
31#ifdef SB_MAXCOUNT
32#define SB_MAX SB_MAXCOUNT /* Sun has to be a little bit different... */
33#else
34#define SB_MAX 32767 /* XXX */
35#endif SB_MAXCOUNT
36#endif SB_MAX
37
38/*
39 * Bill Nowicki pointed out that the page size (CLBYTES) has
40 * nothing to do with the mbuf cluster size. So, we followed
41 * Sun's lead and made the new define MCLBYTES stand for the mbuf
42 * cluster size. The following define makes up backwards compatible
43 * with 4.3 and 4.2. If CLBYTES is >1024 on your machine, check
44 * this against the mbuf cluster definitions in /usr/include/sys/mbuf.h.
45 */
46#ifndef MCLBYTES
47#define MCLBYTES CLBYTES /* XXX */
48#endif
49
50/*
51 * The routine in_localaddr is broken in Sun's 3.4. We redefine ours
52 * (in tcp_input.c) so we use can it but won't have a name conflict.
53 */
54#ifdef sun
55#define in_localaddr tcp_in_localaddr
56#endif
57
58/* --------------- end of TCP config ---------------- */
59
ad6d0022
BJ
60/*
61 * Kernel variables for tcp.
62 */
63
64/*
405c9168 65 * Tcp control block, one per tcp; fields:
ad6d0022 66 */
53a5409e 67struct tcpcb {
a6503abf
BJ
68 struct tcpiphdr *seg_next; /* sequencing queue */
69 struct tcpiphdr *seg_prev;
4aed14e3 70 short t_state; /* state of this connection */
a41e26c7 71 short t_timer[TCPT_NTIMERS]; /* tcp timers */
405c9168 72 short t_rxtshift; /* log(2) of rexmt exp. backoff */
a6bbda13 73 short t_rxtcur; /* current retransmit value */
e1ead9e7 74 short t_dupacks; /* consecutive dup acks recd */
faa26a98 75 u_short t_maxseg; /* maximum segment size */
4aed14e3 76 char t_force; /* 1 if forcing out a byte */
2ff61f9d 77 u_char t_flags;
6f638424
MK
78#define TF_ACKNOW 0x01 /* ack peer immediately */
79#define TF_DELACK 0x02 /* ack, but try to delay it */
80#define TF_NODELAY 0x04 /* don't delay packets to coalesce */
81#define TF_NOOPT 0x08 /* don't use tcp options */
faa26a98 82#define TF_SENTFIN 0x10 /* have sent FIN */
2ff61f9d
BJ
83 struct tcpiphdr *t_template; /* skeletal packet for transmit */
84 struct inpcb *t_inpcb; /* back pointer to internet pcb */
ad6d0022 85/*
2ff61f9d
BJ
86 * The following fields are used as in the protocol specification.
87 * See RFC783, Dec. 1981, page 21.
ad6d0022 88 */
2ff61f9d
BJ
89/* send sequence variables */
90 tcp_seq snd_una; /* send unacknowledged */
91 tcp_seq snd_nxt; /* send next */
2ff61f9d
BJ
92 tcp_seq snd_up; /* send urgent pointer */
93 tcp_seq snd_wl1; /* window update seg seq number */
94 tcp_seq snd_wl2; /* window update seg ack number */
95 tcp_seq iss; /* initial send sequence number */
4aed14e3 96 u_short snd_wnd; /* send window */
2ff61f9d 97/* receive sequence variables */
6f638424 98 u_short rcv_wnd; /* receive window */
4aed14e3 99 tcp_seq rcv_nxt; /* receive next */
2ff61f9d
BJ
100 tcp_seq rcv_up; /* receive urgent pointer */
101 tcp_seq irs; /* initial receive sequence number */
ad6d0022 102/*
2ff61f9d 103 * Additional variables for this implementation.
ad6d0022 104 */
2ff61f9d 105/* receive variables */
a6503abf
BJ
106 tcp_seq rcv_adv; /* advertised window */
107/* retransmit variables */
f630ffc2 108 tcp_seq snd_max; /* highest sequence number sent;
05586739
MK
109 * used to recognize retransmits
110 */
e1ead9e7 111/* congestion control (for slow start, source quench, retransmit after loss) */
05586739 112 u_short snd_cwnd; /* congestion-controlled window */
e1ead9e7
MK
113 u_short snd_ssthresh; /* snd_cwnd size threshhold for
114 * for slow start exponential to
f630ffc2
MK
115 * linear switch
116 */
7cc62c26 117/*
f630ffc2 118 * transmit timing stuff. See below for scale of srtt and rttvar.
e1ead9e7 119 * "Variance" is actually smoothed difference.
7cc62c26 120 */
405c9168
BJ
121 short t_idle; /* inactivity time */
122 short t_rtt; /* round trip time */
123 tcp_seq t_rtseq; /* sequence number being timed */
7cc62c26
MK
124 short t_srtt; /* smoothed round-trip time */
125 short t_rttvar; /* variance in round-trip time */
f630ffc2 126 u_short t_rttmin; /* minimum rtt allowed */
18a438b6 127 u_short max_sndwnd; /* largest window peer has offered */
f630ffc2 128
8b5a83bb
BJ
129/* out-of-band data */
130 char t_oobflags; /* have some */
b2db9217 131 char t_iobc; /* input character */
8b5a83bb 132#define TCPOOB_HAVEDATA 0x01
22b0776e 133#define TCPOOB_HADDATA 0x02
f630ffc2 134 short t_softerror; /* possible error not yet reported */
2ff61f9d 135};
ad6d0022 136
2ff61f9d
BJ
137#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
138#define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
ad6d0022 139
f630ffc2
MK
140/*
141 * The smoothed round-trip time and estimated variance
142 * are stored as fixed point numbers scaled by the values below.
143 * For convenience, these scales are also used in smoothing the average
144 * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
145 * With these scales, srtt has 3 bits to the right of the binary point,
146 * and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the
147 * binary point, and is smoothed with an ALPHA of 0.75.
148 */
149#define TCP_RTT_SCALE 8 /* multiplier for srtt; 3 bits frac. */
150#define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */
151#define TCP_RTTVAR_SCALE 4 /* multiplier for rttvar; 2 bits */
152#define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */
153
154/*
155 * The initial retransmission should happen at rtt + 4 * rttvar.
156 * Because of the way we do the smoothing, srtt and rttvar
157 * will each average +1/2 tick of bias. When we compute
158 * the retransmit timer, we want 1/2 tick of rounding and
159 * 1 extra tick because of +-1/2 tick uncertainty in the
160 * firing of the timer. The bias will give us exactly the
161 * 1.5 tick we need. But, because the bias is
162 * statistical, we have to test that we don't drop below
163 * the minimum feasible timer (which is 2 ticks).
164 * This macro assumes that the value of TCP_RTTVAR_SCALE
165 * is the same as the multiplier for rttvar.
166 */
167#define TCP_REXMTVAL(tp) \
168 (((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar)
169
170/* XXX
171 * We want to avoid doing m_pullup on incoming packets but that
172 * means avoiding dtom on the tcp reassembly code. That in turn means
173 * keeping an mbuf pointer in the reassembly queue (since we might
174 * have a cluster). As a quick hack, the source & destination
175 * port numbers (which are no longer needed once we've located the
176 * tcpcb) are overlayed with an mbuf pointer.
177 */
178#define REASS_MBUF(ti) (*(struct mbuf **)&((ti)->ti_t))
179
3b52afc5
MK
180/*
181 * TCP statistics.
182 * Many of these should be kept per connection,
183 * but that's inconvenient at the moment.
184 */
2b4b57cd 185struct tcpstat {
ac4e7106
MK
186#ifdef OLDSTAT
187 /*
188 * Declare statistics the same as in 4.3
189 * at the start of tcpstat (same size and
190 * position) for netstat.
191 */
192 int tcps_rcvbadsum;
193 int tcps_rcvbadoff;
194 int tcps_rcvshort;
195 int tcps_badsegs;
196 int tcps_unack;
197#define tcps_badsum tcps_rcvbadsum
198#define tcps_badoff tcps_rcvbadoff
199#define tcps_hdrops tcps_rcvshort
200
201#endif OLDSTAT
3b52afc5
MK
202 u_long tcps_connattempt; /* connections initiated */
203 u_long tcps_accepts; /* connections accepted */
204 u_long tcps_connects; /* connections established */
205 u_long tcps_drops; /* connections dropped */
206 u_long tcps_conndrops; /* embryonic connections dropped */
207 u_long tcps_closed; /* conn. closed (includes drops) */
208 u_long tcps_segstimed; /* segs where we tried to get rtt */
209 u_long tcps_rttupdated; /* times we succeeded */
210 u_long tcps_delack; /* delayed acks sent */
211 u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */
212 u_long tcps_rexmttimeo; /* retransmit timeouts */
213 u_long tcps_persisttimeo; /* persist timeouts */
214 u_long tcps_keeptimeo; /* keepalive timeouts */
215 u_long tcps_keepprobe; /* keepalive probes sent */
216 u_long tcps_keepdrops; /* connections dropped in keepalive */
217
218 u_long tcps_sndtotal; /* total packets sent */
219 u_long tcps_sndpack; /* data packets sent */
220 u_long tcps_sndbyte; /* data bytes sent */
221 u_long tcps_sndrexmitpack; /* data packets retransmitted */
222 u_long tcps_sndrexmitbyte; /* data bytes retransmitted */
223 u_long tcps_sndacks; /* ack-only packets sent */
224 u_long tcps_sndprobe; /* window probes sent */
225 u_long tcps_sndurg; /* packets sent with URG only */
226 u_long tcps_sndwinup; /* window update-only packets sent */
227 u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */
228
229 u_long tcps_rcvtotal; /* total packets received */
230 u_long tcps_rcvpack; /* packets received in sequence */
231 u_long tcps_rcvbyte; /* bytes received in sequence */
232 u_long tcps_rcvbadsum; /* packets received with ccksum errs */
233 u_long tcps_rcvbadoff; /* packets received with bad offset */
234 u_long tcps_rcvshort; /* packets received too short */
ac4e7106 235#endif
3b52afc5
MK
236 u_long tcps_rcvduppack; /* duplicate-only packets received */
237 u_long tcps_rcvdupbyte; /* duplicate-only bytes received */
238 u_long tcps_rcvpartduppack; /* packets with some duplicate data */
239 u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */
240 u_long tcps_rcvoopack; /* out-of-order packets received */
241 u_long tcps_rcvoobyte; /* out-of-order bytes received */
242 u_long tcps_rcvpackafterwin; /* packets with data after window */
243 u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */
244 u_long tcps_rcvafterclose; /* packets rcvd after "close" */
245 u_long tcps_rcvwinprobe; /* rcvd window probe packets */
246 u_long tcps_rcvdupack; /* rcvd duplicate acks */
247 u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */
248 u_long tcps_rcvackpack; /* rcvd ack packets */
249 u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */
250 u_long tcps_rcvwinupd; /* rcvd window update packets */
2b4b57cd
BJ
251};
252
ad6d0022 253#ifdef KERNEL
2ff61f9d
BJ
254struct inpcb tcb; /* head of queue of active tcpcb's */
255struct tcpstat tcpstat; /* tcp statistics */
53a5409e 256struct tcpiphdr *tcp_template();
0e3936fa
SL
257struct tcpcb *tcp_close(), *tcp_drop();
258struct tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();
ad6d0022 259#endif