MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tcp_autorcvbuf

Function tcp_autorcvbuf

freebsd/netinet/tcp_input.c:1450–1473  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

1448 * the buffer to better manage the socket buffer resources.
1449 */
1450int
1451tcp_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
1475void
1476tcp_handle_wakeup(struct tcpcb *tp, struct socket *so)

Callers 3

tcp_do_segmentFunction · 0.85
rack_do_fastnewdataFunction · 0.85
bbr_do_fastnewdataFunction · 0.85

Calls 2

minFunction · 0.85
tcp_ts_getticksFunction · 0.70

Tested by

no test coverage detected