[net.bugs.4bsd] TCP congestion fix

jbn@wdl1.UUCP (11/21/85)

Index:	ucb/netinet/tcp_output.c 4.2BSD

Symptom:
	Very poor TELNET performance over non-local networks; broken
	network connections, gateway congestion, high dropped packet
	rates in gateways, etc.

Description:
	TCP sends too many tiny packets over long-haul links, congesting
	networks, links, gateways, etc.

	Sites with a connection to the ARPANET or CSNET, Ethernet
	bridges, gateways, packet forwarders, DMC or DMR links, X.25 links,
	or any non-trivial network architecture need this fix.
	Any TELNET use of a low-speed net (<56Kb) by a 4.2 system without 
	this fix will clog the net to the point of unusability.

	Sites with nothing but a local area net not connected to any other
	net do not need this fix, although it is harmless in such situations.

	There is a better solution in 4.3BSD but it is more complex.

	There is a related fix to the TCP retransmission timer which
	should also be installed in tcp_output.c but is not a mandatory 
	prerequisite for this fix.  See Mt. Xinu buglist.

					J. Nagle

Cause:
	Poor TCP send policy in tcp_output.c.
Fix:
	(Line numbers reference Mt. Xinu's 4.2BSD)


*** tcp_output.c ***
76,77c76,77
< 	 * Sender silly window avoidance.  If can send all data,
< 	 * a maximum segment, at least 1/4 of window do it,
---
> 	 * Sender silly window and congestion avoidance.
> 	 * If a maximum segment, no outstanding data,
78a79,81
> 	 * This is a simplified version of the technique described in
> 	 * ACM Computer Communications Review, October 1984, p. 11.
> 	 *						J. Nagle
81c84
< 		if (len == tp->t_maxseg || off+len >= so->so_snd.sb_cc)
---
> 		if (len == tp->t_maxseg)		/* if max size seg */
83c86
< 		if (len * 4 >= tp->snd_wnd)		/* a lot */
---
> 		if (tp->snd_nxt == tp->snd_una)		/* if no outstanding */
99,100c102
< 	 * next expected input.)  If this is 35% or more of the
< 	 * maximum possible window, then want to send a segment to peer.
---
> 	 * next expected input.)  
103,105d104
< 	if (win > 0 &&
< 	    ((100*(win-(tp->rcv_adv-tp->rcv_nxt))/so->so_rcv.sb_hiwat) >= 35))
< 		goto send;