tcp_timer.h revision 28bcddec322ed1073dc7dbaf82c4c622aed468fd
662N/A/* $Id$ */
662N/A/** @file
662N/A * NAT - TCP timer (declarations/defines).
662N/A */
662N/A
662N/A/*
662N/A * Copyright (C) 2006-2010 Oracle Corporation
662N/A *
662N/A * This file is part of VirtualBox Open Source Edition (OSE), as
662N/A * available from http://www.virtualbox.org. This file is free software;
662N/A * you can redistribute it and/or modify it under the terms of the GNU
662N/A * General Public License (GPL) as published by the Free Software
662N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
662N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
662N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
662N/A */
662N/A
662N/A/*
873N/A * This code is based on:
662N/A *
662N/A * Copyright (c) 1982, 1986, 1993
662N/A * The Regents of the University of California. All rights reserved.
662N/A *
662N/A * Redistribution and use in source and binary forms, with or without
3231N/A * modification, are permitted provided that the following conditions
662N/A * are met:
662N/A * 1. Redistributions of source code must retain the above copyright
1970N/A * notice, this list of conditions and the following disclaimer.
662N/A * 2. Redistributions in binary form must reproduce the above copyright
2086N/A * notice, this list of conditions and the following disclaimer in the
2086N/A * documentation and/or other materials provided with the distribution.
2086N/A * 3. All advertising materials mentioning features or use of this software
662N/A * must display the following acknowledgement:
662N/A * This product includes software developed by the University of
662N/A * California, Berkeley and its contributors.
662N/A * 4. Neither the name of the University nor the names of its contributors
662N/A * may be used to endorse or promote products derived from this software
662N/A * without specific prior written permission.
662N/A *
662N/A * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
662N/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
662N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
662N/A * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
662N/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
662N/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
662N/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
662N/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
662N/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
662N/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
662N/A * SUCH DAMAGE.
662N/A *
662N/A * @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93
662N/A * tcp_timer.h,v 1.4 1994/08/21 05:27:38 paul Exp
662N/A */
662N/A
662N/A#ifndef _TCP_TIMER_H_
662N/A#define _TCP_TIMER_H_
662N/A
662N/A/*
662N/A * Definitions of the TCP timers. These timers are counted
662N/A * down PR_SLOWHZ times a second.
662N/A */
662N/A#define TCPT_NTIMERS 4
662N/A
662N/A#define TCPT_REXMT 0 /* retransmit */
662N/A#define TCPT_PERSIST 1 /* retransmit persistence */
662N/A#define TCPT_KEEP 2 /* keep alive */
662N/A#define TCPT_2MSL 3 /* 2*msl quiet time timer */
662N/A
662N/A/*
2086N/A * The TCPT_REXMT timer is used to force retransmissions.
662N/A * The TCP has the TCPT_REXMT timer set whenever segments
662N/A * have been sent for which ACKs are expected but not yet
662N/A * received. If an ACK is received which advances tp->snd_una,
662N/A * then the retransmit timer is cleared (if there are no more
662N/A * outstanding segments) or reset to the base value (if there
2086N/A * are more ACKs expected). Whenever the retransmit timer goes off,
662N/A * we retransmit one unacknowledged segment, and do a backoff
662N/A * on the retransmit timer.
662N/A *
662N/A * The TCPT_PERSIST timer is used to keep window size information
662N/A * flowing even if the window goes shut. If all previous transmissions
662N/A * have been acknowledged (so that there are no retransmissions in progress),
662N/A * and the window is too small to bother sending anything, then we start
662N/A * the TCPT_PERSIST timer. When it expires, if the window is nonzero,
662N/A * we go to transmit state. Otherwise, at intervals send a single byte
662N/A * into the peer's window to force him to update our window information.
662N/A * We do this at most as often as TCPT_PERSMIN time intervals,
662N/A * but no more frequently than the current estimate of round-trip
2086N/A * packet time. The TCPT_PERSIST timer is cleared whenever we receive
662N/A * a window update from the peer.
662N/A *
662N/A * The TCPT_KEEP timer is used to keep connections alive. If an
662N/A * connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time,
662N/A * but not yet established, then we drop the connection. Once the connection
662N/A * is established, if the connection is idle for TCPTV_KEEP_IDLE time
662N/A * (and keepalives have been enabled on the socket), we begin to probe
662N/A * the connection. We force the peer to send us a segment by sending:
662N/A * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
662N/A * This segment is (deliberately) outside the window, and should elicit
662N/A * an ack segment in response from the peer. If, despite the TCPT_KEEP
662N/A * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE
662N/A * amount of time probing, then we drop the connection.
662N/A */
662N/A
662N/A/*
662N/A * Time constants.
662N/A */
662N/A#define TCPTV_MSL ( 5*PR_SLOWHZ) /* max seg lifetime (hah!) */
662N/A
662N/A#define TCPTV_SRTTBASE 0 /* base roundtrip time;
662N/A if 0, no idea yet */
662N/A#define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */
662N/A
662N/A#define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistence */
662N/A#define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */
662N/A
662N/A#define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ) /* initial connect keep alive */
662N/A#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */
662N/A#define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ) /* default probe interval */
662N/A#define TCPTV_KEEPCNT 8 /* max probes before drop */
662N/A
2086N/A#define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */
662N/A#define TCPTV_REXMTMAX ( 12*PR_SLOWHZ) /* max allowable REXMT value */
662N/A
662N/A#define TCP_LINGERTIME 120 /* linger at most 2 minutes */
662N/A
662N/A#define TCP_MAXRXTSHIFT 12 /* maximum retransmits */
662N/A
662N/A
662N/A#ifdef TCPTIMERS
2086N/Achar *tcptimers[] =
662N/A { "REXMT", "PERSIST", "KEEP", "2MSL" };
662N/A#endif
662N/A
662N/A/*
662N/A * Force a time value to be in a certain range.
662N/A */
662N/A#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \
662N/A (tv) = (value); \
662N/A if ((tv) < (tvmin)) \
662N/A (tv) = (tvmin); \
662N/A else if ((tv) > (tvmax)) \
662N/A (tv) = (tvmax); \
662N/A}
662N/A
662N/Aextern const int tcp_backoff[];
662N/A
662N/Astruct tcpcb;
2086N/A
662N/Avoid tcp_fasttimo (PNATState);
2086N/Avoid tcp_slowtimo (PNATState);
2086N/Avoid tcp_canceltimers (struct tcpcb *);
2086N/A#if 0
2086N/Astruct tcpcb * tcp_timers (PNATState, register struct tcpcb *, int);
2086N/A#endif
662N/A
662N/A#endif
662N/A