⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcp_var.h

📁 VRTX 商用嵌入式实时操作系统
💻 H
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************
*
*               Copyright (c) 1993 READY SYSTEMS CORPORATION.
*
*       All rights reserved. READY SYSTEMS' source code is an unpublished
*       work and the use of a copyright notice does not imply otherwise.
*       This source code contains confidential, trade secret material of
*       READY SYSTEMS. Any attempt or participation in deciphering, decoding,
*       reverse engineering or in any way altering the source code is
*       strictly prohibited, unless the prior written consent of
*       READY SYSTEMS is obtained.
*
*
*       Module Name:            tcp_var.h
*
*       Identification:         @(#) 1.3 tcp_var.h
*
*       Date:                   1/6/94  16:37:32
*
****************************************************************************
*/

/*
 RCS header identifier - tcp_var.h,v 1.2 1995/01/05 16:32:29 sriram Exp
*/
/*
 * Copyrighted as an unpublished work.
 * (c) Copyright 1987-1993 Lachman Technology, Incorporated
 * All rights reserved.
 * 
 * RESTRICTED RIGHTS
 * 
 * These programs are supplied under a license.  They may be used,
 * disclosed, and/or copied only as permitted under such license
 * agreement.  Any copy must contain the above copyright notice and
 * this restricted rights notice.  Use, copying, and/or disclosure
 * of the programs is strictly prohibited unless otherwise provided
 * in the license agreement.
 */
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that this notice is preserved and that due credit is given
 * to the University of California at Berkeley. The name of the University
 * may not be used to endorse or promote products derived from this
 * software without specific prior written permission. This software
 * is provided ``as is'' without express or implied warranty.
 *
 *	@(#)tcp_var.h	7.7 (Berkeley) 2/27/88
 */

/* **********************************************************************
 * 
 * CHANGE HISTORY:
 *
 * ----------------------------------------------------------------------
 * DATE           CHANGES
 * ----------------------------------------------------------------------
 *
 * 12/14/94       Included the Version 5 TCP compatible code for SNMP_V2.
 *                Check for #ifdef VER5_COMPAT.
 * 
 * ********************************************************************* */


#ifdef SNX
#ifndef VER5_COMPAT
#define VER5_COMPAT  /* This needs to be compiled, SNX */
#endif
#endif

#ifndef  in_pcb_h
#include "netinet/in_pcb.h"
#endif

#ifndef tcp_var_h
#define tcp_var_h

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Kernel variables for tcp. 
 */

/*
 * Tcp control block, one per tcp; fields: 
 */
struct tcpcb {
	struct tcpiphdr *seg_next;	/* sequencing queue */
	short           t_state;/* state of this connection */
	short           t_timer[TCPT_NTIMERS];	/* tcp timers */
	short           t_rxtshift;	/* log(2) of rexmt exp. backoff */
	u_short         t_maxseg;	/* maximum segment size */
	short		t_rxtcur;	/* current retransmit value */
	short		t_dupacks;	/* consecutive dup acks recd */
	char            t_force;/* 1 if forcing out a byte */
	u_short         t_flags;
#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 */
#define TF_IOLOCK	0x20
#define TF_NEEDIN	0x40
#define TF_NEEDOUT	0x80
#define TF_NEEDTIMER	0x0100
	struct tcpiphdr *t_template;	/* skeletal packet for transmit */
	mblk_t         *t_tmplhdr;	/* template back-pointer for dealloc */
	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. 
	 */
	/* receive variables */
	tcp_seq         rcv_adv;/* advertised window */
	/* retransmit variables */
	tcp_seq         snd_max;/* highest sequence number sent used to
				 * recognize retransmits */
	u_short		t_maxwin;	/* max window size to use */
/* 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
					 * linear switch */
/*
 * transmit timing stuff.
 * srtt and rttvar are stored as fixed point; for convenience in smoothing,
 * srtt has 3 bits to the right of the binary point, rttvar has 2.
 * "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 */
	short		t_rttmin;	/* minimum rtt allowed */
	u_short 	max_rcvd;	/* most peer has sent into window */
	u_short         max_sndwnd;	/* largest window peer has offered */
	/* out-of-band data */
	char            t_oobflags;	/* have some */
	char            t_iobc;	/* input character */
#define	TCPOOB_HAVEDATA	0x01
#define	TCPOOB_HADDATA	0x02
	/* connection queueing */
	struct tcpcb   *t_head;	/* back pointer to accept tcpcb */
	struct tcpcb   *t_q0;	/* queue of partial connections */
	struct tcpcb   *t_q;	/* queue of incoming connections */
	short           t_q0len;/* partials on t_q0 */
	short           t_qlen;	/* number of connections on so_q */
	short           t_qlimit;	/* max number queued connections */
	/*
	 * here we save mblks that arrive before the connection is accepted
	 * by the user and those received when the user's queue is full. 
	 * we also save mblks that still need to be sent when the
	 * connection is closed by the user.
	 */
	queue_t        *t_strq;		/* queue pair for stalled data */
	mblk_t         *t_infirst;	/* queue for incoming data */
	mblk_t         *t_inlast;	/* queue for incoming data */
	mblk_t         *t_ordrel;	/* template for ordrel */
	ulong           t_iqsize;	/* amount of data on input queue */
	ulong           t_qsize;	/* number of data chars on outq */
	short           t_linger;	/* linger flag */

	/*
	 * The following stuff is for "one-packet mode", which supports
	 * slow interfaces that can't handle back-to-back packets.
	 * These values are taken from the provider structure of
	 * the interface if IFF_ONEPACKET is on.
	 */
	u_char		t_onepacket;	/* one-packet mode in effect */
	u_short		t_spsize;	/* short packet size */
	int		t_spthresh;	/* short packet threshold */
	int		t_spcount;	/* consecutive short packet count */
};

#define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
#define qtotcpcb(q) ((struct tcpcb *) ((struct inpcb *) (q)->q_ptr)->inp_ppcb)
#define tcpcbtoq(tp) ((tp)->t_inpcb->inp_q)

/*
 * 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)

/*
 * TCP statistics.
 * Many of these should be kept per connection,
 * but that's inconvenient at the moment.
 */
struct	tcpstat {
	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 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -