* Copyright (c) 1982, 1986 Regents of the University of California.
* %sccs.include.redist.c%
* @(#)tcp_var.h 7.10 (Berkeley) %G%
* TCP configuration: This is a half-assed attempt to make TCP
* self-configure for a few varieties of 4.2 and 4.3-based unixes.
* If you don't have a) a 4.3bsd vax or b) a 3.x Sun (x<6), check
* this carefully (it's probably not right). Please send me mail
* if you run into configuration problems.
* - Van Jacobson (van@lbl-csam.arpa)
#define BSD 42 /* if we're not 4.3, pretend we're 4.2 */
#define OLDSTAT /* set if we have to use old netstat binaries */
/* #define OLDSTAT /* set if we have to use old netstat binaries */
#define TCP_COMPAT_42 /* set if we have to interop w/4.2 systems */
#define SB_MAX SB_MAXCOUNT /* Sun has to be a little bit different... */
#define SB_MAX 32767 /* XXX */
* Bill Nowicki pointed out that the page size (CLBYTES) has
* nothing to do with the mbuf cluster size. So, we followed
* Sun's lead and made the new define MCLBYTES stand for the mbuf
* cluster size. The following define makes up backwards compatible
* with 4.3 and 4.2. If CLBYTES is >1024 on your machine, check
* this against the mbuf cluster definitions in /usr/include/sys/mbuf.h.
#define MCLBYTES CLBYTES /* XXX */
* The routine in_localaddr is broken in Sun's 3.4. We redefine ours
* (in tcp_input.c) so we use can it but won't have a name conflict.
#define in_localaddr tcp_in_localaddr
/* --------------- end of TCP config ---------------- */
* Kernel variables for tcp.
* Tcp control block, one per tcp; fields:
struct tcpiphdr
*seg_next
; /* sequencing queue */
struct tcpiphdr
*seg_prev
;
short t_state
; /* state of this connection */
short t_timer
[TCPT_NTIMERS
]; /* tcp timers */
short t_rxtshift
; /* log(2) of rexmt exp. backoff */
short t_rxtcur
; /* current retransmit value */
short t_dupacks
; /* consecutive dup acks recd */
u_short t_maxseg
; /* maximum segment size */
char t_force
; /* 1 if forcing out a byte */
#define TF_ACKNOW 0x01 /* ack peer immediately */
#define TF_DELACK 0x02 /* ack, but try to delay it */
#define TF_NODELAY 0x04 /* don't delay packets to coalesce */
#define TF_NOOPT 0x08 /* don't use tcp options */
#define TF_SENTFIN 0x10 /* have sent FIN */
struct tcpiphdr
*t_template
; /* skeletal packet for transmit */
struct inpcb
*t_inpcb
; /* back pointer to internet pcb */
* The following fields are used as in the protocol specification.
* See RFC783, Dec. 1981, page 21.
/* send sequence variables */
tcp_seq snd_una
; /* send unacknowledged */
tcp_seq snd_nxt
; /* send next */
tcp_seq snd_up
; /* send urgent pointer */
tcp_seq snd_wl1
; /* window update seg seq number */
tcp_seq snd_wl2
; /* window update seg ack number */
tcp_seq iss
; /* initial send sequence number */
u_short snd_wnd
; /* send window */
/* receive sequence variables */
u_short rcv_wnd
; /* receive window */
tcp_seq rcv_nxt
; /* receive next */
tcp_seq rcv_up
; /* receive urgent pointer */
tcp_seq irs
; /* initial receive sequence number */
* Additional variables for this implementation.
tcp_seq rcv_adv
; /* advertised window */
/* retransmit variables */
tcp_seq snd_max
; /* highest sequence number sent;
* used to recognize retransmits
/* congestion control (for slow start, source quench, retransmit after loss) */
u_short snd_cwnd
; /* congestion-controlled window */
u_short snd_ssthresh
; /* snd_cwnd size threshhold for
* for slow start exponential to
* transmit timing stuff. See below for scale of srtt and rttvar.
* "Variance" is actually smoothed difference.
short t_idle
; /* inactivity time */
short t_rtt
; /* round trip time */
tcp_seq t_rtseq
; /* sequence number being timed */
short t_srtt
; /* smoothed round-trip time */
short t_rttvar
; /* variance in round-trip time */
u_short t_rttmin
; /* minimum rtt allowed */
u_short max_sndwnd
; /* largest window peer has offered */
char t_oobflags
; /* have some */
char t_iobc
; /* input character */
#define TCPOOB_HAVEDATA 0x01
#define TCPOOB_HADDATA 0x02
short t_softerror
; /* possible error not yet reported */
#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
#define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
* The smoothed round-trip time and estimated variance
* are stored as fixed point numbers scaled by the values below.
* For convenience, these scales are also used in smoothing the average
* (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
* With these scales, srtt has 3 bits to the right of the binary point,
* and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the
* binary point, and is smoothed with an ALPHA of 0.75.
#define TCP_RTT_SCALE 8 /* multiplier for srtt; 3 bits frac. */
#define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */
#define TCP_RTTVAR_SCALE 4 /* multiplier for rttvar; 2 bits */
#define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */
* The initial retransmission should happen at rtt + 4 * rttvar.
* Because of the way we do the smoothing, srtt and rttvar
* will each average +1/2 tick of bias. When we compute
* the retransmit timer, we want 1/2 tick of rounding and
* 1 extra tick because of +-1/2 tick uncertainty in the
* firing of the timer. The bias will give us exactly the
* 1.5 tick we need. But, because the bias is
* statistical, we have to test that we don't drop below
* the minimum feasible timer (which is 2 ticks).
* This macro assumes that the value of TCP_RTTVAR_SCALE
* is the same as the multiplier for rttvar.
#define TCP_REXMTVAL(tp) \
(((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar)
* We want to avoid doing m_pullup on incoming packets but that
* means avoiding dtom on the tcp reassembly code. That in turn means
* keeping an mbuf pointer in the reassembly queue (since we might
* have a cluster). As a quick hack, the source & destination
* port numbers (which are no longer needed once we've located the
* tcpcb) are overlayed with an mbuf pointer.
#define REASS_MBUF(ti) (*(struct mbuf **)&((ti)->ti_t))
* Many of these should be kept per connection,
* but that's inconvenient at the moment.
* Declare statistics the same as in 4.3
* at the start of tcpstat (same size and
#define tcps_badsum tcps_rcvbadsum
#define tcps_badoff tcps_rcvbadoff
#define tcps_hdrops tcps_rcvshort
u_long tcps_connattempt
; /* connections initiated */
u_long tcps_accepts
; /* connections accepted */
u_long tcps_connects
; /* connections established */
u_long tcps_drops
; /* connections dropped */
u_long tcps_conndrops
; /* embryonic connections dropped */
u_long tcps_closed
; /* conn. closed (includes drops) */
u_long tcps_segstimed
; /* segs where we tried to get rtt */
u_long tcps_rttupdated
; /* times we succeeded */
u_long tcps_delack
; /* delayed acks sent */
u_long tcps_timeoutdrop
; /* conn. dropped in rxmt timeout */
u_long tcps_rexmttimeo
; /* retransmit timeouts */
u_long tcps_persisttimeo
; /* persist timeouts */
u_long tcps_keeptimeo
; /* keepalive timeouts */
u_long tcps_keepprobe
; /* keepalive probes sent */
u_long tcps_keepdrops
; /* connections dropped in keepalive */
u_long tcps_sndtotal
; /* total packets sent */
u_long tcps_sndpack
; /* data packets sent */
u_long tcps_sndbyte
; /* data bytes sent */
u_long tcps_sndrexmitpack
; /* data packets retransmitted */
u_long tcps_sndrexmitbyte
; /* data bytes retransmitted */
u_long tcps_sndacks
; /* ack-only packets sent */
u_long tcps_sndprobe
; /* window probes sent */
u_long tcps_sndurg
; /* packets sent with URG only */
u_long tcps_sndwinup
; /* window update-only packets sent */
u_long tcps_sndctrl
; /* control (SYN|FIN|RST) packets sent */
u_long tcps_rcvtotal
; /* total packets received */
u_long tcps_rcvpack
; /* packets received in sequence */
u_long tcps_rcvbyte
; /* bytes received in sequence */
u_long tcps_rcvbadsum
; /* packets received with ccksum errs */
u_long tcps_rcvbadoff
; /* packets received with bad offset */
u_long tcps_rcvshort
; /* packets received too short */
u_long tcps_rcvduppack
; /* duplicate-only packets received */
u_long tcps_rcvdupbyte
; /* duplicate-only bytes received */
u_long tcps_rcvpartduppack
; /* packets with some duplicate data */
u_long tcps_rcvpartdupbyte
; /* dup. bytes in part-dup. packets */
u_long tcps_rcvoopack
; /* out-of-order packets received */
u_long tcps_rcvoobyte
; /* out-of-order bytes received */
u_long tcps_rcvpackafterwin
; /* packets with data after window */
u_long tcps_rcvbyteafterwin
; /* bytes rcvd after window */
u_long tcps_rcvafterclose
; /* packets rcvd after "close" */
u_long tcps_rcvwinprobe
; /* rcvd window probe packets */
u_long tcps_rcvdupack
; /* rcvd duplicate acks */
u_long tcps_rcvacktoomuch
; /* rcvd acks for unsent data */
u_long tcps_rcvackpack
; /* rcvd ack packets */
u_long tcps_rcvackbyte
; /* bytes acked by rcvd acks */
u_long tcps_rcvwinupd
; /* rcvd window update packets */
struct inpcb tcb
; /* head of queue of active tcpcb's */
struct tcpstat tcpstat
; /* tcp statistics */
struct tcpiphdr
*tcp_template();
struct tcpcb
*tcp_close(), *tcp_drop();
struct tcpcb
*tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();