Linux – Reported bandwidth usage differs between iproute2 and ifconfig

bandwidthifconfigiproute2linuxmonitoring

My group has a server set up to image our workstations using FOG. I was a bit curious to see how much bandwidth we were using. When I run ifconfig eth0, the TX/RX lines read

RX packets:166949376 errors:0 dropped:0 overruns:0 frame:0
TX packets:350126730 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000 
RX bytes:31757576798 (29.5 GiB)  TX bytes:458006556301 (426.5 GiB)

But when I run ip -s link show eth0, the equivalent output is

RX: bytes  packets  errors  dropped overrun mcast   
1693647583 166958818 0       0       0       18979  
TX: bytes  packets  errors  dropped carrier collsns 
2741139294 350136238 0       0       0       0      

Which corresponds to a TX/RX of about 1.8/2.6 GiB. What is causing the discrepancy between the values reported by iproute2 and ifconfig? Is there some sort of integer overflow for iproute2?

Thanks!

Best Answer

I was able to find some iproute2 documentation which shed some light on the issue.

Thanks to Jonathan Ross's answer, I learned that ifconfig pulls its data from /proc/net/dev. In the iproute2 docs, it appears that the bandwidth counter in iproute2 "wraps when the maximal length of the natural data type on the architecture is exceeded".

It's evident that iproute2 uses a 32-bit integer to store this info, as this is a 64-bit system. The bandwidth counter would then wrap at 4 GiB.