spx_timer.h revision 256281
1252190Srpaulo/*-
2252190Srpaulo * Copyright (c) 1982, 1986, 1988, 1993
3252190Srpaulo *	The Regents of the University of California.  All rights reserved.
4252190Srpaulo *
5252190Srpaulo * Redistribution and use in source and binary forms, with or without
6252190Srpaulo * modification, are permitted provided that the following conditions
7252190Srpaulo * are met:
8252190Srpaulo * 1. Redistributions of source code must retain the above copyright
9252190Srpaulo *    notice, this list of conditions and the following disclaimer.
10252190Srpaulo * 2. Redistributions in binary form must reproduce the above copyright
11252190Srpaulo *    notice, this list of conditions and the following disclaimer in the
12252190Srpaulo *    documentation and/or other materials provided with the distribution.
13252190Srpaulo * 4. Neither the name of the University nor the names of its contributors
14252190Srpaulo *    may be used to endorse or promote products derived from this software
15252190Srpaulo *    without specific prior written permission.
16252190Srpaulo *
17252190Srpaulo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18252190Srpaulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19252190Srpaulo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20252190Srpaulo * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21252190Srpaulo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22252190Srpaulo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23252190Srpaulo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24252190Srpaulo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25252190Srpaulo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26252190Srpaulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27252190Srpaulo * SUCH DAMAGE.
28252190Srpaulo *
29252190Srpaulo * Copyright (c) 1995, Mike Mitchell
30252190Srpaulo *
31252190Srpaulo * Redistribution and use in source and binary forms, with or without
32252190Srpaulo * modification, are permitted provided that the following conditions
33252190Srpaulo * are met:
34252190Srpaulo * 1. Redistributions of source code must retain the above copyright
35252190Srpaulo *    notice, this list of conditions and the following disclaimer.
36252190Srpaulo * 2. Redistributions in binary form must reproduce the above copyright
37252190Srpaulo *    notice, this list of conditions and the following disclaimer in the
38252190Srpaulo *    documentation and/or other materials provided with the distribution.
39252190Srpaulo * 3. All advertising materials mentioning features or use of this software
40252190Srpaulo *    must display the following acknowledgement:
41252190Srpaulo *	This product includes software developed by the University of
42252190Srpaulo *	California, Berkeley and its contributors.
43252190Srpaulo * 4. Neither the name of the University nor the names of its contributors
44252190Srpaulo *    may be used to endorse or promote products derived from this software
45252190Srpaulo *    without specific prior written permission.
46252190Srpaulo *
47252190Srpaulo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48252190Srpaulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49252190Srpaulo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50252190Srpaulo * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51252190Srpaulo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52252190Srpaulo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53252190Srpaulo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54252190Srpaulo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55252190Srpaulo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56252190Srpaulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57252190Srpaulo * SUCH DAMAGE.
58252190Srpaulo *
59252190Srpaulo *	@(#)spx_timer.h
60252190Srpaulo *
61252190Srpaulo * $FreeBSD: stable/10/sys/netipx/spx_timer.h 165899 2007-01-08 22:14:00Z rwatson $
62252190Srpaulo */
63252190Srpaulo
64252190Srpaulo#ifndef _NETIPX_SPX_TIMER_H_
65252190Srpaulo#define _NETIPX_SPX_TIMER_H_
66252190Srpaulo
67252190Srpaulo/*
68252190Srpaulo * Definitions of the SPX timers.  These timers are counted
69252190Srpaulo * down PR_SLOWHZ times a second.
70252190Srpaulo */
71252190Srpaulo#define	SPXT_REXMT	0		/* retransmit */
72252190Srpaulo#define	SPXT_PERSIST	1		/* retransmit persistence */
73252190Srpaulo#define	SPXT_KEEP	2		/* keep alive */
74252190Srpaulo#define	SPXT_2MSL	3		/* 2*msl quiet time timer */
75252190Srpaulo
76252190Srpaulo/*
77252190Srpaulo * The SPXT_REXMT timer is used to force retransmissions.
78252190Srpaulo * The SPX has the SPXT_REXMT timer set whenever segments
79252190Srpaulo * have been sent for which ACKs are expected but not yet
80252190Srpaulo * received.  If an ACK is received which advances tp->snd_una,
81252190Srpaulo * then the retransmit timer is cleared (if there are no more
82252190Srpaulo * outstanding segments) or reset to the base value (if there
83252190Srpaulo * are more ACKs expected).  Whenever the retransmit timer goes off,
84252190Srpaulo * we retransmit one unacknowledged segment, and do a backoff
85252190Srpaulo * on the retransmit timer.
86252190Srpaulo *
87252190Srpaulo * The SPXT_PERSIST timer is used to keep window size information
88252190Srpaulo * flowing even if the window goes shut.  If all previous transmissions
89252190Srpaulo * have been acknowledged (so that there are no retransmissions in progress),
90252190Srpaulo * and the window is too small to bother sending anything, then we start
91252190Srpaulo * the SPXT_PERSIST timer.  When it expires, if the window is nonzero,
92252190Srpaulo * we go to transmit state.  Otherwise, at intervals send a single byte
93252190Srpaulo * into the peer's window to force him to update our window information.
94252190Srpaulo * We do this at most as often as SPXT_PERSMIN time intervals,
95252190Srpaulo * but no more frequently than the current estimate of round-trip
96252190Srpaulo * packet time.  The SPXT_PERSIST timer is cleared whenever we receive
97252190Srpaulo * a window update from the peer.
98252190Srpaulo *
99252190Srpaulo * The SPXT_KEEP timer is used to keep connections alive.  If an
100252190Srpaulo * connection is idle (no segments received) for SPXTV_KEEP amount of time,
101252190Srpaulo * but not yet established, then we drop the connection.  If the connection
102252190Srpaulo * is established, then we force the peer to send us a segment by sending:
103252190Srpaulo *	<SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
104252190Srpaulo * This segment is (deliberately) outside the window, and should elicit
105252190Srpaulo * an ack segment in response from the peer.  If, despite the SPXT_KEEP
106252190Srpaulo * initiated segments we cannot elicit a response from a peer in SPXT_MAXIDLE
107252190Srpaulo * amount of time, then we drop the connection.
108252190Srpaulo */
109252190Srpaulo
110252190Srpaulo#define	SPX_TTL		30		/* default time to live for SPX segs */
111252190Srpaulo/*
112252190Srpaulo * Time constants.
113252190Srpaulo */
114252190Srpaulo#define	SPXTV_MSL	( 15*PR_SLOWHZ)		/* max seg lifetime */
115252190Srpaulo#define	SPXTV_SRTTBASE	0			/* base roundtrip time;
116252190Srpaulo						   if 0, no idea yet */
117252190Srpaulo#define	SPXTV_SRTTDFLT	(  3*PR_SLOWHZ)		/* assumed RTT if no info */
118252190Srpaulo
119252190Srpaulo#define	SPXTV_PERSMIN	(  5*PR_SLOWHZ)		/* retransmit persistence */
120252190Srpaulo#define	SPXTV_PERSMAX	( 60*PR_SLOWHZ)		/* maximum persist interval */
121252190Srpaulo
122252190Srpaulo#define	SPXTV_KEEP	( 75*PR_SLOWHZ)		/* keep alive - 75 secs */
123252190Srpaulo#define	SPXTV_MAXIDLE	(  8*SPXTV_KEEP)	/* maximum allowable idle
124252190Srpaulo						   time before drop conn */
125252190Srpaulo
126252190Srpaulo#define	SPXTV_MIN	(  1*PR_SLOWHZ)		/* minimum allowable value */
127252190Srpaulo#define	SPXTV_REXMTMAX	( 64*PR_SLOWHZ)		/* max allowable REXMT value */
128252190Srpaulo
129252190Srpaulo#define	SPX_LINGERTIME	120			/* linger at most 2 minutes */
130252190Srpaulo
131252190Srpaulo#define	SPX_MAXRXTSHIFT	12			/* maximum retransmits */
132252190Srpaulo
133252190Srpaulo#ifdef	SPXTIMERS
134252190Srpaulochar *spxtimers[] =
135252190Srpaulo    { "REXMT", "PERSIST", "KEEP", "2MSL" };
136252190Srpaulo#endif
137252190Srpaulo
138252190Srpaulo/*
139252190Srpaulo * Force a time value to be in a certain range.
140252190Srpaulo */
141252190Srpaulo#define	SPXT_RANGESET(tv, value, tvmin, tvmax) { \
142252190Srpaulo	(tv) = (value); \
143252190Srpaulo	if ((tv) < (tvmin)) \
144252190Srpaulo		(tv) = (tvmin); \
145252190Srpaulo	else if ((tv) > (tvmax)) \
146252190Srpaulo		(tv) = (tvmax); \
147252190Srpaulo}
148252190Srpaulo
149252190Srpaulo#endif /* !_NETIPX_SPX_TIMER_H_ */
150252190Srpaulo