X

News, tips, partners, and perspectives for the Oracle Solaris operating system

Netperf

Guest Author

Netperf is a cool little utility that I discovered while working with Network Virtualization. It's technically a network benchmarking tool, but it's fun to use to hammer your network with load and test out the bandwidth control features provided by network virtualization.

Netperf used to be available in the now decommissioned contrib repository. That's OK, it's easy enough to build.

Building Netperf for Solaris

If you want to save yourself the steps below, just save the following binaries to your /usr/bin directory: netperf and netserver. Here are the instructions from the Netperf manual.

  1. Download Netperf.  At the time of this writing the latest stable build is netperf-2.4.5.

  2. Extract the archive:
    bleonard@solaris:~/Downloads$ tar -xvf netperf-2.4.5.tar.bz2 
    netperf-2.4.5/
    netperf-2.4.5/src/
    ...
    netperf-2.4.5/doc/examples/udp_stream_script
    netperf-2.4.5/doc/netperf.info
  3. Make sure you have gcc-3 and header-math installed:
    bleonard@solaris:~$ pkg list gcc-3 header-math
    NAME (PUBLISHER) VERSION STATE UFOXI
    developer/gcc-3 3.4.3-0.151.0.1 installed -----
    system/library/math/header-math 0.5.11-0.151.0.1 installed -----
  4. Run configure, overriding the default install directory of /usr/local to /usr:
    bleonard@solaris:~/Downloads/netperf-2.4.5$ ./configure --prefix=/usr
    checking build system type... i386-pc-solaris2.11
    ...
    config.status: executing depfiles commands

  5. Run make:
    bleonard@solaris:~/Downloads/netperf-2.4.5$ make
    make all-recursive
    make[1]: Entering directory `/home/bleonard/Downloads/netperf-2.4.5'
    ..
    make[1]: Leaving directory `/home/bleonard/Downloads/netperf-2.4.5'
  6. The run make install:
    bleonard@solaris:~/Downloads/netperf-2.4.5$ sudo make install
    Password:
    Making install in src
    make[1]: Entering directory `/home/bleonard/Downloads/netperf-2.4.5/src'
    ...
    make[1]: Leaving directory `/home/bleonard/Downloads/netperf-2.4.5'
  7. Verify the binaries were made:
    bleonard@solaris:~$ which netperf netserver
    /usr/bin/netperf
    /usr/bin/netserver

Using Netperf

To verify the installation, first start the benchmark server:

bleonard@solaris:~$ netserver
Starting netserver at port 12865
Starting netserver at hostname 0.0.0.0 port 12865 and family AF_UNSPEC

Then run netperf over the loopback interface, which will run a TCP_STREAM test of 10 seconds:

bleonard@solaris:~$ netperf -H 127.0.0.1
TCP STREAM TEST from ::ffff:0.0.0.0 (0.0.0.0) port 0 AF_INET to ::ffff:127.0.0.1 (127.0.0.1) port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
128000 49152 49152 9.99 19036.97

Now that we know Netperf is set up correctly, we can use it to test bulk data transfer performance between 2 hosts (or 2 zones). TCP stream performance is the default test type and it's simply performed by running the command:

netperf -H <remotehost>

which will run a 10 second test between the local and remote system.

So I'm going to use Netperf to run some tests between the global zone and a local zone, which has been set up to use a virtual NIC exclusively. To create such a configuration on your own, see the blog entry Zones and Network Virtualization.

The local zone, myzone, is currently up and running:

bleonard@solaris:~$ zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- myzone running /zones/myzone ipkg excl

The first thing I'm going to do is copy the netserver program over to the local zone:

bleonard@solaris:~$ sudo cp /usr/bin/netserver /zones/myzone/root/usr/bin/.

And then start the netserver:

bleonard@solaris:~$ sudo zlogin myzone /usr/bin/netserver
Password:
Starting netserver at port 12865
Starting netserver at hostname 0.0.0.0 port 12865 and family AF_UNSPEC

Now let's test the connection between the global and local zone:

bleonard@solaris:~$ netperf -H 10.0.1.25
TCP STREAM TEST from ::ffff:0.0.0.0 (0.0.0.0) port 0 AF_INET to ::ffff:10.0.1.25 (10.0.1.25) port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
128000 49152 49152 10.00 1722.31

Here we can see the throughput between my zones is 1722 Mbit/s. Now let's reduce the max bandwidth of the virtual NIC to 500 Mbit/s and try the test again:

bleonard@solaris:~$ sudo dladm set-linkprop -p maxbw=500 myzone0
bleonard@solaris:~$ dladm show-vnic
LINK OVER SPEED MACADDRESS MACADDRTYPE VID
myzone0 e1000g0 500 2:8:20:59:0:b5 random 0
bleonard@solaris:~$ netperf -H 10.0.1.25
TCP STREAM TEST from ::ffff:0.0.0.0 (0.0.0.0) port 0 AF_INET to ::ffff:10.0.1.25 (10.0.1.25) port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
128000 49152 49152 10.00 482.77

Or at a ridiculously low 2 Mbit/s:

bleonard@solaris:~$ sudo dladm set-linkprop -p maxbw=2 myzone0
bleonard@solaris:~$ netperf -H 10.0.1.25
TCP STREAM TEST from ::ffff:0.0.0.0 (0.0.0.0) port 0 AF_INET to ::ffff:10.0.1.25 (10.0.1.25) port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
128000 49152 49152 10.38 1.07

Good stuff.

I've just scratched the surface of Netperf, but this simple introduction suits my purposes for testing network virtualization. For more fun check out the Netperf manual.

Join the discussion

Comments ( 13 )
  • Pablo Wednesday, October 7, 2009

    What about uperf, from Solaris.

    How they compare and why Netperf is better for this job?

    Tahnks

    - Pablo


  • Neelakanth Nadgir Thursday, October 8, 2009

    Uperf allows you to model more realistic network loads as well as benchmarks. There are prebuilt XML profiles for what netperf does. You can do multiple protocols, multiple hosts etc.


  • Robert Milkowski Thursday, October 8, 2009

    Netperf is also available in Open Solaris /contrib repository.


  • Brian Leonard Wednesday, October 21, 2009

    Hi Rick, good to hear from you. I'll tell you the version numbers if you can tell me how to find it. I didn't see a -version option to either the netperf or netserver commands.


  • rick jones Wednesday, October 21, 2009

    Kids today, forgetting the Tao of Unix :) Netperf and netserver have what strings embedded in them, so "what netperf" and "what netserver"

    Having said that, starting with 2.4.something, there is also a -V option for emitting a version string.


  • Brian Leonard Wednesday, October 21, 2009

    Hey, I grow up a bit every day :-). It looks like the version at Blastwave is 2.3. The version at Contrib is 2.4.4. I'll update the entry to refer folks to Contrib over Blastwave. It's a much nicer install experience anyhow.


  • rick jones Monday, January 4, 2010

    There is a bit about the getaddrinfo message emitted by netperf in the netperf-talk archives. As there was finally a bug opened against (Open)Solaris on the issue, I was talked into commenting-out the message in the latest version of netperf. Now, if the bug languishes I may have to re-instate the message :)


  • guest Sunday, December 11, 2011

    Hi,

    is there anyway i could modify netperf to support ssl protocol using openssl?


  • W Brian Leonard Monday, December 12, 2011

    Try uperf :-).


  • rick jones Monday, December 12, 2011

    The most straightforward way would be to write a few tests in something like nettest_ssl.c, following the model of say send_tcp_stream()/recv_tcp_stream() of nettest_bsd.c. You would need to make some mods to netsh.c, netperf.c and netserver.c I suspect.


  • rick jones Wednesday, January 25, 2012

    I received some notifications suggesting someone was posting replies here asking about Solaris 11 compilation of netperf. I don't see them here at the moment, but perhaps the best place to ask questions about netperf would be netperf-talk@netperf.org.


  • tweene Wednesday, August 15, 2012

    i've already install netperf on my server machine,

    bit when i run netserver, it said :

    "Unable to start netserver with 'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC"

    how can i fix my problem?


  • guest Friday, March 13, 2015

    How we can consider jitter in uperf ??? how can we set delay jitter in xml profile.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.