由于工作需要,最近在测试ipv6网络设备,发现支持ipv6测试工具还有点少,于是各种折腾。


备注:对于ipv6组网及ipv6网站架设这里就不累赘了,大家可以网上搜索,现已知的IIS6.0及以上支持IPv6,apache 2.0(Linux版)以上支持,nginx支持。windows 2003的DNS不支持ipv6,2008中的dns支持ipv6。



1、前置条件


(1)本地环境要求


本地环境

[root@dr101 curl-loader-0.56]# cat /etc/redhat-release 

CentOS release 6.2 (Final)

[root@dr101 curl-loader-0.56]# 

(2)要求安装SSL相关包,gcc、make等工具


在CentOS下安装直接使用yum工具来安装即可,保证你的机器可以上外网


yum install gcc make openssl


官方说明查看地址:

http://curl-loader.sourceforge.net/doc/fast.html


Build it using general C development environment with bash, gcc compiler (3 or 4 series), make, etc on a linux machine.


Building pre-requirements are:

a. openssl binaries;

b. openssl development package with include files (on debian package libssl-dev);


curl-loader介绍


      curl-loader(也被称为“omes-NIK”和“davilka”)是一个开源的C语言编写的工具,模拟应用负载和成千上万的几十万人的HTTP / HTTPS和FTP/ FTPS的客户端应用程序的行为,每个有其自己的源IP地址。相反,其他curl-loader使用真正的C编写的客户端协议栈,即libcurl和TLS/ openssl的SSL的HTTP和FTP协议栈,支持登录和验证口味和模拟用户行为的工具。 


(3)ipv6地址配置


此处以我测试的系统为例

[root@dr101 curl-loader-0.56]# cat /etc/sysconfig/network-scripts/ifcfg-Auto_eth2

HWADDR=00:0C:29:09:F6:42

TYPE=Ethernet

BOOTPROTO=none

IPADDR=192.168.202.101

PREFIX=24

GATEWAY=192.168.202.1

DNS1=202.102.192.68#如果你有ipv6的DNS,可以将ipv6的DNS也加上,这样后面可以使用域名进行压力测试

DEFROUTE=yes

IPV4_FAILURE_FATAL=yes

IPV6INIT=yes #修改为yes

IPVADDR=fc00:0:0:202::101 #添加ipv6地址,注意IPVADDR不是IPV6ADDR,有点怪异

IPV6_DEFAULTGW=fc00:0:0:202::1#添加默认IPv6网关

NAME="Auto eth2"

UUID=4d4bee9e-f139-4ab0-95e0-57fc7c11cc37

ONBOOT=yes

IPV6_AUTOCONF=no#关闭IPv6自动配置

IPV6ADDR=fc00:0:0:202::101/64#再次设置ipv6地址

IPV6_DEFROUTE=yes#开启ipv6默认路由

IPV6_FAILURE_FATAL=no

GATEWAY=fc00:0:0:202::1#再次设置IPv6网关

[root@dr101 curl-loader-0.56]# ifconfig

eth2      Link encap:Ethernet  HWaddr 00:0C:29:09:F6:42  

          inet addr:192.168.202.101  Bcast:192.168.202.255  Mask:255.255.255.0

          inet6 addr: fc00:0:0:202::101/64 Scope:Global

          inet6 addr: fe80::20c:29ff:fe09:f642/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:5652 errors:0 dropped:0 overruns:0 frame:0

          TX packets:5263 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:604459 (590.2 KiB)  TX bytes:1015130 (991.3 KiB)


lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:76 errors:0 dropped:0 overruns:0 frame:0

          TX packets:76 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:5280 (5.1 KiB)  TX bytes:5280 (5.1 KiB)


[root@dr101 curl-loader-0.56]# 



2、下载地址


官方下载地址:http://sourceforge.net/projects/curl-loader/files/curl-loader/ 


[root@dr101 mysoft]# wget http://ncu.dl.sourceforge.net/project/curl-loader/curl-loader-stable/curl-loader-0.56/curl-loader-0.56.tar.bz2

[root@dr101 mysoft]# tar jvxf curl-loader-0.56.tar.bz2 


3、安装




(1)注意,如要是curl-load支持ipv6必须在安装即make之前修改Makefile文件中的如下内容

修改Makefile

将--disable-ipv6改为--enable-ipv6

[root@dr101 curl-loader-0.56]# vi Makefile

# To enable IPv6 change --disable-ipv6 to --enable-ipv6


$(LIBCURL):

        cd ./packages; tar jxfv curl-$(CURL_VER).tar.bz2; ln -sf curl-$(CURL_VER) curl; \

        patch -d curl -p1 < ../patches/curl-trace-info-error.patch

        mkdir -p $(CURL_BUILD);

        cd $(CURL_BUILD); ../../packages/curl/configure --prefix=$(CURL_BUILD) \

        --without-libidn \

        --without-libssh2 \

        --disable-ldap \

# To enable IPv6 change --disable-ipv6 to --enable-ipv6#这里提示如果要使curl-load支持ipv6需要开启--enable-ipv6


$(LIBCURL):

        cd ./packages; tar jxfv curl-$(CURL_VER).tar.bz2; ln -sf curl-$(CURL_VER) curl; \

        patch -d curl -p1 < ../patches/curl-trace-info-error.patch

        mkdir -p $(CURL_BUILD);

        cd $(CURL_BUILD); ../../packages/curl/configure --prefix=$(CURL_BUILD) \

        --without-libidn \

        --without-libssh2 \

        --disable-ldap \

        --enable-ipv6 \#这里默认是--disable-ipv6,需要修改为--enable-ipv6

        --enable-thread \

        --with-random=/dev/urandom \

        --with-ssl=/usr/include/openssl \

        --enable-shared=no \

        --enable-ares=$(CARES_MAKE_DIR) \


如果不理解,可以看官方文档,即查看解压后文档中的README,并搜索到ipv6:(E文还是要好好学的)

[root@202 curl-loader-0.56]# vi README 


NETMASK - netmask for the loading clients IP-addresses (from IP_ADDR_MIN to

IP_ADDR_MAX). For IPv4 you can use either quad-dotted netmask string or CIDR

number from 0-32. For IPv6 only CIDR values from 0 to 128 are supported.

To enable IPv6 change --disable-ipv6 to --enable-ipv6 in Makefile


(2)make and make install

[root@dr101 curl-loader-0.56]# make

[root@dr101 curl-loader-0.56]# make install

mkdir -p /usr/bin 

mkdir -p /usr/share/man/man1

mkdir -p /usr/share/man/man5

mkdir -p /usr/share/doc/curl-loader/

cp -f curl-loader /usr/bin

cp -f doc/curl-loader.1 /usr/share/man/man1/  

cp -f doc/curl-loader-config.5 /usr/share/man/man5/

cp -f doc/* /usr/share/doc/curl-loader/ 

cp -rf conf-examples /usr/share/doc/curl-loader/


4、使用curl-load进行测试


由于curl-load没用进行configure步骤,即没有指定安装目录,默认就是当前解压目录,比如我这里的/home/mysoft/curl-load-0.56

(1)配置文件存放路径

[root@dr101 conf-examples]# pwd

/home/mysoft/curl-loader-0.56/conf-examples

[root@dr101 conf-examples]# ls

10K.conf                          https.conf

60K.conf                          ipv6.conf

bax.conf                          log-hdr-body.conf

bax-login-logoff-noncycling.conf  login-uas-cycling.conf

bax-logs.conf                     login-uas-logoff-cycling.conf

big-load.conf                     multipart-formdata-post.conf

bulk.conf                         post-form-tokens-fr-file.conf

bulk-dual-url.conf                post-xml.conf

credentials.cred                  put.conf

custom-hdrs.conf                  random_file_records.conf

delete.conf                       rate-limit.conf

fetch-probability.conf            resp-errors.conf

fetch-probability-once.conf       some.xml

ftp.conf                          timers-random-range.conf

ftp-http.conf                     url-randomize.conf

ftp-upload.conf                   url-template-file.txt

get-forms.conf                    url-template-fr-file.conf

get-post-login.conf               url-template-resp-dynamic.conf

get-post-login-cycling.conf

[root@dr101 conf-examples]# 


(2)修改ipv6配置文件


本次主要是使用curl-load进行ipv6 web服务器的测试工作,于是修改ipv6.conf文件

[root@dr101 conf-examples]# vi ipv6.conf 

########### GENERAL SECTION ################################


BATCH_NAME= ipv6

CLIENTS_NUM_MAX = 20 #10000

INTERFACE   =eth2 #需要修改为你进行ipv6通信的接口,不知道了,用ifconfig查看

NETMASK=64

IP_ADDR_MIN=  fc00:0:0:202::111 #2001:db8:fff5:6::101,IP_ADDR_MIN &MAX是用来指定ipv6地址范围的,必须和物理接口的ipv6地址在一个网段,同时没有被其他主机使用

IP_ADDR_MAX= fc00:0:0:202::130 #2001:db8:fff5:6::103 #2001:db8:fff5:ffff::1

IP_SHARED_NUM=20 #上面写了地址范围,但是不是每个地址都会用上的,这里就是指明使用上面ipv6地址范围中多少个地址用来进行测试,curl-load会在本地网卡上绑定一批ipv6的地址

CYCLES_NUM= -1

URLS_NUM     = 1


########### URL SECTION ####################################


URL= http://[fc00:0:0:216::11]/hunlian.htm #http://ip6-localhost/apache2-default/index.html 填写要测试的URL,当然URL也可以是一个文件中的多个url,注意ipv6webURL的写法,如果你使用了域名,可以直接用域名进行测试

REQUEST_TYPE=GET

TIMER_URL_COMPLETION = 0  # In msec. When positive, Now it is enforced by cancelling url fetch on timeout

TIMER_AFTER_URL_SLEEP =300 #默认为1000


(3)进行简单测试


[root@dr101 curl-loader-0.56]# ./curl-loader -f conf-examples/ipv6.conf 

会先绑定一下ipv6地址到eth2上

这下err的错误少了,有了2XX即成功的请求了


============  loading batch is: ipv6       ======================================

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

Interval stats (latest:3 sec, clients:20, CAPS-curr:159):

H/F   Req:480,1xx:0,2xx:480,3xx:0,4xx:0,5xx:0,Err:0,T-Err:0,D:2ms,D-2xx:2ms,Ti:134400B/s,To:21120B/s

H/F/S Req:0,1xx:0,2xx:0,3xx:0,4xx:0,5xx:0,Err:0,T-Err:0,D:0ms,D-2xx:0ms,Ti:0B/s,To:0B/s

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

Summary stats (runs:24 secs, CAPS-average:172):

H/F   Req:3778,1xx:0,2xx:3778,3xx:0,4xx:0,5xx:0,Err:353,T-Err:0,D:1ms,D-2xx:1ms,Ti:132230B/s,To:20779B/s

H/F/S Req:0,1xx:0,2xx:0,3xx:0,4xx:0,5xx:0,Err:0,T-Err:0,D:0ms,D-2xx:0ms,Ti:0B/s,To:0B/s

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

 Manual: clients:max[20],curr[20]. Inc num: [+|*].

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


ctrl+c来结束测试



此时再开窗口,可以看到接口上绑定了很多ipv6的地址


[root@dr101 ~]# ifconfig

eth2      Link encap:Ethernet  HWaddr 00:0C:29:09:F6:42  

          inet addr:192.168.202.101  Bcast:192.168.202.255  Mask:255.255.255.0

          inet6 addr: fc00:0:0:202::123/64 Scope:Global

          inet6 addr: fc00:0:0:202::101/64 Scope:Global

          inet6 addr: fc00:0:0:202::122/64 Scope:Global

          inet6 addr: fc00:0:0:202::111/64 Scope:Global

          inet6 addr: fc00:0:0:202::121/64 Scope:Global

          inet6 addr: fc00:0:0:202::112/64 Scope:Global

          inet6 addr: fe80::20c:29ff:fe09:f642/64 Scope:Link

          inet6 addr: fc00:0:0:202::120/64 Scope:Global

          inet6 addr: fc00:0:0:202::113/64 Scope:Global

          inet6 addr: fc00:0:0:202::114/64 Scope:Global

          inet6 addr: fc00:0:0:202::115/64 Scope:Global

          inet6 addr: fc00:0:0:202::116/64 Scope:Global

          inet6 addr: fc00:0:0:202::124/64 Scope:Global

          inet6 addr: fc00:0:0:202::117/64 Scope:Global

          inet6 addr: fc00:0:0:202::118/64 Scope:Global

          inet6 addr: fc00:0:0:202::119/64 Scope:Global

          inet6 addr: fc00:0:0:202::11a/64 Scope:Global

          inet6 addr: fc00:0:0:202::11b/64 Scope:Global

          inet6 addr: fc00:0:0:202::11c/64 Scope:Global

          inet6 addr: fc00:0:0:202::11d/64 Scope:Global

          inet6 addr: fc00:0:0:202::11e/64 Scope:Global

          inet6 addr: fc00:0:0:202::11f/64 Scope:Global

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:6110 errors:0 dropped:0 overruns:0 frame:0

          TX packets:6005 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:854295 (834.2 KiB)  TX bytes:1124859 (1.0 MiB)


lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:76 errors:0 dropped:0 overruns:0 frame:0

          TX packets:76 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:5280 (5.1 KiB)  TX bytes:5280 (5.1 KiB)

如何去掉这些绑定的ipv6呢?

这些地址是临时加上去的,可以重启网卡service network restart来实现。



5、一些参数说明


(1)配置参数


########### GENERAL SECTION ################################

BATCH_NAME= baidu                 //测试对象的名称

CLIENTS_NUM_MAX=20     //最大虚拟用户数

CLIENTS_NUM_START=1     //一开始启动用户数   

CLIENTS_RAMPUP_INC=1     //每秒钟启动几个用户

INTERFACE   =eth0         //使用的网卡eth0

NETMASK=16           //子网掩码位数

IP_ADDR_MIN= 192.168.1.1       //起始IP地址

IP_ADDR_MAX= 192.168.53.255  #Actually - this is for self-control      //最后的IP地址范围

CYCLES_NUM= -1    // -1 表示无限循环

URLS_NUM= 1   


########### URL SECTION ####################################


URL=http://www.baidu.com/index.html      //要测试的URL

#URL=http://localhost/ACE-INSTALL.html    

URL_SHORT_NAME="local-index"

REQUEST_TYPE=GET

TIMER_URL_COMPLETION = 5000      # In msec. When positive, Now it is enforced by cancelling url fetch on timeout

TIMER_AFTER_URL_SLEEP =20



(2)结果参数

各项参数说明:


interval stats  间隔统计


latest 最新数据(3秒内的)


clients 并发用户数量


CAPS-curr 最新发送请求数


req:  request (请求)


- 1xx成功NUM;  - 2xx成功NUM;- 3xx的重定向数量;- 4xx客户端错误数;- 5xx服务器错误数;


       平均2XX(成功)的HTTP响应中的应用服务器延时,如上,但只有2xx有应答。来推动是3xx的重定向和5xx服务器错误/拒绝未必能真实反映一个测试服务器工作的功能(D2XX);


 Ti (T-in) 吞吐量“吞”,平均值,字节/每秒


 To (T-out) 吞吐量“吐”,平均值,字节/每秒


 Summary stats 总结统计


 runs 运行时间


 CAPS-average  总平均发送请求数(秒)


错误类型:


err      - 其他NUM错误,如解析,TCP连接,服务器关闭或空响应;


T-err  - URL完成时间到期的错误;


两个参考blog

https://tt-topia.rhcloud.com/?cat=6

http://www.cnblogs.com/fnng/archive/2012/02/29/2373954.html


6、弯路及错误解决方法

如果不修改Makefile

即不将将--disable-ipv6改为--enable-ipv6就进行make && make install



可以看到全是Err的错误,看不到2XX

============  loading batch is: ipv6       ======================================

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

Interval stats (latest:3 sec, clients:10, CAPS-curr:440):

H/F   Req:0,1xx:0,2xx:0,3xx:0,4xx:0,5xx:0,Err:1330,T-Err:0,D:0ms,D-2xx:0ms,Ti:0B/s,To:0B/s

H/F/S Req:0,1xx:0,2xx:0,3xx:0,4xx:0,5xx:0,Err:0,T-Err:0,D:0ms,D-2xx:0ms,Ti:0B/s,To:0B/s

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

Summary stats (runs:9 secs, CAPS-average:458):

H/F   Req:0,1xx:0,2xx:0,3xx:0,4xx:0,5xx:0,Err:4130,T-Err:0,D:0ms,D-2xx:0ms,Ti:0B/s,To:0B/s

H/F/S Req:0,1xx:0,2xx:0,3xx:0,4xx:0,5xx:0,Err:0,T-Err:0,D:0ms,D-2xx:0ms,Ti:0B/s,To:0B/s

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

 Manual: clients:max[10],curr[10]. Inc num: [+|*].

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



在测试的时候回出现如下错误

[root@202 curl-loader-0.56]# tail -n 10 ipv6.log 

12031 545 0 1 !! ERR Couldn't resolve host 'fc00:0:0:216::11'

12031 545 0 2 !! ERR Couldn't resolve host 'fc00:0:0:216::11'

12031 545 0 3 !! ERR Couldn't resolve host 'fc00:0:0:216::11'

12031 545 0 4 !! ERR Couldn't resolve host 'fc00:0:0:216::11'

12031 545 0 5 !! ERR Couldn't resolve host 'fc00:0:0:216::11'

12031 545 0 6 !! ERR Couldn't resolve host 'fc00:0:0:216::11'

12031 545 0 7 !! ERR Couldn't resolve host 'fc00:0:0:216::11'

12031 545 0 8 !! ERR Couldn't resolve host 'fc00:0:0:216::11'

12031 545 0 9 !! ERR Couldn't resolve host 'fc00:0:0:216::11'

12031 545 0 10 !! ERR Couldn't resolve host 'fc00:0:0:216::11'