xref: /csrg-svn/sys/netinet/tcp_var.h (revision 32789)
1 /*
2  * Copyright (c) 1982, 1986 Regents of the University of California.
3  * All rights reserved.
4  *
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  *
12  *	@(#)tcp_var.h	7.6 (Berkeley) 12/07/87
13  */
14 
15 /*
16  * Kernel variables for tcp.
17  */
18 
19 /*
20  * Tcp control block, one per tcp; fields:
21  */
22 struct tcpcb {
23 	struct	tcpiphdr *seg_next;	/* sequencing queue */
24 	struct	tcpiphdr *seg_prev;
25 	short	t_state;		/* state of this connection */
26 	short	t_timer[TCPT_NTIMERS];	/* tcp timers */
27 	short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
28 	short	t_rxtcur;		/* current retransmit value */
29 	short	t_dupacks;		/* consecutive dup acks recd */
30 	u_short	t_maxseg;		/* maximum segment size */
31 	char	t_force;		/* 1 if forcing out a byte */
32 	u_char	t_flags;
33 #define	TF_ACKNOW	0x01		/* ack peer immediately */
34 #define	TF_DELACK	0x02		/* ack, but try to delay it */
35 #define	TF_NODELAY	0x04		/* don't delay packets to coalesce */
36 #define	TF_NOOPT	0x08		/* don't use tcp options */
37 #define	TF_SENTFIN	0x10		/* have sent FIN */
38 	struct	tcpiphdr *t_template;	/* skeletal packet for transmit */
39 	struct	inpcb *t_inpcb;		/* back pointer to internet pcb */
40 /*
41  * The following fields are used as in the protocol specification.
42  * See RFC783, Dec. 1981, page 21.
43  */
44 /* send sequence variables */
45 	tcp_seq	snd_una;		/* send unacknowledged */
46 	tcp_seq	snd_nxt;		/* send next */
47 	tcp_seq	snd_up;			/* send urgent pointer */
48 	tcp_seq	snd_wl1;		/* window update seg seq number */
49 	tcp_seq	snd_wl2;		/* window update seg ack number */
50 	tcp_seq	iss;			/* initial send sequence number */
51 	u_short	snd_wnd;		/* send window */
52 /* receive sequence variables */
53 	u_short	rcv_wnd;		/* receive window */
54 	tcp_seq	rcv_nxt;		/* receive next */
55 	tcp_seq	rcv_up;			/* receive urgent pointer */
56 	tcp_seq	irs;			/* initial receive sequence number */
57 /*
58  * Additional variables for this implementation.
59  */
60 /* receive variables */
61 	tcp_seq	rcv_adv;		/* advertised window */
62 /* retransmit variables */
63 	tcp_seq	snd_max;		/* highest sequence number sent
64 					 * used to recognize retransmits
65 					 */
66 /* congestion control (for slow start, source quench, retransmit after loss) */
67 	u_short	snd_cwnd;		/* congestion-controlled window */
68 	u_short snd_ssthresh;		/* snd_cwnd size threshhold for
69 					 * for slow start exponential to
70 					 * linear switch */
71 /*
72  * transmit timing stuff.
73  * srtt and rttvar are stored as fixed point; for convenience in smoothing,
74  * srtt has 3 bits to the right of the binary point, rttvar has 2.
75  * "Variance" is actually smoothed difference.
76  */
77 	short	t_idle;			/* inactivity time */
78 	short	t_rtt;			/* round trip time */
79 	tcp_seq	t_rtseq;		/* sequence number being timed */
80 	short	t_srtt;			/* smoothed round-trip time */
81 	short	t_rttvar;		/* variance in round-trip time */
82 	u_short max_rcvd;		/* most peer has sent into window */
83 	u_short	max_sndwnd;		/* largest window peer has offered */
84 /* out-of-band data */
85 	char	t_oobflags;		/* have some */
86 	char	t_iobc;			/* input character */
87 #define	TCPOOB_HAVEDATA	0x01
88 #define	TCPOOB_HADDATA	0x02
89 };
90 
91 #define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
92 #define	sototcpcb(so)	(intotcpcb(sotoinpcb(so)))
93 
94 /*
95  * TCP statistics.
96  * Many of these should be kept per connection,
97  * but that's inconvenient at the moment.
98  */
99 struct	tcpstat {
100 	u_long	tcps_connattempt;	/* connections initiated */
101 	u_long	tcps_accepts;		/* connections accepted */
102 	u_long	tcps_connects;		/* connections established */
103 	u_long	tcps_drops;		/* connections dropped */
104 	u_long	tcps_conndrops;		/* embryonic connections dropped */
105 	u_long	tcps_closed;		/* conn. closed (includes drops) */
106 	u_long	tcps_segstimed;		/* segs where we tried to get rtt */
107 	u_long	tcps_rttupdated;	/* times we succeeded */
108 	u_long	tcps_delack;		/* delayed acks sent */
109 	u_long	tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
110 	u_long	tcps_rexmttimeo;	/* retransmit timeouts */
111 	u_long	tcps_persisttimeo;	/* persist timeouts */
112 	u_long	tcps_keeptimeo;		/* keepalive timeouts */
113 	u_long	tcps_keepprobe;		/* keepalive probes sent */
114 	u_long	tcps_keepdrops;		/* connections dropped in keepalive */
115 
116 	u_long	tcps_sndtotal;		/* total packets sent */
117 	u_long	tcps_sndpack;		/* data packets sent */
118 	u_long	tcps_sndbyte;		/* data bytes sent */
119 	u_long	tcps_sndrexmitpack;	/* data packets retransmitted */
120 	u_long	tcps_sndrexmitbyte;	/* data bytes retransmitted */
121 	u_long	tcps_sndacks;		/* ack-only packets sent */
122 	u_long	tcps_sndprobe;		/* window probes sent */
123 	u_long	tcps_sndurg;		/* packets sent with URG only */
124 	u_long	tcps_sndwinup;		/* window update-only packets sent */
125 	u_long	tcps_sndctrl;		/* control (SYN|FIN|RST) packets sent */
126 
127 	u_long	tcps_rcvtotal;		/* total packets received */
128 	u_long	tcps_rcvpack;		/* packets received in sequence */
129 	u_long	tcps_rcvbyte;		/* bytes received in sequence */
130 	u_long	tcps_rcvbadsum;		/* packets received with ccksum errs */
131 	u_long	tcps_rcvbadoff;		/* packets received with bad offset */
132 	u_long	tcps_rcvshort;		/* packets received too short */
133 	u_long	tcps_rcvduppack;	/* duplicate-only packets received */
134 	u_long	tcps_rcvdupbyte;	/* duplicate-only bytes received */
135 	u_long	tcps_rcvpartduppack;	/* packets with some duplicate data */
136 	u_long	tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
137 	u_long	tcps_rcvoopack;		/* out-of-order packets received */
138 	u_long	tcps_rcvoobyte;		/* out-of-order bytes received */
139 	u_long	tcps_rcvpackafterwin;	/* packets with data after window */
140 	u_long	tcps_rcvbyteafterwin;	/* bytes rcvd after window */
141 	u_long	tcps_rcvafterclose;	/* packets rcvd after "close" */
142 	u_long	tcps_rcvwinprobe;	/* rcvd window probe packets */
143 	u_long	tcps_rcvdupack;		/* rcvd duplicate acks */
144 	u_long	tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
145 	u_long	tcps_rcvackpack;	/* rcvd ack packets */
146 	u_long	tcps_rcvackbyte;	/* bytes acked by rcvd acks */
147 	u_long	tcps_rcvwinupd;		/* rcvd window update packets */
148 };
149 
150 #ifdef KERNEL
151 struct	inpcb tcb;		/* head of queue of active tcpcb's */
152 struct	tcpstat tcpstat;	/* tcp statistics */
153 struct	tcpiphdr *tcp_template();
154 struct	tcpcb *tcp_close(), *tcp_drop();
155 struct	tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();
156 #endif
157