Re: git: b5a8abe9502e - main - How to show interface traffic in bits per second

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Tue, 03 Dec 2024 16:09:17 UTC
--------
John Baldwin writes:

> > +When netstat reports every 8 seconds, it tells traffic in bits per second:
> > +
> > +$ netstat -I bge0 8
> > +%
>
> Hmm, I'm pretty sure it's in bytes, and checking the code, it seems like show_stat()
> in netstat/if.c just shows the raw delta in values without scaling it by 'interval',
> so I think the counts are the number of bytes sent/received in 8 seconds:

And since

	bytes/8 seconds == bits/second

Q.E.D

> I do think having a tip about 'netstat -I foo <N>' is useful btw.  I'm not sure if
> you are trying to do [...]

I have personally used this trick for 35+ years from V.22bis modems
til 10Gbit/s ethernet, to figure out how saturated a particular
transmission facility is.

Transmission media are always in nominal bits per second, and counters
are almost invariably in bytes, so using 8 second integration eliminates
the need for math.

The 8 second integration time also averages most of the burstiness of the
traffic quite nicely.

As the author of the bikeshed email, I should have known better
than to commit something this trivial :-)

Poul-Henning

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.