Subversion Repositories SvarDOS

Rev

Rev 616 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
207 mateuszvis 1
/*!\file netinet/tcp_time.h
2
 * TCP timer definitions.
3
 */
4
 
5
/*
6
 * Copyright (c) 1982, 1986, 1993
7
 *      The Regents of the University of California.  All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the distribution.
17
 * 3. All advertising materials mentioning features or use of this software
18
 *    must display the following acknowledgement:
19
 *      This product includes software developed by the University of
20
 *      California, Berkeley and its contributors.
21
 * 4. Neither the name of the University nor the names of its contributors
22
 *    may be used to endorse or promote products derived from this software
23
 *    without specific prior written permission.
24
 *
25
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35
 * SUCH DAMAGE.
36
 *
37
 *      @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93
38
 *      $Id: tcp_timer.h,v 1.10 1996/09/13 23:51:43 pst Exp $
39
 */
40
 
41
#ifndef __NETINET_TCP_TIMER_H
42
#define __NETINET_TCP_TIMER_H
43
 
44
/*
45
 * Definitions of the TCP timers.  These timers are counted
46
 * down PR_SLOWHZ times a second.
47
 */
48
#define TCPT_NTIMERS    4
49
 
50
#define TCPT_REXMT      0               /* retransmit */
51
#define TCPT_PERSIST    1               /* retransmit persistence */
52
#define TCPT_KEEP       2               /* keep alive */
53
#define TCPT_2MSL       3               /* 2*msl quiet time timer */
54
 
55
/*
56
 * The TCPT_REXMT timer is used to force retransmissions.
57
 * The TCP has the TCPT_REXMT timer set whenever segments
58
 * have been sent for which ACKs are expected but not yet
59
 * received.  If an ACK is received which advances tp->snd_una,
60
 * then the retransmit timer is cleared (if there are no more
61
 * outstanding segments) or reset to the base value (if there
62
 * are more ACKs expected).  Whenever the retransmit timer goes off,
63
 * we retransmit one unacknowledged segment, and do a backoff
64
 * on the retransmit timer.
65
 *
66
 * The TCPT_PERSIST timer is used to keep window size information
67
 * flowing even if the window goes shut.  If all previous transmissions
68
 * have been acknowledged (so that there are no retransmissions in progress),
69
 * and the window is too small to bother sending anything, then we start
70
 * the TCPT_PERSIST timer.  When it expires, if the window is nonzero,
71
 * we go to transmit state.  Otherwise, at intervals send a single byte
72
 * into the peer's window to force him to update our window information.
73
 * We do this at most as often as TCPT_PERSMIN time intervals,
74
 * but no more frequently than the current estimate of round-trip
75
 * packet time.  The TCPT_PERSIST timer is cleared whenever we receive
76
 * a window update from the peer.
77
 *
78
 * The TCPT_KEEP timer is used to keep connections alive.  If an
79
 * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time,
80
 * but not yet established, then we drop the connection.  Once the connection
81
 * is established, if the connection is idle for TCPTV_KEEP_IDLE time
82
 * (and keepalives have been enabled on the socket), we begin to probe
83
 * the connection.  We force the peer to send us a segment by sending:
84
 *      <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
85
 * This segment is (deliberately) outside the window, and should elicit
86
 * an ack segment in response from the peer.  If, despite the TCPT_KEEP
87
 * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE
88
 * amount of time probing, then we drop the connection.
89
 */
90
 
91
/*
92
 * Time constants.
93
 */
94
#define TCPTV_MSL       ( 30*PR_SLOWHZ)         /* max seg lifetime (hah!) */
95
#define TCPTV_SRTTBASE  0                       /* base roundtrip time;
96
                                                   if 0, no idea yet */
97
#define TCPTV_RTOBASE   (  3*PR_SLOWHZ)         /* assumed RTO if no info */
98
#define TCPTV_SRTTDFLT  (  3*PR_SLOWHZ)         /* assumed RTT if no info */
99
 
100
#define TCPTV_PERSMIN   (  5*PR_SLOWHZ)         /* retransmit persistence */
101
#define TCPTV_PERSMAX   ( 60*PR_SLOWHZ)         /* maximum persist interval */
102
 
103
#define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ)         /* initial connect keep alive */
104
#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ)      /* dflt time before probing */
105
#define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ)         /* default probe interval */
106
#define TCPTV_KEEPCNT   8                       /* max probes before drop */
107
 
108
#define TCPTV_MIN       (  1*PR_SLOWHZ)         /* minimum allowable value */
109
#define TCPTV_REXMTMAX  ( 64*PR_SLOWHZ)         /* max allowable REXMT value */
110
 
111
#define TCPTV_TWTRUNC   8                       /* RTO factor to truncate TW */
112
 
113
#define TCP_LINGERTIME  120                     /* linger at most 2 minutes */
114
 
115
#define TCP_MAXRXTSHIFT 12                      /* maximum retransmits */
116
 
117
#ifdef  TCPTIMERS
118
static char *tcptimers[] =
119
    { "REXMT", "PERSIST", "KEEP", "2MSL" };
120
#endif
121
 
122
/*
123
 * Force a time value to be in a certain range.
124
 */
125
#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \
126
        (tv) = (value);                          \
127
        if ((u_long)(tv) < (u_long)(tvmin))      \
128
                (tv) = (tvmin);                  \
129
        else if ((u_long)(tv) > (u_long)(tvmax)) \
130
                (tv) = (tvmax);                  \
131
      }
132
 
133
#endif