tcp_input.c - keep track of how many times a route contained a cached rtt

or ssthresh that we were able to use

tcp_var.h - declare tcpstat entries for above; declare tcp_{send,recv}space

in_rmx.c - fill in the MTU and pipe sizes with the defaults TCP would have
	used anyway in the absence of values here
This commit is contained in:
Garrett Wollman 1995-07-10 15:39:16 +00:00
parent 8e718bb4af
commit dd22498271
4 changed files with 61 additions and 17 deletions

View File

@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: in_rmx.c,v 1.13 1995/05/30 08:09:31 rgrimes Exp $
* $Id: in_rmx.c,v 1.14 1995/06/21 19:48:53 wollman Exp $
*/
/*
@ -57,6 +57,15 @@
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/tcp_seq.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/tcpip.h>
#define RTPRF_OURS RTF_PROTO3 /* set on routes we manage */
/*
@ -67,17 +76,45 @@ in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
struct radix_node *treenodes)
{
struct rtentry *rt = (struct rtentry *)treenodes;
struct sockaddr_in *sin = (struct sockaddr_in *)rt_key(rt);
/*
* For IP, all unicast non-host routes are automatically cloning.
*/
if(!(rt->rt_flags & (RTF_HOST | RTF_CLONING))) {
struct sockaddr_in *sin = (struct sockaddr_in *)rt_key(rt);
if(!IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) {
rt->rt_flags |= RTF_PRCLONING;
}
}
/*
* We also specify a send and receive pipe size for every
* route added, to help TCP a bit. TCP doesn't actually
* want a true pipe size, which would be prohibitive in memory
* costs and is hard to compute anyway; it simply uses these
* values to size its buffers. So, we fill them in with the
* same values that TCP would have used anyway, and allow the
* installing program or the link layer to override these values
* as it sees fit. This will hopefully allow TCP more
* opportunities to save its ssthresh value.
*/
if (!rt->rt_rmx.rmx_sendpipe && !(rt->rt_rmx.rmx_locks & RTV_SPIPE))
rt->rt_rmx.rmx_sendpipe = tcp_sendspace;
if (!rt->rt_rmx.rmx_recvpipe && !(rt->rt_rmx.rmx_locks & RTV_RPIPE))
rt->rt_rmx.rmx_recvpipe = tcp_recvspace;
/*
* Finally, set an MTU, again duplicating logic in TCP.
* The in_localaddr() business will go away when we have
* proper PMTU discovery.
*/
if (!rt->rt_rmx.rmx_mtu && !(rt->rt_rmx.rmx_locks & RTV_MTU)
&& rt->rt_ifp)
rt->rt_rmx.rmx_mtu = (in_localaddr(sin->sin_addr)
? rt->rt_ifp->if_mtu
: tcp_mssdflt + sizeof(struct tcpiphdr));
return rn_addroute(v_arg, n_arg, head, treenodes);
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* From: @(#)tcp_input.c 8.5 (Berkeley) 4/10/94
* $Id: tcp_input.c,v 1.25 1995/05/30 08:09:55 rgrimes Exp $
* $Id: tcp_input.c,v 1.26 1995/06/29 18:11:22 wollman Exp $
*/
#ifndef TUBA_INCLUDE
@ -1950,7 +1950,6 @@ tcp_mss(tp, offer)
offer = max(offer, 64);
taop->tao_mssopt = offer;
#ifdef RTV_MTU /* if route characteristics exist ... */
/*
* While we're here, check if there's an initial rtt
* or rttvar. Convert from the route-table units
@ -1964,13 +1963,16 @@ tcp_mss(tp, offer)
if (rt->rt_rmx.rmx_locks & RTV_RTT)
tp->t_rttmin = rtt / (RTM_RTTUNIT / PR_SLOWHZ);
tp->t_srtt = rtt / (RTM_RTTUNIT / (PR_SLOWHZ * TCP_RTT_SCALE));
if (rt->rt_rmx.rmx_rttvar)
tcpstat.tcps_usedrtt++;
if (rt->rt_rmx.rmx_rttvar) {
tp->t_rttvar = rt->rt_rmx.rmx_rttvar /
(RTM_RTTUNIT / (PR_SLOWHZ * TCP_RTTVAR_SCALE));
else
tcpstat.tcps_usedrttvar++;
} else {
/* default variation is +- 1 rtt */
tp->t_rttvar =
tp->t_srtt * TCP_RTTVAR_SCALE / TCP_RTT_SCALE;
}
TCPT_RANGESET(tp->t_rxtcur,
((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
tp->t_rttmin, TCPTV_REXMTMAX);
@ -1981,7 +1983,6 @@ tcp_mss(tp, offer)
if (rt->rt_rmx.rmx_mtu)
mss = rt->rt_rmx.rmx_mtu - sizeof(struct tcpiphdr);
else
#endif /* RTV_MTU */
{
mss = ifp->if_mtu - sizeof(struct tcpiphdr);
if (!in_localaddr(inp->inp_faddr))
@ -2054,7 +2055,6 @@ tcp_mss(tp, offer)
if (!in_localaddr(inp->inp_faddr))
tp->snd_cwnd = mss;
#ifdef RTV_SSTHRESH
if (rt->rt_rmx.rmx_ssthresh) {
/*
* There's some sort of gateway or interface
@ -2063,8 +2063,8 @@ tcp_mss(tp, offer)
* threshold to no less than 2*mss.
*/
tp->snd_ssthresh = max(2 * mss, rt->rt_rmx.rmx_ssthresh);
tcpstat.tcps_usedssthresh++;
}
#endif
}
/*

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* From: @(#)tcp_input.c 8.5 (Berkeley) 4/10/94
* $Id: tcp_input.c,v 1.25 1995/05/30 08:09:55 rgrimes Exp $
* $Id: tcp_input.c,v 1.26 1995/06/29 18:11:22 wollman Exp $
*/
#ifndef TUBA_INCLUDE
@ -1950,7 +1950,6 @@ tcp_mss(tp, offer)
offer = max(offer, 64);
taop->tao_mssopt = offer;
#ifdef RTV_MTU /* if route characteristics exist ... */
/*
* While we're here, check if there's an initial rtt
* or rttvar. Convert from the route-table units
@ -1964,13 +1963,16 @@ tcp_mss(tp, offer)
if (rt->rt_rmx.rmx_locks & RTV_RTT)
tp->t_rttmin = rtt / (RTM_RTTUNIT / PR_SLOWHZ);
tp->t_srtt = rtt / (RTM_RTTUNIT / (PR_SLOWHZ * TCP_RTT_SCALE));
if (rt->rt_rmx.rmx_rttvar)
tcpstat.tcps_usedrtt++;
if (rt->rt_rmx.rmx_rttvar) {
tp->t_rttvar = rt->rt_rmx.rmx_rttvar /
(RTM_RTTUNIT / (PR_SLOWHZ * TCP_RTTVAR_SCALE));
else
tcpstat.tcps_usedrttvar++;
} else {
/* default variation is +- 1 rtt */
tp->t_rttvar =
tp->t_srtt * TCP_RTTVAR_SCALE / TCP_RTT_SCALE;
}
TCPT_RANGESET(tp->t_rxtcur,
((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
tp->t_rttmin, TCPTV_REXMTMAX);
@ -1981,7 +1983,6 @@ tcp_mss(tp, offer)
if (rt->rt_rmx.rmx_mtu)
mss = rt->rt_rmx.rmx_mtu - sizeof(struct tcpiphdr);
else
#endif /* RTV_MTU */
{
mss = ifp->if_mtu - sizeof(struct tcpiphdr);
if (!in_localaddr(inp->inp_faddr))
@ -2054,7 +2055,6 @@ tcp_mss(tp, offer)
if (!in_localaddr(inp->inp_faddr))
tp->snd_cwnd = mss;
#ifdef RTV_SSTHRESH
if (rt->rt_rmx.rmx_ssthresh) {
/*
* There's some sort of gateway or interface
@ -2063,8 +2063,8 @@ tcp_mss(tp, offer)
* threshold to no less than 2*mss.
*/
tp->snd_ssthresh = max(2 * mss, rt->rt_rmx.rmx_ssthresh);
tcpstat.tcps_usedssthresh++;
}
#endif
}
/*

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_var.h 8.3 (Berkeley) 4/10/94
* $Id: tcp_var.h,v 1.12 1995/06/19 16:45:33 wollman Exp $
* $Id: tcp_var.h,v 1.13 1995/06/29 18:11:24 wollman Exp $
*/
#ifndef _NETINET_TCP_VAR_H_
@ -282,6 +282,9 @@ struct tcpstat {
u_long tcps_cachedrtt; /* times cached RTT in route updated */
u_long tcps_cachedrttvar; /* times cached rttvar updated */
u_long tcps_cachedssthresh; /* times cached ssthresh updated */
u_long tcps_usedrtt; /* times RTT initialized from route */
u_long tcps_usedrttvar; /* times RTTVAR initialized from rt */
u_long tcps_usedssthresh; /* times ssthresh initialized from rt*/
};
/*
@ -368,6 +371,10 @@ struct tcpcb *
int tcp_usrreq __P((struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *));
void tcp_xmit_timer __P((struct tcpcb *, int));
extern u_long tcp_sendspace;
extern u_long tcp_recvspace;
#endif /* KERNEL */
#endif /* _NETINET_TCP_VAR_H_ */