Pages

Monday, April 2, 2012

Measure network traffic in Solaris

Today I got stuck with a customer who was complaining that his local network was slow. Or as he said: "It feels slow"... What ever this means.
My task was to measure his network traffic on his Solaris 10 database machine and here is what I did. First I took a look at his network card: 

# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.1.76 netmask ffffffc0 broadcast 192.168.1.127
        ether 0:3:ba:6e:aa:f4

The ce0 interface is his interface that is connected to the network. It has a default MTU of 1500 bytes set. The next thing I did was to keep track of his incoming network packages:

# netstat -I ce0 -i 1
    input   ce0       output       input  (Total)    output
packets errs  packets errs  colls  packets errs  packets errs  colls
574     0     405     0     0      632     0     463     0     0
...
1210    0     224     0     0      1210    0     224     0     0    
1165    0     192     0     0      1165    0     192     0     0
...

The -I option defines the interface to track (the customer has no logical interfaces otherwise I would use the -a option too) and the -i option defines the interval - in this case every second. Just like iostat, vmstat etc you can set an interval and a counter like -i 2 2. The first two lines of the netstat command is the usual header with input, output etc. The first line that appears after the header that starts with 574 represent all packages since system boot. All lines after that shows the current transmitted packages.
The next thing I did was the transfer a 177MB file while running the netstat command. I redirected the output to a file and told the customer not to use any network connection. The output I got was the following (only beginning and end):

...
0       0     0       0     0      0       0     0       0     0    
1       0     0       0     0      1       0     0       0     0    
16      0     32      0     0      16      0     32      0     0    
375     0     64      0     0      375     0     64      0     0    
689     0     96      0     0      689     0     96      0     0
...
1058    0     352     0     0      1058    0     352     0     0
889     0     320     0     0      889     0     320     0     0    
1920    0     640     0     0      1920    0     640     0     0    
222     0     96      0     0      222     0     96      0     0    
0       0     0       0     0      0       0     0       0     0
...

During the time range I received a sum of 130255 packages. With a MTU of 1500 bytes set I have to multiple these two numbers:

# echo 130255*1500 | bc -l
195382500

Dividing the 195382500 bytes by 1024 two time gives me the correct value in MB:

# echo 195382500/1024/1024 | bc -l
186.33127212524414062500

Including the transfer protocol (scp) and my own SSH session this value is close enough to 177MB.
During the copy process I got 124 lines of output (whitout the header etc). With an interval of one second I know that each line represent one second, so the server received 186MB in about 2 minutes. Which is pretty slow for a GB network.

No comments:

Post a Comment