Take the 2-minute tour ×

I would like to validate a certain thought with you guys. Assuming that:

  1. The device whose bandwidth I am measuring is an internal, Linux-based, router.
  2. If a NIC is configured to 100mbps, the network is at least 100mbps (that is, the NIC's speed setting it what is limiting the bandwidth, not the network, its latency, etc.)
  3. Elements such as CPU have no impact on bandwidth.

Would it be correct to:

  1. Run ifconfig every 10 seconds
  2. Calculate the bytes TX+RX per second based on the ifconfig's results
  3. Multiply the bytes number by 8 (let's say this is X)
  4. Get the NIC speed settings (10mbps, 100mbps, 1000mbps, this is Y)
  5. Calculate the bandwidth percent usage as: X / (Y*1024*1024)

Is this correct? How does duplicity impact this calculation?

share|improve this question

1 Answer 1

Theoretically this is correct. However, using ifconfig to retrieve the relevant figures is a very roundabout way to achieve this. You'd be much better off using SNMP. All interfaces have entries in the standard SNMP MIBs, which describe them and also their current connection speed, plus all sorts of relevant counters.

SNMP is available through standard packages in all linux distros I know off, and you can either use tools such as snmpwalk or snmpget (if you just want to retrieve the data) or MRTG or cacti (if you want to graph the data). Especially cacti will allow to apply formulae (formulas?) to your data, and it should be easy to get a percentage graph out of that.

share|improve this answer
Thank you for your response. Actually, I was more focusing on the calculation than the method of obtaining the data. How does duplicity impact the calculation? –  Yon Jun 16 '11 at 7:41

Your Answer


