added dnsperf
This commit is contained in:
parent
4b465e4c1a
commit
651bb1703b
37 changed files with 13825 additions and 0 deletions
|
@ -23,3 +23,8 @@ DNSDigger is a programm to gather as much as possible informations from DNS Serv
|
||||||
|
|
||||||
# digg
|
# digg
|
||||||
Zone Transfer Script
|
Zone Transfer Script
|
||||||
|
|
||||||
|
# dnsperf-src-2.0.0.0-1
|
||||||
|
DNSPerf “self-paces” the DNS query load to simulate network conditions. New features in DNSPerf improve the precision of latency measurements and allow for per packet per-query latency reporting is possible. DNSPerf is now multithreaded, multiple DNSPerf clients can be supported in multicore systems (each client requires two cores). The output of DNSPerf has also been improved so it is more concise and useful. Latency data can be used to make detailed graphs so it is simple for network operators to take advantage of the data.
|
||||||
|
|
||||||
|
ResPerf systematically increases the query rate and monitors the response rate to simulate caching DNS services.
|
||||||
|
|
55
dns/dnsperf-src-2.0.0.0-1/Makefile.in
Normal file
55
dns/dnsperf-src-2.0.0.0-1/Makefile.in
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# Copyright 2000, 2001, 2003, 2006-2012 Nominum, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
prefix = @prefix@
|
||||||
|
exec_prefix = @exec_prefix@
|
||||||
|
bindir = @bindir@
|
||||||
|
mandir = @mandir@
|
||||||
|
datarootdir = @datarootdir@
|
||||||
|
|
||||||
|
INSTALL = @INSTALL@
|
||||||
|
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||||
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
|
RANLIB = @RANLIB@
|
||||||
|
|
||||||
|
CC = @PTHREAD_CC@
|
||||||
|
CFLAGS = @CFLAGS@ @DNSCFLAGS@ @DEFS@ @PTHREAD_CFLAGS@
|
||||||
|
LIBS = libperf.a @LIBS@ @DNSLIBS@ @PTHREAD_LIBS@ -lm
|
||||||
|
LIBOBJS = @LIBOBJS@
|
||||||
|
LDFLAGS = @LDFLAGS@ @PTHREAD_CFLAGS@
|
||||||
|
|
||||||
|
PERFOBJS = datafile.o dns.o log.o net.o opt.o os.o
|
||||||
|
|
||||||
|
all: dnsperf resperf
|
||||||
|
|
||||||
|
libperf.a: ${PERFOBJS}
|
||||||
|
${AR} ${ARFLAGS} $@ ${PERFOBJS}
|
||||||
|
${RANLIB} $@
|
||||||
|
|
||||||
|
dnsperf: dnsperf.o libperf.a $(LIBOBJS)
|
||||||
|
$(CC) $(LDFLAGS) dnsperf.o $(LIBOBJS) $(LIBS) -o dnsperf
|
||||||
|
|
||||||
|
resperf: resperf.o libperf.a $(LIBOBJS)
|
||||||
|
$(CC) $(LDFLAGS) resperf.o $(LIBOBJS) $(LIBS) -o resperf
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) $(CFLAGS) -c $<
|
||||||
|
|
||||||
|
installdirs:
|
||||||
|
mkdir -p ${DESTDIR}${bindir}
|
||||||
|
mkdir -p ${DESTDIR}${mandir}/man1
|
||||||
|
|
||||||
|
install: all installdirs
|
||||||
|
${INSTALL_PROGRAM} dnsperf ${DESTDIR}${bindir}
|
||||||
|
${INSTALL_PROGRAM} resperf ${DESTDIR}${bindir}
|
||||||
|
${INSTALL_PROGRAM} resperf-report ${DESTDIR}${bindir}
|
||||||
|
${INSTALL_DATA} dnsperf.1 ${DESTDIR}${mandir}/man1
|
||||||
|
${INSTALL_DATA} resperf.1 ${DESTDIR}${mandir}/man1
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o dnsperf resperf libperf.a
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -f config.log
|
||||||
|
rm -f config.cache
|
||||||
|
rm -f config.status
|
||||||
|
rm -f Makefile
|
21
dns/dnsperf-src-2.0.0.0-1/README
Normal file
21
dns/dnsperf-src-2.0.0.0-1/README
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
This is dnsperf, a collection of DNS server performance testing tools.
|
||||||
|
For more information, see the dnsperf(1) and resperf(1) man pages.
|
||||||
|
|
||||||
|
To configure, compile, and install these programs, follow these steps.
|
||||||
|
|
||||||
|
1. Make sure that BIND 9 (9.4.0 or greater) is installed, including libraries
|
||||||
|
and header files, and that the isc-config.sh program distributed with BIND
|
||||||
|
is in your path.
|
||||||
|
|
||||||
|
Note: many versions of bind do not correctly install the <isc/hmacsha.h>
|
||||||
|
header file, so if the compilation fails, obtain this file from the BIND
|
||||||
|
source distribution, and install it in the appropriate place.
|
||||||
|
|
||||||
|
2. Run "sh configure" to configure the software. Most standard configure
|
||||||
|
options are supported.
|
||||||
|
|
||||||
|
3. Run "make" to build dnsperf and resperf
|
||||||
|
|
||||||
|
4. Run "make install" to install dnsperf and resperf.
|
||||||
|
|
||||||
|
Additional software is available in the contrib/ directory.
|
165
dns/dnsperf-src-2.0.0.0-1/RELEASE_NOTES
Normal file
165
dns/dnsperf-src-2.0.0.0-1/RELEASE_NOTES
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
Nominum dnsperf 2.0.0.0
|
||||||
|
Release Notes
|
||||||
|
*************
|
||||||
|
|
||||||
|
March 1, 2012
|
||||||
|
|
||||||
|
In the dnsperf command, the following changes occurred:
|
||||||
|
|
||||||
|
- The socket buffer size is no longer set to 32 kilobytes by default.
|
||||||
|
|
||||||
|
- A new -c clients option was added to enable the server to act as
|
||||||
|
multiple clients. Each client uses the same source IP address with a
|
||||||
|
unique source port. Use the "clients" argument to specify the number of
|
||||||
|
clients represented by the server. We recommend limiting the number of
|
||||||
|
clients represented by the server because the dnsperf process uses two
|
||||||
|
threads for each client (one thread for sent packets and one for
|
||||||
|
received packets), which impacts CPU and memory.
|
||||||
|
|
||||||
|
- Example query files are no longer included with the dnsperf program.
|
||||||
|
Nominum provides a sample query file that is available for download at:
|
||||||
|
ftp://ftp.nominum.com/pub/nominum/dnsperf/data/
|
||||||
|
|
||||||
|
- Latency reporting improved. When the -v (verbose mode) option is
|
||||||
|
configured with the dnsperf command, the command output now includes
|
||||||
|
latency measurements and the DNS RCODE of each response. This enables
|
||||||
|
users to create their own latency graphs.
|
||||||
|
|
||||||
|
- Performance was enhanced on modern operating systems so that faster
|
||||||
|
name servers can be tested.
|
||||||
|
|
||||||
|
- The dnsperf command output is enhanced to display more information in a
|
||||||
|
compact format.
|
||||||
|
|
||||||
|
The following options were removed from the dnsperf command:
|
||||||
|
|
||||||
|
- The -A option for displaying command line arguments passed to the
|
||||||
|
dnsperf tool in the final statistics output. Now, the dnsperf command
|
||||||
|
output always displays command line arguments.
|
||||||
|
|
||||||
|
- The -T option for printing a histogram showing response latency after
|
||||||
|
completing a test run. Now, the -v option enables users to include
|
||||||
|
latency measurements in the dnsperf command output.
|
||||||
|
|
||||||
|
- The -H option for configuring the number of buckets for which response
|
||||||
|
latency is displayed. Now, the -v option enables users to include
|
||||||
|
latency measurements in the dnsperf command output.
|
||||||
|
|
||||||
|
- The -1 option for configuring the dnsperf tool to run through the input
|
||||||
|
file exactly one time. (Now, you use the -n 1 option to configure the
|
||||||
|
dnsperf tool to run through the input file one time.)
|
||||||
|
|
||||||
|
- The -c option for including the number of responses received (for
|
||||||
|
each DNS RCODE) in the final statistics output. Now, DNS RCODE responses
|
||||||
|
are always reported.
|
||||||
|
|
||||||
|
In the resperf command, the following changes occurred:
|
||||||
|
|
||||||
|
- The socket buffer size is no longer set to 32 kilobytes by default.
|
||||||
|
|
||||||
|
- The -A option, which displayed command line arguments passed to the
|
||||||
|
resperf tool in the final statistics output, was removed. Now, the
|
||||||
|
resperf command output always displays command line arguments.
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------
|
||||||
|
Nominum dnsperf 1.0.2.0
|
||||||
|
December 22, 2011
|
||||||
|
|
||||||
|
This release adds support for RHEL6-64 and for Solaris 10 x86-64.
|
||||||
|
|
||||||
|
Some new configuration options have been added. You can now specify:
|
||||||
|
|
||||||
|
- the local port from which to send requests
|
||||||
|
- the local address from which to send requests
|
||||||
|
- the maximum number of runs through the input file, up
|
||||||
|
to the timeout limit.
|
||||||
|
- when using TSIG, algorithms other than hmac-md5 can be used.
|
||||||
|
|
||||||
|
One default has been changed:
|
||||||
|
|
||||||
|
- The maximum number of outstanding requests now defaults
|
||||||
|
to 100.
|
||||||
|
|
||||||
|
A new example query file for IPv6, queryfile-example-ipv6, is now
|
||||||
|
included with the distribution.
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------
|
||||||
|
Nominum dnsperf 1.0.1.0
|
||||||
|
January 10, 2008
|
||||||
|
|
||||||
|
This release makes binary builds of dnsperf available in addition to
|
||||||
|
the source code version previously released.
|
||||||
|
|
||||||
|
This release of dnsperf includes a sample query file containing
|
||||||
|
100,000 queries to help with performance testing. This query file is
|
||||||
|
useful for checking latencies or a continuous dnsperf run. In the
|
||||||
|
binary distribution, this file is found at:
|
||||||
|
|
||||||
|
/usr/local/nom/examples/dnsperf/queryfile-example-100thousand
|
||||||
|
|
||||||
|
In the source distribution, it is at:
|
||||||
|
|
||||||
|
./examples/queryfile-example-100thousand
|
||||||
|
|
||||||
|
where "." is the directory made by extracting the source tarball.
|
||||||
|
|
||||||
|
Nominum recommends using a query file with at least 3 million queries
|
||||||
|
for a full resperf run as described in the man page; we make such a
|
||||||
|
file available for download at:
|
||||||
|
|
||||||
|
ftp://ftp.nominum.com/pub/nominum/dnsperf/data/queryfile-example-3million.gz
|
||||||
|
|
||||||
|
The following fix is included in the source distribution:
|
||||||
|
|
||||||
|
- 20996: makefile.in does not allow overriding mandir
|
||||||
|
|
||||||
|
The --mandir argument to configure, which allows the user to
|
||||||
|
specify the location man pages are installed, was incorrectly
|
||||||
|
ignored.
|
||||||
|
|
||||||
|
"queryparse" is a contributed program available in the source
|
||||||
|
distribution of dnsperf. It can be found at contrib/queryparse/.
|
||||||
|
The following changes were made to that program:
|
||||||
|
|
||||||
|
- 19717: contrib/queryparse includes outgoing queries
|
||||||
|
|
||||||
|
The queryparse script had no way of distinguishing between incoming
|
||||||
|
queries and outgoing queries when applied to a traffic trace from a
|
||||||
|
caching server. This was addressed by adding a new flag (-r) that,
|
||||||
|
when included in the command line, will keep queries with
|
||||||
|
RD=0. Otherwise, it will default to discarding them.
|
||||||
|
|
||||||
|
- The ability to parse responses instead of queries was added.
|
||||||
|
|
||||||
|
- A check was added to avoid short packets.
|
||||||
|
|
||||||
|
- Logic was added to detect link type and correctly set the initial
|
||||||
|
offset to handle both Ethernet and Cisco HDLC frames.
|
||||||
|
|
||||||
|
- Queryparse now uses pcapy instead of the btk python libcap module.
|
||||||
|
|
||||||
|
Note that announcements of new releases of dnsperf are sent to the
|
||||||
|
mailing list: dnsperf-announce@nominum.com. To be added to the
|
||||||
|
mailing list, send a message to dnsperf-announce-request@nominum.com
|
||||||
|
with "subscribe" as the subject.
|
||||||
|
|
||||||
|
Known Issues:
|
||||||
|
|
||||||
|
- None.
|
||||||
|
|
||||||
|
-----------------------
|
||||||
|
Nominum dnsperf 1.0.0.1
|
||||||
|
December 21, 2006
|
||||||
|
|
||||||
|
This release addresses the following issue in the dnsperf program:
|
||||||
|
|
||||||
|
- 18838/18782: dnsperf slow down issue
|
||||||
|
|
||||||
|
Because of an error in how timeout checking was being done, queries
|
||||||
|
were rarely timing out, so the number of valid queries in flight kept
|
||||||
|
dropping. This error has been corrected.
|
||||||
|
|
||||||
|
|
||||||
|
|
2
dns/dnsperf-src-2.0.0.0-1/aclocal.m4
vendored
Normal file
2
dns/dnsperf-src-2.0.0.0-1/aclocal.m4
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
sinclude(./acx_pthread.m4)dnl
|
||||||
|
|
242
dns/dnsperf-src-2.0.0.0-1/acx_pthread.m4
Normal file
242
dns/dnsperf-src-2.0.0.0-1/acx_pthread.m4
Normal file
|
@ -0,0 +1,242 @@
|
||||||
|
dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||||
|
dnl
|
||||||
|
dnl @summary figure out how to build C programs using POSIX threads
|
||||||
|
dnl
|
||||||
|
dnl This macro figures out how to build C programs using POSIX threads.
|
||||||
|
dnl It sets the PTHREAD_LIBS output variable to the threads library and
|
||||||
|
dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
|
||||||
|
dnl C compiler flags that are needed. (The user can also force certain
|
||||||
|
dnl compiler flags/libs to be tested by setting these environment
|
||||||
|
dnl variables.)
|
||||||
|
dnl
|
||||||
|
dnl Also sets PTHREAD_CC to any special C compiler that is needed for
|
||||||
|
dnl multi-threaded programs (defaults to the value of CC otherwise).
|
||||||
|
dnl (This is necessary on AIX to use the special cc_r compiler alias.)
|
||||||
|
dnl
|
||||||
|
dnl NOTE: You are assumed to not only compile your program with these
|
||||||
|
dnl flags, but also link it with them as well. e.g. you should link
|
||||||
|
dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
|
||||||
|
dnl $LIBS
|
||||||
|
dnl
|
||||||
|
dnl If you are only building threads programs, you may wish to use
|
||||||
|
dnl these variables in your default LIBS, CFLAGS, and CC:
|
||||||
|
dnl
|
||||||
|
dnl LIBS="$PTHREAD_LIBS $LIBS"
|
||||||
|
dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
|
dnl CC="$PTHREAD_CC"
|
||||||
|
dnl
|
||||||
|
dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
|
||||||
|
dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
|
||||||
|
dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||||
|
dnl
|
||||||
|
dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
|
||||||
|
dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
|
||||||
|
dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
|
||||||
|
dnl default action will define HAVE_PTHREAD.
|
||||||
|
dnl
|
||||||
|
dnl Please let the authors know if this macro fails on any platform, or
|
||||||
|
dnl if you have any other suggestions or comments. This macro was based
|
||||||
|
dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
|
||||||
|
dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
|
||||||
|
dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
|
||||||
|
dnl We are also grateful for the helpful feedback of numerous users.
|
||||||
|
dnl
|
||||||
|
dnl @category InstalledPackages
|
||||||
|
dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
|
||||||
|
dnl @version 2006-05-29
|
||||||
|
dnl @license GPLWithACException
|
||||||
|
|
||||||
|
AC_DEFUN([ACX_PTHREAD], [
|
||||||
|
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||||
|
AC_LANG_SAVE
|
||||||
|
AC_LANG_C
|
||||||
|
acx_pthread_ok=no
|
||||||
|
|
||||||
|
# We used to check for pthread.h first, but this fails if pthread.h
|
||||||
|
# requires special compiler flags (e.g. on True64 or Sequent).
|
||||||
|
# It gets checked for in the link test anyway.
|
||||||
|
|
||||||
|
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||||
|
# etcetera environment variables, and if threads linking works using
|
||||||
|
# them:
|
||||||
|
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
||||||
|
save_CFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
|
save_LIBS="$LIBS"
|
||||||
|
LIBS="$PTHREAD_LIBS $LIBS"
|
||||||
|
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
||||||
|
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
|
||||||
|
AC_MSG_RESULT($acx_pthread_ok)
|
||||||
|
if test x"$acx_pthread_ok" = xno; then
|
||||||
|
PTHREAD_LIBS=""
|
||||||
|
PTHREAD_CFLAGS=""
|
||||||
|
fi
|
||||||
|
LIBS="$save_LIBS"
|
||||||
|
CFLAGS="$save_CFLAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We must check for the threads library under a number of different
|
||||||
|
# names; the ordering is very important because some systems
|
||||||
|
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||||
|
# libraries is broken (non-POSIX).
|
||||||
|
|
||||||
|
# Create a list of thread flags to try. Items starting with a "-" are
|
||||||
|
# C compiler flags, and other items are library names, except for "none"
|
||||||
|
# which indicates that we try without any flags at all, and "pthread-config"
|
||||||
|
# which is a program returning the flags for the Pth emulation library.
|
||||||
|
|
||||||
|
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||||
|
|
||||||
|
# The ordering *is* (sometimes) important. Some notes on the
|
||||||
|
# individual items follow:
|
||||||
|
|
||||||
|
# pthreads: AIX (must check this before -lpthread)
|
||||||
|
# none: in case threads are in libc; should be tried before -Kthread and
|
||||||
|
# other compiler flags to prevent continual compiler warnings
|
||||||
|
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||||
|
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||||
|
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||||
|
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
||||||
|
# -pthreads: Solaris/gcc
|
||||||
|
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||||
|
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||||
|
# doesn't hurt to check since this sometimes defines pthreads too;
|
||||||
|
# also defines -D_REENTRANT)
|
||||||
|
# ... -mt is also the pthreads flag for HP/aCC
|
||||||
|
# pthread: Linux, etcetera
|
||||||
|
# --thread-safe: KAI C++
|
||||||
|
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||||
|
|
||||||
|
case "${host_cpu}-${host_os}" in
|
||||||
|
*solaris*)
|
||||||
|
|
||||||
|
# On Solaris (at least, for some versions), libc contains stubbed
|
||||||
|
# (non-functional) versions of the pthreads routines, so link-based
|
||||||
|
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
|
||||||
|
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||||
|
# a function called by this macro, so we could check for that, but
|
||||||
|
# who knows whether they'll stub that too in a future libc.) So,
|
||||||
|
# we'll just look for -pthreads and -lpthread first:
|
||||||
|
|
||||||
|
acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test x"$acx_pthread_ok" = xno; then
|
||||||
|
for flag in $acx_pthread_flags; do
|
||||||
|
|
||||||
|
case $flag in
|
||||||
|
none)
|
||||||
|
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||||
|
;;
|
||||||
|
|
||||||
|
-*)
|
||||||
|
AC_MSG_CHECKING([whether pthreads work with $flag])
|
||||||
|
PTHREAD_CFLAGS="$flag"
|
||||||
|
;;
|
||||||
|
|
||||||
|
pthread-config)
|
||||||
|
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
|
||||||
|
if test x"$acx_pthread_config" = xno; then continue; fi
|
||||||
|
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||||
|
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
||||||
|
PTHREAD_LIBS="-l$flag"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
save_LIBS="$LIBS"
|
||||||
|
save_CFLAGS="$CFLAGS"
|
||||||
|
LIBS="$PTHREAD_LIBS $LIBS"
|
||||||
|
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
|
|
||||||
|
# Check for various functions. We must include pthread.h,
|
||||||
|
# since some functions may be macros. (On the Sequent, we
|
||||||
|
# need a special flag -Kthread to make this header compile.)
|
||||||
|
# We check for pthread_join because it is in -lpthread on IRIX
|
||||||
|
# while pthread_create is in libc. We check for pthread_attr_init
|
||||||
|
# due to DEC craziness with -lpthreads. We check for
|
||||||
|
# pthread_cleanup_push because it is one of the few pthread
|
||||||
|
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||||
|
# We try pthread_create on general principles.
|
||||||
|
AC_TRY_LINK([#include <pthread.h>],
|
||||||
|
[pthread_t th; pthread_join(th, 0);
|
||||||
|
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||||
|
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
||||||
|
[acx_pthread_ok=yes])
|
||||||
|
|
||||||
|
LIBS="$save_LIBS"
|
||||||
|
CFLAGS="$save_CFLAGS"
|
||||||
|
|
||||||
|
AC_MSG_RESULT($acx_pthread_ok)
|
||||||
|
if test "x$acx_pthread_ok" = xyes; then
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
|
||||||
|
PTHREAD_LIBS=""
|
||||||
|
PTHREAD_CFLAGS=""
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Various other checks:
|
||||||
|
if test "x$acx_pthread_ok" = xyes; then
|
||||||
|
save_LIBS="$LIBS"
|
||||||
|
LIBS="$PTHREAD_LIBS $LIBS"
|
||||||
|
save_CFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
|
|
||||||
|
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||||
|
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||||
|
attr_name=unknown
|
||||||
|
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||||
|
AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
|
||||||
|
[attr_name=$attr; break])
|
||||||
|
done
|
||||||
|
AC_MSG_RESULT($attr_name)
|
||||||
|
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
|
||||||
|
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
|
||||||
|
[Define to necessary symbol if this constant
|
||||||
|
uses a non-standard name on your system.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||||
|
flag=no
|
||||||
|
case "${host_cpu}-${host_os}" in
|
||||||
|
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
|
||||||
|
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
|
||||||
|
esac
|
||||||
|
AC_MSG_RESULT(${flag})
|
||||||
|
if test "x$flag" != xno; then
|
||||||
|
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
LIBS="$save_LIBS"
|
||||||
|
CFLAGS="$save_CFLAGS"
|
||||||
|
|
||||||
|
# More AIX lossage: must compile with xlc_r or cc_r
|
||||||
|
if test x"$GCC" != xyes; then
|
||||||
|
AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
|
||||||
|
else
|
||||||
|
PTHREAD_CC=$CC
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
PTHREAD_CC="$CC"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SUBST(PTHREAD_LIBS)
|
||||||
|
AC_SUBST(PTHREAD_CFLAGS)
|
||||||
|
AC_SUBST(PTHREAD_CC)
|
||||||
|
|
||||||
|
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||||
|
if test x"$acx_pthread_ok" = xyes; then
|
||||||
|
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
|
||||||
|
:
|
||||||
|
else
|
||||||
|
acx_pthread_ok=no
|
||||||
|
$2
|
||||||
|
fi
|
||||||
|
AC_LANG_RESTORE
|
||||||
|
])dnl ACX_PTHREAD
|
1447
dns/dnsperf-src-2.0.0.0-1/config.guess
vendored
Normal file
1447
dns/dnsperf-src-2.0.0.0-1/config.guess
vendored
Normal file
File diff suppressed because it is too large
Load diff
1555
dns/dnsperf-src-2.0.0.0-1/config.sub
vendored
Normal file
1555
dns/dnsperf-src-2.0.0.0-1/config.sub
vendored
Normal file
File diff suppressed because it is too large
Load diff
4940
dns/dnsperf-src-2.0.0.0-1/configure
vendored
Executable file
4940
dns/dnsperf-src-2.0.0.0-1/configure
vendored
Executable file
File diff suppressed because it is too large
Load diff
73
dns/dnsperf-src-2.0.0.0-1/configure.in
Normal file
73
dns/dnsperf-src-2.0.0.0-1/configure.in
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2000, 2001 Nominum, Inc.
|
||||||
|
#
|
||||||
|
# Permission to use, copy, modify, and distribute this software for any
|
||||||
|
# purpose with or without fee is hereby granted, provided that the above
|
||||||
|
# copyright notice and this permission notice appear in all copies.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||||
|
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||||
|
# INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||||
|
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
AC_INIT(dnsperf.c)
|
||||||
|
|
||||||
|
AC_PREREQ(2.13)
|
||||||
|
|
||||||
|
AC_PROG_CC
|
||||||
|
AC_PROG_INSTALL
|
||||||
|
AC_PROG_RANLIB
|
||||||
|
|
||||||
|
AC_C_INLINE
|
||||||
|
|
||||||
|
AC_DEFUN(AC_TYPE_SOCKLEN_T,
|
||||||
|
[AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
|
||||||
|
[
|
||||||
|
AC_TRY_COMPILE(
|
||||||
|
[#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>],
|
||||||
|
[socklen_t len = 42; return len;],
|
||||||
|
ac_cv_type_socklen_t=yes,
|
||||||
|
ac_cv_type_socklen_t=no)
|
||||||
|
])
|
||||||
|
if test $ac_cv_type_socklen_t != yes; then
|
||||||
|
AC_DEFINE(socklen_t, int)
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN(AC_SA_LEN,
|
||||||
|
[AC_CACHE_CHECK([for sa_len], ac_cv_sa_len,
|
||||||
|
[
|
||||||
|
AC_TRY_COMPILE(
|
||||||
|
[#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>],
|
||||||
|
[struct sockaddr sa; sa.sa_len = 0;],
|
||||||
|
ac_cv_sa_len=yes,
|
||||||
|
ac_cv_sa_len=no)
|
||||||
|
])
|
||||||
|
if test $ac_cv_sa_len = yes; then
|
||||||
|
AC_DEFINE(HAVE_SA_LEN)
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_CHECK_LIB(socket, socket)
|
||||||
|
AC_CHECK_LIB(nsl, inet_ntoa)
|
||||||
|
|
||||||
|
AC_PATH_PROG(ac_cv_isc_config, [isc-config.sh], "no")
|
||||||
|
if test "$ac_cv_isc_config" = "no"; then
|
||||||
|
AC_MSG_ERROR(BIND 9 libraries must be installed)
|
||||||
|
fi
|
||||||
|
AC_SUBST(DNSLIBS, "`$ac_cv_isc_config --libs dns bind9`")
|
||||||
|
AC_SUBST(DNSCFLAGS, "`$ac_cv_isc_config --cflags dns bind9`")
|
||||||
|
|
||||||
|
AC_TYPE_SOCKLEN_T
|
||||||
|
AC_SA_LEN
|
||||||
|
|
||||||
|
ACX_PTHREAD
|
||||||
|
|
||||||
|
AC_OUTPUT(Makefile)
|
48
dns/dnsperf-src-2.0.0.0-1/contrib/queryparse/INSTALL
Normal file
48
dns/dnsperf-src-2.0.0.0-1/contrib/queryparse/INSTALL
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
Queryparse requires the dnspython and pcapy python modules. Pcapy depends
|
||||||
|
upon the pcap library.
|
||||||
|
|
||||||
|
Libpcap may be obtained from http://www.tcpdump.org/
|
||||||
|
Dnspython may be obtained from http://www.dnspython.org/
|
||||||
|
Pcapy may be obtained from http://oss.coresecurity.com/projects/pcapy.html
|
||||||
|
|
||||||
|
Ensure queryparse is somewhere in your path.
|
||||||
|
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
queryparse -i <input file> -o <output file>
|
||||||
|
|
||||||
|
-i <input file>: the tcpdump file that will be parsed to locate DNS
|
||||||
|
queries.
|
||||||
|
|
||||||
|
-o <output file>: the file to which you wish to save the queries parsed
|
||||||
|
from <input file>. When complete, this file is suitable
|
||||||
|
for use as input to dnsperf.
|
||||||
|
|
||||||
|
-r Keep packets whose RD flag is not set.
|
||||||
|
Use this flag when parsing captures from authoritative
|
||||||
|
servers. When parsing captures from caching servers,
|
||||||
|
do not use this flag unless you also want to parse the
|
||||||
|
queries the server itself is sending.
|
||||||
|
|
||||||
|
-R Parse response packets (QR=1), instead of query packets
|
||||||
|
(QR=0).
|
||||||
|
|
||||||
|
|
||||||
|
Queryparse takes as input a packet capture file as created by tcpdump (or any
|
||||||
|
other program that can save data in pcap format). It parses every UDP packet,
|
||||||
|
looking for DNS queries. When it finds a potential query, it makes every
|
||||||
|
effort to parse it as a valid query.
|
||||||
|
|
||||||
|
Once queryparse has finished, it will print a set of statistics regarding
|
||||||
|
the capture file to STDOUT.
|
||||||
|
|
||||||
|
|
||||||
|
NOTE: Currently, queryparse will correctly handle packets contained in either
|
||||||
|
Ethernet frames or Cisco HDLC frames. It is not guaranteed to work with other
|
||||||
|
framing formats.
|
||||||
|
|
52
dns/dnsperf-src-2.0.0.0-1/contrib/queryparse/USAGE
Normal file
52
dns/dnsperf-src-2.0.0.0-1/contrib/queryparse/USAGE
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
|
||||||
|
|
||||||
|
To use queryparse, you need one or more files containing pcap-formatted packet
|
||||||
|
captures, such as those generated by tcpdump via the -w switch.
|
||||||
|
|
||||||
|
Once you have such a file, call queryparse as follows:
|
||||||
|
|
||||||
|
queryparse -i tcpdump.raw -o outputfile
|
||||||
|
|
||||||
|
where "tcpdump.raw" is the name of the pcap-formatted packet capture file, and
|
||||||
|
"outputfile" is the name you wish to call the saved output of queryparse.
|
||||||
|
|
||||||
|
When queryparse finishes, it will print to STDOUT a count of each type of query
|
||||||
|
encountered during its run. For example:
|
||||||
|
|
||||||
|
Statistics:
|
||||||
|
A: 1175140
|
||||||
|
SOA: 23639
|
||||||
|
NAPTR: 113
|
||||||
|
NS: 1329
|
||||||
|
CNAME: 1667
|
||||||
|
NONE: 38
|
||||||
|
PTR: 186053
|
||||||
|
AAAA: 50858
|
||||||
|
ANY: 2117
|
||||||
|
SRV: 49470
|
||||||
|
KEY: 218
|
||||||
|
A6: 245
|
||||||
|
TXT: 24243
|
||||||
|
MX: 517510
|
||||||
|
-------------------------
|
||||||
|
TOTAL: 2032640
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The resulting output is in a format suitable as input to resperf or dnsperf.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
example.biz. A
|
||||||
|
example.net. MX
|
||||||
|
foo.example.tv. A
|
||||||
|
example.enc. MX
|
||||||
|
example[2].txt. MX
|
||||||
|
foo.]. MX
|
||||||
|
|
||||||
|
|
||||||
|
Note that there are both valid and invalid host names in the output: Neither
|
||||||
|
queryparse nor resperf or dnsperf discriminate on the basis of a host name's
|
||||||
|
adherence to RFCs. If the query was put on the wire and can be recognized as a
|
||||||
|
properly-formed query, it will be saved. If this does not meet your needs, you
|
||||||
|
may wish to parse the resulting output file to eliminate nonconforming host
|
||||||
|
names.
|
115
dns/dnsperf-src-2.0.0.0-1/contrib/queryparse/queryparse
Executable file
115
dns/dnsperf-src-2.0.0.0-1/contrib/queryparse/queryparse
Executable file
|
@ -0,0 +1,115 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import dns.message
|
||||||
|
import dns.rrset
|
||||||
|
import dns.flags
|
||||||
|
import dns.name
|
||||||
|
import pcapy
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
import struct
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
|
||||||
|
__author__ = "Nominum, Inc."
|
||||||
|
__version__ = "1.0.2.0"
|
||||||
|
__date__ = "2007-05-14"
|
||||||
|
|
||||||
|
IPHeader = '!BBHHHBBHLL'
|
||||||
|
|
||||||
|
IPHDRLEN = 20
|
||||||
|
UDPHDRLEN = 8
|
||||||
|
LINKTYPE_C_HDLC = 104
|
||||||
|
LINKTYPE_ETHERNET = 1
|
||||||
|
qtypecount = {}
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
parser = OptionParser(usage="%prog [options]",
|
||||||
|
version = "%prog " + __version__ )
|
||||||
|
parser.add_option("-i", "--input", dest="fin",
|
||||||
|
help="name of tcpdump file to parse", metavar="FILE")
|
||||||
|
parser.add_option("-o", "--output", dest="fout",
|
||||||
|
help="file in which to save parsed DNS queries",
|
||||||
|
metavar="FILE")
|
||||||
|
parser.add_option("-r", "--recursion", dest="recurse", action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="Keep queries whose RD flag is 0 (default: discard)")
|
||||||
|
parser.add_option("-R", "--responses", dest="responses",
|
||||||
|
action="store_true", default=False,
|
||||||
|
help="Parse query responses instead of queries")
|
||||||
|
(opts, args) = parser.parse_args()
|
||||||
|
|
||||||
|
if opts.fin:
|
||||||
|
pcap = pcapy.open_offline(opts.fin)
|
||||||
|
else:
|
||||||
|
pcap = pcapy.open_offline('-')
|
||||||
|
linktype = pcap.datalink()
|
||||||
|
if linktype == LINKTYPE_C_HDLC:
|
||||||
|
IPHDRSTART = 4
|
||||||
|
else:
|
||||||
|
IPHDRSTART = 14
|
||||||
|
if opts.fout:
|
||||||
|
outfile = open(opts.fout, "w")
|
||||||
|
else:
|
||||||
|
outfile = sys.stdout
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
packet = pcap.next()
|
||||||
|
except:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
packet = packet[1]
|
||||||
|
# Toss the stuff before the IP header
|
||||||
|
packet = packet[IPHDRSTART:]
|
||||||
|
|
||||||
|
# Grab the rest of the packet so we can parse proto
|
||||||
|
iphdr = packet[0:IPHDRLEN]
|
||||||
|
if len(iphdr) < IPHDRLEN:
|
||||||
|
continue
|
||||||
|
(vhl, tos, tlen, ipid, fragoff, ttl, proto, cksum, srcip, dstip) = \
|
||||||
|
struct.unpack(IPHeader, iphdr)
|
||||||
|
|
||||||
|
# Toss the IP header, we're done with it. We need to account
|
||||||
|
# for any IP header options.
|
||||||
|
ihl = (vhl & 0xF) * 4
|
||||||
|
packet = packet[ihl:]
|
||||||
|
|
||||||
|
if proto == socket.IPPROTO_UDP: # UDP, 8-byte header
|
||||||
|
packet = packet[UDPHDRLEN:]
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
msg = dns.message.from_wire(packet)
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
if not opts.recurse and not dns.flags.RD:
|
||||||
|
continue
|
||||||
|
if opts.responses:
|
||||||
|
querytest = msg.flags & dns.flags.QR
|
||||||
|
else:
|
||||||
|
querytest = not (msg.flags & dns.flags.QR)
|
||||||
|
if querytest:
|
||||||
|
for query in msg.question: # handle multiple queries per packet
|
||||||
|
fqdn = query.name.to_text()
|
||||||
|
qtype = dns.rdatatype.to_text(query.rdtype)
|
||||||
|
outfile.write("%s %s\n" % (fqdn, qtype))
|
||||||
|
# add qtype to dict if not present, otherwise increment
|
||||||
|
qtypecount[qtype] = qtypecount.get(qtype, 0) + 1
|
||||||
|
|
||||||
|
if outfile is not sys.stdout:
|
||||||
|
outfile.close()
|
||||||
|
sum = 0
|
||||||
|
print "Statistics:"
|
||||||
|
for v, d in qtypecount.items():
|
||||||
|
if d:
|
||||||
|
print " %10s:\t%d" % (v, d)
|
||||||
|
sum += d
|
||||||
|
print "-------------------------"
|
||||||
|
print " TOTAL:\t%d" % sum
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main(sys.argv[1:])
|
||||||
|
|
50
dns/dnsperf-src-2.0.0.0-1/contrib/queryparse/queryparse.1
Normal file
50
dns/dnsperf-src-2.0.0.0-1/contrib/queryparse/queryparse.1
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
.TH "queryparse" 1
|
||||||
|
.SH NAME
|
||||||
|
queryparse \- extract DNS queries from pcap capture files.
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B queryparse [-i
|
||||||
|
.I input file
|
||||||
|
.B ] [-o
|
||||||
|
.I output file
|
||||||
|
.B ] [-r
|
||||||
|
.I recursion only
|
||||||
|
.B ] [-R
|
||||||
|
.I parse responses
|
||||||
|
.B ]
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B queryparse
|
||||||
|
is a tool designed to extract DNS queries from pcap-formatted packet
|
||||||
|
capture files and save them in a form suitable for input to Nominum's
|
||||||
|
dnsperf or resperf benchmarking tools.
|
||||||
|
.B queryparse
|
||||||
|
will only examine UDP packets, and currently supports Ethernet and Cisco HDLC frame types.
|
||||||
|
.SH OPTIONS
|
||||||
|
.IP "\-i filename"
|
||||||
|
Attempt to extract DNS queries from
|
||||||
|
.I filename,
|
||||||
|
which should be a pcap-formatted packet capture session (e.g., a file created
|
||||||
|
by tcpdump or ethereal).
|
||||||
|
.IP "\-o filename"
|
||||||
|
Write queries to
|
||||||
|
.I filename
|
||||||
|
in a format suitable for input to Nominum's dnsperf or resperf benchmarking tools.
|
||||||
|
.IP "\-r"
|
||||||
|
Keep queries that do not have the RD (recursion desired) flag set. This is useful when parsing packet captures from authoritative nameservers. When parsing captures from caching nameservers, do not use it unless you also want to parse the outgoing queries from the nameserver. Defaults to discarding queries with RD=0.
|
||||||
|
.IP "\-R"
|
||||||
|
Parse responses (QR=1) instead of queries (QR=0).
|
||||||
|
.SH FILES
|
||||||
|
None
|
||||||
|
.SH ENVIRONMENT
|
||||||
|
None
|
||||||
|
.SH DIAGNOSTICS
|
||||||
|
None
|
||||||
|
.SH BUGS
|
||||||
|
None
|
||||||
|
.SH AUTHOR
|
||||||
|
Nominum, Inc.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
.BR dnsperf (1),
|
||||||
|
.BR resperf (1),
|
||||||
|
.BR pcap (3),
|
||||||
|
.BR tcpdump (8)
|
||||||
|
|
275
dns/dnsperf-src-2.0.0.0-1/datafile.c
Normal file
275
dns/dnsperf-src-2.0.0.0-1/datafile.c
Normal file
|
@ -0,0 +1,275 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#define ISC_BUFFER_USEINLINE
|
||||||
|
|
||||||
|
#include <isc/buffer.h>
|
||||||
|
#include <isc/mem.h>
|
||||||
|
|
||||||
|
#include "datafile.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "os.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#define BUFFER_SIZE (64 * 1024)
|
||||||
|
|
||||||
|
struct perf_datafile {
|
||||||
|
isc_mem_t *mctx;
|
||||||
|
pthread_mutex_t lock;
|
||||||
|
int pipe_fd;
|
||||||
|
int fd;
|
||||||
|
isc_boolean_t is_file;
|
||||||
|
size_t size;
|
||||||
|
isc_boolean_t cached;
|
||||||
|
char databuf[BUFFER_SIZE + 1];
|
||||||
|
isc_buffer_t data;
|
||||||
|
unsigned int maxruns;
|
||||||
|
unsigned int nruns;
|
||||||
|
isc_boolean_t read_any;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
nul_terminate(perf_datafile_t *dfile)
|
||||||
|
{
|
||||||
|
unsigned char *data;
|
||||||
|
|
||||||
|
data = isc_buffer_used(&dfile->data);
|
||||||
|
*data = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
perf_datafile_t *
|
||||||
|
perf_datafile_open(isc_mem_t *mctx, const char *filename)
|
||||||
|
{
|
||||||
|
perf_datafile_t *dfile;
|
||||||
|
struct stat buf;
|
||||||
|
|
||||||
|
dfile = isc_mem_get(mctx, sizeof(*dfile));
|
||||||
|
if (dfile == NULL)
|
||||||
|
perf_log_fatal("out of memory");
|
||||||
|
|
||||||
|
dfile->mctx = mctx;
|
||||||
|
MUTEX_INIT(&dfile->lock);
|
||||||
|
dfile->pipe_fd = -1;
|
||||||
|
dfile->is_file = ISC_FALSE;
|
||||||
|
dfile->size = 0;
|
||||||
|
dfile->cached = ISC_FALSE;
|
||||||
|
dfile->maxruns = 1;
|
||||||
|
dfile->nruns = 0;
|
||||||
|
dfile->read_any = ISC_FALSE;
|
||||||
|
isc_buffer_init(&dfile->data, dfile->databuf, BUFFER_SIZE);
|
||||||
|
if (filename == NULL) {
|
||||||
|
dfile->fd = STDIN_FILENO;
|
||||||
|
} else {
|
||||||
|
dfile->fd = open(filename, O_RDONLY);
|
||||||
|
if (dfile->fd < 0)
|
||||||
|
perf_log_fatal("unable to open file: %s", filename);
|
||||||
|
if (fstat(dfile->fd, &buf) == 0 && S_ISREG(buf.st_mode)) {
|
||||||
|
dfile->is_file = ISC_TRUE;
|
||||||
|
dfile->size = buf.st_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nul_terminate(dfile);
|
||||||
|
|
||||||
|
return dfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_datafile_close(perf_datafile_t **dfilep)
|
||||||
|
{
|
||||||
|
perf_datafile_t *dfile;
|
||||||
|
|
||||||
|
ISC_INSIST(dfilep != NULL && *dfilep != NULL);
|
||||||
|
|
||||||
|
dfile = *dfilep;
|
||||||
|
*dfilep = NULL;
|
||||||
|
|
||||||
|
if (dfile->fd >= 0 && dfile->fd != STDIN_FILENO)
|
||||||
|
close(dfile->fd);
|
||||||
|
MUTEX_DESTROY(&dfile->lock);
|
||||||
|
isc_mem_put(dfile->mctx, dfile, sizeof(*dfile));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_datafile_setpipefd(perf_datafile_t *dfile, int pipe_fd)
|
||||||
|
{
|
||||||
|
dfile->pipe_fd = pipe_fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_datafile_setmaxruns(perf_datafile_t *dfile, unsigned int maxruns)
|
||||||
|
{
|
||||||
|
dfile->maxruns = maxruns;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
reopen_file(perf_datafile_t *dfile)
|
||||||
|
{
|
||||||
|
if (dfile->cached) {
|
||||||
|
isc_buffer_first(&dfile->data);
|
||||||
|
} else {
|
||||||
|
if (lseek(dfile->fd, 0L, SEEK_SET) < 0)
|
||||||
|
perf_log_fatal("cannot reread input");
|
||||||
|
isc_buffer_clear(&dfile->data);
|
||||||
|
nul_terminate(dfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static isc_result_t
|
||||||
|
read_more(perf_datafile_t *dfile)
|
||||||
|
{
|
||||||
|
unsigned char *data;
|
||||||
|
size_t size;
|
||||||
|
ssize_t n;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
if (!dfile->is_file && dfile->pipe_fd >= 0) {
|
||||||
|
result = perf_os_waituntilreadable(dfile->fd, dfile->pipe_fd,
|
||||||
|
-1);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_buffer_compact(&dfile->data);
|
||||||
|
data = isc_buffer_used(&dfile->data);
|
||||||
|
size = isc_buffer_availablelength(&dfile->data);
|
||||||
|
|
||||||
|
n = read(dfile->fd, data, size);
|
||||||
|
if (n < 0)
|
||||||
|
return (ISC_R_FAILURE);
|
||||||
|
|
||||||
|
isc_buffer_add(&dfile->data, n);
|
||||||
|
nul_terminate(dfile);
|
||||||
|
|
||||||
|
if (dfile->is_file &&
|
||||||
|
isc_buffer_usedlength(&dfile->data) == dfile->size)
|
||||||
|
dfile->cached = ISC_TRUE;
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
static isc_result_t
|
||||||
|
read_one_line(perf_datafile_t *dfile, isc_buffer_t *lines)
|
||||||
|
{
|
||||||
|
const char *cur;
|
||||||
|
unsigned int length, curlen, nrem;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
while (ISC_TRUE) {
|
||||||
|
/* Get the current line */
|
||||||
|
cur = isc_buffer_current(&dfile->data);
|
||||||
|
curlen = strcspn(cur, "\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the current line contains the rest of the buffer,
|
||||||
|
* we need to read more (unless the full file is cached).
|
||||||
|
*/
|
||||||
|
nrem = isc_buffer_remaininglength(&dfile->data);
|
||||||
|
if (curlen == nrem) {
|
||||||
|
if (! dfile->cached) {
|
||||||
|
result = read_more(dfile);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
if (isc_buffer_remaininglength(&dfile->data) == 0) {
|
||||||
|
dfile->nruns++;
|
||||||
|
return (ISC_R_EOF);
|
||||||
|
}
|
||||||
|
if (isc_buffer_remaininglength(&dfile->data) > nrem)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We now have a line. Advance the buffer past it. */
|
||||||
|
isc_buffer_forward(&dfile->data, curlen);
|
||||||
|
if (isc_buffer_remaininglength(&dfile->data) > 0)
|
||||||
|
isc_buffer_forward(&dfile->data, 1);
|
||||||
|
|
||||||
|
/* If the line is empty or a comment, we need to try again. */
|
||||||
|
if (curlen > 0 && cur[0] != ';')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = isc_buffer_availablelength(lines);
|
||||||
|
if (curlen > length - 1)
|
||||||
|
curlen = length - 1;
|
||||||
|
isc_buffer_putmem(lines, cur, curlen);
|
||||||
|
isc_buffer_putuint8(lines, 0);
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
perf_datafile_next(perf_datafile_t *dfile, isc_buffer_t *lines,
|
||||||
|
isc_boolean_t is_update)
|
||||||
|
{
|
||||||
|
const char *current;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
LOCK(&dfile->lock);
|
||||||
|
|
||||||
|
if (dfile->maxruns > 0 && dfile->maxruns == dfile->nruns) {
|
||||||
|
result = ISC_R_EOF;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = read_one_line(dfile, lines);
|
||||||
|
if (result == ISC_R_EOF) {
|
||||||
|
if (!dfile->read_any) {
|
||||||
|
result = ISC_R_INVALIDFILE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (dfile->maxruns != dfile->nruns) {
|
||||||
|
reopen_file(dfile);
|
||||||
|
result = read_one_line(dfile, lines);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
dfile->read_any = ISC_TRUE;
|
||||||
|
|
||||||
|
if (is_update) {
|
||||||
|
while (ISC_TRUE) {
|
||||||
|
current = isc_buffer_current(lines);
|
||||||
|
result = read_one_line(dfile, lines);
|
||||||
|
if (result == ISC_R_EOF &&
|
||||||
|
dfile->maxruns != dfile->nruns) {
|
||||||
|
reopen_file(dfile);
|
||||||
|
}
|
||||||
|
if (result != ISC_R_SUCCESS ||
|
||||||
|
strcasecmp(current, "send") == 0)
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
result = ISC_R_SUCCESS;
|
||||||
|
done:
|
||||||
|
UNLOCK(&dfile->lock);
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
perf_datafile_nruns(const perf_datafile_t *dfile)
|
||||||
|
{
|
||||||
|
return dfile->nruns;
|
||||||
|
}
|
44
dns/dnsperf-src-2.0.0.0-1/datafile.h
Normal file
44
dns/dnsperf-src-2.0.0.0-1/datafile.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PERF_DATAFILE_H
|
||||||
|
#define PERF_DATAFILE_H 1
|
||||||
|
|
||||||
|
#include <isc/types.h>
|
||||||
|
|
||||||
|
typedef struct perf_datafile perf_datafile_t;
|
||||||
|
|
||||||
|
perf_datafile_t *
|
||||||
|
perf_datafile_open(isc_mem_t *mctx, const char *filename);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_datafile_close(perf_datafile_t **dfilep);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_datafile_setmaxruns(perf_datafile_t *dfile, unsigned int maxruns);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_datafile_setpipefd(perf_datafile_t *dfile, int pipe_fd);
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
perf_datafile_next(perf_datafile_t *dfile, isc_buffer_t *lines,
|
||||||
|
isc_boolean_t is_update);
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
perf_datafile_nruns(const perf_datafile_t *dfile);
|
||||||
|
|
||||||
|
#endif
|
849
dns/dnsperf-src-2.0.0.0-1/dns.c
Normal file
849
dns/dnsperf-src-2.0.0.0-1/dns.c
Normal file
|
@ -0,0 +1,849 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2000, 2001 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||||
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||||
|
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||||
|
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2004 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define ISC_BUFFER_USEINLINE
|
||||||
|
|
||||||
|
#include <isc/base64.h>
|
||||||
|
#include <isc/buffer.h>
|
||||||
|
#include <isc/hmacmd5.h>
|
||||||
|
#include <isc/hmacsha.h>
|
||||||
|
#include <isc/lex.h>
|
||||||
|
#include <isc/mem.h>
|
||||||
|
#include <isc/region.h>
|
||||||
|
#include <isc/result.h>
|
||||||
|
#include <isc/util.h>
|
||||||
|
|
||||||
|
#include <dns/callbacks.h>
|
||||||
|
#include <dns/fixedname.h>
|
||||||
|
#include <dns/message.h>
|
||||||
|
#include <dns/name.h>
|
||||||
|
#include <dns/rdata.h>
|
||||||
|
#include <dns/rdataclass.h>
|
||||||
|
#include <dns/rdatatype.h>
|
||||||
|
#include <dns/ttl.h>
|
||||||
|
|
||||||
|
#include "dns.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "opt.h"
|
||||||
|
|
||||||
|
#define WHITESPACE " \t\n"
|
||||||
|
|
||||||
|
#define MAX_RDATA_LENGTH 65535
|
||||||
|
#define EDNSLEN 11
|
||||||
|
|
||||||
|
const char *perf_dns_rcode_strings[] = {
|
||||||
|
"NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN",
|
||||||
|
"NOTIMP", "REFUSED", "YXDOMAIN", "YXRRSET",
|
||||||
|
"NXRRSET", "NOTAUTH", "NOTZONE", "rcode11",
|
||||||
|
"rcode12", "rcode13", "rcode14", "rcode15"
|
||||||
|
};
|
||||||
|
|
||||||
|
#define TSIG_HMACMD5_NAME "\010hmac-md5\007sig-alg\003reg\003int"
|
||||||
|
#define TSIG_HMACSHA1_NAME "\011hmac-sha1"
|
||||||
|
#define TSIG_HMACSHA224_NAME "\013hmac-sha224"
|
||||||
|
#define TSIG_HMACSHA256_NAME "\013hmac-sha256"
|
||||||
|
#define TSIG_HMACSHA384_NAME "\013hmac-sha384"
|
||||||
|
#define TSIG_HMACSHA512_NAME "\013hmac-sha512"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TSIG_HMACMD5,
|
||||||
|
TSIG_HMACSHA1,
|
||||||
|
TSIG_HMACSHA224,
|
||||||
|
TSIG_HMACSHA256,
|
||||||
|
TSIG_HMACSHA384,
|
||||||
|
TSIG_HMACSHA512
|
||||||
|
} hmac_type_t;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
isc_hmacmd5_t hmacmd5;
|
||||||
|
isc_hmacsha1_t hmacsha1;
|
||||||
|
isc_hmacsha224_t hmacsha224;
|
||||||
|
isc_hmacsha256_t hmacsha256;
|
||||||
|
isc_hmacsha384_t hmacsha384;
|
||||||
|
isc_hmacsha512_t hmacsha512;
|
||||||
|
} hmac_ctx_t;
|
||||||
|
|
||||||
|
struct perf_dnstsigkey {
|
||||||
|
isc_mem_t *mctx;
|
||||||
|
unsigned int alglen;
|
||||||
|
isc_constregion_t alg;
|
||||||
|
hmac_type_t hmactype;
|
||||||
|
unsigned int digestlen;
|
||||||
|
dns_fixedname_t fname;
|
||||||
|
dns_name_t *name;
|
||||||
|
unsigned char secretdata[256];
|
||||||
|
isc_buffer_t secret;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct perf_dnsctx {
|
||||||
|
isc_mem_t *mctx;
|
||||||
|
dns_compress_t compress;
|
||||||
|
isc_lex_t *lexer;
|
||||||
|
};
|
||||||
|
|
||||||
|
perf_dnsctx_t *
|
||||||
|
perf_dns_createctx(isc_boolean_t updates)
|
||||||
|
{
|
||||||
|
isc_mem_t *mctx;
|
||||||
|
perf_dnsctx_t *ctx;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
if (!updates)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
mctx = NULL;
|
||||||
|
result = isc_mem_create(0, 0, &mctx);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
perf_log_fatal("creating memory context: %s",
|
||||||
|
isc_result_totext(result));
|
||||||
|
|
||||||
|
ctx = isc_mem_get(mctx, sizeof(*ctx));
|
||||||
|
if (ctx == NULL)
|
||||||
|
perf_log_fatal("out of memory");
|
||||||
|
|
||||||
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
|
ctx->mctx = mctx;
|
||||||
|
|
||||||
|
result = dns_compress_init(&ctx->compress, 0, ctx->mctx);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_fatal("creating compression context: %s",
|
||||||
|
isc_result_totext(result));
|
||||||
|
}
|
||||||
|
dns_compress_setmethods(&ctx->compress, DNS_COMPRESS_GLOBAL14);
|
||||||
|
|
||||||
|
result = isc_lex_create(ctx->mctx, 1024, &ctx->lexer);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_fatal("creating lexer: %s",
|
||||||
|
isc_result_totext(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_dns_destroyctx(perf_dnsctx_t **ctxp)
|
||||||
|
{
|
||||||
|
perf_dnsctx_t *ctx;
|
||||||
|
isc_mem_t *mctx;
|
||||||
|
|
||||||
|
INSIST(ctxp != NULL);
|
||||||
|
ctx = *ctxp;
|
||||||
|
*ctxp = NULL;
|
||||||
|
|
||||||
|
if (ctx == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mctx = ctx->mctx;
|
||||||
|
isc_lex_destroy(&ctx->lexer);
|
||||||
|
dns_compress_invalidate(&ctx->compress);
|
||||||
|
isc_mem_put(mctx, ctx, sizeof(*ctx));
|
||||||
|
isc_mem_destroy(&mctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static isc_result_t
|
||||||
|
name_fromstring(dns_name_t *name, dns_name_t *origin,
|
||||||
|
const char *str, unsigned int len,
|
||||||
|
isc_buffer_t *target, const char *type)
|
||||||
|
{
|
||||||
|
isc_buffer_t buffer;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
isc_buffer_init(&buffer, str, len);
|
||||||
|
isc_buffer_add(&buffer, len);
|
||||||
|
result = dns_name_fromtext(name, &buffer, origin, 0, target);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
perf_log_warning("invalid %s name: %.*s", type, (int)len, str);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SET_KEY(key, type) do { \
|
||||||
|
(key)->alg.base = TSIG_HMAC ## type ## _NAME; \
|
||||||
|
(key)->alg.length = sizeof(TSIG_HMAC ## type ## _NAME); \
|
||||||
|
(key)->hmactype = TSIG_HMAC ## type; \
|
||||||
|
(key)->digestlen = ISC_ ## type ## _DIGESTLENGTH; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
perf_dnstsigkey_t *
|
||||||
|
perf_dns_parsetsigkey(const char *arg, isc_mem_t *mctx)
|
||||||
|
{
|
||||||
|
perf_dnstsigkey_t *tsigkey;
|
||||||
|
const char *sep1, *sep2, *alg, *name, *secret;
|
||||||
|
int alglen, namelen;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
tsigkey = isc_mem_get(mctx, sizeof (*tsigkey));
|
||||||
|
if (tsigkey == NULL)
|
||||||
|
perf_log_fatal("out of memory");
|
||||||
|
memset(tsigkey, 0, sizeof (*tsigkey));
|
||||||
|
tsigkey->mctx = mctx;
|
||||||
|
|
||||||
|
sep1 = strchr(arg, ':');
|
||||||
|
if (sep1 == NULL) {
|
||||||
|
perf_log_warning("invalid TSIG [alg:]name:secret");
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sep2 = strchr(sep1 + 1, ':');
|
||||||
|
if (sep2 == NULL) {
|
||||||
|
/* name:key */
|
||||||
|
alg = NULL;
|
||||||
|
alglen = 0;
|
||||||
|
name = arg;
|
||||||
|
namelen = sep1 - arg;
|
||||||
|
secret = sep1 + 1;
|
||||||
|
} else {
|
||||||
|
/* [alg:]name:secret */
|
||||||
|
alg = arg;
|
||||||
|
alglen = sep1 - arg;
|
||||||
|
name = sep1 + 1;
|
||||||
|
namelen = sep2 - sep1 - 1;
|
||||||
|
secret = sep2 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Algorithm */
|
||||||
|
|
||||||
|
if (alg == NULL || strncasecmp(alg, "hmac-md5:", 9) == 0) {
|
||||||
|
SET_KEY(tsigkey, MD5);
|
||||||
|
} else if (strncasecmp(alg, "hmac-sha1:", 10) == 0) {
|
||||||
|
SET_KEY(tsigkey, SHA1);
|
||||||
|
} else if (strncasecmp(alg, "hmac-sha224:", 12) == 0) {
|
||||||
|
SET_KEY(tsigkey, SHA224);
|
||||||
|
} else if (strncasecmp(alg, "hmac-sha256:", 12) == 0) {
|
||||||
|
SET_KEY(tsigkey, SHA256);
|
||||||
|
} else if (strncasecmp(alg, "hmac-sha384:", 12) == 0) {
|
||||||
|
SET_KEY(tsigkey, SHA384);
|
||||||
|
} else if (strncasecmp(alg, "hmac-sha512:", 12) == 0) {
|
||||||
|
SET_KEY(tsigkey, SHA512);
|
||||||
|
} else {
|
||||||
|
perf_log_warning("invalid TSIG algorithm %.*s", alglen, alg);
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Name */
|
||||||
|
|
||||||
|
dns_fixedname_init(&tsigkey->fname);
|
||||||
|
tsigkey->name = dns_fixedname_name(&tsigkey->fname);
|
||||||
|
result = name_fromstring(tsigkey->name, dns_rootname, name, namelen,
|
||||||
|
NULL, "TSIG key");
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
(void)dns_name_downcase(tsigkey->name, tsigkey->name, NULL);
|
||||||
|
|
||||||
|
/* Secret */
|
||||||
|
|
||||||
|
isc_buffer_init(&tsigkey->secret, tsigkey->secretdata,
|
||||||
|
sizeof(tsigkey->secretdata));
|
||||||
|
result = isc_base64_decodestring(secret, &tsigkey->secret);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_warning("invalid TSIG secret '%s'", secret);
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tsigkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_dns_destroytsigkey(perf_dnstsigkey_t **tsigkeyp)
|
||||||
|
{
|
||||||
|
perf_dnstsigkey_t *tsigkey;
|
||||||
|
|
||||||
|
INSIST(tsigkeyp != NULL && *tsigkeyp != NULL);
|
||||||
|
|
||||||
|
tsigkey = *tsigkeyp;
|
||||||
|
*tsigkeyp = NULL;
|
||||||
|
|
||||||
|
isc_mem_put(tsigkey->mctx, tsigkey, sizeof(*tsigkey));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Appends an OPT record to the packet.
|
||||||
|
*/
|
||||||
|
static isc_result_t
|
||||||
|
add_edns(isc_buffer_t *packet, isc_boolean_t dnssec) {
|
||||||
|
unsigned char *base;
|
||||||
|
|
||||||
|
if (isc_buffer_availablelength(packet) < EDNSLEN) {
|
||||||
|
perf_log_warning("failed to add OPT to query packet");
|
||||||
|
return (ISC_R_NOSPACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
base = isc_buffer_base(packet);
|
||||||
|
|
||||||
|
isc_buffer_putuint8(packet, 0); /* root name */
|
||||||
|
isc_buffer_putuint16(packet, dns_rdatatype_opt);/* type */
|
||||||
|
isc_buffer_putuint16(packet, MAX_EDNS_PACKET); /* class */
|
||||||
|
isc_buffer_putuint8(packet, 0); /* xrcode */
|
||||||
|
isc_buffer_putuint8(packet, 0); /* version */
|
||||||
|
if (dnssec) /* flags */
|
||||||
|
isc_buffer_putuint16(packet, 0x8000);
|
||||||
|
else
|
||||||
|
isc_buffer_putuint16(packet, 0);
|
||||||
|
isc_buffer_putuint16(packet, 0); /* rdlen */
|
||||||
|
|
||||||
|
base[11]++; /* increment record count */
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
hmac_init(perf_dnstsigkey_t *tsigkey, hmac_ctx_t *ctx)
|
||||||
|
{
|
||||||
|
unsigned char *secret;
|
||||||
|
unsigned int length;
|
||||||
|
|
||||||
|
secret = isc_buffer_base(&tsigkey->secret);
|
||||||
|
length = isc_buffer_usedlength(&tsigkey->secret);
|
||||||
|
|
||||||
|
switch (tsigkey->hmactype) {
|
||||||
|
case TSIG_HMACMD5:
|
||||||
|
isc_hmacmd5_init(&ctx->hmacmd5, secret, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA1:
|
||||||
|
isc_hmacsha1_init(&ctx->hmacsha1, secret, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA224:
|
||||||
|
isc_hmacsha224_init(&ctx->hmacsha224, secret, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA256:
|
||||||
|
isc_hmacsha256_init(&ctx->hmacsha256, secret, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA384:
|
||||||
|
isc_hmacsha384_init(&ctx->hmacsha384, secret, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA512:
|
||||||
|
isc_hmacsha512_init(&ctx->hmacsha512, secret, length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
hmac_update(perf_dnstsigkey_t *tsigkey, hmac_ctx_t *ctx,
|
||||||
|
unsigned char *data, unsigned int length)
|
||||||
|
{
|
||||||
|
switch (tsigkey->hmactype) {
|
||||||
|
case TSIG_HMACMD5:
|
||||||
|
isc_hmacmd5_update(&ctx->hmacmd5, data, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA1:
|
||||||
|
isc_hmacsha1_update(&ctx->hmacsha1, data, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA224:
|
||||||
|
isc_hmacsha224_update(&ctx->hmacsha224, data, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA256:
|
||||||
|
isc_hmacsha256_update(&ctx->hmacsha256, data, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA384:
|
||||||
|
isc_hmacsha384_update(&ctx->hmacsha384, data, length);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA512:
|
||||||
|
isc_hmacsha512_update(&ctx->hmacsha512, data, length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
hmac_sign(perf_dnstsigkey_t *tsigkey, hmac_ctx_t *ctx, unsigned char *digest,
|
||||||
|
unsigned int digestlen)
|
||||||
|
{
|
||||||
|
switch (tsigkey->hmactype) {
|
||||||
|
case TSIG_HMACMD5:
|
||||||
|
isc_hmacmd5_sign(&ctx->hmacmd5, digest);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA1:
|
||||||
|
isc_hmacsha1_sign(&ctx->hmacsha1, digest, digestlen);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA224:
|
||||||
|
isc_hmacsha224_sign(&ctx->hmacsha224, digest, digestlen);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA256:
|
||||||
|
isc_hmacsha256_sign(&ctx->hmacsha256, digest, digestlen);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA384:
|
||||||
|
isc_hmacsha384_sign(&ctx->hmacsha384, digest, digestlen);
|
||||||
|
break;
|
||||||
|
case TSIG_HMACSHA512:
|
||||||
|
isc_hmacsha512_sign(&ctx->hmacsha512, digest, digestlen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Appends a TSIG record to the packet.
|
||||||
|
*/
|
||||||
|
static isc_result_t
|
||||||
|
add_tsig(isc_buffer_t *packet, perf_dnstsigkey_t *tsigkey)
|
||||||
|
{
|
||||||
|
unsigned char *base;
|
||||||
|
hmac_ctx_t hmac;
|
||||||
|
isc_region_t name_r;
|
||||||
|
isc_region_t *alg_r;
|
||||||
|
unsigned int rdlen, totallen;
|
||||||
|
unsigned char tmpdata[512];
|
||||||
|
isc_buffer_t tmp;
|
||||||
|
isc_uint32_t now;
|
||||||
|
unsigned char digest[ISC_SHA256_DIGESTLENGTH];
|
||||||
|
|
||||||
|
hmac_init(tsigkey, &hmac);
|
||||||
|
now = time(NULL);
|
||||||
|
dns_name_toregion(tsigkey->name, &name_r);
|
||||||
|
alg_r = (isc_region_t *) &tsigkey->alg;
|
||||||
|
|
||||||
|
/* Make sure everything will fit */
|
||||||
|
rdlen = tsigkey->alglen + 16 + tsigkey->digestlen;
|
||||||
|
totallen = name_r.length + 10 + rdlen;
|
||||||
|
if (totallen > isc_buffer_availablelength(packet)) {
|
||||||
|
perf_log_warning("adding TSIG: out of space");
|
||||||
|
return (ISC_R_NOSPACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
base = isc_buffer_base(packet);
|
||||||
|
|
||||||
|
/* Digest the message */
|
||||||
|
hmac_update(tsigkey, &hmac, isc_buffer_base(packet),
|
||||||
|
isc_buffer_usedlength(packet));
|
||||||
|
|
||||||
|
/* Digest the TSIG record */
|
||||||
|
isc_buffer_init(&tmp, tmpdata, sizeof tmpdata);
|
||||||
|
isc_buffer_copyregion(&tmp, &name_r); /* name */
|
||||||
|
isc_buffer_putuint16(&tmp, dns_rdataclass_any); /* class */
|
||||||
|
isc_buffer_putuint32(&tmp, 0); /* ttl */
|
||||||
|
isc_buffer_copyregion(&tmp, alg_r); /* alg */
|
||||||
|
isc_buffer_putuint16(&tmp, 0); /* time high */
|
||||||
|
isc_buffer_putuint32(&tmp, now); /* time low */
|
||||||
|
isc_buffer_putuint16(&tmp, 300); /* fudge */
|
||||||
|
isc_buffer_putuint16(&tmp, 0); /* error */
|
||||||
|
isc_buffer_putuint16(&tmp, 0); /* other length */
|
||||||
|
hmac_update(tsigkey, &hmac, isc_buffer_base(&tmp),
|
||||||
|
isc_buffer_usedlength(&tmp));
|
||||||
|
hmac_sign(tsigkey, &hmac, digest, tsigkey->digestlen);
|
||||||
|
|
||||||
|
/* Add the TSIG record. */
|
||||||
|
isc_buffer_copyregion(packet, &name_r); /* name */
|
||||||
|
isc_buffer_putuint16(packet, dns_rdatatype_tsig); /* type */
|
||||||
|
isc_buffer_putuint16(packet, dns_rdataclass_any); /* class */
|
||||||
|
isc_buffer_putuint32(packet, 0); /* ttl */
|
||||||
|
isc_buffer_putuint16(packet, rdlen); /* rdlen */
|
||||||
|
isc_buffer_copyregion(packet, alg_r); /* alg */
|
||||||
|
isc_buffer_putuint16(packet, 0); /* time high */
|
||||||
|
isc_buffer_putuint32(packet, now); /* time low */
|
||||||
|
isc_buffer_putuint16(packet, 300); /* fudge */
|
||||||
|
isc_buffer_putuint16(packet, tsigkey->digestlen); /* digest len */
|
||||||
|
isc_buffer_putmem(packet, digest, tsigkey->digestlen); /* digest */
|
||||||
|
isc_buffer_putmem(packet, base, 2); /* orig ID */
|
||||||
|
isc_buffer_putuint16(packet, 0); /* error */
|
||||||
|
isc_buffer_putuint16(packet, 0); /* other len */
|
||||||
|
|
||||||
|
base[11]++; /* increment record count */
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
static isc_result_t
|
||||||
|
build_query(const isc_textregion_t *line, isc_buffer_t *msg)
|
||||||
|
{
|
||||||
|
char *domain_str;
|
||||||
|
int domain_len;
|
||||||
|
dns_name_t name;
|
||||||
|
dns_offsets_t offsets;
|
||||||
|
isc_textregion_t qtype_r;
|
||||||
|
dns_rdatatype_t qtype;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
domain_str = line->base;
|
||||||
|
domain_len = strcspn(line->base, WHITESPACE);
|
||||||
|
|
||||||
|
qtype_r.base = line->base + domain_len;
|
||||||
|
while (isspace(*qtype_r.base & 0xff))
|
||||||
|
qtype_r.base++;
|
||||||
|
qtype_r.length = strcspn(qtype_r.base, WHITESPACE);
|
||||||
|
|
||||||
|
/* Create the question section */
|
||||||
|
DNS_NAME_INIT(&name, offsets);
|
||||||
|
result = name_fromstring(&name, dns_rootname, domain_str, domain_len,
|
||||||
|
msg, "domain");
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
|
||||||
|
if (qtype_r.length == 0) {
|
||||||
|
perf_log_warning("invalid query input format: %s", line->base);
|
||||||
|
return (ISC_R_FAILURE);
|
||||||
|
}
|
||||||
|
result = dns_rdatatype_fromtext(&qtype, &qtype_r);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_warning("invalid query type: %.*s",
|
||||||
|
(int) qtype_r.length, qtype_r.base);
|
||||||
|
return (ISC_R_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_buffer_putuint16(msg, qtype);
|
||||||
|
isc_buffer_putuint16(msg, dns_rdataclass_in);
|
||||||
|
|
||||||
|
return ISC_R_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static isc_boolean_t
|
||||||
|
token_equals(const isc_textregion_t *token, const char *str)
|
||||||
|
{
|
||||||
|
return (strlen(str) == token->length &&
|
||||||
|
strncasecmp(str, token->base, token->length) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reads one line containing an individual update for a dynamic update message.
|
||||||
|
*/
|
||||||
|
static isc_result_t
|
||||||
|
read_update_line(perf_dnsctx_t *ctx, const isc_textregion_t *line, char *str,
|
||||||
|
dns_name_t *zname, int want_ttl, int need_type,
|
||||||
|
int want_rdata, int need_rdata, dns_name_t *name,
|
||||||
|
isc_uint32_t *ttlp, dns_rdatatype_t *typep,
|
||||||
|
dns_rdata_t *rdata, isc_buffer_t *rdatabuf)
|
||||||
|
{
|
||||||
|
char *curr_str;
|
||||||
|
unsigned int curr_len;
|
||||||
|
isc_buffer_t buffer;
|
||||||
|
isc_textregion_t src;
|
||||||
|
dns_rdatacallbacks_t callbacks;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
while (isspace(*str & 0xff))
|
||||||
|
str++;
|
||||||
|
|
||||||
|
/* Read the owner name */
|
||||||
|
curr_str = str;
|
||||||
|
curr_len = strcspn(curr_str, WHITESPACE);
|
||||||
|
result = name_fromstring(name, zname, curr_str, curr_len, NULL,
|
||||||
|
"owner");
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
str += curr_len;
|
||||||
|
while (isspace(*str & 0xff))
|
||||||
|
str++;
|
||||||
|
|
||||||
|
/* Read the ttl */
|
||||||
|
if (want_ttl) {
|
||||||
|
curr_str = str;
|
||||||
|
curr_len = strcspn(curr_str, WHITESPACE);
|
||||||
|
src.base = curr_str;
|
||||||
|
src.length = curr_len;
|
||||||
|
result = dns_ttl_fromtext(&src, ttlp);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_warning("invalid ttl: %.*s",
|
||||||
|
curr_len, curr_str);
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
str += curr_len;
|
||||||
|
while (isspace(*str & 0xff))
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the type */
|
||||||
|
curr_str = str;
|
||||||
|
curr_len = strcspn(curr_str, WHITESPACE);
|
||||||
|
if (curr_len == 0) {
|
||||||
|
if (!need_type)
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
perf_log_warning("invalid update command: %s", line->base);
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
src.base = curr_str;
|
||||||
|
src.length = curr_len;
|
||||||
|
result = dns_rdatatype_fromtext(typep, &src);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_warning("invalid type: %.*s", curr_len, curr_str);
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
str += curr_len;
|
||||||
|
while (isspace(*str & 0xff))
|
||||||
|
str++;
|
||||||
|
|
||||||
|
/* Read the rdata */
|
||||||
|
if (!want_rdata)
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
if (*str == 0) {
|
||||||
|
if (!need_rdata)
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
perf_log_warning("invalid update command: %s\n", line->base);
|
||||||
|
return (ISC_R_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_buffer_init(&buffer, str, strlen(str));
|
||||||
|
isc_buffer_add(&buffer, strlen(str));
|
||||||
|
result = isc_lex_openbuffer(ctx->lexer, &buffer);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_warning("setting up lexer: %s",
|
||||||
|
isc_result_totext(result));
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
dns_rdatacallbacks_init_stdio(&callbacks);
|
||||||
|
result = dns_rdata_fromtext(rdata, dns_rdataclass_in, *typep,
|
||||||
|
ctx->lexer, zname, 0, ctx->mctx, rdatabuf,
|
||||||
|
&callbacks);
|
||||||
|
(void)isc_lex_close(ctx->lexer);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_warning("parsing rdata: %s", str);
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reads a complete dynamic update message and sends it.
|
||||||
|
*/
|
||||||
|
static isc_result_t
|
||||||
|
build_update(perf_dnsctx_t *ctx, const isc_textregion_t *record,
|
||||||
|
isc_buffer_t *msg)
|
||||||
|
{
|
||||||
|
isc_textregion_t input;
|
||||||
|
char *msgbase;
|
||||||
|
isc_buffer_t rdlenbuf, rdatabuf;
|
||||||
|
unsigned char rdataarray[MAX_RDATA_LENGTH];
|
||||||
|
isc_textregion_t token;
|
||||||
|
char *str;
|
||||||
|
isc_boolean_t is_update;
|
||||||
|
int updates = 0;
|
||||||
|
int prereqs = 0;
|
||||||
|
dns_fixedname_t fzname, foname;
|
||||||
|
dns_name_t *zname, *oname;
|
||||||
|
isc_uint32_t ttl;
|
||||||
|
dns_rdatatype_t rdtype;
|
||||||
|
dns_rdataclass_t rdclass;
|
||||||
|
dns_rdata_t rdata;
|
||||||
|
isc_uint16_t rdlen;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
/* Reset compression context */
|
||||||
|
dns_compress_rollback(&ctx->compress, 0);
|
||||||
|
|
||||||
|
input = *record;
|
||||||
|
msgbase = isc_buffer_base(msg);
|
||||||
|
|
||||||
|
/* Initialize */
|
||||||
|
|
||||||
|
dns_fixedname_init(&foname);
|
||||||
|
oname = dns_fixedname_name(&foname);
|
||||||
|
|
||||||
|
/* Parse zone name */
|
||||||
|
dns_fixedname_init(&fzname);
|
||||||
|
zname = dns_fixedname_name(&fzname);
|
||||||
|
result = name_fromstring(zname, dns_rootname,
|
||||||
|
input.base, strlen(input.base),
|
||||||
|
NULL, "zone");
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
/* Render zone section */
|
||||||
|
result = dns_name_towire(zname, &ctx->compress, msg);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_warning("error rendering zone name: %s",
|
||||||
|
isc_result_totext(result));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
isc_buffer_putuint16(msg, dns_rdatatype_soa);
|
||||||
|
isc_buffer_putuint16(msg, dns_rdataclass_in);
|
||||||
|
|
||||||
|
while (ISC_TRUE) {
|
||||||
|
input.base += strlen(input.base) + 1;
|
||||||
|
if (input.base >= record->base + record->length) {
|
||||||
|
perf_log_warning("warning: incomplete update");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
ttl = 0;
|
||||||
|
rdtype = dns_rdatatype_any;
|
||||||
|
isc_buffer_init(&rdatabuf, rdataarray, sizeof(rdataarray));
|
||||||
|
dns_rdata_init(&rdata);
|
||||||
|
rdlen = 0;
|
||||||
|
rdclass = dns_rdataclass_in;
|
||||||
|
is_update = ISC_FALSE;
|
||||||
|
|
||||||
|
token.base = input.base;
|
||||||
|
token.length = strcspn(token.base, WHITESPACE);
|
||||||
|
str = input.base + token.length;
|
||||||
|
if (token_equals(&token, "send")) {
|
||||||
|
break;
|
||||||
|
} else if (token_equals(&token, "add")) {
|
||||||
|
result = read_update_line(ctx, &input, str, zname,
|
||||||
|
ISC_TRUE,
|
||||||
|
ISC_TRUE, ISC_TRUE, ISC_TRUE,
|
||||||
|
oname, &ttl, &rdtype,
|
||||||
|
&rdata, &rdatabuf);
|
||||||
|
rdclass = dns_rdataclass_in;
|
||||||
|
is_update = ISC_TRUE;
|
||||||
|
} else if (token_equals(&token, "delete")) {
|
||||||
|
result = read_update_line(ctx, &input, str, zname,
|
||||||
|
ISC_FALSE,
|
||||||
|
ISC_FALSE, ISC_TRUE,
|
||||||
|
ISC_FALSE, oname, &ttl,
|
||||||
|
&rdtype, &rdata, &rdatabuf);
|
||||||
|
if (isc_buffer_usedlength(&rdatabuf) > 0)
|
||||||
|
rdclass = dns_rdataclass_none;
|
||||||
|
else
|
||||||
|
rdclass = dns_rdataclass_any;
|
||||||
|
is_update = ISC_TRUE;
|
||||||
|
} else if (token_equals(&token, "require")) {
|
||||||
|
result = read_update_line(ctx, &input, str, zname,
|
||||||
|
ISC_FALSE,
|
||||||
|
ISC_FALSE, ISC_TRUE,
|
||||||
|
ISC_FALSE, oname, &ttl,
|
||||||
|
&rdtype, &rdata, &rdatabuf);
|
||||||
|
if (isc_buffer_usedlength(&rdatabuf) > 0)
|
||||||
|
rdclass = dns_rdataclass_in;
|
||||||
|
else
|
||||||
|
rdclass = dns_rdataclass_any;
|
||||||
|
is_update = ISC_FALSE;
|
||||||
|
} else if (token_equals(&token, "prohibit")) {
|
||||||
|
result = read_update_line(ctx, &input, str, zname,
|
||||||
|
ISC_FALSE,
|
||||||
|
ISC_FALSE, ISC_FALSE,
|
||||||
|
ISC_FALSE, oname, &ttl,
|
||||||
|
&rdtype, &rdata, &rdatabuf);
|
||||||
|
rdclass = dns_rdataclass_none;
|
||||||
|
is_update = ISC_FALSE;
|
||||||
|
} else {
|
||||||
|
perf_log_warning("invalid update command: %s",
|
||||||
|
input.base);
|
||||||
|
result = ISC_R_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
if (!is_update && updates > 0) {
|
||||||
|
perf_log_warning("prereqs must precede updates");
|
||||||
|
result = ISC_R_FAILURE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Render record */
|
||||||
|
result = dns_name_towire(oname, &ctx->compress, msg);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_warning("rendering record name: %s",
|
||||||
|
isc_result_totext(result));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (isc_buffer_availablelength(msg) < 10) {
|
||||||
|
perf_log_warning("out of space in message buffer");
|
||||||
|
result = ISC_R_NOSPACE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_buffer_putuint16(msg, rdtype);
|
||||||
|
isc_buffer_putuint16(msg, rdclass);
|
||||||
|
isc_buffer_putuint32(msg, ttl);
|
||||||
|
rdlenbuf = *msg;
|
||||||
|
isc_buffer_putuint16(msg, 0); /* rdlen */
|
||||||
|
rdlen = isc_buffer_usedlength(&rdatabuf);
|
||||||
|
if (rdlen > 0) {
|
||||||
|
result = dns_rdata_towire(&rdata, &ctx->compress, msg);
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
perf_log_warning("rendering rdata: %s",
|
||||||
|
isc_result_totext(result));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
rdlen = msg->used - rdlenbuf.used - 2;
|
||||||
|
isc_buffer_putuint16(&rdlenbuf, rdlen);
|
||||||
|
}
|
||||||
|
if (is_update)
|
||||||
|
updates++;
|
||||||
|
else
|
||||||
|
prereqs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
msgbase[7] = prereqs; /* ANCOUNT = number of prereqs */
|
||||||
|
msgbase[9] = updates; /* AUCOUNT = number of updates */
|
||||||
|
|
||||||
|
result = ISC_R_SUCCESS;
|
||||||
|
|
||||||
|
done:
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
perf_dns_buildrequest(perf_dnsctx_t *ctx, const isc_textregion_t *record,
|
||||||
|
isc_uint16_t qid,
|
||||||
|
isc_boolean_t edns, isc_boolean_t dnssec,
|
||||||
|
perf_dnstsigkey_t *tsigkey, isc_buffer_t *msg)
|
||||||
|
{
|
||||||
|
unsigned int flags;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
if (ctx != NULL)
|
||||||
|
flags = dns_opcode_update << 11;
|
||||||
|
else
|
||||||
|
flags = DNS_MESSAGEFLAG_RD;
|
||||||
|
|
||||||
|
/* Create the DNS packet header */
|
||||||
|
isc_buffer_putuint16(msg, qid);
|
||||||
|
isc_buffer_putuint16(msg, flags); /* flags */
|
||||||
|
isc_buffer_putuint16(msg, 1); /* qdcount */
|
||||||
|
isc_buffer_putuint16(msg, 0); /* ancount */
|
||||||
|
isc_buffer_putuint16(msg, 0); /* aucount */
|
||||||
|
isc_buffer_putuint16(msg, 0); /* arcount */
|
||||||
|
|
||||||
|
if (ctx != NULL) {
|
||||||
|
result = build_update(ctx, record, msg);
|
||||||
|
} else {
|
||||||
|
result = build_query(record, msg);
|
||||||
|
}
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
|
||||||
|
if (edns) {
|
||||||
|
result = add_edns(msg, dnssec);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsigkey != NULL) {
|
||||||
|
result = add_tsig(msg, tsigkey);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
66
dns/dnsperf-src-2.0.0.0-1/dns.h
Normal file
66
dns/dnsperf-src-2.0.0.0-1/dns.h
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2000, 2001 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||||
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||||
|
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||||
|
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2004 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <isc/types.h>
|
||||||
|
|
||||||
|
#ifndef PERF_DNS_H
|
||||||
|
#define PERF_DNS_H 1
|
||||||
|
|
||||||
|
#define MAX_UDP_PACKET 512
|
||||||
|
#define MAX_EDNS_PACKET 4096
|
||||||
|
|
||||||
|
typedef struct perf_dnstsigkey perf_dnstsigkey_t;
|
||||||
|
typedef struct perf_dnsctx perf_dnsctx_t;
|
||||||
|
|
||||||
|
extern const char *perf_dns_rcode_strings[];
|
||||||
|
|
||||||
|
perf_dnstsigkey_t *
|
||||||
|
perf_dns_parsetsigkey(const char *arg, isc_mem_t *mctx);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_dns_destroytsigkey(perf_dnstsigkey_t **tsigkeyp);
|
||||||
|
|
||||||
|
perf_dnsctx_t *
|
||||||
|
perf_dns_createctx(isc_boolean_t updates);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_dns_destroyctx(perf_dnsctx_t **ctxp);
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
perf_dns_buildrequest(perf_dnsctx_t *ctx, const isc_textregion_t *record,
|
||||||
|
isc_uint16_t qid,
|
||||||
|
isc_boolean_t edns, isc_boolean_t dnssec,
|
||||||
|
perf_dnstsigkey_t *tsigkey, isc_buffer_t *msg);
|
||||||
|
|
||||||
|
#endif
|
304
dns/dnsperf-src-2.0.0.0-1/dnsperf.1
Normal file
304
dns/dnsperf-src-2.0.0.0-1/dnsperf.1
Normal file
|
@ -0,0 +1,304 @@
|
||||||
|
.\" Copyright (C) Nominum, Inc.
|
||||||
|
.\"
|
||||||
|
.\" All rights reserved.
|
||||||
|
.TH DNSPERF 1 "Jan 10, 2012" Nominum Nominum
|
||||||
|
.SH NAME
|
||||||
|
\%dnsperf - test the performance of a DNS server
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.hy 0
|
||||||
|
.ad l
|
||||||
|
\fBdnsperf\fR\ [\fB\-a\ \fIlocal_addr\fR\fR]
|
||||||
|
[\fB\-b\ \fIbufsize\fR\fR]
|
||||||
|
[\fB\-c\ \fIclients\fR\fR]
|
||||||
|
[\fB\-d\ \fIdatafile\fR\fR]
|
||||||
|
[\fB\-D\fR]
|
||||||
|
[\fB\-e\fR]
|
||||||
|
[\fB\-f\ \fIfamily\fR\fR]
|
||||||
|
[\fB\-h\fR]
|
||||||
|
[\fB\-l\ \fIlimit\fR\fR]
|
||||||
|
[\fB\-n\ \fIruns_through_file\fR\fR]
|
||||||
|
[\fB\-p\ \fIport\fR\fR]
|
||||||
|
[\fB\-q\ \fInum_queries\fR\fR]
|
||||||
|
[\fB\-Q\ \fImax_qps\fR\fR]
|
||||||
|
[\fB\-s\ \fIserver_addr\fR\fR]
|
||||||
|
[\fB\-S\ \fIstats_interval\fR\fR]
|
||||||
|
[\fB\-t\ \fItimeout\fR\fR]
|
||||||
|
[\fB\-u\fR]
|
||||||
|
[\fB\-v\fR]
|
||||||
|
[\fB\-x\ \fIlocal_port\fR\fR]
|
||||||
|
[\fB\-y\ \fI[alg:]name:secret\fR\fR]
|
||||||
|
.ad
|
||||||
|
.hy
|
||||||
|
.SH DESCRIPTION
|
||||||
|
\fBdnsperf\fR is a DNS server performance testing tool. It is primarily
|
||||||
|
intended for measuring the performance of authoritative DNS servers, but it
|
||||||
|
can also be used for measuring caching server performance in a closed
|
||||||
|
laboratory environment. For testing caching servers resolving against the
|
||||||
|
live Internet, the \fBresperf\fR program is preferred.
|
||||||
|
|
||||||
|
It is recommended that \fBdnsperf\fR and the name server under test be run
|
||||||
|
on separate machines, so that the CPU usage of \fBdnsperf\fR itself does not
|
||||||
|
slow down the name server. The two machines should be connected with a fast
|
||||||
|
network, preferably a dedicated Gigabit Ethernet segment. Testing through a
|
||||||
|
router or firewall is not advisable.
|
||||||
|
.SS "Configuring the name server"
|
||||||
|
If using \fBdnsperf\fR to test an authoritative server, the name server
|
||||||
|
under test should be set up to serve one or more zones similar in size and
|
||||||
|
number to what the server is expected to serve in production.
|
||||||
|
|
||||||
|
Also, be sure to turn off recursion in the server's configuration (in BIND
|
||||||
|
8/9, specify "recursion no;" in the options block). In BIND 8, you should
|
||||||
|
also specify "fetch-glue no;"; otherwise the server may attempt to retrieve
|
||||||
|
glue information from the Internet during the test, slowing it down by an
|
||||||
|
unpredictable factor.
|
||||||
|
.SS "Constructing a query input file"
|
||||||
|
A \fBdnsperf\fR input file should contain a large and realistic set of
|
||||||
|
queries, on the order of ten thousand to a million. The input file contains
|
||||||
|
one line per query, consisting of a domain name and an RR type name
|
||||||
|
separated by a space. The class of the query is implicitly IN.
|
||||||
|
|
||||||
|
When measuring the performance serving non-terminal zones such as the root
|
||||||
|
zone or TLDs, note that such servers spend most of their time providing
|
||||||
|
referral responses, not authoritative answers. Therefore, a realistic input
|
||||||
|
file might consist mostly of queries for type A for names *below*, not at,
|
||||||
|
the delegations present in the zone. For example, when testing the
|
||||||
|
performance of a server configured to be authoritative for the top-level
|
||||||
|
domain "fi.", which contains delegations for domains like "helsinki.fi" and
|
||||||
|
"turku.fi", the input file could contain lines like
|
||||||
|
.RS
|
||||||
|
.hy 0
|
||||||
|
|
||||||
|
.nf
|
||||||
|
www.turku.fi A
|
||||||
|
www.helsinki.fi A
|
||||||
|
.fi
|
||||||
|
.hy
|
||||||
|
.RE
|
||||||
|
|
||||||
|
where the "www" prefix ensures that the server will respond with a referral.
|
||||||
|
Ideally, a realistic proportion of queries for nonexistent domains should be
|
||||||
|
mixed in with those for existing ones, and the lines of the input file
|
||||||
|
should be in a random order.
|
||||||
|
.SS "Constructing a dynamic update input file"
|
||||||
|
To test dynamic update performance, \fBdnsperf\fR is run with the \fB\-u\fR
|
||||||
|
option, and the input file is constructed of blocks of lines describing
|
||||||
|
dynamic update messages. The first line in a block contains the zone name:
|
||||||
|
.RS
|
||||||
|
.hy 0
|
||||||
|
|
||||||
|
.nf
|
||||||
|
example.com
|
||||||
|
.fi
|
||||||
|
.hy
|
||||||
|
.RE
|
||||||
|
|
||||||
|
Subsequent lines contain prerequisites, if there are any. Prerequisites can
|
||||||
|
specify that a name may or may not exist, an rrset may or may not exist, or
|
||||||
|
an rrset exists and its rdata matches all specified rdata for that name and
|
||||||
|
type. The keywords "require" and "prohibit" are followed by the appropriate
|
||||||
|
information. All relative names are considered to be relative to the zone
|
||||||
|
name. The following lines show the 5 types of prerequisites.
|
||||||
|
.RS
|
||||||
|
.hy 0
|
||||||
|
|
||||||
|
.nf
|
||||||
|
require a
|
||||||
|
require a A
|
||||||
|
require a A 1.2.3.4
|
||||||
|
prohibit x
|
||||||
|
prohibit x A
|
||||||
|
.fi
|
||||||
|
.hy
|
||||||
|
.RE
|
||||||
|
|
||||||
|
Subsequent lines contain records to be added, records to be deleted, rrsets
|
||||||
|
to be deleted, or names to be deleted. The keywords "add" or "delete" are
|
||||||
|
followed by the appropriate information. All relative names are considered
|
||||||
|
to be relative to the zone name. The following lines show the 4 types of
|
||||||
|
updates.
|
||||||
|
.RS
|
||||||
|
.hy 0
|
||||||
|
|
||||||
|
.nf
|
||||||
|
add x 3600 A 10.1.2.3
|
||||||
|
delete y A 10.1.2.3
|
||||||
|
delete z A
|
||||||
|
delete w
|
||||||
|
.fi
|
||||||
|
.hy
|
||||||
|
.RE
|
||||||
|
|
||||||
|
Each update message is terminated by a line containing the command:
|
||||||
|
.RS
|
||||||
|
.hy 0
|
||||||
|
|
||||||
|
.nf
|
||||||
|
send
|
||||||
|
.fi
|
||||||
|
.hy
|
||||||
|
.RE
|
||||||
|
.SS "Running the tests"
|
||||||
|
When running \fBdnsperf\fR, a data file (the \fB\-d\fR option) and server
|
||||||
|
(the \fB\-s\fR option) will normally be specified. The output of dnsperf is
|
||||||
|
mostly self-explanatory. Pay attention to the number of dropped packets
|
||||||
|
reported - when running the test over a local Ethernet connection, it should
|
||||||
|
be zero. If one or more packets has been dropped, there may be a problem
|
||||||
|
with the network connection. In that case, the results should be considered
|
||||||
|
suspect and the test repeated.
|
||||||
|
.SH OPTIONS
|
||||||
|
|
||||||
|
\fB-a \fIlocal_addr\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the local address from which to send requests. The default is the
|
||||||
|
wildcard address.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-b \fIbufsize\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Sets the size of the socket's send and receive buffers, in kilobytes. If not
|
||||||
|
specified, the operating system's default is used.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-c \fIclients\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Act as multiple clients. Requests are sent from multiple sockets. The
|
||||||
|
default is to act as 1 client.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-d \fIdatafile\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the input data file. If not specified, \fBdnsperf\fR will read
|
||||||
|
from standard input.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-D\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Sets the DO (DNSSEC OK) bit [RFC3225] in all packets sent. This also enables
|
||||||
|
EDNS0, which is required for DNSSEC.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-e\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Enables EDNS0 [RFC2671], by adding an OPT record to all packets sent.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-f \fIfamily\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the address family used for sending DNS packets. The possible
|
||||||
|
values are "inet", "inet6", or "any". If "any" (the default value) is
|
||||||
|
specified, \fBdnsperf\fR will use whichever address family is appropriate
|
||||||
|
for the server it is sending packets to.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-h\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Print a usage statement and exit.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-l \fIlimit\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies a time limit for the run, in seconds. This may cause the input to
|
||||||
|
be read multiple times, or only some of the input to be read. The default
|
||||||
|
behavior is to read the input once, and have no specific time limit.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-n \fIruns_through_file\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Run through the input file at most this many times. If no time limit is set,
|
||||||
|
the file will be read exactly this number of times; if a time limit is set,
|
||||||
|
the file may be read fewer times.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-p \fIport\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Sets the port on which the DNS packets are sent. If not specified, the
|
||||||
|
standard DNS port (53) is used.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-q \fInum_queries\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Sets the maximum number of outstanding requests. When this value is reached,
|
||||||
|
\fBdnsperf\fR will not send any more requests until either responses are
|
||||||
|
received or requests time out. The default value is 100.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-Q \fImax_qps\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Limits the number of requests per second. There is no default limit.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-s \fIserver_addr\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the name or address of the server to which requests will be sent.
|
||||||
|
The default is the loopback address, 127.0.0.1.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-S \fIstats_interval\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
If this parameter is specified, a count of the number of queries per second
|
||||||
|
during the interval will be printed out every stats_interval seconds.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-t \fItimeout\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the request timeout value, in seconds. \fBdnsperf\fR will no
|
||||||
|
longer wait for a response to a particular request after this many seconds
|
||||||
|
have elapsed. The default is 5 seconds.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-u\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Instructs \fBdnsperf\fR to send DNS dynamic update messages, rather than
|
||||||
|
queries. The format of the input file is different in this case; see the
|
||||||
|
"Constructing a dynamic update input file" section for more details.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-v\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Enables verbose mode. The DNS RCODE of each response will be reported to
|
||||||
|
standard output when the response is received, as will the latency. If a
|
||||||
|
query times out, it will be reported with the special string "T" instead of
|
||||||
|
a normal DNS RCODE. If a query is interrupted, it will be reported with the
|
||||||
|
special string "I".
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-x \fIlocal_port\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the local port from which to send requests. The default is the
|
||||||
|
wildcard port (0).
|
||||||
|
|
||||||
|
If acting as multiple clients and the wildcard port is used, each client
|
||||||
|
will use a different random port. If a port is specified, the clients will
|
||||||
|
use a range of ports starting with the specified one.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-y \fI[alg:]name:secret\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Add a TSIG record [RFC2845] to all packets sent, using the specified TSIG
|
||||||
|
key algorithm, name and secret, where the algorithm defaults to hmac-md5 and
|
||||||
|
the secret is expressed as a base-64 encoded string.
|
||||||
|
.RE
|
||||||
|
.SH AUTHOR
|
||||||
|
Nominum, Inc.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
\fBresperf\fR(1)
|
1059
dns/dnsperf-src-2.0.0.0-1/dnsperf.c
Normal file
1059
dns/dnsperf-src-2.0.0.0-1/dnsperf.c
Normal file
File diff suppressed because it is too large
Load diff
BIN
dns/dnsperf-src-2.0.0.0-1/doc/caching-dns-performance.pdf
Normal file
BIN
dns/dnsperf-src-2.0.0.0-1/doc/caching-dns-performance.pdf
Normal file
Binary file not shown.
BIN
dns/dnsperf-src-2.0.0.0-1/doc/dnsperf.pdf
Normal file
BIN
dns/dnsperf-src-2.0.0.0-1/doc/dnsperf.pdf
Normal file
Binary file not shown.
BIN
dns/dnsperf-src-2.0.0.0-1/doc/resperf.pdf
Normal file
BIN
dns/dnsperf-src-2.0.0.0-1/doc/resperf.pdf
Normal file
Binary file not shown.
250
dns/dnsperf-src-2.0.0.0-1/install-sh
Executable file
250
dns/dnsperf-src-2.0.0.0-1/install-sh
Executable file
|
@ -0,0 +1,250 @@
|
||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# install - install a program, script, or datafile
|
||||||
|
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||||
|
#
|
||||||
|
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||||
|
#
|
||||||
|
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
# documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
# the above copyright notice appear in all copies and that both that
|
||||||
|
# copyright notice and this permission notice appear in supporting
|
||||||
|
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||||
|
# publicity pertaining to distribution of the software without specific,
|
||||||
|
# written prior permission. M.I.T. makes no representations about the
|
||||||
|
# suitability of this software for any purpose. It is provided "as is"
|
||||||
|
# without express or implied warranty.
|
||||||
|
#
|
||||||
|
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||||
|
# `make' implicit rules from creating a file called install from it
|
||||||
|
# when there is no Makefile.
|
||||||
|
#
|
||||||
|
# This script is compatible with the BSD install script, but was written
|
||||||
|
# from scratch. It can only install one file at a time, a restriction
|
||||||
|
# shared with many OS's install programs.
|
||||||
|
|
||||||
|
|
||||||
|
# set DOITPROG to echo to test this script
|
||||||
|
|
||||||
|
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||||
|
doit="${DOITPROG-}"
|
||||||
|
|
||||||
|
|
||||||
|
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||||
|
|
||||||
|
mvprog="${MVPROG-mv}"
|
||||||
|
cpprog="${CPPROG-cp}"
|
||||||
|
chmodprog="${CHMODPROG-chmod}"
|
||||||
|
chownprog="${CHOWNPROG-chown}"
|
||||||
|
chgrpprog="${CHGRPPROG-chgrp}"
|
||||||
|
stripprog="${STRIPPROG-strip}"
|
||||||
|
rmprog="${RMPROG-rm}"
|
||||||
|
mkdirprog="${MKDIRPROG-mkdir}"
|
||||||
|
|
||||||
|
transformbasename=""
|
||||||
|
transform_arg=""
|
||||||
|
instcmd="$mvprog"
|
||||||
|
chmodcmd="$chmodprog 0755"
|
||||||
|
chowncmd=""
|
||||||
|
chgrpcmd=""
|
||||||
|
stripcmd=""
|
||||||
|
rmcmd="$rmprog -f"
|
||||||
|
mvcmd="$mvprog"
|
||||||
|
src=""
|
||||||
|
dst=""
|
||||||
|
dir_arg=""
|
||||||
|
|
||||||
|
while [ x"$1" != x ]; do
|
||||||
|
case $1 in
|
||||||
|
-c) instcmd="$cpprog"
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-d) dir_arg=true
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-m) chmodcmd="$chmodprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-o) chowncmd="$chownprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-g) chgrpcmd="$chgrpprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-s) stripcmd="$stripprog"
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
*) if [ x"$src" = x ]
|
||||||
|
then
|
||||||
|
src=$1
|
||||||
|
else
|
||||||
|
# this colon is to work around a 386BSD /bin/sh bug
|
||||||
|
:
|
||||||
|
dst=$1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ x"$src" = x ]
|
||||||
|
then
|
||||||
|
echo "install: no input file specified"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x"$dir_arg" != x ]; then
|
||||||
|
dst=$src
|
||||||
|
src=""
|
||||||
|
|
||||||
|
if [ -d $dst ]; then
|
||||||
|
instcmd=:
|
||||||
|
else
|
||||||
|
instcmd=mkdir
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
|
||||||
|
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||||
|
# might cause directories to be created, which would be especially bad
|
||||||
|
# if $src (and thus $dsttmp) contains '*'.
|
||||||
|
|
||||||
|
if [ -f $src -o -d $src ]
|
||||||
|
then
|
||||||
|
true
|
||||||
|
else
|
||||||
|
echo "install: $src does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x"$dst" = x ]
|
||||||
|
then
|
||||||
|
echo "install: no destination specified"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If destination is a directory, append the input filename; if your system
|
||||||
|
# does not like double slashes in filenames, you may need to add some logic
|
||||||
|
|
||||||
|
if [ -d $dst ]
|
||||||
|
then
|
||||||
|
dst="$dst"/`basename $src`
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
## this sed command emulates the dirname command
|
||||||
|
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||||
|
|
||||||
|
# Make sure that the destination directory exists.
|
||||||
|
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||||
|
|
||||||
|
# Skip lots of stat calls in the usual case.
|
||||||
|
if [ ! -d "$dstdir" ]; then
|
||||||
|
defaultIFS='
|
||||||
|
'
|
||||||
|
IFS="${IFS-${defaultIFS}}"
|
||||||
|
|
||||||
|
oIFS="${IFS}"
|
||||||
|
# Some sh's can't handle IFS=/ for some reason.
|
||||||
|
IFS='%'
|
||||||
|
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||||
|
IFS="${oIFS}"
|
||||||
|
|
||||||
|
pathcomp=''
|
||||||
|
|
||||||
|
while [ $# -ne 0 ] ; do
|
||||||
|
pathcomp="${pathcomp}${1}"
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ ! -d "${pathcomp}" ] ;
|
||||||
|
then
|
||||||
|
$mkdirprog "${pathcomp}"
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
|
||||||
|
pathcomp="${pathcomp}/"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x"$dir_arg" != x ]
|
||||||
|
then
|
||||||
|
$doit $instcmd $dst &&
|
||||||
|
|
||||||
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||||
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||||
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||||
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||||
|
else
|
||||||
|
|
||||||
|
# If we're going to rename the final executable, determine the name now.
|
||||||
|
|
||||||
|
if [ x"$transformarg" = x ]
|
||||||
|
then
|
||||||
|
dstfile=`basename $dst`
|
||||||
|
else
|
||||||
|
dstfile=`basename $dst $transformbasename |
|
||||||
|
sed $transformarg`$transformbasename
|
||||||
|
fi
|
||||||
|
|
||||||
|
# don't allow the sed command to completely eliminate the filename
|
||||||
|
|
||||||
|
if [ x"$dstfile" = x ]
|
||||||
|
then
|
||||||
|
dstfile=`basename $dst`
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make a temp file name in the proper directory.
|
||||||
|
|
||||||
|
dsttmp=$dstdir/#inst.$$#
|
||||||
|
|
||||||
|
# Move or copy the file name to the temp name
|
||||||
|
|
||||||
|
$doit $instcmd $src $dsttmp &&
|
||||||
|
|
||||||
|
trap "rm -f ${dsttmp}" 0 &&
|
||||||
|
|
||||||
|
# and set any options; do chmod last to preserve setuid bits
|
||||||
|
|
||||||
|
# If any of these fail, we abort the whole thing. If we want to
|
||||||
|
# ignore errors from any of these, just make sure not to ignore
|
||||||
|
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||||
|
|
||||||
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||||
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||||
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||||
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||||
|
|
||||||
|
# Now rename the file to the real destination.
|
||||||
|
|
||||||
|
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||||
|
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||||
|
|
||||||
|
fi &&
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
63
dns/dnsperf-src-2.0.0.0-1/log.c
Normal file
63
dns/dnsperf-src-2.0.0.0-1/log.c
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
pthread_mutex_t log_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
static void
|
||||||
|
vlog(FILE *stream, const char *prefix, const char *fmt, va_list args)
|
||||||
|
{
|
||||||
|
LOCK(&log_lock);
|
||||||
|
fflush(stdout);
|
||||||
|
if (prefix != NULL)
|
||||||
|
fprintf(stream, "%s: ", prefix);
|
||||||
|
vfprintf(stream, fmt, args);
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
UNLOCK(&log_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_log_printf(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
vlog(stdout, NULL, fmt, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_log_fatal(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
vlog(stderr, "Error", fmt, args);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_log_warning(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
vlog(stderr, "Warning", fmt, args);
|
||||||
|
}
|
32
dns/dnsperf-src-2.0.0.0-1/log.h
Normal file
32
dns/dnsperf-src-2.0.0.0-1/log.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <isc/types.h>
|
||||||
|
|
||||||
|
#ifndef PERF_LOG_H
|
||||||
|
#define PERF_LOG_H 1
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_log_printf(const char *fmt, ...);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_log_fatal(const char *fmt, ...);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_log_warning(const char *fmt, ...);
|
||||||
|
|
||||||
|
#endif
|
185
dns/dnsperf-src-2.0.0.0-1/net.c
Normal file
185
dns/dnsperf-src-2.0.0.0-1/net.c
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2000, 2001 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||||
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||||
|
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||||
|
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2004 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <isc/result.h>
|
||||||
|
#include <isc/sockaddr.h>
|
||||||
|
|
||||||
|
#include <bind9/getaddresses.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
#include "net.h"
|
||||||
|
#include "opt.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
perf_net_parsefamily(const char *family)
|
||||||
|
{
|
||||||
|
if (family == NULL || strcmp(family, "any") == 0)
|
||||||
|
return AF_UNSPEC;
|
||||||
|
else if (strcmp(family, "inet") == 0)
|
||||||
|
return AF_INET;
|
||||||
|
#ifdef AF_INET6
|
||||||
|
else if (strcmp(family, "inet6") == 0)
|
||||||
|
return AF_INET6;
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "invalid family %s\n", family);
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_net_parseserver(int family, const char *name, unsigned int port,
|
||||||
|
isc_sockaddr_t *addr)
|
||||||
|
{
|
||||||
|
isc_sockaddr_t addrs[8];
|
||||||
|
int count, i;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
if (port == 0) {
|
||||||
|
fprintf(stderr, "server port cannot be 0\n");
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
result = bind9_getaddresses(name, port, addrs, 8, &count);
|
||||||
|
if (result == ISC_R_SUCCESS) {
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
if (isc_sockaddr_pf(&addrs[i]) == family ||
|
||||||
|
family == AF_UNSPEC)
|
||||||
|
{
|
||||||
|
*addr = addrs[i];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "invalid server address %s\n", name);
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_net_parselocal(int family, const char *name, unsigned int port,
|
||||||
|
isc_sockaddr_t *addr)
|
||||||
|
{
|
||||||
|
struct in_addr in4a;
|
||||||
|
struct in6_addr in6a;
|
||||||
|
|
||||||
|
if (name == NULL) {
|
||||||
|
isc_sockaddr_anyofpf(addr, family);
|
||||||
|
isc_sockaddr_setport(addr, port);
|
||||||
|
} else if (inet_pton(AF_INET, name, &in4a) == 1) {
|
||||||
|
isc_sockaddr_fromin(addr, &in4a, port);
|
||||||
|
} else if (inet_pton(AF_INET6, name, &in6a) == 1) {
|
||||||
|
isc_sockaddr_fromin6(addr, &in6a, port);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "invalid local address %s\n", name);
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
perf_net_opensocket(const isc_sockaddr_t *server, const isc_sockaddr_t *local,
|
||||||
|
unsigned int offset, int bufsize)
|
||||||
|
{
|
||||||
|
int family;
|
||||||
|
int sock;
|
||||||
|
isc_sockaddr_t tmp;
|
||||||
|
int port;
|
||||||
|
int ret;
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
family = isc_sockaddr_pf(server);
|
||||||
|
|
||||||
|
if (isc_sockaddr_pf(local) != family)
|
||||||
|
perf_log_fatal("server and local addresses have "
|
||||||
|
"different families");
|
||||||
|
|
||||||
|
sock = socket(family, SOCK_DGRAM, 0);
|
||||||
|
if (sock == -1)
|
||||||
|
perf_log_fatal("Error: socket: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
#if defined(AF_INET6) && defined(IPV6_V6ONLY)
|
||||||
|
if (family == AF_INET6) {
|
||||||
|
int on = 1;
|
||||||
|
|
||||||
|
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||||
|
&on, sizeof(on)) == -1) {
|
||||||
|
perf_log_warning("setsockopt(IPV6_V6ONLY) failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
tmp = *local;
|
||||||
|
port = isc_sockaddr_getport(&tmp);
|
||||||
|
if (port != 0)
|
||||||
|
port += offset;
|
||||||
|
if (port >= 0xFFFF)
|
||||||
|
perf_log_fatal("port %d out of range", port);
|
||||||
|
|
||||||
|
if (bind(sock, &tmp.type.sa, tmp.length) == -1)
|
||||||
|
perf_log_fatal("bind: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
if (bufsize > 0) {
|
||||||
|
bufsize *= 1024;
|
||||||
|
|
||||||
|
ret = setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
|
||||||
|
&bufsize, sizeof(bufsize));
|
||||||
|
if (ret < 0)
|
||||||
|
perf_log_warning("setsockbuf(SO_RCVBUF) failed");
|
||||||
|
|
||||||
|
ret = setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
|
||||||
|
&bufsize, sizeof(bufsize));
|
||||||
|
if (ret < 0)
|
||||||
|
perf_log_warning("setsockbuf(SO_SNDBUF) failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
flags = fcntl(sock, F_GETFL, 0);
|
||||||
|
if (flags < 0)
|
||||||
|
perf_log_fatal("fcntl(F_GETFL)");
|
||||||
|
ret = fcntl(sock, F_SETFL, flags | O_NONBLOCK);
|
||||||
|
if (ret < 0)
|
||||||
|
perf_log_fatal("fcntl(F_SETFL)");
|
||||||
|
|
||||||
|
return sock;
|
||||||
|
}
|
53
dns/dnsperf-src-2.0.0.0-1/net.h
Normal file
53
dns/dnsperf-src-2.0.0.0-1/net.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2000, 2001 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||||
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||||
|
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||||
|
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2004 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PERF_NET_H
|
||||||
|
#define PERF_NET_H 1
|
||||||
|
|
||||||
|
int
|
||||||
|
perf_net_parsefamily(const char *family);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_net_parseserver(int family, const char *name, unsigned int port,
|
||||||
|
isc_sockaddr_t *addr);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_net_parselocal(int family, const char *name, unsigned int port,
|
||||||
|
isc_sockaddr_t *addr);
|
||||||
|
|
||||||
|
int
|
||||||
|
perf_net_opensocket(const isc_sockaddr_t *server, const isc_sockaddr_t *local,
|
||||||
|
unsigned int offset, int bufsize);
|
||||||
|
|
||||||
|
#endif
|
242
dns/dnsperf-src-2.0.0.0-1/opt.c
Normal file
242
dns/dnsperf-src-2.0.0.0-1/opt.c
Normal file
|
@ -0,0 +1,242 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <isc/file.h>
|
||||||
|
#include <isc/parseint.h>
|
||||||
|
#include <isc/result.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
#include "opt.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#define MAX_OPTS 64
|
||||||
|
#define LINE_LENGTH 80
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char c;
|
||||||
|
perf_opttype_t type;
|
||||||
|
const char *desc;
|
||||||
|
const char *help;
|
||||||
|
const char *defval;
|
||||||
|
char defvalbuf[32];
|
||||||
|
union {
|
||||||
|
void *valp;
|
||||||
|
char **stringp;
|
||||||
|
isc_boolean_t *boolp;
|
||||||
|
unsigned int *uintp;
|
||||||
|
isc_uint64_t *uint64p;
|
||||||
|
double *doublep;
|
||||||
|
in_port_t *portp;
|
||||||
|
} u;
|
||||||
|
} opt_t;
|
||||||
|
|
||||||
|
static opt_t opts[MAX_OPTS];
|
||||||
|
static unsigned int nopts;
|
||||||
|
static char optstr[MAX_OPTS * 2 + 2];
|
||||||
|
static const char *progname;
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_opt_add(char c, perf_opttype_t type, const char *desc, const char *help,
|
||||||
|
const char *defval, void *valp)
|
||||||
|
{
|
||||||
|
opt_t *opt;
|
||||||
|
char s[3];
|
||||||
|
|
||||||
|
if (nopts == MAX_OPTS)
|
||||||
|
perf_log_fatal("too many defined options");
|
||||||
|
opt = &opts[nopts++];
|
||||||
|
opt->c = c;
|
||||||
|
opt->type = type;
|
||||||
|
opt->desc = desc;
|
||||||
|
opt->help = help;
|
||||||
|
if (defval != NULL) {
|
||||||
|
strncpy(opt->defvalbuf, defval, sizeof(opt->defvalbuf));
|
||||||
|
opt->defval = opt->defvalbuf;
|
||||||
|
} else {
|
||||||
|
opt->defval = NULL;
|
||||||
|
}
|
||||||
|
opt->u.valp = valp;
|
||||||
|
|
||||||
|
sprintf(s, "%c%s", c, (type == perf_opt_boolean ? "" : ":"));
|
||||||
|
strcat(optstr, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_opt_usage(void)
|
||||||
|
{
|
||||||
|
unsigned int prefix_len, position, arg_len, i, j;
|
||||||
|
|
||||||
|
prefix_len = fprintf(stderr, "Usage: %s", progname);
|
||||||
|
position = prefix_len;
|
||||||
|
for (i = 0; i < nopts; i++) {
|
||||||
|
arg_len = 6;
|
||||||
|
if (opts[i].desc != NULL)
|
||||||
|
arg_len += strlen(opts[i].desc) + 1;
|
||||||
|
if (LINE_LENGTH - position - 1 < arg_len) {
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
for (j = 0; j < prefix_len; j++)
|
||||||
|
fprintf(stderr, " ");
|
||||||
|
position = prefix_len;
|
||||||
|
}
|
||||||
|
fprintf(stderr, " [-%c", opts[i].c);
|
||||||
|
if (opts[i].desc != NULL)
|
||||||
|
fprintf(stderr, " %s", opts[i].desc);
|
||||||
|
fprintf(stderr, "]");
|
||||||
|
position += arg_len;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
for (i = 0; i < nopts; i++) {
|
||||||
|
fprintf(stderr, " -%c %s", opts[i].c, opts[i].help);
|
||||||
|
if (opts[i].defval)
|
||||||
|
fprintf(stderr, " (default: %s)", opts[i].defval);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static isc_uint32_t
|
||||||
|
parse_uint(const char *desc, const char *str,
|
||||||
|
unsigned int min, unsigned int max)
|
||||||
|
{
|
||||||
|
isc_uint32_t val;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
val = 0;
|
||||||
|
result = isc_parse_uint32(&val, str, 10);
|
||||||
|
if (result != ISC_R_SUCCESS || val < min || val > max) {
|
||||||
|
fprintf(stderr, "invalid %s: %s\n", desc, str);
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static isc_uint64_t
|
||||||
|
parse_timeval(const char *desc, const char *str)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
char c;
|
||||||
|
isc_boolean_t seen_dot = ISC_FALSE;
|
||||||
|
|
||||||
|
s = str;
|
||||||
|
while (*s != 0) {
|
||||||
|
c = *s++;
|
||||||
|
if (c == '.') {
|
||||||
|
if (seen_dot)
|
||||||
|
goto fail;
|
||||||
|
seen_dot = ISC_TRUE;
|
||||||
|
} else if (c < '0' || c > '9') {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return MILLION * atof(str);
|
||||||
|
fail:
|
||||||
|
fprintf(stderr, "invalid %s: %s\n", desc, str);
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static double
|
||||||
|
parse_double(const char *desc, const char *str) {
|
||||||
|
char c;
|
||||||
|
int index = 0;
|
||||||
|
isc_boolean_t seen_dot = ISC_FALSE;
|
||||||
|
|
||||||
|
while (str[index] != 0) {
|
||||||
|
c = str[index];
|
||||||
|
if (c == '.') {
|
||||||
|
if (seen_dot)
|
||||||
|
goto fail;
|
||||||
|
seen_dot = ISC_TRUE;
|
||||||
|
} else if (c < '0' || c > '9') {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return atof(str);
|
||||||
|
fail:
|
||||||
|
fprintf(stderr, "invalid %s: %s\n", desc, str);
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_opt_parse(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
opt_t *opt;
|
||||||
|
isc_result_t result;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
progname = isc_file_basename(argv[0]);
|
||||||
|
|
||||||
|
perf_opt_add('h', perf_opt_boolean, NULL, "print this help",
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
while ((c = getopt(argc, argv, optstr)) != -1) {
|
||||||
|
for (i = 0; i < nopts; i++) {
|
||||||
|
if (opts[i].c == c)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == nopts) {
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (c == 'h') {
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
opt = &opts[i];
|
||||||
|
result = ISC_R_SUCCESS;
|
||||||
|
switch (opt->type) {
|
||||||
|
case perf_opt_string:
|
||||||
|
*opt->u.stringp = optarg;
|
||||||
|
break;
|
||||||
|
case perf_opt_boolean:
|
||||||
|
*opt->u.boolp = ISC_TRUE;
|
||||||
|
break;
|
||||||
|
case perf_opt_uint:
|
||||||
|
*opt->u.uintp = parse_uint(opt->desc, optarg,
|
||||||
|
1, 0xFFFFFFFF);
|
||||||
|
break;
|
||||||
|
case perf_opt_timeval:
|
||||||
|
*opt->u.uint64p = parse_timeval(opt->desc, optarg);
|
||||||
|
break;
|
||||||
|
case perf_opt_double:
|
||||||
|
*opt->u.doublep = parse_double(opt->desc, optarg);
|
||||||
|
break;
|
||||||
|
case perf_opt_port:
|
||||||
|
*opt->u.portp = parse_uint(opt->desc, optarg,
|
||||||
|
0, 0xFFFF);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (optind != argc) {
|
||||||
|
fprintf(stderr, "unexpected argument %s\n", argv[optind]);
|
||||||
|
perf_opt_usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
40
dns/dnsperf-src-2.0.0.0-1/opt.h
Normal file
40
dns/dnsperf-src-2.0.0.0-1/opt.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PERF_OPT_H
|
||||||
|
#define PERF_OPT_H 1
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
perf_opt_string,
|
||||||
|
perf_opt_boolean,
|
||||||
|
perf_opt_uint,
|
||||||
|
perf_opt_timeval,
|
||||||
|
perf_opt_double,
|
||||||
|
perf_opt_port,
|
||||||
|
} perf_opttype_t;
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_opt_add(char c, perf_opttype_t type, const char *desc, const char *help,
|
||||||
|
const char *defval, void *valp);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_opt_usage(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_opt_parse(int argc, char **argv);
|
||||||
|
|
||||||
|
#endif
|
90
dns/dnsperf-src-2.0.0.0-1/os.c
Normal file
90
dns/dnsperf-src-2.0.0.0-1/os.c
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sys/select.h>
|
||||||
|
|
||||||
|
#include <isc/result.h>
|
||||||
|
#include <isc/types.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
#include "os.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_os_blocksignal(int sig, isc_boolean_t block)
|
||||||
|
{
|
||||||
|
sigset_t sset;
|
||||||
|
int op;
|
||||||
|
|
||||||
|
op = block ? SIG_BLOCK : SIG_UNBLOCK;
|
||||||
|
|
||||||
|
if (sigemptyset(&sset) < 0 ||
|
||||||
|
sigaddset(&sset, sig) < 0 ||
|
||||||
|
pthread_sigmask(op, &sset, NULL) < 0)
|
||||||
|
perf_log_fatal("pthread_sigmask: %s", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_os_handlesignal(int sig, void (*handler)(int))
|
||||||
|
{
|
||||||
|
struct sigaction sa;
|
||||||
|
|
||||||
|
memset(&sa, 0, sizeof(sa));
|
||||||
|
sa.sa_handler = handler;
|
||||||
|
|
||||||
|
if (sigfillset(&sa.sa_mask) < 0 ||
|
||||||
|
sigaction(sig, &sa, NULL) < 0)
|
||||||
|
perf_log_fatal("sigaction: %s", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
perf_os_waituntilreadable(int fd, int pipe_fd, isc_int64_t timeout)
|
||||||
|
{
|
||||||
|
fd_set read_fds;
|
||||||
|
int maxfd;
|
||||||
|
struct timeval tv, *tvp;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
FD_ZERO(&read_fds);
|
||||||
|
FD_SET(fd, &read_fds);
|
||||||
|
FD_SET(pipe_fd, &read_fds);
|
||||||
|
maxfd = pipe_fd > fd ? pipe_fd : fd;
|
||||||
|
if (timeout < 0) {
|
||||||
|
tvp = NULL;
|
||||||
|
} else {
|
||||||
|
tv.tv_sec = timeout / MILLION;
|
||||||
|
tv.tv_usec = timeout % MILLION;
|
||||||
|
tvp = &tv;
|
||||||
|
}
|
||||||
|
n = select(maxfd + 1, &read_fds, NULL, NULL, tvp);
|
||||||
|
if (n < 0) {
|
||||||
|
if (errno != EINTR)
|
||||||
|
perf_log_fatal("select() failed");
|
||||||
|
return (ISC_R_CANCELED);
|
||||||
|
} else if (FD_ISSET(fd, &read_fds)) {
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
} else if (FD_ISSET(pipe_fd, &read_fds)) {
|
||||||
|
return (ISC_R_CANCELED);
|
||||||
|
} else {
|
||||||
|
return (ISC_R_TIMEDOUT);
|
||||||
|
}
|
||||||
|
}
|
30
dns/dnsperf-src-2.0.0.0-1/os.h
Normal file
30
dns/dnsperf-src-2.0.0.0-1/os.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PERF_OS_H
|
||||||
|
#define PERF_OS_H 1
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_os_blocksignal(int sig, isc_boolean_t block);
|
||||||
|
|
||||||
|
void
|
||||||
|
perf_os_handlesignal(int sig, void (*handler)(int));
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
perf_os_waituntilreadable(int fd, int pipe_fd, isc_int64_t timeout);
|
||||||
|
|
||||||
|
#endif
|
96
dns/dnsperf-src-2.0.0.0-1/resperf-report
Executable file
96
dns/dnsperf-src-2.0.0.0-1/resperf-report
Executable file
|
@ -0,0 +1,96 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Driver script to run resperf and generate an HTML report of
|
||||||
|
# the results, with graphs.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Program locations - change these if not in $PATH
|
||||||
|
resperf=resperf
|
||||||
|
gnuplot=gnuplot
|
||||||
|
|
||||||
|
# The gnuplot terminal type. This determines the image format for the
|
||||||
|
# plots; "png" or "gif" will both work as long as the corresponding
|
||||||
|
# terminal support is compiled into your copy of gnuplot.
|
||||||
|
terminal=png
|
||||||
|
|
||||||
|
# Create a unique ID for this report
|
||||||
|
id=`date '+%Y%m%d-%H%M'`
|
||||||
|
|
||||||
|
# Set up file names
|
||||||
|
reportfile="$id.html"
|
||||||
|
outputfile="$id.output"
|
||||||
|
plotfile="$id.gnuplot"
|
||||||
|
rate_graph="$id.rate.$terminal"
|
||||||
|
latency_graph="$id.latency.$terminal"
|
||||||
|
|
||||||
|
# Run the test
|
||||||
|
$resperf -P "$plotfile" "$@" >"$outputfile" 2>&1 ||
|
||||||
|
{ echo "`basename $0`: error running resperf:" >&2;
|
||||||
|
cat $outputfile >&2;
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create plots
|
||||||
|
|
||||||
|
if
|
||||||
|
$gnuplot <<EOF
|
||||||
|
set terminal $terminal
|
||||||
|
set output "$rate_graph"
|
||||||
|
set title "Query / response / failure rate"
|
||||||
|
set key top left
|
||||||
|
set xlabel "Time (seconds)"
|
||||||
|
set yrange [0:]
|
||||||
|
plot \
|
||||||
|
"$plotfile" using 1:3 title "Queries sent per second" with lines, \
|
||||||
|
"$plotfile" using 1:4 title "Total responses received per second" with lines, \
|
||||||
|
"$plotfile" using 1:5 title "Failure responses received per second" with lines
|
||||||
|
EOF
|
||||||
|
then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo "`basename $0`: error running gnuplot" >&2; exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if
|
||||||
|
$gnuplot <<EOF
|
||||||
|
set terminal $terminal
|
||||||
|
set output "$latency_graph"
|
||||||
|
set title "Latency"
|
||||||
|
set key top left
|
||||||
|
set xlabel "Time (seconds)"
|
||||||
|
set yrange [0:]
|
||||||
|
plot \
|
||||||
|
"$plotfile" using 1:6 title "Average latency (seconds)" with lines
|
||||||
|
EOF
|
||||||
|
then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo "`basename $0`: error running gnuplot" >&2; exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate the report
|
||||||
|
|
||||||
|
exec >"$reportfile"
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
<html><head></head><body>
|
||||||
|
<h1>Resperf report $id</h1>
|
||||||
|
<h2>Resperf output</h2>
|
||||||
|
<pre>
|
||||||
|
EOF
|
||||||
|
cat "$outputfile"
|
||||||
|
cat <<EOF
|
||||||
|
</pre>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
<h2>Plots</h2>
|
||||||
|
<p>
|
||||||
|
<img src="$rate_graph" />
|
||||||
|
<img src="$latency_graph" />
|
||||||
|
</p>
|
||||||
|
</body></html>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Done, report is in $reportfile" >&2
|
||||||
|
|
572
dns/dnsperf-src-2.0.0.0-1/resperf.1
Normal file
572
dns/dnsperf-src-2.0.0.0-1/resperf.1
Normal file
|
@ -0,0 +1,572 @@
|
||||||
|
.\" Copyright (C) Nominum, Inc.
|
||||||
|
.\"
|
||||||
|
.\" All rights reserved.
|
||||||
|
.TH RESPERF 1 "Nov 22, 2011" Nominum Nominum
|
||||||
|
.SH NAME
|
||||||
|
\%resperf - test the resolution performance of a caching DNS server
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.hy 0
|
||||||
|
.ad l
|
||||||
|
\fBresperf\-report\fR\ [\fB\-a\ \fIlocal_addr\fR\fR]
|
||||||
|
[\fB\-d\ \fIdatafile\fR\fR]
|
||||||
|
[\fB\-s\ \fIserver_addr\fR\fR]
|
||||||
|
[\fB\-p\ \fIport\fR\fR]
|
||||||
|
[\fB\-x\ \fIlocal_port\fR\fR]
|
||||||
|
[\fB\-t\ \fItimeout\fR\fR]
|
||||||
|
[\fB\-b\ \fIbufsize\fR\fR]
|
||||||
|
[\fB\-f\ \fIfamily\fR\fR]
|
||||||
|
[\fB\-e\fR]
|
||||||
|
[\fB\-D\fR]
|
||||||
|
[\fB\-y\ \fI[alg:]name:secret\fR\fR]
|
||||||
|
[\fB\-h\fR]
|
||||||
|
[\fB\-i\ \fIinterval\fR\fR]
|
||||||
|
[\fB\-m\ \fImax_qps\fR\fR]
|
||||||
|
[\fB\-r\ \fIrampup_time\fR\fR]
|
||||||
|
[\fB\-L\ \fImax_loss\fR\fR]
|
||||||
|
.ad
|
||||||
|
.hy
|
||||||
|
.hy 0
|
||||||
|
.ad l
|
||||||
|
|
||||||
|
\fBresperf\fR\ [\fB\-a\ \fIlocal_addr\fR\fR]
|
||||||
|
[\fB\-d\ \fIdatafile\fR\fR]
|
||||||
|
[\fB\-s\ \fIserver_addr\fR\fR]
|
||||||
|
[\fB\-p\ \fIport\fR\fR]
|
||||||
|
[\fB\-x\ \fIlocal_port\fR\fR]
|
||||||
|
[\fB\-t\ \fItimeout\fR\fR]
|
||||||
|
[\fB\-b\ \fIbufsize\fR\fR]
|
||||||
|
[\fB\-f\ \fIfamily\fR\fR]
|
||||||
|
[\fB\-e\fR]
|
||||||
|
[\fB\-D\fR]
|
||||||
|
[\fB\-y\ \fIname:secret\fR\fR]
|
||||||
|
[\fB\-h\fR]
|
||||||
|
[\fB\-i\ \fIinterval\fR\fR]
|
||||||
|
[\fB\-m\ \fImax_qps\fR\fR]
|
||||||
|
[\fB\-P\ \fIplot_data_file\fR\fR]
|
||||||
|
[\fB\-r\ \fIrampup_time\fR\fR]
|
||||||
|
[\fB\-L\ \fImax_loss\fR\fR]
|
||||||
|
.ad
|
||||||
|
.hy
|
||||||
|
.SH DESCRIPTION
|
||||||
|
\fBresperf\fR is a companion tool to \fBdnsperf\fR. \fBdnsperf\fR was
|
||||||
|
primarily designed for benchmarking authoritative servers, and it does not
|
||||||
|
work well with caching servers that are talking to the live Internet. One
|
||||||
|
reason for this is that dnsperf uses a "self-pacing" approach, which is
|
||||||
|
based on the assumption that you can keep the server 100% busy simply by
|
||||||
|
sending it a small burst of back-to-back queries to fill up network buffers,
|
||||||
|
and then send a new query whenever you get a response back. This approach
|
||||||
|
works well for authoritative servers that process queries in order and one
|
||||||
|
at a time; it also works pretty well for a caching server in a closed
|
||||||
|
laboratory environment talking to a simulated Internet that's all on the
|
||||||
|
same LAN. Unfortunately, it does not work well with a caching server talking
|
||||||
|
to the actual Internet, which may need to work on thousands of queries in
|
||||||
|
parallel to achieve its maximum throughput. There have been numerous
|
||||||
|
attempts to use dnsperf (or its predecessor, queryperf) for benchmarking
|
||||||
|
live caching servers, usually with poor results. Therefore, a separate tool
|
||||||
|
designed specifically for caching servers is needed.
|
||||||
|
.SS "How resperf works"
|
||||||
|
Unlike the "self-pacing" approach of dnsperf, resperf works by sending DNS
|
||||||
|
queries at a controlled, steadily increasing rate. By default, resperf will
|
||||||
|
send traffic for 60 seconds, linearly increasing the amount of traffic from
|
||||||
|
zero to 100,000 queries per second.
|
||||||
|
|
||||||
|
During the test, resperf listens for responses from the server and keeps
|
||||||
|
track of response rates, failure rates, and latencies. It will also continue
|
||||||
|
listening for responses for an additional 40 seconds after it has stopped
|
||||||
|
sending traffic, so that there is time for the server to respond to the last
|
||||||
|
queries sent. This time period was chosen to be longer than the overall
|
||||||
|
query timeout of both Nominum CNS and current versions of BIND.
|
||||||
|
|
||||||
|
If the test is successful, the query rate will at some point exceed the
|
||||||
|
capacity of the server and queries will be dropped, causing the response
|
||||||
|
rate to stop growing or even decrease as the query rate increases.
|
||||||
|
|
||||||
|
The result of the test is a set of measurements of the query rate, response
|
||||||
|
rate, failure response rate, and average query latency as functions of time.
|
||||||
|
.SS "What you will need"
|
||||||
|
Benchmarking a live caching server is serious business. A fast caching
|
||||||
|
server like Nominum CNS running on an Opteron server, resolving a mix of
|
||||||
|
cacheable and non-cacheable queries typical of ISP customer traffic, is
|
||||||
|
capable of resolving more than 50,000 queries per second. In the process, it
|
||||||
|
will send more than 20,000 queries per second to authoritative servers on
|
||||||
|
the Internet, and receive responses to most of them. Assuming an average
|
||||||
|
request size of 50 bytes and a response size of 100 bytes, this amounts to
|
||||||
|
some 8 Mbps of outgoing and 16 Mbps of incoming traffic. If your Internet
|
||||||
|
connection can't handle the bandwidth, you will end up measuring the speed
|
||||||
|
of the connection, not the server, and may saturate the connection causing a
|
||||||
|
degradation in service for other users.
|
||||||
|
|
||||||
|
Make sure there is no stateful firewall between the server and the Internet,
|
||||||
|
because most of them can't handle the amount of UDP traffic the test will
|
||||||
|
generate and will end up dropping packets, skewing the test results. Some
|
||||||
|
will even lock up or crash.
|
||||||
|
|
||||||
|
You should run resperf on a machine separate from the server under test, on
|
||||||
|
the same LAN. Preferably, this should be a Gigabit Ethernet network. The
|
||||||
|
machine running resperf should be at least as fast as the machine being
|
||||||
|
tested; otherwise, it may end up being the bottleneck.
|
||||||
|
|
||||||
|
There should be no other applications running on the machine running
|
||||||
|
resperf. Performance testing at the traffic levels involved is essentially a
|
||||||
|
hard real-time application - consider the fact that at a query rate of
|
||||||
|
100,000 queries per second, if resperf gets delayed by just 1/100 of a
|
||||||
|
second, 1000 incoming UDP packets will arrive in the meantime. This is more
|
||||||
|
than most operating systems will buffer, which means packets will be
|
||||||
|
dropped.
|
||||||
|
|
||||||
|
Because the granularity of the timers provided by operating systems is
|
||||||
|
typically too coarse to accurately schedule packet transmissions at
|
||||||
|
sub-millisecond intervals, resperf will busy-wait between packet
|
||||||
|
transmissions, constantly polling for responses in the meantime. Therefore,
|
||||||
|
it is normal for resperf to consume 100% CPU during the whole test run, even
|
||||||
|
during periods where query rates are relatively low.
|
||||||
|
|
||||||
|
You will also need a set of test queries in the \fBdnsperf\fR file format.
|
||||||
|
See the \fBdnsperf\fR man page for instructions on how to construct this
|
||||||
|
query file. To make the test as realistic as possible, the queries should be
|
||||||
|
derived from recorded production client DNS traffic, without removing
|
||||||
|
duplicate queries or other filtering. With the default settings, resperf
|
||||||
|
will use up to 3 million queries in each test run.
|
||||||
|
|
||||||
|
If the caching server to be tested has a configurable limit on the number of
|
||||||
|
simultaneous resolutions, like the \fBmax\-recursive\-clients\fR statement
|
||||||
|
in Nominum CNS or the \fBrecursive\-clients\fR option in BIND 9, you will
|
||||||
|
probably have to increase it. As a starting point, we recommend a value of
|
||||||
|
10000 for Nominum CNS and 100000 for BIND 9. Should the limit be reached, it
|
||||||
|
will show up in the plots as an increase in the number of failure responses.
|
||||||
|
|
||||||
|
The server being tested should be restarted at the beginning of each test to
|
||||||
|
make sure it is starting with an empty cache. If the cache already contains
|
||||||
|
data from a previous test run that used the same set of queries, almost all
|
||||||
|
queries will be answered from the cache, yielding inflated performance
|
||||||
|
numbers.
|
||||||
|
|
||||||
|
To use the \fBresperf\-report\fR script, you need to have \fBgnuplot\fR
|
||||||
|
installed. Make sure your installed version of \fBgnuplot\fR supports the
|
||||||
|
png terminal driver. If your \fBgnuplot\fR doesn't support png but does
|
||||||
|
support gif, you can change the line saying terminal=png in the
|
||||||
|
\fBresperf\-report\fR script to terminal=gif.
|
||||||
|
.SS "Running the test"
|
||||||
|
Resperf is typically invoked via the \fBresperf\-report\fR script, which
|
||||||
|
will run \fBresperf\fR with its output redirected to a file and then
|
||||||
|
automatically generate an illustrated report in HTML format. Command line
|
||||||
|
arguments given to resperf-report will be passed on unchanged to resperf.
|
||||||
|
|
||||||
|
When running resperf-report, you will need to specify at least the server IP
|
||||||
|
address and the query data file. A typical invocation will look like
|
||||||
|
.RS
|
||||||
|
.hy 0
|
||||||
|
|
||||||
|
.nf
|
||||||
|
resperf\-report \-s 10.0.0.2 \-d queryfile
|
||||||
|
.fi
|
||||||
|
.hy
|
||||||
|
.RE
|
||||||
|
|
||||||
|
With default settings, the test run will take at most 100 seconds (60
|
||||||
|
seconds of ramping up traffic and then 40 seconds of waiting for responses),
|
||||||
|
but in practice, the 60-second traffic phase will usually be cut short. To
|
||||||
|
be precise, resperf can transition from the traffic-sending phase to the
|
||||||
|
waiting-for-responses phase in three different ways:
|
||||||
|
.IP \(bu 2
|
||||||
|
Running for the full allotted time and successfully reaching the maximum
|
||||||
|
query rate (by default, 60 seconds and 100,000 qps, respectively). Since
|
||||||
|
this is a very high query rate, this will rarely happen (with today's
|
||||||
|
hardware); one of the other two conditions listed below will usually occur
|
||||||
|
first.
|
||||||
|
.IP \(bu 2
|
||||||
|
Exceeding 65,536 outstanding queries. This often happens as a result of
|
||||||
|
(successfully) exceeding the capacity of the server being tested, causing
|
||||||
|
the excess queries to be dropped. The limit of 65,536 queries comes from the
|
||||||
|
number of possible values for the ID field in the DNS packet. Resperf needs
|
||||||
|
to allocate a unique ID for each outstanding query, and is therefore unable
|
||||||
|
to send further queries if the set of possible IDs is exhausted.
|
||||||
|
.IP \(bu 2
|
||||||
|
When resperf finds itself unable to send queries fast enough. Resperf will
|
||||||
|
notice if it is falling behind in its scheduled query transmissions, and if
|
||||||
|
this backlog reaches 1000 queries, it will print a message like "Fell behind
|
||||||
|
by 1000 queries" (or whatever the actual number is at the time) and stop
|
||||||
|
sending traffic.
|
||||||
|
.PP
|
||||||
|
Regardless of which of the above conditions caused the traffic-sending phase
|
||||||
|
of the test to end, you should examine the resulting plots to make sure the
|
||||||
|
server's response rate is flattening out toward the end of the test. If it
|
||||||
|
is not, then you are not loading the server enough. If you are getting the
|
||||||
|
"Fell behind" message, make sure that the machine running resperf is fast
|
||||||
|
enough and has no other applications running.
|
||||||
|
|
||||||
|
You should also monitor the CPU usage of the server under test. It should
|
||||||
|
reach close to 100% CPU at the point of maximum traffic; if it does not, you
|
||||||
|
most likely have a bottleneck in some other part of your test setup, for
|
||||||
|
example, your external Internet connection.
|
||||||
|
|
||||||
|
The report generated by \fBresperf\-report\fR will be stored with a unique
|
||||||
|
file name based on the current date and time, e.g.,
|
||||||
|
\fI20060812-1550.html\fR. The PNG images of the plots and other auxiliary
|
||||||
|
files will be stored in separate files beginning with the same date-time
|
||||||
|
string. To view the report, simply open the \fI.html\fR file in a web
|
||||||
|
browser.
|
||||||
|
|
||||||
|
If you need to copy the report to a separate machine for viewing, make sure
|
||||||
|
to copy the .png files along with the .html file (or simply copy all the
|
||||||
|
files, e.g., using scp 20060812-1550.* host:directory/).
|
||||||
|
.SS "Interpreting the report"
|
||||||
|
The \fI.html\fR file produced by \fBresperf\-report\fR consists of two
|
||||||
|
sections. The first section, "Resperf output", contains output from the
|
||||||
|
\fBresperf\fR program such as progress messages, a summary of the command
|
||||||
|
line arguments, and summary statistics. The second section, "Plots",
|
||||||
|
contains two plots generated by \fBgnuplot\fR: "Query/response/failure rate"
|
||||||
|
and "Latency".
|
||||||
|
|
||||||
|
The "Query/response/failure rate" plot contains three graphs. The "Queries
|
||||||
|
sent per second" graph shows the amount of traffic being sent to the server;
|
||||||
|
this should be very close to a straight diagonal line, reflecting the linear
|
||||||
|
ramp-up of traffic.
|
||||||
|
|
||||||
|
The "Total responses received per second" graph shows how many of the
|
||||||
|
queries received a response from the server. All responses are counted,
|
||||||
|
whether successful (NOERROR or NXDOMAIN) or not (e.g., SERVFAIL).
|
||||||
|
|
||||||
|
The "Failure responses received per second" graph shows how many of the
|
||||||
|
queries received a failure response. A response is considered to be a
|
||||||
|
failure if its RCODE is neither NOERROR nor NXDOMAIN.
|
||||||
|
|
||||||
|
By visually inspecting the graphs, you can get an idea of how the server
|
||||||
|
behaves under increasing load. The "Total responses received per second"
|
||||||
|
graph will initially closely follow the "Queries sent per second" graph
|
||||||
|
(often rendering it invisible in the plot as the two graphs are plotted on
|
||||||
|
top of one another), but when the load exceeds the server's capacity, the
|
||||||
|
"Total responses received per second" graph may diverge from the "Queries
|
||||||
|
sent per second" graph and flatten out, indicating that some of the queries
|
||||||
|
are being dropped.
|
||||||
|
|
||||||
|
The "Failure responses received per second" graph will normally show a
|
||||||
|
roughly linear ramp close to the bottom of the plot with some random
|
||||||
|
fluctuation, since typical query traffic will contain some small percentage
|
||||||
|
of failing queries randomly interspersed with the successful ones. As the
|
||||||
|
total traffic increases, the number of failures will increase
|
||||||
|
proportionally.
|
||||||
|
|
||||||
|
If the "Failure responses received per second" graph turns sharply upwards,
|
||||||
|
this can be another indication that the load has exceeded the server's
|
||||||
|
capacity. This will happen if the server reacts to overload by sending
|
||||||
|
SERVFAIL responses rather than by dropping queries. Since Nominum CNS and
|
||||||
|
BIND 9 will both respond with SERVFAIL when they exceed their
|
||||||
|
\fBmax\-recursive\-clients\fR or \fBrecursive\-clients\fR limit,
|
||||||
|
respectively, a sudden increase in the number of failures could mean that
|
||||||
|
the limit needs to be increased.
|
||||||
|
|
||||||
|
The "Latency" plot contains a single graph marked "Average latency". This
|
||||||
|
shows how the latency varies during the course of the test. Typically, the
|
||||||
|
latency graph will exhibit a downwards trend because the cache hit rate
|
||||||
|
improves as ever more responses are cached during the test, and the latency
|
||||||
|
for a cache hit is much smaller than for a cache miss. The latency graph is
|
||||||
|
provided as an aid in determining the point where the server gets
|
||||||
|
overloaded, which can be seen as a sharp upwards turn in the graph. The
|
||||||
|
latency graph is not intended for making absolute latency measurements or
|
||||||
|
comparisons between servers; the latencies shown in the graph are not
|
||||||
|
representative of production latencies due to the initially empty cache and
|
||||||
|
the deliberate overloading of the server towards the end of the test.
|
||||||
|
|
||||||
|
Note that all measurements are displayed on the plot at the horizontal
|
||||||
|
position corresponding to the point in time when the query was sent, not
|
||||||
|
when the response (if any) was received. This makes it it easy to compare
|
||||||
|
the query and response rates; for example, if no queries are dropped, the
|
||||||
|
query and response graphs will be identical. As another example, if the plot
|
||||||
|
shows 10% failure responses at t=5 seconds, this means that 10% of the
|
||||||
|
queries sent at t=5 seconds eventually failed, not that 10% of the responses
|
||||||
|
received at t=5 seconds were failures.
|
||||||
|
.SS "Determining the server's maximum throughput"
|
||||||
|
Often, the goal of running \fBresperf\fR is to determine the server's
|
||||||
|
maximum throughput, in other words, the number of queries per second it is
|
||||||
|
capable of handling. This is not always an easy task, because as a server is
|
||||||
|
driven into overload, the service it provides may deteriorate gradually, and
|
||||||
|
this deterioration can manifest itself either as queries being dropped, as
|
||||||
|
an increase in the number of SERVFAIL responses, or an increase in latency.
|
||||||
|
The maximum throughput may be defined as the highest level of traffic at
|
||||||
|
which the server still provides an acceptable level of service, but that
|
||||||
|
means you first need to decide what an acceptable level of service means in
|
||||||
|
terms of packet drop percentage, SERVFAIL percentage, and latency.
|
||||||
|
|
||||||
|
The summary statistics in the "Resperf output" section of the report
|
||||||
|
contains a "Maximum throughput" value which by default is determined from
|
||||||
|
the maximum rate at which the server was able to return responses, without
|
||||||
|
regard to the number of queries being dropped or failing at that point. This
|
||||||
|
method of throughput measurement has the advantage of simplicity, but it may
|
||||||
|
or may not be appropriate for your needs; the reported value should always
|
||||||
|
be validated by a visual inspection of the graphs to ensure that service has
|
||||||
|
not already deteriorated unacceptably before the maximum response rate is
|
||||||
|
reached. It may also be helpful to look at the "Lost at that point" value in
|
||||||
|
the summary statistics; this indicates the percentage of the queries that
|
||||||
|
was being dropped at the point in the test when the maximum throughput was
|
||||||
|
reached.
|
||||||
|
|
||||||
|
Alternatively, you can make resperf report the throughput at the point in
|
||||||
|
the test where the percentage of queries dropped exceeds a given limit (or
|
||||||
|
the maximum as above if the limit is never exceeded). This can be a more
|
||||||
|
realistic indication of how much the server can be loaded while still
|
||||||
|
providing an acceptable level of service. This is done using the \fB\-L\fR
|
||||||
|
command line option; for example, specifying \fB\-L 10\fR makes resperf
|
||||||
|
report the highest throughput reached before the server starts dropping more
|
||||||
|
than 10% of the queries.
|
||||||
|
|
||||||
|
There is no corresponding way of automatically constraining results based on
|
||||||
|
the number of failed queries, because unlike dropped queries, resolution
|
||||||
|
failures will occur even when the the server is not overloaded, and the
|
||||||
|
number of such failures is heavily dependent on the query data and network
|
||||||
|
conditions. Therefore, the plots should be manually inspected to ensure that
|
||||||
|
there is not an abnormal number of failures.
|
||||||
|
.SH "GENERATING CONSTANT TRAFFIC"
|
||||||
|
In addition to ramping up traffic linearly, \fBresperf\fR also has the
|
||||||
|
capability to send a constant stream of traffic. This can be useful when
|
||||||
|
using \fBresperf\fR for tasks other than performance measurement; for
|
||||||
|
example, it can be used to "soak test" a server by subjecting it to a
|
||||||
|
sustained load for an extended period of time.
|
||||||
|
|
||||||
|
To generate a constant traffic load, use the \fB\-c\fR command line option,
|
||||||
|
together with the \fB\-m\fR option which specifies the desired constant
|
||||||
|
query rate. For example, to send 10000 queries per second for an hour, use
|
||||||
|
\fB\-m 10000 \-c 3600\fR. This will include the usual 30-second gradual
|
||||||
|
ramp-up of traffic at the beginning, which may be useful to avoid initially
|
||||||
|
overwhelming a server that is starting with an empty cache. To start the
|
||||||
|
onslaught of traffic instantly, use \fB\-m 10000 \-c 3600 \-r 0\fR.
|
||||||
|
|
||||||
|
To be precise, \fBresperf\fR will do a linear ramp-up of traffic from 0 to
|
||||||
|
\fB\-m\fR queries per second over a period of \fB\-r\fR seconds, followed by
|
||||||
|
a plateau of steady traffic at \fB\-m\fR queries per second lasting for
|
||||||
|
\fB\-c\fR seconds, followed by waiting for responses for an extra 40
|
||||||
|
seconds. Either the ramp-up or the plateau can be suppressed by supplying a
|
||||||
|
duration of zero seconds with \fB\-r 0\fR and \fB\-c 0\fR, respectively. The
|
||||||
|
latter is the default.
|
||||||
|
|
||||||
|
Sending traffic at high rates for hours on end will of course require very
|
||||||
|
large amounts of input data. Also, a long-running test will generate a large
|
||||||
|
amount of plot data, which is kept in memory for the duration of the test.
|
||||||
|
To reduce the memory usage and the size of the plot file, consider
|
||||||
|
increasing the interval between measurements from the default of 0.5 seconds
|
||||||
|
using the \fB\-i\fR option in long-running tests.
|
||||||
|
|
||||||
|
When using \fBresperf\fR for long-running tests, it is important that the
|
||||||
|
traffic rate specified using the \fB\-m\fR is one that both \fBresperf\fR
|
||||||
|
itself and the server under test can sustain. Otherwise, the test is likely
|
||||||
|
to be cut short as a result of either running out of query IDs (because of
|
||||||
|
large numbers of dropped queries) or of resperf falling behind its
|
||||||
|
transmission schedule.
|
||||||
|
.SH OPTIONS
|
||||||
|
Because the \fBresperf\-report\fR script passes its command line options
|
||||||
|
directly to the \fBresperf\fR programs, they both accept the same set of
|
||||||
|
options, with one exception: \fBresperf\-report\fR automatically adds an
|
||||||
|
appropriate \fB\-P\fR to the \fBresperf\fR command line, and therefore does
|
||||||
|
not itself take a \fB\-P\fR option.
|
||||||
|
|
||||||
|
\fB-d \fIdatafile\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the input data file. If not specified, \fBresperf\fR will read
|
||||||
|
from standard input.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-s \fIserver_addr\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the name or address of the server to which requests will be sent.
|
||||||
|
The default is the loopback address, 127.0.0.1.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-p \fIport\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Sets the port on which the DNS packets are sent. If not specified, the
|
||||||
|
standard DNS port (53) is used.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-a \fIlocal_addr\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the local address from which to send requests. The default is the
|
||||||
|
wildcard address.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-x \fIlocal_port\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the local port from which to send requests. The default is the
|
||||||
|
wildcard port (0).
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-t \fItimeout\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the request timeout value, in seconds. \fBresperf\fR will no
|
||||||
|
longer wait for a response to a particular request after this many seconds
|
||||||
|
have elapsed. The default is 45 seconds.
|
||||||
|
|
||||||
|
\fBresperf\fR times out unanswered requests in order to reclaim query IDs so
|
||||||
|
that the query ID space will not be exhausted in a long-running test, such
|
||||||
|
as when "soak testing" a server for an day with \fB\-m 10000 \-c 86400\fR.
|
||||||
|
The timeouts and the ability to tune them are of little use in the more
|
||||||
|
typical use case of a performance test lasting only a minute or two.
|
||||||
|
|
||||||
|
The default timeout of 45 seconds was chosen to be longer than the query
|
||||||
|
timeout of current caching servers. Note that this is longer than the
|
||||||
|
corresponding default in \fBdnsperf\fR, because caching servers can take
|
||||||
|
many orders of magnitude longer to answer a query than authoritative servers
|
||||||
|
do.
|
||||||
|
|
||||||
|
If a short timeout is used, there is a possibility that \fBresperf\fR will
|
||||||
|
receive a response after the corresponding request has timed out; in this
|
||||||
|
case, a message like Warning: Received a response with an unexpected id: 141
|
||||||
|
will be printed.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-b \fIbufsize\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Sets the size of the socket's send and receive buffers, in kilobytes. If not
|
||||||
|
specified, the default value is 32k.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-f \fIfamily\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the address family used for sending DNS packets. The possible
|
||||||
|
values are "inet", "inet6", or "any". If "any" (the default value) is
|
||||||
|
specified, \fBresperf\fR will use whichever address family is appropriate
|
||||||
|
for the server it is sending packets to.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-e\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Enables EDNS0 [RFC2671], by adding an OPT record to all packets sent.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-D\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Sets the DO (DNSSEC OK) bit [RFC3225] in all packets sent. This also enables
|
||||||
|
EDNS0, which is required for DNSSEC.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-y \fI[alg:]name:secret\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Add a TSIG record [RFC2845] to all packets sent, using the specified TSIG
|
||||||
|
key algorithm, name and secret, where the algorithm defaults to hmac-md5 and
|
||||||
|
the secret is expressed as a base-64 encoded string.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-h\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Print a usage statement and exit.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-i \fIinterval\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the time interval between data points in the plot file. The
|
||||||
|
default is 0.5 seconds.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-m \fImax_qps\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the target maximum query rate (in queries per second). This should
|
||||||
|
be higher than the expected maximum throughput of the server being tested.
|
||||||
|
Traffic will be ramped up at a linearly increasing rate until this value is
|
||||||
|
reached, or until one of the other conditions described in the section
|
||||||
|
"Running the test" occurs. The default is 100000 queries per second.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-P \fIplot_data_file\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the name of the plot data file. The default is
|
||||||
|
\fIresperf.gnuplot\fR.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-r \fIrampup_time\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the length of time over which traffic will be ramped up. The
|
||||||
|
default is 60 seconds.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-c \fIconstant_traffic_time\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the length of time for which traffic will be sent at a constant
|
||||||
|
rate following the initial ramp-up. The default is 0 seconds, meaning no
|
||||||
|
sending of traffic at a constant rate will be done.
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fB-L \fImax_loss\fR\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
Specifies the maximum acceptable query loss percentage for purposes of
|
||||||
|
determining the maximum throughput value. The default is 100%, meaning that
|
||||||
|
\fBresperf\fR will measure the maximum throughput without regard to query
|
||||||
|
loss.
|
||||||
|
.RE
|
||||||
|
.SH "THE PLOT DATA FILE"
|
||||||
|
The plot data file is written by the \fBresperf\fR program and contains the
|
||||||
|
data to be plotted using \fBgnuplot\fR. When running \fBresperf\fR via the
|
||||||
|
\fBresperf\-report\fR script, there is no need for the user to deal with
|
||||||
|
this file directly, but its format and contents are documented here for
|
||||||
|
completeness and in case you wish to run \fBresperf\fR directly and use its
|
||||||
|
output for purposes other than viewing it with \fBgnuplot\fR.
|
||||||
|
|
||||||
|
The first line of the file is a comment identifying the fields. It may be
|
||||||
|
recognized as a comment by its leading hash sign (#).
|
||||||
|
|
||||||
|
Subsequent lines contain the actual plot data. For purposes of generating
|
||||||
|
the plot data file, the test run is divided into time intervals of 0.5
|
||||||
|
seconds (or some other length of time specified with the \fB\-i\fR command
|
||||||
|
line option). Each line corresponds to one such interval, and contains the
|
||||||
|
following values as floating-point numbers:
|
||||||
|
|
||||||
|
\fBTime\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
The midpoint of this time interval, in seconds since the beginning of the
|
||||||
|
run
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fBTarget queries per second\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
The number of queries per second scheduled to be sent in this time interval
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fBActual queries per second\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
The number of queries per second actually sent in this time interval
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fBResponses per second\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
The number of responses received corresponding to queries sent in this time
|
||||||
|
interval, divided by the length of the interval
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fBFailures per second\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
The number of responses received corresponding to queries sent in this time
|
||||||
|
interval and having an RCODE other than NOERROR or NXDOMAIN, divided by the
|
||||||
|
length of the interval
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fBAverage latency\fR
|
||||||
|
.br
|
||||||
|
.RS
|
||||||
|
The average time between sending the query and receiving a response, for
|
||||||
|
queries sent in this time interval
|
||||||
|
.RE
|
||||||
|
.SH AUTHOR
|
||||||
|
Nominum, Inc.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
\fBdnsperf\fR(1)
|
678
dns/dnsperf-src-2.0.0.0-1/resperf.c
Normal file
678
dns/dnsperf-src-2.0.0.0-1/resperf.c
Normal file
|
@ -0,0 +1,678 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2000, 2001 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||||
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||||
|
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||||
|
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2004 - 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***
|
||||||
|
*** DNS Resolution Performance Testing Tool
|
||||||
|
***
|
||||||
|
*** Version $Id: resperf.c 213200 2012-02-07 02:33:07Z bwelling $
|
||||||
|
***/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <isc/buffer.h>
|
||||||
|
#include <isc/file.h>
|
||||||
|
#include <isc/list.h>
|
||||||
|
#include <isc/mem.h>
|
||||||
|
#include <isc/region.h>
|
||||||
|
#include <isc/result.h>
|
||||||
|
#include <isc/sockaddr.h>
|
||||||
|
#include <isc/types.h>
|
||||||
|
|
||||||
|
#include <dns/result.h>
|
||||||
|
|
||||||
|
#include "datafile.h"
|
||||||
|
#include "dns.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "net.h"
|
||||||
|
#include "opt.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Global stuff
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEFAULT_SERVER_NAME "127.0.0.1"
|
||||||
|
#define DEFAULT_SERVER_PORT 53
|
||||||
|
#define DEFAULT_LOCAL_PORT 0
|
||||||
|
#define DEFAULT_SOCKET_BUFFER 32
|
||||||
|
#define DEFAULT_TIMEOUT 45
|
||||||
|
|
||||||
|
#define MAX_INPUT_DATA (4 * 1024)
|
||||||
|
|
||||||
|
struct query_info;
|
||||||
|
|
||||||
|
typedef ISC_LIST(struct query_info) query_list;
|
||||||
|
|
||||||
|
typedef struct query_info {
|
||||||
|
isc_uint64_t sent_timestamp;
|
||||||
|
/*
|
||||||
|
* This link links the query into the list of outstanding
|
||||||
|
* queries or the list of available query IDs.
|
||||||
|
*/
|
||||||
|
ISC_LINK(struct query_info) link;
|
||||||
|
/*
|
||||||
|
* The list this query is on.
|
||||||
|
*/
|
||||||
|
query_list *list;
|
||||||
|
} query_info;
|
||||||
|
|
||||||
|
static query_list outstanding_list;
|
||||||
|
static query_list instanding_list;
|
||||||
|
|
||||||
|
#define NQIDS 65536
|
||||||
|
static query_info queries[NQIDS];
|
||||||
|
|
||||||
|
static isc_mem_t *mctx;
|
||||||
|
|
||||||
|
static isc_sockaddr_t server_addr;
|
||||||
|
static isc_sockaddr_t local_addr;
|
||||||
|
static int query_socket;
|
||||||
|
|
||||||
|
static isc_uint64_t query_timeout;
|
||||||
|
static isc_boolean_t edns;
|
||||||
|
static isc_boolean_t dnssec;
|
||||||
|
|
||||||
|
static perf_datafile_t *input;
|
||||||
|
|
||||||
|
/* The target traffic level at the end of the ramp-up */
|
||||||
|
double max_qps = 100000.0;
|
||||||
|
|
||||||
|
/* The time period over which we ramp up traffic */
|
||||||
|
#define DEFAULT_RAMP_TIME 60
|
||||||
|
static isc_uint64_t ramp_time;
|
||||||
|
|
||||||
|
/* How long to send constant traffic after the initial ramp-up */
|
||||||
|
#define DEFAULT_SUSTAIN_TIME 0
|
||||||
|
static isc_uint64_t sustain_time;
|
||||||
|
|
||||||
|
/* How long to wait for responses after sending traffic */
|
||||||
|
static isc_uint64_t wait_time = 40 * MILLION;
|
||||||
|
|
||||||
|
/* Total duration of the traffic-sending part of the test */
|
||||||
|
static isc_uint64_t traffic_time;
|
||||||
|
|
||||||
|
/* Total duration of the test */
|
||||||
|
static isc_uint64_t end_time;
|
||||||
|
|
||||||
|
/* Interval between plot data points, in microseconds */
|
||||||
|
#define DEFAULT_BUCKET_INTERVAL 0.5
|
||||||
|
static isc_uint64_t bucket_interval;
|
||||||
|
|
||||||
|
/* The number of plot data points */
|
||||||
|
static int n_buckets;
|
||||||
|
|
||||||
|
/* The plot data file */
|
||||||
|
static const char *plotfile = "resperf.gnuplot";
|
||||||
|
|
||||||
|
/* The largest acceptable query loss when reporting max throughput */
|
||||||
|
static double max_loss_percent = 100.0;
|
||||||
|
|
||||||
|
static unsigned int num_queries_sent;
|
||||||
|
static unsigned int num_queries_outstanding;
|
||||||
|
static unsigned int num_queries_timed_out;
|
||||||
|
|
||||||
|
static isc_uint64_t time_now;
|
||||||
|
static isc_uint64_t time_of_program_start;
|
||||||
|
static isc_uint64_t time_of_end_of_run;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The last plot data point containing actual data; this can
|
||||||
|
* be less than than (n_buckets - 1) if the traffic sending
|
||||||
|
* phase is cut short
|
||||||
|
*/
|
||||||
|
static int last_bucket_used;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The statistics for queries sent during one bucket_interval
|
||||||
|
* of the traffic sending phase.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
int queries;
|
||||||
|
int responses;
|
||||||
|
int failures;
|
||||||
|
double latency_sum;
|
||||||
|
} ramp_bucket;
|
||||||
|
|
||||||
|
/* Pointer to array of n_buckets ramp_bucket structures */
|
||||||
|
static ramp_bucket *buckets;
|
||||||
|
|
||||||
|
enum phase {
|
||||||
|
/*
|
||||||
|
* The ramp-up phase: we are steadily increasing traffic.
|
||||||
|
*/
|
||||||
|
PHASE_RAMP,
|
||||||
|
/*
|
||||||
|
* The sustain phase: we are sending traffic at a constant
|
||||||
|
* rate.
|
||||||
|
*/
|
||||||
|
PHASE_SUSTAIN,
|
||||||
|
/*
|
||||||
|
* The wait phase: we have stopped sending queries and are
|
||||||
|
* just waiting for any remaining responses.
|
||||||
|
*/
|
||||||
|
PHASE_WAIT
|
||||||
|
};
|
||||||
|
static enum phase phase = PHASE_RAMP;
|
||||||
|
|
||||||
|
/* The time when the sustain/wait phase began */
|
||||||
|
static isc_uint64_t sustain_phase_began, wait_phase_began;
|
||||||
|
|
||||||
|
static perf_dnstsigkey_t *tsigkey;
|
||||||
|
|
||||||
|
static char *
|
||||||
|
stringify(double value, int precision)
|
||||||
|
{
|
||||||
|
static char buf[20];
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%.*f", precision, value);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup(int argc, char **argv)
|
||||||
|
{
|
||||||
|
const char *family = NULL;
|
||||||
|
const char *server_name = DEFAULT_SERVER_NAME;
|
||||||
|
in_port_t server_port = DEFAULT_SERVER_PORT;
|
||||||
|
const char *local_name = NULL;
|
||||||
|
in_port_t local_port = DEFAULT_LOCAL_PORT;
|
||||||
|
const char *filename = NULL;
|
||||||
|
const char *tsigkey_str = NULL;
|
||||||
|
int sock_family;
|
||||||
|
unsigned int bufsize;
|
||||||
|
unsigned int i;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
result = isc_mem_create(0, 0, &mctx);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
perf_log_fatal("creating memory context: %s",
|
||||||
|
isc_result_totext(result));
|
||||||
|
|
||||||
|
dns_result_register();
|
||||||
|
|
||||||
|
ISC_LIST_INIT(outstanding_list);
|
||||||
|
ISC_LIST_INIT(instanding_list);
|
||||||
|
for (i = 0; i < NQIDS; i++) {
|
||||||
|
ISC_LINK_INIT(&queries[i], link);
|
||||||
|
ISC_LIST_APPEND(instanding_list, &queries[i], link);
|
||||||
|
queries[i].list = &instanding_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
sock_family = AF_UNSPEC;
|
||||||
|
server_port = DEFAULT_SERVER_PORT;
|
||||||
|
local_port = DEFAULT_LOCAL_PORT;
|
||||||
|
bufsize = DEFAULT_SOCKET_BUFFER;
|
||||||
|
query_timeout = DEFAULT_TIMEOUT * MILLION;
|
||||||
|
ramp_time = DEFAULT_RAMP_TIME * MILLION;
|
||||||
|
sustain_time = DEFAULT_SUSTAIN_TIME * MILLION;
|
||||||
|
bucket_interval = DEFAULT_BUCKET_INTERVAL * MILLION;
|
||||||
|
|
||||||
|
perf_opt_add('f', perf_opt_string, "family",
|
||||||
|
"address family of DNS transport, inet or inet6", "any",
|
||||||
|
&family);
|
||||||
|
perf_opt_add('s', perf_opt_string, "server_addr",
|
||||||
|
"the server to query", DEFAULT_SERVER_NAME, &server_name);
|
||||||
|
perf_opt_add('p', perf_opt_port, "port",
|
||||||
|
"the port on which to query the server",
|
||||||
|
stringify(DEFAULT_SERVER_PORT, 0), &server_port);
|
||||||
|
perf_opt_add('a', perf_opt_string, "local_addr",
|
||||||
|
"the local address from which to send queries", NULL,
|
||||||
|
&local_name);
|
||||||
|
perf_opt_add('x', perf_opt_port, "local_port",
|
||||||
|
"the local port from which to send queries",
|
||||||
|
stringify(DEFAULT_LOCAL_PORT, 0), &local_port);
|
||||||
|
perf_opt_add('d', perf_opt_string, "datafile",
|
||||||
|
"the input data file", "stdin", &filename);
|
||||||
|
perf_opt_add('t', perf_opt_timeval, "timeout",
|
||||||
|
"the timeout for query completion in seconds",
|
||||||
|
stringify(DEFAULT_TIMEOUT, 0), &query_timeout);
|
||||||
|
perf_opt_add('b', perf_opt_uint, "buffer_size",
|
||||||
|
"socket send/receive buffer size in kilobytes", NULL,
|
||||||
|
&bufsize);
|
||||||
|
perf_opt_add('e', perf_opt_boolean, NULL,
|
||||||
|
"enable EDNS 0", NULL, &edns);
|
||||||
|
perf_opt_add('D', perf_opt_boolean, NULL,
|
||||||
|
"set the DNSSEC OK bit (implies EDNS)", NULL, &dnssec);
|
||||||
|
perf_opt_add('y', perf_opt_string, "[alg:]name:secret",
|
||||||
|
"the TSIG algorithm, name and secret", NULL,
|
||||||
|
&tsigkey_str);
|
||||||
|
perf_opt_add('i', perf_opt_timeval, "plot_interval",
|
||||||
|
"the time interval between plot data points, in seconds",
|
||||||
|
stringify(DEFAULT_BUCKET_INTERVAL, 1), &bucket_interval);
|
||||||
|
perf_opt_add('m', perf_opt_double, "max_qps",
|
||||||
|
"the maximum number of queries per second",
|
||||||
|
stringify(max_qps, 0), &max_qps);
|
||||||
|
perf_opt_add('P', perf_opt_string, "plotfile",
|
||||||
|
"the name of the plot data file", plotfile, &plotfile);
|
||||||
|
perf_opt_add('r', perf_opt_timeval, "ramp_time",
|
||||||
|
"the ramp-up time in seconds",
|
||||||
|
stringify(DEFAULT_RAMP_TIME, 0), &ramp_time);
|
||||||
|
perf_opt_add('c', perf_opt_timeval, "constant_traffic_time",
|
||||||
|
"how long to send constant traffic, in seconds",
|
||||||
|
stringify(DEFAULT_SUSTAIN_TIME, 0), &sustain_time);
|
||||||
|
perf_opt_add('L', perf_opt_double, "max_query_loss",
|
||||||
|
"the maximum acceptable query loss, in percent",
|
||||||
|
stringify(max_loss_percent, 0), &max_loss_percent);
|
||||||
|
|
||||||
|
perf_opt_parse(argc, argv);
|
||||||
|
|
||||||
|
if (family != NULL)
|
||||||
|
sock_family = perf_net_parsefamily(family);
|
||||||
|
perf_net_parseserver(sock_family, server_name, server_port,
|
||||||
|
&server_addr);
|
||||||
|
perf_net_parselocal(isc_sockaddr_pf(&server_addr),
|
||||||
|
local_name, local_port, &local_addr);
|
||||||
|
|
||||||
|
input = perf_datafile_open(mctx, filename);
|
||||||
|
|
||||||
|
if (dnssec)
|
||||||
|
edns = ISC_TRUE;
|
||||||
|
|
||||||
|
if (tsigkey_str != NULL)
|
||||||
|
tsigkey = perf_dns_parsetsigkey(tsigkey_str, mctx);
|
||||||
|
|
||||||
|
query_socket = perf_net_opensocket(&server_addr, &local_addr, 0,
|
||||||
|
bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cleanup(void)
|
||||||
|
{
|
||||||
|
perf_datafile_close(&input);
|
||||||
|
(void) close(query_socket);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the ramp_bucket for queries sent at time "when" */
|
||||||
|
|
||||||
|
static ramp_bucket *
|
||||||
|
find_bucket(isc_uint64_t when) {
|
||||||
|
isc_uint64_t sent_at = when - time_of_program_start;
|
||||||
|
int i = (int) ((n_buckets * sent_at) / traffic_time);
|
||||||
|
/*
|
||||||
|
* Guard against array bounds violations due to roundoff
|
||||||
|
* errors or scheduling jitter
|
||||||
|
*/
|
||||||
|
if (i < 0)
|
||||||
|
i = 0;
|
||||||
|
if (i > n_buckets - 1)
|
||||||
|
i = n_buckets - 1;
|
||||||
|
return &buckets[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* print_statistics:
|
||||||
|
* Print out statistics based on the results of the test
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
print_statistics(void) {
|
||||||
|
int i;
|
||||||
|
double max_throughput;
|
||||||
|
double loss_at_max_throughput;
|
||||||
|
isc_uint64_t run_time = time_of_end_of_run - time_of_program_start;
|
||||||
|
|
||||||
|
printf("\nStatistics:\n\n");
|
||||||
|
|
||||||
|
printf(" Queries sent: %u\n", num_queries_sent);
|
||||||
|
printf(" Queries completed: %u\n",
|
||||||
|
num_queries_sent - num_queries_outstanding);
|
||||||
|
printf(" Queries lost: %u\n", num_queries_outstanding);
|
||||||
|
printf(" Run time (s): %u.%06u\n",
|
||||||
|
(unsigned int)(run_time / MILLION),
|
||||||
|
(unsigned int)(run_time % MILLION));
|
||||||
|
|
||||||
|
/* Find the maximum throughput, subject to the -L option */
|
||||||
|
max_throughput = 0.0;
|
||||||
|
loss_at_max_throughput = 0.0;
|
||||||
|
for (i = 0; i <= last_bucket_used; i++) {
|
||||||
|
ramp_bucket *b = &buckets[i];
|
||||||
|
double responses_per_sec =
|
||||||
|
b->responses / (bucket_interval / (double) MILLION);
|
||||||
|
double loss = b->queries ?
|
||||||
|
(b->queries - b->responses) / (double) b->queries : 0.0;
|
||||||
|
double loss_percent = loss * 100.0;
|
||||||
|
if (loss_percent > max_loss_percent)
|
||||||
|
break;
|
||||||
|
if (responses_per_sec > max_throughput) {
|
||||||
|
max_throughput = responses_per_sec;
|
||||||
|
loss_at_max_throughput = loss_percent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf(" Maximum throughput: %.6lf qps\n", max_throughput);
|
||||||
|
printf(" Lost at that point: %.2f%%\n", loss_at_max_throughput);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ramp_bucket *
|
||||||
|
init_buckets(int n) {
|
||||||
|
ramp_bucket *p = malloc(n * sizeof(*p));
|
||||||
|
int i;
|
||||||
|
if (p == NULL)
|
||||||
|
perf_log_fatal("out of memory");
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
p[i].queries = p[i].responses = p[i].failures = 0;
|
||||||
|
p[i].latency_sum = 0.0;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send a query based on a line of input.
|
||||||
|
* Return ISC_R_NOMORE if we ran out of query IDs.
|
||||||
|
*/
|
||||||
|
static isc_result_t
|
||||||
|
do_one_line(isc_buffer_t *lines, isc_buffer_t *msg) {
|
||||||
|
query_info *q;
|
||||||
|
unsigned int qid;
|
||||||
|
isc_region_t used;
|
||||||
|
unsigned char *base;
|
||||||
|
unsigned int length;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
isc_buffer_clear(lines);
|
||||||
|
result = perf_datafile_next(input, lines, ISC_FALSE);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
perf_log_fatal("ran out of query data");
|
||||||
|
isc_buffer_usedregion(lines, &used);
|
||||||
|
|
||||||
|
q = ISC_LIST_HEAD(instanding_list);
|
||||||
|
if (! q)
|
||||||
|
return (ISC_R_NOMORE);
|
||||||
|
qid = q - queries;
|
||||||
|
|
||||||
|
isc_buffer_clear(msg);
|
||||||
|
result = perf_dns_buildrequest(NULL, (isc_textregion_t *) &used,
|
||||||
|
qid, edns, dnssec, tsigkey, msg);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
|
||||||
|
q->sent_timestamp = time_now;
|
||||||
|
|
||||||
|
base = isc_buffer_base(msg);
|
||||||
|
length = isc_buffer_usedlength(msg);
|
||||||
|
if (sendto(query_socket, base, length, 0,
|
||||||
|
&server_addr.type.sa,
|
||||||
|
server_addr.length) < 1)
|
||||||
|
{
|
||||||
|
perf_log_warning("failed to send packet: %s",
|
||||||
|
strerror(errno));
|
||||||
|
return (ISC_R_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
ISC_LIST_UNLINK(instanding_list, q, link);
|
||||||
|
ISC_LIST_PREPEND(outstanding_list, q, link);
|
||||||
|
q->list = &outstanding_list;
|
||||||
|
|
||||||
|
num_queries_sent++;
|
||||||
|
num_queries_outstanding++;
|
||||||
|
|
||||||
|
return ISC_R_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
enter_sustain_phase(void) {
|
||||||
|
phase = PHASE_SUSTAIN;
|
||||||
|
if (sustain_time != 0.0)
|
||||||
|
printf("[Status] Ramp-up done, sending constant traffic\n");
|
||||||
|
sustain_phase_began = time_now;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
enter_wait_phase(void) {
|
||||||
|
phase = PHASE_WAIT;
|
||||||
|
printf("[Status] Waiting for more responses\n");
|
||||||
|
wait_phase_began = time_now;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* try_process_response:
|
||||||
|
*
|
||||||
|
* Receive from the given socket & process an individual response packet.
|
||||||
|
* Remove it from the list of open queries (status[]) and decrement the
|
||||||
|
* number of outstanding queries if it matches an open query.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
try_process_response(int sockfd) {
|
||||||
|
unsigned char packet_buffer[MAX_EDNS_PACKET];
|
||||||
|
isc_uint16_t *packet_header;
|
||||||
|
isc_uint16_t qid, rcode;
|
||||||
|
query_info *q;
|
||||||
|
double latency;
|
||||||
|
ramp_bucket *b;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
packet_header = (isc_uint16_t *) packet_buffer;
|
||||||
|
n = recvfrom(sockfd, packet_buffer, sizeof(packet_buffer),
|
||||||
|
0, NULL, NULL);
|
||||||
|
if (n < 0) {
|
||||||
|
if (errno == EAGAIN || errno == EINTR) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
perf_log_fatal("failed to receive packet: %s",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
} else if (n < 4) {
|
||||||
|
perf_log_warning("received short response");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qid = ntohs(packet_header[0]);
|
||||||
|
rcode = ntohs(packet_header[1]) & 0xF;
|
||||||
|
|
||||||
|
q = &queries[qid];
|
||||||
|
if (q->list != &outstanding_list) {
|
||||||
|
perf_log_warning("received a response with an "
|
||||||
|
"unexpected id: %u", qid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISC_LIST_UNLINK(outstanding_list, q, link);
|
||||||
|
ISC_LIST_APPEND(instanding_list, q, link);
|
||||||
|
q->list = &instanding_list;
|
||||||
|
|
||||||
|
num_queries_outstanding--;
|
||||||
|
|
||||||
|
latency = (time_now - q->sent_timestamp) / (double)MILLION;
|
||||||
|
b = find_bucket(q->sent_timestamp);
|
||||||
|
b->responses++;
|
||||||
|
if (!(rcode == dns_rcode_noerror || rcode == dns_rcode_nxdomain))
|
||||||
|
b->failures++;
|
||||||
|
b->latency_sum += latency;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
retire_old_queries(void)
|
||||||
|
{
|
||||||
|
query_info *q;
|
||||||
|
|
||||||
|
while (ISC_TRUE) {
|
||||||
|
q = ISC_LIST_TAIL(outstanding_list);
|
||||||
|
if (q == NULL ||
|
||||||
|
(time_now - q->sent_timestamp) < query_timeout)
|
||||||
|
break;
|
||||||
|
ISC_LIST_UNLINK(outstanding_list, q, link);
|
||||||
|
ISC_LIST_APPEND(instanding_list, q, link);
|
||||||
|
q->list = &instanding_list;
|
||||||
|
|
||||||
|
num_queries_outstanding--;
|
||||||
|
num_queries_timed_out++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
num_scheduled(isc_uint64_t time_since_start)
|
||||||
|
{
|
||||||
|
if (phase == PHASE_RAMP) {
|
||||||
|
return 0.5 * max_qps *
|
||||||
|
(double)time_since_start * time_since_start /
|
||||||
|
(ramp_time * MILLION);
|
||||||
|
} else { /* PHASE_SUSTAIN */
|
||||||
|
return 0.5 * max_qps * (ramp_time / (double)MILLION) +
|
||||||
|
max_qps *
|
||||||
|
(time_since_start - ramp_time) / (double)MILLION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv) {
|
||||||
|
int i;
|
||||||
|
FILE *plotf;
|
||||||
|
isc_buffer_t lines, msg;
|
||||||
|
char input_data[MAX_INPUT_DATA];
|
||||||
|
unsigned char outpacket_buffer[MAX_EDNS_PACKET];
|
||||||
|
unsigned int max_packet_size;
|
||||||
|
|
||||||
|
printf("DNS Resolution Performance Testing Tool\n"
|
||||||
|
"Nominum Version " VERSION "\n\n");
|
||||||
|
|
||||||
|
setup(argc, argv);
|
||||||
|
|
||||||
|
isc_buffer_init(&lines, input_data, sizeof(input_data));
|
||||||
|
|
||||||
|
max_packet_size = edns ? MAX_EDNS_PACKET : MAX_UDP_PACKET;
|
||||||
|
isc_buffer_init(&msg, outpacket_buffer, max_packet_size);
|
||||||
|
|
||||||
|
traffic_time = ramp_time + sustain_time;
|
||||||
|
end_time = traffic_time + wait_time;
|
||||||
|
|
||||||
|
n_buckets = (traffic_time + bucket_interval - 1) / bucket_interval;
|
||||||
|
buckets = init_buckets(n_buckets);
|
||||||
|
|
||||||
|
time_now = get_time();
|
||||||
|
time_of_program_start = time_now;
|
||||||
|
|
||||||
|
printf("[Status] Command line: %s", isc_file_basename(argv[0]));
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
printf(" %s", argv[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
printf("[Status] Sending\n");
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
int should_send;
|
||||||
|
isc_uint64_t time_since_start = time_now -
|
||||||
|
time_of_program_start;
|
||||||
|
switch (phase) {
|
||||||
|
case PHASE_RAMP:
|
||||||
|
if (time_since_start >= ramp_time)
|
||||||
|
enter_sustain_phase();
|
||||||
|
break;
|
||||||
|
case PHASE_SUSTAIN:
|
||||||
|
if (time_since_start >= traffic_time)
|
||||||
|
enter_wait_phase();
|
||||||
|
break;
|
||||||
|
case PHASE_WAIT:
|
||||||
|
if (time_since_start >= end_time)
|
||||||
|
goto end_loop;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (phase != PHASE_WAIT) {
|
||||||
|
should_send = num_scheduled(time_since_start) -
|
||||||
|
num_queries_sent;
|
||||||
|
if (should_send >= 1000) {
|
||||||
|
printf("[Status] Fell behind by %d queries, "
|
||||||
|
"ending test at %.0f qps\n",
|
||||||
|
should_send,
|
||||||
|
(max_qps * time_since_start) /
|
||||||
|
ramp_time);
|
||||||
|
enter_wait_phase();
|
||||||
|
}
|
||||||
|
if (should_send > 0) {
|
||||||
|
isc_result_t result = do_one_line(&lines, &msg);
|
||||||
|
if (result == ISC_R_SUCCESS)
|
||||||
|
find_bucket(time_now)->queries++;
|
||||||
|
if (result == ISC_R_NOMORE) {
|
||||||
|
printf("[Status] Reached 65536 outstanding queries\n");
|
||||||
|
enter_wait_phase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try_process_response(query_socket);
|
||||||
|
retire_old_queries();
|
||||||
|
time_now = get_time();
|
||||||
|
}
|
||||||
|
end_loop:
|
||||||
|
time_now = get_time();
|
||||||
|
time_of_end_of_run = time_now;
|
||||||
|
|
||||||
|
printf("[Status] Testing complete\n");
|
||||||
|
|
||||||
|
plotf = fopen(plotfile, "w");
|
||||||
|
if (! plotf) {
|
||||||
|
perf_log_fatal("could not open %s: %s", plotfile,
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print column headers */
|
||||||
|
fprintf(plotf, "# time target_qps actual_qps "
|
||||||
|
"responses_per_sec failures_per_sec "
|
||||||
|
"avg_latency\n");
|
||||||
|
|
||||||
|
/* Don't print unused buckets */
|
||||||
|
last_bucket_used = find_bucket(wait_phase_began) - buckets;
|
||||||
|
|
||||||
|
/* Don't print a partial bucket at the end */
|
||||||
|
if (last_bucket_used > 0)
|
||||||
|
--last_bucket_used;
|
||||||
|
|
||||||
|
for (i = 0; i <= last_bucket_used; i++) {
|
||||||
|
double t = (i + 0.5) * traffic_time /
|
||||||
|
(n_buckets * (double)MILLION);
|
||||||
|
double ramp_dtime = ramp_time / (double)MILLION;
|
||||||
|
double target_qps =
|
||||||
|
t <= ramp_dtime ? (t / ramp_dtime) * max_qps : max_qps;
|
||||||
|
double latency = buckets[i].responses ?
|
||||||
|
buckets[i].latency_sum / buckets[i].responses : 0;
|
||||||
|
double interval = bucket_interval / (double) MILLION;
|
||||||
|
fprintf(plotf, "%7.3f %8.2f %8.2f %8.2f %8.2f %8.6f\n",
|
||||||
|
t,
|
||||||
|
target_qps,
|
||||||
|
buckets[i].queries / interval,
|
||||||
|
buckets[i].responses / interval,
|
||||||
|
buckets[i].failures / interval,
|
||||||
|
latency);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(plotf);
|
||||||
|
print_statistics();
|
||||||
|
cleanup();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
122
dns/dnsperf-src-2.0.0.0-1/util.h
Normal file
122
dns/dnsperf-src-2.0.0.0-1/util.h
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2012 Nominum, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and its
|
||||||
|
* documentation for any purpose with or without fee is hereby granted,
|
||||||
|
* provided that the above copyright notice and this permission notice
|
||||||
|
* appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <isc/types.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
#ifndef PERF_UTIL_H
|
||||||
|
#define PERF_UTIL_H 1
|
||||||
|
|
||||||
|
#define MILLION ((isc_uint64_t) 1000000)
|
||||||
|
|
||||||
|
#define THREAD(thread, start, arg) do { \
|
||||||
|
int __n = pthread_create((thread), NULL, (start), (arg)); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_create failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define JOIN(thread, valuep) do { \
|
||||||
|
int __n = pthread_join((thread), (valuep)); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_join failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define MUTEX_INIT(mutex) do { \
|
||||||
|
int __n = pthread_mutex_init((mutex), NULL); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_mutex_init failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define MUTEX_DESTROY(mutex) do { \
|
||||||
|
int __n = pthread_mutex_destroy((mutex)); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_mutex_destroy failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LOCK(mutex) do { \
|
||||||
|
int __n = pthread_mutex_lock((mutex)); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_mutex_lock failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define UNLOCK(mutex) do { \
|
||||||
|
int __n = pthread_mutex_unlock((mutex)); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_mutex_unlock failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define COND_INIT(cond) do { \
|
||||||
|
int __n = pthread_cond_init((cond), NULL); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_cond_init failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define SIGNAL(cond) do { \
|
||||||
|
int __n = pthread_cond_signal((cond)); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_cond_signal failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define BROADCAST(cond) do { \
|
||||||
|
int __n = pthread_cond_broadcast((cond)); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_cond_broadcast failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define WAIT(cond, mutex) do { \
|
||||||
|
int __n = pthread_cond_wait((cond), (mutex)); \
|
||||||
|
if (__n != 0) \
|
||||||
|
perf_log_fatal("pthread_cond_wait failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define TIMEDWAIT(cond, mutex, when, timedout) do { \
|
||||||
|
int __n = pthread_cond_timedwait((cond), (mutex), (when)); \
|
||||||
|
isc_boolean_t *res = (timedout); \
|
||||||
|
if (__n != 0 && __n != ETIMEDOUT) \
|
||||||
|
perf_log_fatal("pthread_cond_timedwait failed: %s", \
|
||||||
|
strerror(__n)); \
|
||||||
|
if (res != NULL) \
|
||||||
|
*res = ISC_TF(__n != 0); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
static __inline__ isc_uint64_t
|
||||||
|
get_time(void)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
return tv.tv_sec * MILLION + tv.tv_usec;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SAFE_DIV(n, d) ( (d) == 0 ? 0 : (n) / (d) )
|
||||||
|
|
||||||
|
#endif
|
5
dns/dnsperf-src-2.0.0.0-1/version.h
Normal file
5
dns/dnsperf-src-2.0.0.0-1/version.h
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#ifndef VERSION_H
|
||||||
|
|
||||||
|
#define VERSION "2.0.0.0"
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue