xref: /csrg-svn/sys/netinet/tcp_var.h (revision 32789)
123197Smckusick /*
229156Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
3*32789Sbostic  * All rights reserved.
423197Smckusick  *
5*32789Sbostic  * Redistribution and use in source and binary forms are permitted
6*32789Sbostic  * provided that this notice is preserved and that due credit is given
7*32789Sbostic  * to the University of California at Berkeley. The name of the University
8*32789Sbostic  * may not be used to endorse or promote products derived from this
9*32789Sbostic  * software without specific prior written permission. This software
10*32789Sbostic  * is provided ``as is'' without express or implied warranty.
11*32789Sbostic  *
12*32789Sbostic  *	@(#)tcp_var.h	7.6 (Berkeley) 12/07/87
1323197Smckusick  */
144808Swnj 
154808Swnj /*
164808Swnj  * Kernel variables for tcp.
174808Swnj  */
184808Swnj 
194808Swnj /*
205166Swnj  * Tcp control block, one per tcp; fields:
214808Swnj  */
224881Swnj struct tcpcb {
235076Swnj 	struct	tcpiphdr *seg_next;	/* sequencing queue */
245076Swnj 	struct	tcpiphdr *seg_prev;
255246Sroot 	short	t_state;		/* state of this connection */
265092Swnj 	short	t_timer[TCPT_NTIMERS];	/* tcp timers */
275166Swnj 	short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
2832034Skarels 	short	t_rxtcur;		/* current retransmit value */
2932099Skarels 	short	t_dupacks;		/* consecutive dup acks recd */
3027068Skarels 	u_short	t_maxseg;		/* maximum segment size */
315246Sroot 	char	t_force;		/* 1 if forcing out a byte */
325067Swnj 	u_char	t_flags;
3325894Skarels #define	TF_ACKNOW	0x01		/* ack peer immediately */
3425894Skarels #define	TF_DELACK	0x02		/* ack, but try to delay it */
3525894Skarels #define	TF_NODELAY	0x04		/* don't delay packets to coalesce */
3625894Skarels #define	TF_NOOPT	0x08		/* don't use tcp options */
3727068Skarels #define	TF_SENTFIN	0x10		/* have sent FIN */
384881Swnj 	struct	tcpiphdr *t_template;	/* skeletal packet for transmit */
395067Swnj 	struct	inpcb *t_inpcb;		/* back pointer to internet pcb */
404808Swnj /*
415067Swnj  * The following fields are used as in the protocol specification.
425067Swnj  * See RFC783, Dec. 1981, page 21.
434808Swnj  */
445067Swnj /* send sequence variables */
455067Swnj 	tcp_seq	snd_una;		/* send unacknowledged */
465067Swnj 	tcp_seq	snd_nxt;		/* send next */
475067Swnj 	tcp_seq	snd_up;			/* send urgent pointer */
485067Swnj 	tcp_seq	snd_wl1;		/* window update seg seq number */
495067Swnj 	tcp_seq	snd_wl2;		/* window update seg ack number */
505067Swnj 	tcp_seq	iss;			/* initial send sequence number */
515246Sroot 	u_short	snd_wnd;		/* send window */
525067Swnj /* receive sequence variables */
5325894Skarels 	u_short	rcv_wnd;		/* receive window */
545067Swnj 	tcp_seq	rcv_nxt;		/* receive next */
555067Swnj 	tcp_seq	rcv_up;			/* receive urgent pointer */
565067Swnj 	tcp_seq	irs;			/* initial receive sequence number */
575067Swnj /*
585067Swnj  * Additional variables for this implementation.
595067Swnj  */
605076Swnj /* receive variables */
615076Swnj 	tcp_seq	rcv_adv;		/* advertised window */
625067Swnj /* retransmit variables */
635092Swnj 	tcp_seq	snd_max;		/* highest sequence number sent
6417359Skarels 					 * used to recognize retransmits
6517359Skarels 					 */
6632099Skarels /* congestion control (for slow start, source quench, retransmit after loss) */
6717359Skarels 	u_short	snd_cwnd;		/* congestion-controlled window */
6832099Skarels 	u_short snd_ssthresh;		/* snd_cwnd size threshhold for
6932099Skarels 					 * for slow start exponential to
7032099Skarels 					 * linear switch */
7131726Skarels /*
7231726Skarels  * transmit timing stuff.
7331726Skarels  * srtt and rttvar are stored as fixed point; for convenience in smoothing,
7431726Skarels  * srtt has 3 bits to the right of the binary point, rttvar has 2.
7532099Skarels  * "Variance" is actually smoothed difference.
7631726Skarels  */
775166Swnj 	short	t_idle;			/* inactivity time */
785166Swnj 	short	t_rtt;			/* round trip time */
795166Swnj 	tcp_seq	t_rtseq;		/* sequence number being timed */
8031726Skarels 	short	t_srtt;			/* smoothed round-trip time */
8131726Skarels 	short	t_rttvar;		/* variance in round-trip time */
8232099Skarels 	u_short max_rcvd;		/* most peer has sent into window */
8325262Skarels 	u_short	max_sndwnd;		/* largest window peer has offered */
845443Swnj /* out-of-band data */
855443Swnj 	char	t_oobflags;		/* have some */
865550Swnj 	char	t_iobc;			/* input character */
875443Swnj #define	TCPOOB_HAVEDATA	0x01
8824822Skarels #define	TCPOOB_HADDATA	0x02
895067Swnj };
904808Swnj 
914881Swnj #define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
924881Swnj #define	sototcpcb(so)	(intotcpcb(sotoinpcb(so)))
934881Swnj 
9430527Skarels /*
9530527Skarels  * TCP statistics.
9630527Skarels  * Many of these should be kept per connection,
9730527Skarels  * but that's inconvenient at the moment.
9830527Skarels  */
994926Swnj struct	tcpstat {
10030527Skarels 	u_long	tcps_connattempt;	/* connections initiated */
10130527Skarels 	u_long	tcps_accepts;		/* connections accepted */
10230527Skarels 	u_long	tcps_connects;		/* connections established */
10330527Skarels 	u_long	tcps_drops;		/* connections dropped */
10430527Skarels 	u_long	tcps_conndrops;		/* embryonic connections dropped */
10530527Skarels 	u_long	tcps_closed;		/* conn. closed (includes drops) */
10630527Skarels 	u_long	tcps_segstimed;		/* segs where we tried to get rtt */
10730527Skarels 	u_long	tcps_rttupdated;	/* times we succeeded */
10830527Skarels 	u_long	tcps_delack;		/* delayed acks sent */
10930527Skarels 	u_long	tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
11030527Skarels 	u_long	tcps_rexmttimeo;	/* retransmit timeouts */
11130527Skarels 	u_long	tcps_persisttimeo;	/* persist timeouts */
11230527Skarels 	u_long	tcps_keeptimeo;		/* keepalive timeouts */
11330527Skarels 	u_long	tcps_keepprobe;		/* keepalive probes sent */
11430527Skarels 	u_long	tcps_keepdrops;		/* connections dropped in keepalive */
11530527Skarels 
11630527Skarels 	u_long	tcps_sndtotal;		/* total packets sent */
11730527Skarels 	u_long	tcps_sndpack;		/* data packets sent */
11830527Skarels 	u_long	tcps_sndbyte;		/* data bytes sent */
11930527Skarels 	u_long	tcps_sndrexmitpack;	/* data packets retransmitted */
12030527Skarels 	u_long	tcps_sndrexmitbyte;	/* data bytes retransmitted */
12130527Skarels 	u_long	tcps_sndacks;		/* ack-only packets sent */
12230527Skarels 	u_long	tcps_sndprobe;		/* window probes sent */
12330527Skarels 	u_long	tcps_sndurg;		/* packets sent with URG only */
12430527Skarels 	u_long	tcps_sndwinup;		/* window update-only packets sent */
12530527Skarels 	u_long	tcps_sndctrl;		/* control (SYN|FIN|RST) packets sent */
12630527Skarels 
12730527Skarels 	u_long	tcps_rcvtotal;		/* total packets received */
12830527Skarels 	u_long	tcps_rcvpack;		/* packets received in sequence */
12930527Skarels 	u_long	tcps_rcvbyte;		/* bytes received in sequence */
13030527Skarels 	u_long	tcps_rcvbadsum;		/* packets received with ccksum errs */
13130527Skarels 	u_long	tcps_rcvbadoff;		/* packets received with bad offset */
13230527Skarels 	u_long	tcps_rcvshort;		/* packets received too short */
13330527Skarels 	u_long	tcps_rcvduppack;	/* duplicate-only packets received */
13430527Skarels 	u_long	tcps_rcvdupbyte;	/* duplicate-only bytes received */
13530527Skarels 	u_long	tcps_rcvpartduppack;	/* packets with some duplicate data */
13630527Skarels 	u_long	tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
13730527Skarels 	u_long	tcps_rcvoopack;		/* out-of-order packets received */
13830527Skarels 	u_long	tcps_rcvoobyte;		/* out-of-order bytes received */
13930527Skarels 	u_long	tcps_rcvpackafterwin;	/* packets with data after window */
14030527Skarels 	u_long	tcps_rcvbyteafterwin;	/* bytes rcvd after window */
14130527Skarels 	u_long	tcps_rcvafterclose;	/* packets rcvd after "close" */
14230527Skarels 	u_long	tcps_rcvwinprobe;	/* rcvd window probe packets */
14330527Skarels 	u_long	tcps_rcvdupack;		/* rcvd duplicate acks */
14430527Skarels 	u_long	tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
14530527Skarels 	u_long	tcps_rcvackpack;	/* rcvd ack packets */
14630527Skarels 	u_long	tcps_rcvackbyte;	/* bytes acked by rcvd acks */
14730527Skarels 	u_long	tcps_rcvwinupd;		/* rcvd window update packets */
1484926Swnj };
1494926Swnj 
1504808Swnj #ifdef KERNEL
1515067Swnj struct	inpcb tcb;		/* head of queue of active tcpcb's */
1525067Swnj struct	tcpstat tcpstat;	/* tcp statistics */
1534881Swnj struct	tcpiphdr *tcp_template();
15410398Ssam struct	tcpcb *tcp_close(), *tcp_drop();
15510398Ssam struct	tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();
1564808Swnj #endif
157