# Calculate bandwidth using SNMP index

Jan 19th, 2009

Hi

Can you tell me how to calculate bandwidth using snmp index ifInoctets and ifOutOctets.

I can see the output of this indexes using snmpwalk command at different time interval.

But how do I derive the utilization when it reaches 80%.

Archana.

Overall Rating: 0 (0 ratings)

## Replies

Giuseppe Larosa Tue, 01/20/2009 - 01:50
• Super Silver, 17500 points or more
• Hall of Fame,

Founding Member

Hello Archana,

to measure link usage you need to perform the difference between two readings divided for the time interval between the readings and by 8 (bits/byte)

so now you now the speed and you need to compare to link speed to see when it reaches 80%.

Be aware that being these 32bits counters on high speed links they can wrap:

when the counter reaches 2^32-1 next read will be a lower number then the previous.

There are different ways to deal with this.

One is to use if available the HC versions of counters (64 bits counters)

Another is to read other mibs that track if wrapping has happened

Hope to help

Giuseppe

marchanamendon Thu, 01/29/2009 - 23:11

Hello

Since this parameters are new for me and trying to find the formula,it would be great if you can tell me how do I know what is the bandwidth usage and formula to calculate.

I have collected the MIB value for serial interface of router for 1 min time interval.

At 12.25

IF-MIB::ifInOctets.7 = Counter32: 1427402450

IF-MIB::ifOutOctets.7 = Counter32: 4040163899

At 12.26

IF-MIB::ifInOctets.7 = Counter32: 1427697887

IF-MIB::ifOutOctets.7 = Counter32: 4041427307

ifspeed value for serial interface is this.

IF-MIB::ifSpeed.6 = Gauge32: 1544000

With these value how can I derive the percentage of bandwidth usage for the time period of 1 min.

It would great if you can work it out and explain me.

Thanks,

Archana.

Giuseppe Larosa Fri, 01/30/2009 - 03:31
• Super Silver, 17500 points or more
• Hall of Fame,

Founding Member

Hello Archana,

providing an example is a good idea.

time= 60 seconds

Diff. Inoctets = 1427697887 - 1427402450 = 295437 octets received in 60 seconds

1 octet = 8 bits

average bit rate = Diff.InOcoctets*8/60 =

39391,6 bps

so the usage is :

39391,6 / 1544000 = 2,55 % usage of BW inbound direction

you can perform a similar calculation for outbound direction

Hope to help

Giuseppe

marchanamendon Fri, 01/30/2009 - 03:48

Hello Giuseppe,

Its really helpful with the way you have explained.

But I have one more doubt,the 2.55% which gives the utilization for an inbound direction.

How do I calculate the total bandwidth utilization for the link?

Thanks,

Archana.

Giuseppe Larosa Fri, 01/30/2009 - 04:58
• Super Silver, 17500 points or more
• Hall of Fame,

Founding Member

Hello Archana,

from a technical point of view I would keep separated the two directions because it is really normal that usage in the two directions can be quite different.

However, if you want to associate a usage percentage to both direction you can use:

overall_usage= (usage_inbound+usage_outbound)/2

Hope to help

Giuseppe