1

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!

Ben Webber
  • 63
  • 1
  • 1
  • 7

2 Answers2

2

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.

Ben Webber
  • 63
  • 1
  • 1
  • 7
1

There are different ways of pulling traffic stats from the system with libraries or from the kernel, one being cat /proc/net/dev. I'd check that file for comparison.

Slightly OT: apparently you can reset ifconfig counters with loadable NIC kernel drivers but not built-in drivers.

Jonathan Ross
  • 2,183
  • 11
  • 14
  • Thanks! Now I know where ``ifconfig`` pulls its data. The ``/proc/net/dev`` file lists the proper bandwidth usage (TX/RX of 29.5/426.5 GiB). I found some ``iproute2`` documentation which answered my question. – Ben Webber Apr 10 '11 at 09:47