Path: blob/a-new-beginning/SharedDependencies/Sources/libslirp/include/tcp_var.h
2 views
/* SPDX-License-Identifier: BSD-3-Clause */1/*2* Copyright (c) 1982, 1986, 1993, 19943* The Regents of the University of California. All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13* 3. Neither the name of the University nor the names of its contributors14* may be used to endorse or promote products derived from this software15* without specific prior written permission.16*17* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE21* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*29* @(#)tcp_var.h 8.3 (Berkeley) 4/10/9430* tcp_var.h,v 1.3 1994/08/21 05:27:39 paul Exp31*/3233#ifndef TCP_VAR_H34#define TCP_VAR_H3536#include "tcpip.h"37#include "tcp_timer.h"3839/*40* Tcp control block, one per tcp; fields:41*/42struct tcpcb {43struct tcpiphdr *seg_next; /* sequencing queue */44struct tcpiphdr *seg_prev;45short t_state; /* state of this connection */46short t_timer[TCPT_NTIMERS]; /* tcp timers */47short t_rxtshift; /* log(2) of rexmt exp. backoff */48short t_rxtcur; /* current retransmit value */49short t_dupacks; /* consecutive dup acks recd */50uint16_t t_maxseg; /* maximum segment size */51uint8_t t_force; /* 1 if forcing out a byte */52uint16_t t_flags;53#define TF_ACKNOW 0x0001 /* ack peer immediately */54#define TF_DELACK 0x0002 /* ack, but try to delay it */55#define TF_NODELAY 0x0004 /* don't delay packets to coalesce */56#define TF_NOOPT 0x0008 /* don't use tcp options */57#define TF_SENTFIN 0x0010 /* have sent FIN */58#define TF_REQ_SCALE 0x0020 /* have/will request window scaling */59#define TF_RCVD_SCALE 0x0040 /* other side has requested scaling */60#define TF_REQ_TSTMP 0x0080 /* have/will request timestamps */61#define TF_RCVD_TSTMP 0x0100 /* a timestamp was received in SYN */62#define TF_SACK_PERMIT 0x0200 /* other side said I could SACK */6364struct tcpiphdr t_template; /* static skeletal packet for xmit */6566struct socket *t_socket; /* back pointer to socket */67/*68* The following fields are used as in the protocol specification.69* See RFC783, Dec. 1981, page 21.70*/71/* send sequence variables */72tcp_seq snd_una; /* send unacknowledged */73tcp_seq snd_nxt; /* send next */74tcp_seq snd_up; /* send urgent pointer */75tcp_seq snd_wl1; /* window update seg seq number */76tcp_seq snd_wl2; /* window update seg ack number */77tcp_seq iss; /* initial send sequence number */78uint32_t snd_wnd; /* send window */79/* receive sequence variables */80uint32_t rcv_wnd; /* receive window */81tcp_seq rcv_nxt; /* receive next */82tcp_seq rcv_up; /* receive urgent pointer */83tcp_seq irs; /* initial receive sequence number */84/*85* Additional variables for this implementation.86*/87/* receive variables */88tcp_seq rcv_adv; /* advertised window */89/* retransmit variables */90tcp_seq snd_max; /* highest sequence number sent;91* used to recognize retransmits92*/93/* congestion control (for slow start, source quench, retransmit after loss)94*/95uint32_t snd_cwnd; /* congestion-controlled window */96uint32_t snd_ssthresh; /* snd_cwnd size threshold for97* for slow start exponential to98* linear switch99*/100/*101* transmit timing stuff. See below for scale of srtt and rttvar.102* "Variance" is actually smoothed difference.103*/104short t_idle; /* inactivity time */105short t_rtt; /* round trip time */106tcp_seq t_rtseq; /* sequence number being timed */107short t_srtt; /* smoothed round-trip time */108short t_rttvar; /* variance in round-trip time */109uint16_t t_rttmin; /* minimum rtt allowed */110uint32_t max_sndwnd; /* largest window peer has offered */111112/* out-of-band data */113uint8_t t_oobflags; /* have some */114uint8_t t_iobc; /* input character */115#define TCPOOB_HAVEDATA 0x01116#define TCPOOB_HADDATA 0x02117short t_softerror; /* possible error not yet reported */118119/* RFC 1323 variables */120uint8_t snd_scale; /* window scaling for send window */121uint8_t rcv_scale; /* window scaling for recv window */122uint8_t request_r_scale; /* pending window scaling */123uint8_t requested_s_scale;124uint32_t ts_recent; /* timestamp echo data */125uint32_t ts_recent_age; /* when last updated */126tcp_seq last_ack_sent;127};128129#define sototcpcb(so) ((so)->so_tcpcb)130131/*132* The smoothed round-trip time and estimated variance133* are stored as fixed point numbers scaled by the values below.134* For convenience, these scales are also used in smoothing the average135* (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).136* With these scales, srtt has 3 bits to the right of the binary point,137* and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the138* binary point, and is smoothed with an ALPHA of 0.75.139*/140#define TCP_RTT_SCALE 8 /* multiplier for srtt; 3 bits frac. */141#define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */142#define TCP_RTTVAR_SCALE 4 /* multiplier for rttvar; 2 bits */143#define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */144145/*146* The initial retransmission should happen at rtt + 4 * rttvar.147* Because of the way we do the smoothing, srtt and rttvar148* will each average +1/2 tick of bias. When we compute149* the retransmit timer, we want 1/2 tick of rounding and150* 1 extra tick because of +-1/2 tick uncertainty in the151* firing of the timer. The bias will give us exactly the152* 1.5 tick we need. But, because the bias is153* statistical, we have to test that we don't drop below154* the minimum feasible timer (which is 2 ticks).155* This macro assumes that the value of TCP_RTTVAR_SCALE156* is the same as the multiplier for rttvar.157*/158#define TCP_REXMTVAL(tp) (((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar)159160#endif161162163