代码改变世界

dnsperf

2019-07-12 18:37  Loull  阅读(1137)  评论(0编辑  收藏  举报

 

github 地址:https://github.com/DNS-OARC/dnsperf

mac安装:brew install dnsperf

 

参数详解

Dnsperf 支持下面的这些命令行参数:

 

-s     用来指定DNS服务器的IP地址,默认值是127.0.0.1
-p     用来指定DNS服务器的端口,默认值是53
-d     用来指定DNS消息的内容文件,该文件中包含要探测的域名和资源记录类型,见下文
-t      用来指定每个请求的超时时间,默认值是3000ms
-Q     用来指定本次压测的最大请求数,默认值是1000
-c     用来指定并发探测数,默认值是100. dnsperf会从-d指定的文件中随机选取100个座位探测域名来发送DNS请求.
-l      用来指定本次压测的时间,默认值是无穷大。
-e     本选项通过EDNS0,在OPT资源记录中运用edns-client-subnet来指定真实的client ip. 

-P     指定用哪个传输层协议发送DNS请求,udp或者tcp。默认值是udp
-f      指定用什么地址类型发送DNS请求,inet或者inet6。默认值是inet
-v     除了标准的输出外,还输出每个相应码的个数。
-h     打印帮助

-f address family of DNS transport, inet or inet6 (default: any)
-s the server to query (default: 127.0.0.1)
-p the port on which to query the server (default: 53)
-a the local address from which to send queries
-x the local port from which to send queries (default: 0)
-d the input data file (default: stdin)
-c the number of clients to act as
-T the number of threads to run
-n run through input at most N times
-l run for at most this many seconds
-b socket send/receive buffer size in kilobytes
-t the timeout for query completion in seconds (default: 5)
-e enable EDNS 0
-E send EDNS option
-D set the DNSSEC OK bit (implies EDNS)
-y the TSIG algorithm, name and secret
-q the maximum number of queries outstanding (default: 100)
-Q limit the number of queries per second
-S print qps statistics every N seconds
-u send dynamic updates instead of queries
-v verbose: report each query to stdout

 

数据文件示例:

上文中提到,-d选项指定数据文件名,数据文件示例如下:

1
2
3
# This is a comment and is ommited
# The columns after column 2 will be ommited if one line contains more than 3 colums.
www.app1.com A

数据文件中以“#”开头的行被认为是注释行,会被dnsperf忽略。

其中有效数据由两列组成,第一列是查询域名,第二列是查询的资源类型,dnsperf支持的资源类型如下:

ANSMDMFCNAMESOAMBMGMRNULLWKSPTRHINFOMINFOMXTXTAAAASRVNAPTRA6ASFRMAILBMAILAANY.

 

如果请求很多次,要写入非常多域名,如

for i in $(seq 1 100000);do echo "qq.com A" >> tt.net.data; done

 

性能评测指标

下图是一个示例输出:

1
2
3
4
5
6
7
8
9
10
11
12
13
DNS Performance Testing Tool
 
[Status] Processing query data
[Status] Sending queries to 127.0.0.1:53
time up
[Status]DNS Query Performance Testing Finish
[Result]Quries sent:        35650
[Result]Quries completed:   35578
[Result]Complete percentage:    99.80%
 
[Result]Elapsed time(s):    1.00000
 
[Result]Queries Per Second: 35650.0000

标准输出中,queies sent是指本次探测发送的总请求数,queries completed是指本次探测收到响应的请求数,complete percentage是指本次探测的成功率(queies_completed/queries_sent),elapsed time是指本次探测的时间,queries per second是指本次探测的QPS。