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