add Berkeley specific copyright
[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 *
2b6b6284
KB
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
11 *
914527c0 12 * @(#)tcp_var.h 7.7 (Berkeley) %G%
8ae0e4b4 13 */
ad6d0022 14
9d866d2f
MK
15/*
16 * TCP configuration: This is a half-assed attempt to make TCP
17 * self-configure for a few varieties of 4.2 and 4.3-based unixes.
18 * If you don't have a) a 4.3bsd vax or b) a 3.x Sun (x<6), check
19 * this carefully (it's probably not right). Please send me mail
20 * if you run into configuration problems.
21 * - Van Jacobson (van@lbl-csam.arpa)
22 */
23
24#ifndef BSD
25#define BSD 42 /* if we're not 4.3, pretend we're 4.2 */
ac4e7106 26#define OLDSTAT /* set if we have to use old netstat binaries */
9d866d2f
MK
27#endif
28
ac4e7106
MK
29/* #define OLDSTAT /* set if we have to use old netstat binaries */
30
9d866d2f
MK
31#if sun || BSD < 43
32#define TCP_COMPAT_42 /* set if we have to interop w/4.2 systems */
33#endif
34
35#ifndef SB_MAX
36#ifdef SB_MAXCOUNT
37#define SB_MAX SB_MAXCOUNT /* Sun has to be a little bit different... */
38#else
39#define SB_MAX 32767 /* XXX */
40#endif SB_MAXCOUNT
41#endif SB_MAX
42
914527c0
MK
43#ifndef IP_MAXPACKET
44#define IP_MAXPACKET 65535 /* maximum packet size */
45#endif
46
47/*
48 * Bill Nowicki pointed out that the page size (CLBYTES) has
49 * nothing to do with the mbuf cluster size. So, we followed
50 * Sun's lead and made the new define MCLBYTES stand for the mbuf
51 * cluster size. The following define makes up backwards compatible
52 * with 4.3 and 4.2. If CLBYTES is >1024 on your machine, check
53 * this against the mbuf cluster definitions in /usr/include/sys/mbuf.h.
54 */
55#ifndef MCLBYTES
56#define MCLBYTES CLBYTES /* XXX */
57#endif
58
59/*
60 * The routine in_localaddr is broken in Sun's 3.4. We redefine ours
61 * (in tcp_input.c) so we use can it but won't have a name conflict.
62 */
63#ifdef sun
64#define in_localaddr tcp_in_localaddr
65#endif
66
67/* --------------- end of TCP config ---------------- */
68
69/*
70 * TCP configuration: This is a half-assed attempt to make TCP
71 * self-configure for a few varieties of 4.2 and 4.3-based unixes.
72 * If you don't have a) a 4.3bsd vax or b) a 3.x Sun (x<6), check
73 * this carefully (it's probably not right). Please send me mail
74 * if you run into configuration problems.
75 * - Van Jacobson (van@lbl-csam.arpa)
76 */
77
78#ifndef BSD
79#define BSD 42 /* if we're not 4.3, pretend we're 4.2 */
80#define OLDSTAT /* set if we have to use old netstat binaries */
81#endif
82
83/* #define OLDSTAT /* set if we have to use old netstat binaries */
84
85#if sun || BSD < 43
86#define TCP_COMPAT_42 /* set if we have to interop w/4.2 systems */
87#endif
88
89#ifndef SB_MAX
90#ifdef SB_MAXCOUNT
91#define SB_MAX SB_MAXCOUNT /* Sun has to be a little bit different... */
92#else
93#define SB_MAX 32767 /* XXX */
94#endif SB_MAXCOUNT
95#endif SB_MAX
96
9d866d2f
MK
97/*
98 * Bill Nowicki pointed out that the page size (CLBYTES) has
99 * nothing to do with the mbuf cluster size. So, we followed
100 * Sun's lead and made the new define MCLBYTES stand for the mbuf
101 * cluster size. The following define makes up backwards compatible
102 * with 4.3 and 4.2. If CLBYTES is >1024 on your machine, check
103 * this against the mbuf cluster definitions in /usr/include/sys/mbuf.h.
104 */
105#ifndef MCLBYTES
106#define MCLBYTES CLBYTES /* XXX */
107#endif
108
109/*
110 * The routine in_localaddr is broken in Sun's 3.4. We redefine ours
111 * (in tcp_input.c) so we use can it but won't have a name conflict.
112 */
113#ifdef sun
114#define in_localaddr tcp_in_localaddr
115#endif
116
117/* --------------- end of TCP config ---------------- */
118
ad6d0022
BJ
119/*
120 * Kernel variables for tcp.
121 */
122
123/*
405c9168 124 * Tcp control block, one per tcp; fields:
ad6d0022 125 */
53a5409e 126struct tcpcb {
a6503abf
BJ
127 struct tcpiphdr *seg_next; /* sequencing queue */
128 struct tcpiphdr *seg_prev;
4aed14e3 129 short t_state; /* state of this connection */
a41e26c7 130 short t_timer[TCPT_NTIMERS]; /* tcp timers */
405c9168 131 short t_rxtshift; /* log(2) of rexmt exp. backoff */
a6bbda13 132 short t_rxtcur; /* current retransmit value */
e1ead9e7 133 short t_dupacks; /* consecutive dup acks recd */
faa26a98 134 u_short t_maxseg; /* maximum segment size */
4aed14e3 135 char t_force; /* 1 if forcing out a byte */
2ff61f9d 136 u_char t_flags;
6f638424
MK
137#define TF_ACKNOW 0x01 /* ack peer immediately */
138#define TF_DELACK 0x02 /* ack, but try to delay it */
139#define TF_NODELAY 0x04 /* don't delay packets to coalesce */
140#define TF_NOOPT 0x08 /* don't use tcp options */
faa26a98 141#define TF_SENTFIN 0x10 /* have sent FIN */
2ff61f9d
BJ
142 struct tcpiphdr *t_template; /* skeletal packet for transmit */
143 struct inpcb *t_inpcb; /* back pointer to internet pcb */
ad6d0022 144/*
2ff61f9d
BJ
145 * The following fields are used as in the protocol specification.
146 * See RFC783, Dec. 1981, page 21.
ad6d0022 147 */
2ff61f9d
BJ
148/* send sequence variables */
149 tcp_seq snd_una; /* send unacknowledged */
150 tcp_seq snd_nxt; /* send next */
2ff61f9d
BJ
151 tcp_seq snd_up; /* send urgent pointer */
152 tcp_seq snd_wl1; /* window update seg seq number */
153 tcp_seq snd_wl2; /* window update seg ack number */
154 tcp_seq iss; /* initial send sequence number */
4aed14e3 155 u_short snd_wnd; /* send window */
2ff61f9d 156/* receive sequence variables */
6f638424 157 u_short rcv_wnd; /* receive window */
4aed14e3 158 tcp_seq rcv_nxt; /* receive next */
2ff61f9d
BJ
159 tcp_seq rcv_up; /* receive urgent pointer */
160 tcp_seq irs; /* initial receive sequence number */
ad6d0022 161/*
2ff61f9d 162 * Additional variables for this implementation.
ad6d0022 163 */
2ff61f9d 164/* receive variables */
a6503abf
BJ
165 tcp_seq rcv_adv; /* advertised window */
166/* retransmit variables */
a41e26c7 167 tcp_seq snd_max; /* highest sequence number sent
05586739
MK
168 * used to recognize retransmits
169 */
e1ead9e7 170/* congestion control (for slow start, source quench, retransmit after loss) */
05586739 171 u_short snd_cwnd; /* congestion-controlled window */
e1ead9e7
MK
172 u_short snd_ssthresh; /* snd_cwnd size threshhold for
173 * for slow start exponential to
174 * linear switch */
7cc62c26
MK
175/*
176 * transmit timing stuff.
177 * srtt and rttvar are stored as fixed point; for convenience in smoothing,
178 * srtt has 3 bits to the right of the binary point, rttvar has 2.
e1ead9e7 179 * "Variance" is actually smoothed difference.
7cc62c26 180 */
405c9168
BJ
181 short t_idle; /* inactivity time */
182 short t_rtt; /* round trip time */
183 tcp_seq t_rtseq; /* sequence number being timed */
7cc62c26
MK
184 short t_srtt; /* smoothed round-trip time */
185 short t_rttvar; /* variance in round-trip time */
e1ead9e7 186 u_short max_rcvd; /* most peer has sent into window */
18a438b6 187 u_short max_sndwnd; /* largest window peer has offered */
8b5a83bb
BJ
188/* out-of-band data */
189 char t_oobflags; /* have some */
b2db9217 190 char t_iobc; /* input character */
8b5a83bb 191#define TCPOOB_HAVEDATA 0x01
22b0776e 192#define TCPOOB_HADDATA 0x02
2ff61f9d 193};
ad6d0022 194
2ff61f9d
BJ
195#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
196#define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
ad6d0022 197
3b52afc5
MK
198/*
199 * TCP statistics.
200 * Many of these should be kept per connection,
201 * but that's inconvenient at the moment.
202 */
2b4b57cd 203struct tcpstat {
ac4e7106
MK
204#ifdef OLDSTAT
205 /*
206 * Declare statistics the same as in 4.3
207 * at the start of tcpstat (same size and
208 * position) for netstat.
209 */
210 int tcps_rcvbadsum;
211 int tcps_rcvbadoff;
212 int tcps_rcvshort;
213 int tcps_badsegs;
214 int tcps_unack;
215#define tcps_badsum tcps_rcvbadsum
216#define tcps_badoff tcps_rcvbadoff
217#define tcps_hdrops tcps_rcvshort
218
914527c0
MK
219#endif OLDSTAT
220#ifdef OLDSTAT
221 /*
222 * Declare statistics the same as in 4.3
223 * at the start of tcpstat (same size and
224 * position) for netstat.
225 */
226 int tcps_rcvbadsum;
227 int tcps_rcvbadoff;
228 int tcps_rcvshort;
229 int tcps_badsegs;
230 int tcps_unack;
231#define tcps_badsum tcps_rcvbadsum
232#define tcps_badoff tcps_rcvbadoff
233#define tcps_hdrops tcps_rcvshort
234
ac4e7106 235#endif OLDSTAT
3b52afc5
MK
236 u_long tcps_connattempt; /* connections initiated */
237 u_long tcps_accepts; /* connections accepted */
238 u_long tcps_connects; /* connections established */
239 u_long tcps_drops; /* connections dropped */
240 u_long tcps_conndrops; /* embryonic connections dropped */
241 u_long tcps_closed; /* conn. closed (includes drops) */
242 u_long tcps_segstimed; /* segs where we tried to get rtt */
243 u_long tcps_rttupdated; /* times we succeeded */
244 u_long tcps_delack; /* delayed acks sent */
245 u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */
246 u_long tcps_rexmttimeo; /* retransmit timeouts */
247 u_long tcps_persisttimeo; /* persist timeouts */
248 u_long tcps_keeptimeo; /* keepalive timeouts */
249 u_long tcps_keepprobe; /* keepalive probes sent */
250 u_long tcps_keepdrops; /* connections dropped in keepalive */
251
252 u_long tcps_sndtotal; /* total packets sent */
253 u_long tcps_sndpack; /* data packets sent */
254 u_long tcps_sndbyte; /* data bytes sent */
255 u_long tcps_sndrexmitpack; /* data packets retransmitted */
256 u_long tcps_sndrexmitbyte; /* data bytes retransmitted */
257 u_long tcps_sndacks; /* ack-only packets sent */
258 u_long tcps_sndprobe; /* window probes sent */
259 u_long tcps_sndurg; /* packets sent with URG only */
260 u_long tcps_sndwinup; /* window update-only packets sent */
261 u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */
262
263 u_long tcps_rcvtotal; /* total packets received */
264 u_long tcps_rcvpack; /* packets received in sequence */
265 u_long tcps_rcvbyte; /* bytes received in sequence */
914527c0 266#ifndef OLDSTAT
ac4e7106 267#ifndef OLDSTAT
3b52afc5
MK
268 u_long tcps_rcvbadsum; /* packets received with ccksum errs */
269 u_long tcps_rcvbadoff; /* packets received with bad offset */
270 u_long tcps_rcvshort; /* packets received too short */
914527c0 271#endif
ac4e7106 272#endif
3b52afc5
MK
273 u_long tcps_rcvduppack; /* duplicate-only packets received */
274 u_long tcps_rcvdupbyte; /* duplicate-only bytes received */
275 u_long tcps_rcvpartduppack; /* packets with some duplicate data */
276 u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */
277 u_long tcps_rcvoopack; /* out-of-order packets received */
278 u_long tcps_rcvoobyte; /* out-of-order bytes received */
279 u_long tcps_rcvpackafterwin; /* packets with data after window */
280 u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */
281 u_long tcps_rcvafterclose; /* packets rcvd after "close" */
282 u_long tcps_rcvwinprobe; /* rcvd window probe packets */
283 u_long tcps_rcvdupack; /* rcvd duplicate acks */
284 u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */
285 u_long tcps_rcvackpack; /* rcvd ack packets */
286 u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */
287 u_long tcps_rcvwinupd; /* rcvd window update packets */
2b4b57cd
BJ
288};
289
ad6d0022 290#ifdef KERNEL
2ff61f9d
BJ
291struct inpcb tcb; /* head of queue of active tcpcb's */
292struct tcpstat tcpstat; /* tcp statistics */
53a5409e 293struct tcpiphdr *tcp_template();
0e3936fa
SL
294struct tcpcb *tcp_close(), *tcp_drop();
295struct tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();
ad6d0022 296#endif