xref: /csrg-svn/sys/netns/spp_timer.h (revision 63231)
133720Skarels /*
2*63231Sbostic  * Copyright (c) 1982, 1986, 1988, 1993
3*63231Sbostic  *	The Regents of the University of California.  All rights reserved.
433720Skarels  *
544506Sbostic  * %sccs.include.redist.c%
633720Skarels  *
7*63231Sbostic  *	@(#)spp_timer.h	8.1 (Berkeley) 06/10/93
833720Skarels  */
933720Skarels 
1033720Skarels /*
1133720Skarels  * Definitions of the SPP timers.  These timers are counted
1233720Skarels  * down PR_SLOWHZ times a second.
1333720Skarels  */
1433720Skarels #define	SPPT_NTIMERS	4
1533720Skarels 
1633720Skarels #define	SPPT_REXMT	0		/* retransmit */
1733720Skarels #define	SPPT_PERSIST	1		/* retransmit persistance */
1833720Skarels #define	SPPT_KEEP	2		/* keep alive */
1933720Skarels #define	SPPT_2MSL	3		/* 2*msl quiet time timer */
2033720Skarels 
2133720Skarels /*
2233720Skarels  * The SPPT_REXMT timer is used to force retransmissions.
2333720Skarels  * The SPP has the SPPT_REXMT timer set whenever segments
2433720Skarels  * have been sent for which ACKs are expected but not yet
2533720Skarels  * received.  If an ACK is received which advances tp->snd_una,
2633720Skarels  * then the retransmit timer is cleared (if there are no more
2733720Skarels  * outstanding segments) or reset to the base value (if there
2833720Skarels  * are more ACKs expected).  Whenever the retransmit timer goes off,
2933720Skarels  * we retransmit one unacknowledged segment, and do a backoff
3033720Skarels  * on the retransmit timer.
3133720Skarels  *
3233720Skarels  * The SPPT_PERSIST timer is used to keep window size information
3333720Skarels  * flowing even if the window goes shut.  If all previous transmissions
3433720Skarels  * have been acknowledged (so that there are no retransmissions in progress),
3533720Skarels  * and the window is too small to bother sending anything, then we start
3633720Skarels  * the SPPT_PERSIST timer.  When it expires, if the window is nonzero,
3733720Skarels  * we go to transmit state.  Otherwise, at intervals send a single byte
3833720Skarels  * into the peer's window to force him to update our window information.
3933720Skarels  * We do this at most as often as SPPT_PERSMIN time intervals,
4033720Skarels  * but no more frequently than the current estimate of round-trip
4133720Skarels  * packet time.  The SPPT_PERSIST timer is cleared whenever we receive
4233720Skarels  * a window update from the peer.
4333720Skarels  *
4433720Skarels  * The SPPT_KEEP timer is used to keep connections alive.  If an
4533720Skarels  * connection is idle (no segments received) for SPPTV_KEEP amount of time,
4633720Skarels  * but not yet established, then we drop the connection.  If the connection
4733720Skarels  * is established, then we force the peer to send us a segment by sending:
4833720Skarels  *	<SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
4933720Skarels  * This segment is (deliberately) outside the window, and should elicit
5033720Skarels  * an ack segment in response from the peer.  If, despite the SPPT_KEEP
5133720Skarels  * initiated segments we cannot elicit a response from a peer in SPPT_MAXIDLE
5233720Skarels  * amount of time, then we drop the connection.
5333720Skarels  */
5433720Skarels 
5533720Skarels #define	SPP_TTL		30		/* default time to live for SPP segs */
5633720Skarels /*
5733720Skarels  * Time constants.
5833720Skarels  */
5933720Skarels #define	SPPTV_MSL	( 15*PR_SLOWHZ)		/* max seg lifetime */
6033720Skarels #define	SPPTV_SRTTBASE	0			/* base roundtrip time;
6133720Skarels 						   if 0, no idea yet */
6233720Skarels #define	SPPTV_SRTTDFLT	(  3*PR_SLOWHZ)		/* assumed RTT if no info */
6333720Skarels 
6433720Skarels #define	SPPTV_PERSMIN	(  5*PR_SLOWHZ)		/* retransmit persistance */
6533720Skarels #define	SPPTV_PERSMAX	( 60*PR_SLOWHZ)		/* maximum persist interval */
6633720Skarels 
6733720Skarels #define	SPPTV_KEEP	( 75*PR_SLOWHZ)		/* keep alive - 75 secs */
6833720Skarels #define	SPPTV_MAXIDLE	(  8*SPPTV_KEEP)	/* maximum allowable idle
6933720Skarels 						   time before drop conn */
7033720Skarels 
7133720Skarels #define	SPPTV_MIN	(  1*PR_SLOWHZ)		/* minimum allowable value */
7233720Skarels #define	SPPTV_REXMTMAX	( 64*PR_SLOWHZ)		/* max allowable REXMT value */
7333720Skarels 
7433720Skarels #define	SPP_LINGERTIME	120			/* linger at most 2 minutes */
7533720Skarels 
7633720Skarels #define	SPP_MAXRXTSHIFT	12			/* maximum retransmits */
7733720Skarels 
7833720Skarels #ifdef	SPPTIMERS
7933720Skarels char *spptimers[] =
8033720Skarels     { "REXMT", "PERSIST", "KEEP", "2MSL" };
8133720Skarels #endif
8233720Skarels 
8333720Skarels /*
8433720Skarels  * Force a time value to be in a certain range.
8533720Skarels  */
8633720Skarels #define	SPPT_RANGESET(tv, value, tvmin, tvmax) { \
8733720Skarels 	(tv) = (value); \
8833720Skarels 	if ((tv) < (tvmin)) \
8933720Skarels 		(tv) = (tvmin); \
9033720Skarels 	else if ((tv) > (tvmax)) \
9133720Skarels 		(tv) = (tvmax); \
9233720Skarels }
9333720Skarels 
9433720Skarels #ifdef KERNEL
9533720Skarels extern int spp_backoff[];
9633720Skarels #endif
97