Page MenuHomeFreeBSD

Make use of stats(3) in the TCP stack
Needs ReviewPublic

Authored by trasz on Jun 15 2019, 2:48 PM.

Details

Reviewers
thj
hiren
Group Reviewers
manpages
transport
Summary

Make use of stats(3) in the TCP stack. This makes it possible to retrieve
per-connection statistical information such as receive window, RTT, or goodput,
using a newly added TCP_STATS getsockopt(3) option, and extract it using
stats_voistat_fetch(3) API. See the net/tcprtt port for an example consumer
of this API.

Compared to the existing TCP_INFO, the main differences are that this
mechanism is easy to extend without breaking ABI, and it provides statistical
information instead of raw "snapshots" of values at a given point of time.

This depends on https://reviews.freebsd.org/D20477, https://reviews.freebsd.org/D20116, and https://reviews.freebsd.org/D20324. Example tool using it is here: https://reviews.freebsd.org/D20656.

Sponsored By: Klara Inc, Netflix
Obtained from: Netflix

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 24870
Build 23611: arc lint + arc unit

Event Timeline

trasz created this revision.Jun 15 2019, 2:48 PM
trasz retitled this revision from Make use of stats(3) in the TCP stack. This depends on https://reviews.freebsd.org/D20477, https://reviews.freebsd.org/D20116, and https://reviews.freebsd.org/D20324. to Make use of stats(3) in the TCP stack.Jun 15 2019, 2:50 PM
trasz edited the summary of this revision. (Show Details)
trasz edited the summary of this revision. (Show Details)Jun 15 2019, 3:47 PM
trasz updated this revision to Diff 58673.Jun 15 2019, 3:58 PM

Drop unneeded diff.

allanjude added inline comments.
sys/netinet/tcp_usrreq.c
1533

should the fixup of missing TF_FASTOPEN bits be a separate commit?

thj added a subscriber: thj.Jun 19 2019, 10:18 AM
thj added inline comments.
sys/netinet/tcp.h
335

tcpsyninfo looks to be 16 bytes to me, shouldn't this update to

__tcpi_pad[10]

trasz added inline comments.Fri, Jun 28, 8:52 PM
sys/netinet/tcp.h
335

But __tcpi_pad[] is u_int32_t, not a char?

allanjude added inline comments.Sat, Jun 29, 3:21 PM
sys/netinet/tcp.h
335

indeed, tcpi_pad[] is a u_int32_t (so 4 bytes), so dropping it from 26 to 22 accounts for the 16 bytes. Unless I am missing something.

thj added inline comments.Wed, Jul 3, 8:19 AM
sys/netinet/tcp.h
335

Ah okay, I missed that.

sys/netinet/tcp_input.c
321

Is the goodput measurement time (i.e. number of ms for the measurement window) reported by stats somewhere?

Does the calculation break with an rtt <1ms?

I think a comment here might be helpful for future readers of the code, something along the lines of

report goodput in bits per [time]
trasz edited the summary of this revision. (Show Details)Mon, Jul 15, 4:30 PM
trasz edited the summary of this revision. (Show Details)Mon, Jul 15, 6:43 PM
trasz added inline comments.Wed, Jul 17, 8:06 PM
sys/netinet/tcp_input.c
321

I don't think the raw measurement time is reported - but there's the digest computed for goodput, which I'm guessing is what you'd want the times for?

Regarding rtt < 1ms - well, it's just 'capped from the bottom' with the max(), but I don't know how realistic times below 1ms are, given that the resolution of tcp_ts_getticks() seems to be 1ms?

As for the units - that's a good suggestion; let me do a little experiment to make sure I get this right and I'll add it to the VOI declarations in tcp.h.

trasz edited the summary of this revision. (Show Details)Thu, Jul 18, 9:36 PM