Unix How-To: Checking on Collisions

By  

One metric that helps gauge how well your network is holding up to the strain of busy users and applications is the number of packets that slam into other packets, generating what is called a "collision". Let's check out an easy tool for calculating the collision rate for a particular network interface.

To begin this journey into network traffic analysis, we're going to take a look at the output of the netstat -i command that displays stats for the interfaces used for IP traffic. I've straightened up the output below (lined up the columns) to make it make it more readable, but this is the kind of data you would expect to see:

boson$ netstat -i
Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue
lo0 8232 loopback localhost 250528 0 250528 0 0 0
dmfe0 1500 spants spants 136556959 6 173865370 1723663 27690 0
dmfe1 1500 default 0.0.0.0 0 0 0 0 0 0

This is a Sun system with two network interfaces, only of which is un use (dnfe0) and, of course, the loopback (lo0).

The number of collisions tells us how many packets (ethernet frames) ended up colliding (being put on the network medium at the same time as) other packets, the result being that each of them would have to be recalled and resent by their respective network interfaces shortly afterwards. A high collision rate would indicate that the network is very busy, possibly overloaded. The more collisions you have, the more packets have to be resent, the more traffic you have and so on.

You can try using the expr command to calculate the percent of collisions, but you aren't likely to get an answer that's worth much:

boson$ expr 27690 / 173865370
0

You can append a bunch of zeroes to your collision count, but you'll have to then figure out where to put the decimal point when you're done. The answer below represents .015% (one and a half times 1/100th of 1%). In other words, very small.

$ expr 2769000000 / 173865370
15

You can also use grep to grab the two data fields, awk to run the calculation

boson$ netstat -i | grep ^dmfe0 | awk '{print $9 / $7 }'
0.000159242

If you want to turn your commands into a script, you can do something like this to determine which of your network interfaces are operational.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

IT ManagementWhite Papers & Webcasts

Webcast On Demand

Data Breaches - Don't Be a Headline

Sponsor: Absolute Software Corporation

White Paper

PCI 3.0 Compliance

See more White Papers | Webcasts

Answers - Powered by ITworld

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question
randomness