Chinaunix首页 | 论坛 | 博客
  • 博客访问: 314370
  • 博文数量: 28
  • 博客积分: 2156
  • 博客等级: 大尉
  • 技术积分: 232
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-02 15:31
文章分类

全部博文(28)

文章存档

2011年(7)

2010年(21)

分类: LINUX

2011-06-22 11:04:59

在Linux机器上交叉编译netperf,使其可以运行在基于PowerPC架构的CPU处理器上。


1、下载
       从ftp://ftp.netperf.org/netperf/ 下载

        

2、解压
          tar zxvf netperf-2.4.5.tar.gz

3、编译 cd netperf-2.4.5
   3.1  ./configure --host=powerpc-linux-gnu
         只不过在笔者的编译环境下,有个检查通不过,我就把它注释掉了。我的netperf版本是2.4.5。
7149 echo "$as_me: error: cannot check setpgrp when cross compiling" >&2;}
7150 #   { (exit 1); exit 1; };
7151     }
   3.2  make
   3.3  cd src/
   3.4  file netperf netserver
        

netperf: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for GNU/Linux 2.6.10, dynamically linked (uses shared libs), for GNU/Linux 2.6.10, not stripped
netserver: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for GNU/Linux 2.6.10, dynamically linked (uses shared libs), for GNU/Linux 2.6.10, not stripped

   
4、使用

Netperf是一种网络性能的测量工具,主要针对基于TCP或UDP的传输。Netperf根据应用的不同,可以进行不同模式的网络性能测试,即批量数据传输(bulk data transfer)模式和请求/应答(request/reponse)模式。Netperf测试结果所反映的是一个系统能够以多快的速度向另外一个系统发送数据,以及另外一个系统能够以多块的速度接收数据。

Netperf工具以client/server方式工作。server端是netserver,用来侦听来自client端的连接,client端是netperf,用来向server发起网络测试。在client与server之间,首先建立一个控制连接,传递有关测试配置的信息,以及测试的结果;在控制连接建立并传递了测试配置信息以后,client与server之间会再建立一个测试连接,用来来回传递着特殊的流量模式,以测试网络的性能。

当netserver在server端启动以后,就可以在client端运行netperf来测试网络的性能。netperf通过命令行参数来控制测试的类型和具体的测试选项。

Usage: netperf [global options] -- [test options] 

=========================================

Global options:

    -a send,recv      Set the local send,recv buffer alignment

    -A send,recv      Set the remote send,recv buffer alignment

    -B brandstr       Specify a string to be emitted with brief output

    -c [cpu_rate]     Report local CPU usage

    -C [cpu_rate]     Report remote CPU usage

    -d                Increase debugging output

    -D [secs,units] * Display interim results at least every secs seconds

                      using units as the initial guess for units per second

    -f G|M|K|g|m|k    Set the output units

    -F fill_file      Pre-fill buffers with data from fill_file

    -h                Display this text

    -H name|ip,fam *  Specify the target machine and/or local ip and family

    -i max,min        Specify the max and min number of iterations (15,1)

    -I lvl[,intvl]    Specify confidence level (95 or 99) (99) 

                      and confidence interval in percentage (10)

    -l testlen        Specify test duration (>0 secs) (<0 bytes|trans)

    -L name|ip,fam *  Specify the local ip|name and address family

    -o send,recv      Set the local send,recv buffer offsets

    -O send,recv      Set the remote send,recv buffer offset

    -n numcpu         Set the number of processors for CPU util

    -N                Establish no control connection, do 'send' side only

    -p port,lport*    Specify netserver port number and/or local port

    -P 0|1            Don't/Do display test headers

    -r                Allow confidence to be hit on result only

    -t testname       Specify test to perform

    -T lcpu,rcpu      Request netperf/netserver be bound to local/remote cpu

    -v verbosity      Specify the verbosity level

    -W send,recv      Set the number of send,recv buffers

    -v level          Set the verbosity level (default 1, min 0)

    -V                Display the netperf version and exit

=======================================================

Client[192.168.1.2]: 

         #./netperf.sh 192.168.1.1 17171

           netperf -p $2 -cC -H $1 -t TCP_STREAM -- -m 65535 -s 16384 -S 16384

  1. netperf 是命令
  2. -p 指定端口号, 要与netserver使用的端口号一致
  3. $2, 因为这行命令来自脚本, 所有这个代表脚本运行时的第二个参数,此处代表端口号17171
  4. -cC, 报告CPU的使用情况, -c代表的本地CPU;-C代表远端的CPU
  5. -H,  指的是服务器IP地址192.168.1.1
  6. -t, 指定进行的测试类型,包括TCP_STREAM,UDP_STREAM,TCP_RR,TCP_CRR,UDP_RR
  7. -m,设置本地系统发送测试分组的大小
  8. -M, 设置远端系统接收测试分组的大小
  9. -s, 设置本地系统的socket发送与接收缓冲大小
  10. -S, 设置远端系统的socket发送与接收缓冲大小
-----------------------------------------------------------------------------------------------------------------------

Server[“192.168.1.1]:

       #./netserver -p 17171

-----------------------------------------------------------------------------------------------------------------------


5、测试输出结果

-----------------------------------------------------------------

TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.1.10 (192.168.1.10) port 0 AF_INET

Recv   Send    Send                          Utilization       Service Demand

Socket Socket  Message  Elapsed              Send     Recv     Send    Recv

Size   Size    Size     Time     Throughput  local    remote   local   remote

bytes  bytes   bytes    secs.    10^6bits/s  % S      % S      us/KB   us/KB

32768  32768  65535    10.00       478.43   13.44    35.03    18.409  11.996 

-------------------------------------------------------------------

6、总结

 在使用netperf进行网络性能测试的时候,对CPU的利用率影响不大,也就在10%~20%之间,其提供的多种选项可以方便的对各种要求进行测试,在实际使用的时候可以采用多次测试取平均值的方式。


阅读(4237) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~