* Automatic sizing of receive socket buffer. Often the send * buffer size is not optimally adjusted to the actual network * conditions at hand (delay bandwidth product). Setting the * buffer size too small limits throughput on links with high * bandwidth and high delay (eg. trans-continental/oceanic links). * * On the receive side the socket buffer memory is only rarely * used to any sign
| 1448 | * the buffer to better manage the socket buffer resources. |
| 1449 | */ |
| 1450 | int |
| 1451 | tcp_autorcvbuf(struct mbuf *m, struct tcphdr *th, struct socket *so, |
| 1452 | struct tcpcb *tp, int tlen) |
| 1453 | { |
| 1454 | int newsize = 0; |
| 1455 | |
| 1456 | if (V_tcp_do_autorcvbuf && (so->so_rcv.sb_flags & SB_AUTOSIZE) && |
| 1457 | tp->t_srtt != 0 && tp->rfbuf_ts != 0 && |
| 1458 | TCP_TS_TO_TICKS(tcp_ts_getticks() - tp->rfbuf_ts) > |
| 1459 | ((tp->t_srtt >> TCP_RTT_SHIFT)/2)) { |
| 1460 | if (tp->rfbuf_cnt > ((so->so_rcv.sb_hiwat / 2)/ 4 * 3) && |
| 1461 | so->so_rcv.sb_hiwat < V_tcp_autorcvbuf_max) { |
| 1462 | newsize = min((so->so_rcv.sb_hiwat + (so->so_rcv.sb_hiwat/2)), V_tcp_autorcvbuf_max); |
| 1463 | } |
| 1464 | TCP_PROBE6(receive__autoresize, NULL, tp, m, tp, th, newsize); |
| 1465 | |
| 1466 | /* Start over with next RTT. */ |
| 1467 | tp->rfbuf_ts = 0; |
| 1468 | tp->rfbuf_cnt = 0; |
| 1469 | } else { |
| 1470 | tp->rfbuf_cnt += tlen; /* add up */ |
| 1471 | } |
| 1472 | return (newsize); |
| 1473 | } |
| 1474 | |
| 1475 | void |
| 1476 | tcp_handle_wakeup(struct tcpcb *tp, struct socket *so) |
no test coverage detected