tailscale/net/sockstats
Will Norris 7c386ca6d2 net/sockstats: fix calculation of radio power usage
When splitting the radio monitor usage array, we were splitting at now %
3600 to get values into chronological order.  This caused the value for
the final second to be included at the beginning of the ordered slice
rather than the end.  If there was activity during that final second, an
extra five seconds of high power usage would get recorded in some cases.
This could result in a final calculation of greater than 100% usage.

This corrects that by splitting values at (now+1 % 3600).

This also simplifies the percentage calculation by always rounding
values down, which is sufficient for our usage.

Signed-off-by: Will Norris <will@tailscale.com>
2023-04-19 13:18:02 -07:00
..
label_string.go sockstats: add labels for netlog and sockstatlog packages 2023-03-29 14:53:07 -07:00
sockstats_noop.go net/sockstats: pass in logger to sockstats.WithSockStats 2023-04-12 18:40:03 -07:00
sockstats_tsgo_darwin.go sockstats: add validation for TCP socket stats 2023-03-08 13:39:30 -08:00
sockstats_tsgo_test.go net/sockstats: fix calculation of radio power usage 2023-04-19 13:18:02 -07:00
sockstats_tsgo.go net/sockstats: fix calculation of radio power usage 2023-04-19 13:18:02 -07:00
sockstats.go net/sockstats: pass in logger to sockstats.WithSockStats 2023-04-12 18:40:03 -07:00