Thursday, April 26, 2012

Packets per second crossing an interface?


The following is a method you can use to determine the number of packets per second crossing an interface. The example interface used is eth-s1p1:
nokia[admin]# netstat –i | grep eth-s1p1; sleep 10; netstat –i | grep eth-s1p1


Name        Mtu   Network    Address            Ipkts Ierrs    Opkts Oerrs  Coll

eth-s1p1     9600      0:a0:8e:70:fd:48 3254126830     0 1488520554 

eth-s1p1     9600      0:a0:8e:70:fd:48 3254399730     0 1488822824
 What the preceding command does is output two lines: the number of packets the interface has seen when the command is first executed, and the number of packets seen 10 seconds later. Given that information, we can deduce the number of packets per second, both coming into and going out of the box.

As you see there are 2 columns for each interface after the MAC address.  The first column input packets, the second is out packets.  To figure out total:

  ((3254399730–3254126830)/10)+((1488822824–1488520554)/10) = 57517 packets


Here is how you find packets per second and bytes per second
nokia[admin]# netstat -ib | grep eth-s1p1; sleep 10; netstat -ib | grep eth-s1p1

Name        Mtu   Network    Address            Ipkts Ierrs     Ibytes    Opkts Oerrs     Obytes  Coll

eth-s1p1     9600      0:a0:8e:70:fd:48 3286824714     0 3134996150 1524566033     0  703331799     0

eth-s1p1     9600      0:a0:8e:70:fd:48 3287099394     0 3335905031 1524872800    0  867944108     0


Packets per second – to find total add both Ipkts and Opkts

((3287099394-3286824714)/10)+((1524872800-1524566033)/10)= 58144

Bytes per second - to find total add both Ibytes and Obytes

((3335905031-3134996150)/10)+((867944108-703331799)/10)=
 36552118 bytes

To get your average packet size divide bytes by packets

No comments:

Post a Comment