| 1 | /* tcp_timer.h 4.7 82/02/03 */ |
| 2 | |
| 3 | /* |
| 4 | * Definitions of the TCP timers. These timers are counted |
| 5 | * down PR_SLOWHZ times a second. |
| 6 | */ |
| 7 | #define TCPT_NTIMERS 5 |
| 8 | |
| 9 | #define TCPT_REXMT 0 /* retransmit */ |
| 10 | #define TCPT_PERSIST 1 /* retransmit persistance */ |
| 11 | #define TCPT_KEEP 2 /* keep alive */ |
| 12 | #define TCPT_2MSL 3 /* 2*msl quiet time timer */ |
| 13 | #ifdef TCPTRUEOOB |
| 14 | #define TCPT_OOBREXMT 4 /* out-of-band rexmt */ |
| 15 | #endif |
| 16 | |
| 17 | /* |
| 18 | * The TCPT_REXMT timer is used to force retransmissions. |
| 19 | * The TCP has the TCPT_REXMT timer set whenever segments |
| 20 | * have been sent for which ACKs are expected but not yet |
| 21 | * received. If an ACK is received which advances tp->snd_una, |
| 22 | * then the retransmit timer is cleared (if there are no more |
| 23 | * outstanding segments) or reset to the base value (if there |
| 24 | * are more ACKs expected). Whenever the retransmit timer goes off, |
| 25 | * we retransmit all unacknowledged segments, and do an exponential |
| 26 | * backoff on the retransmit timer. |
| 27 | * |
| 28 | * The TCPT_PERSIST timer is used to keep window size information |
| 29 | * flowing even if the window goes shut. If an output is attempted when there |
| 30 | * is data ready to transmit, but nothing gets sent because the window |
| 31 | * is shut, then we start the TCPT_PERSIST timer, and at intervals |
| 32 | * send a single byte into the peers window to force him to update |
| 33 | * our window information. We do this at most as often as TCPT_PERSMIN |
| 34 | * time intervals, but no more frequently than the current estimate of |
| 35 | * round-trip packet time. The TCPT_PERSIST timer is cleared whenever |
| 36 | * we receive a window update from the peer. |
| 37 | * |
| 38 | * The TCPT_KEEP timer is used to keep connections alive. If an |
| 39 | * connection is idle (no segments received) for TCPTV_KEEP amount of time, |
| 40 | * but not yet established, then we drop the connection. If the connection |
| 41 | * is established, then we force the peer to send us a segment by sending: |
| 42 | * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK> |
| 43 | * This segment is (deliberately) outside the window, and should elicit |
| 44 | * an ack segment in response from the peer. If, despite the TCPT_KEEP |
| 45 | * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE |
| 46 | * amount of time, then we drop the connection. |
| 47 | * |
| 48 | * The OOBREXMT timer is to force retransmissions of out-of-band indications. |
| 49 | * Because out-of-band data is considered critical, it does not exponential |
| 50 | * backoff, but runs at a multiple of smoothed round trip time until acked. |
| 51 | */ |
| 52 | |
| 53 | #define TCP_TTL 15 /* time to live for TCP segs */ |
| 54 | /* |
| 55 | * Time constants. |
| 56 | */ |
| 57 | #define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime */ |
| 58 | #define TCPTV_SRTTBASE ( 1*PR_SLOWHZ) /* base roundtrip time */ |
| 59 | #define TCPTV_KEEP ( 60*PR_SLOWHZ) /* keep alive - 1 min */ |
| 60 | #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ |
| 61 | |
| 62 | #define TCPTV_MAXIDLE ( 4*TCPTV_KEEP) /* maximum allowable idle |
| 63 | time before drop conn */ |
| 64 | |
| 65 | #define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ |
| 66 | #define TCPTV_MAX ( 30*PR_SLOWHZ) /* maximum allowable value */ |
| 67 | |
| 68 | #define TCP_LINGERTIME 120 /* linger at most 2 minutes */ |
| 69 | |
| 70 | #define TCP_MAXRXTSHIFT 10 /* maximum retransmits */ |
| 71 | |
| 72 | #ifdef TCPTIMERS |
| 73 | char *tcptimers[] = |
| 74 | { "REXMT", "PERSIST", "KEEP", "2MSL", "OOBREXMT" }; |
| 75 | #endif |
| 76 | |
| 77 | /* |
| 78 | * Retransmission smoothing constants. |
| 79 | * Smoothed round trip time is updated by |
| 80 | * tp->t_srtt = (tcp_alpha * tp->t_srtt) + ((1 - tcp_alpha) * tp->t_rtt) |
| 81 | * each time a new value of tp->t_rtt is available. The initial |
| 82 | * retransmit timeout is then based on |
| 83 | * tp->t_timer[TCPT_REXMT] = tcp_beta * tp->t_srtt; |
| 84 | * limited, however to be at least TCPTV_REXMTLO and at most TCPTV_REXMTHI. |
| 85 | */ |
| 86 | float tcp_alpha, tcp_beta; |
| 87 | |
| 88 | /* |
| 89 | * Initial values of tcp_alpha and tcp_beta. |
| 90 | * These are conservative: averaging over a long |
| 91 | * period of time, and allowing for large individual deviations from |
| 92 | * tp->t_srtt. |
| 93 | */ |
| 94 | #define TCP_ALPHA 0.9 |
| 95 | #define TCP_BETA 2.0 |
| 96 | |
| 97 | /* |
| 98 | * Force a time value to be in a certain range. |
| 99 | */ |
| 100 | #define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ |
| 101 | (tv) = (value); \ |
| 102 | if ((tv) < (tvmin)) \ |
| 103 | (tv) = (tvmin); \ |
| 104 | if ((tv) > (tvmax)) \ |
| 105 | (tv) = (tvmax); \ |
| 106 | } |