diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2003-01-25 15:27:30 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2003-01-25 15:27:30 +0000 |
commit | bd3350dedd6b239e3673cff5da580b3077282709 (patch) | |
tree | 281887ce28d5236e2873de06aa0a13afa21ea7f2 | |
parent | 03e177532fb70a13df8f4a91b753d91743939074 (diff) |
don't send more than half of the send buffer space limit in
one tcp segment, improves performance of tcp over interfaces
with large mtu (e.g. lo0); based on similar change in netbsd;
ok djm, henning, henric, millert, deraadt
-rw-r--r-- | sys/netinet/tcp_output.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 5523f172ec8..7ce63727feb 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_output.c,v 1.53 2002/08/28 15:43:03 pefo Exp $ */ +/* $OpenBSD: tcp_output.c,v 1.54 2003/01/25 15:27:29 markus Exp $ */ /* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */ /* @@ -220,7 +220,7 @@ tcp_output(tp) register struct tcpcb *tp; { register struct socket *so = tp->t_inpcb->inp_socket; - register long len, win; + register long len, win, txmaxseg; int off, flags, error; register struct mbuf *m; register struct tcphdr *th; @@ -383,8 +383,17 @@ again: tcp_setpersist(tp); } } - if (len > tp->t_maxseg) { - len = tp->t_maxseg; + + /* + * Never send more than half a buffer full. This insures that we can + * always keep 2 packets on the wire, no matter what SO_SNDBUF is, and + * therefore acks will never be delayed unless we run out of data to + * transmit. + */ + txmaxseg = ulmin(so->so_snd.sb_hiwat / 2, tp->t_maxseg); + + if (len > txmaxseg) { + len = txmaxseg; sendalot = 1; } if (off + len < so->so_snd.sb_cc) @@ -403,7 +412,7 @@ again: * to send into a small window), then must resend. */ if (len) { - if (len == tp->t_maxseg) + if (len == txmaxseg) goto send; if ((idle || tp->t_flags & TF_NODELAY) && len + off >= so->so_snd.sb_cc) |