├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── README.aix ├── README.hpux ├── README.osx ├── README.ovms ├── README.solaris ├── README.vmware ├── README.windows ├── Release_Notes ├── acinclude.m4 ├── aclocal.m4 ├── autogen.sh ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── depcomp ├── doc ├── Makefile.am ├── Makefile.in ├── examples │ ├── Makefile.am │ ├── Makefile.in │ ├── arr_script │ ├── bloat.py │ ├── bloat.sh │ ├── find_max_burst.sh │ ├── mins_maxes.awk │ ├── netperf_by_flavor.py │ ├── netperf_interim_to_rrd.sh │ ├── packet_byte_script │ ├── post_proc.py │ ├── post_proc.sh │ ├── remote_hosts │ ├── runemomni.sh │ ├── runemomniagg2.sh │ ├── runemomniaggdemo.sh │ ├── sctp_stream_script │ ├── set_affinity.sh │ ├── snapshot_script │ ├── tcp_range_script │ ├── tcp_rr_script │ ├── tcp_stream_script │ ├── udp_rr_script │ ├── udp_stream_script │ └── vrules.awk ├── netperf.html ├── netperf.info ├── netperf.man ├── netperf.pdf ├── netperf.ps ├── netperf.texi ├── netperf.txt ├── netperf.xml ├── netperf_old.ps ├── netserver.man ├── omni_output_list.txt └── texinfo.tex ├── inet_ntop.c ├── install-sh ├── m4 └── m4 │ ├── salen.m4 │ ├── sockaddrin6.m4 │ └── sockinttypes.m4 ├── missing ├── mkinstalldirs ├── netperf.spec.in └── src ├── Makefile.am ├── Makefile.in ├── Makefile.uw ├── NetPerfDir ├── inet_ntop.c ├── makefile └── sources ├── NetServerDir ├── inet_ntop.c ├── makefile └── sources ├── dirs ├── dscp.c ├── hist.h ├── missing ├── Makefile.am ├── Makefile.in ├── getaddrinfo.c ├── getaddrinfo.h ├── inet_ntop.c ├── inttypes.h ├── m4 │ ├── Makefile.am │ ├── Makefile.in │ ├── herrno.m4 │ ├── in6addr.m4 │ ├── salen.m4 │ ├── sockaddrin6.m4 │ ├── sockinttypes.m4 │ ├── socklent.m4 │ └── type_socklen_t.m4 └── stdint.h ├── net_uuid.c ├── netcpu.h ├── netcpu_kstat.c ├── netcpu_kstat10.c ├── netcpu_looper.c ├── netcpu_none.c ├── netcpu_ntperf.c ├── netcpu_osx.c ├── netcpu_perfstat.c ├── netcpu_procstat.c ├── netcpu_pstat.c ├── netcpu_pstatnew.c ├── netcpu_sysctl.c ├── netdrv_ethtool.c ├── netdrv_none.c ├── netdrv_solaris.c ├── netlib.c ├── netlib.h ├── netperf.c ├── netperf_version.h.in ├── netrt_none.c ├── netrt_rtmget.c ├── netrt_rtnetlink.c ├── netsec_linux.c ├── netsec_none.c ├── netsec_win.c ├── netserver.c ├── netsh.c ├── netsh.h ├── netslot_linux.c ├── netslot_none.c ├── netslot_solaris.c ├── netslot_ux1131.c ├── netsys_hpux11i.c ├── netsys_linux.c ├── netsys_none.c ├── netsys_solaris.c ├── nettest_bsd.c ├── nettest_bsd.h ├── nettest_dlpi.c ├── nettest_dlpi.h ├── nettest_omni.c ├── nettest_sctp.c ├── nettest_sctp.h ├── nettest_sdp.c ├── nettest_sdp.h ├── nettest_unix.c ├── nettest_unix.h ├── nettest_xti.c └── nettest_xti.h /COPYING: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright (C) 1993 Hewlett-Packard Company 4 | ALL RIGHTS RESERVED. 5 | 6 | The enclosed software and documentation includes copyrighted works 7 | of Hewlett-Packard Co. For as long as you comply with the following 8 | limitations, you are hereby authorized to (i) use, reproduce, and 9 | modify the software and documentation, and to (ii) distribute the 10 | software and documentation, including modifications, for 11 | non-commercial purposes only. 12 | 13 | 1. The enclosed software and documentation is made available at no 14 | charge in order to advance the general development of 15 | high-performance networking products. 16 | 17 | 2. You may not delete any copyright notices contained in the 18 | software or documentation. All hard copies, and copies in 19 | source code or object code form, of the software or 20 | documentation (including modifications) must contain at least 21 | one of the copyright notices. 22 | 23 | 3. The enclosed software and documentation has not been subjected 24 | to testing and quality control and is not a Hewlett-Packard Co. 25 | product. At a future time, Hewlett-Packard Co. may or may not 26 | offer a version of the software and documentation as a product. 27 | 28 | 4. THE SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS". 29 | HEWLETT-PACKARD COMPANY DOES NOT WARRANT THAT THE USE, 30 | REPRODUCTION, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR 31 | DOCUMENTATION WILL NOT INFRINGE A THIRD PARTY'S INTELLECTUAL 32 | PROPERTY RIGHTS. HP DOES NOT WARRANT THAT THE SOFTWARE OR 33 | DOCUMENTATION IS ERROR FREE. HP DISCLAIMS ALL WARRANTIES, 34 | EXPRESS AND IMPLIED, WITH REGARD TO THE SOFTWARE AND THE 35 | DOCUMENTATION. HP SPECIFICALLY DISCLAIMS ALL WARRANTIES OF 36 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 37 | 38 | 5. HEWLETT-PACKARD COMPANY WILL NOT IN ANY EVENT BE LIABLE FOR ANY 39 | DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES 40 | (INCLUDING LOST PROFITS) RELATED TO ANY USE, REPRODUCTION, 41 | MODIFICATION, OR DISTRIBUTION OF THE SOFTWARE OR DOCUMENTATION. 42 | 43 | 44 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | See the file Release_Notes. -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AUTOMAKE_OPTIONS = dist-bzip2 dist-zip 3 | SUBDIRS = src doc 4 | EXTRA_DIST = README.* Release_Notes inet_ntop.c autogen.sh m4 5 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/multipath-tcp/netperf/1f639fa7e242b81a667c547c78adfb3f8fff3d30/NEWS -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | BE SURE TO READ THE MANUAL. EVEN THOUGH IT MAY BE OUTDATED. 3 | 4 | This is a brief readme file for the netperf TCP/UDP/sockets/etc 5 | performance benchmark. This is here mostly as a boot-strap. The real 6 | information is in the manual, which can be found in netperf.ps and 7 | online from http://www.netperf.org/netperf/NetperfPage.html. The 8 | sources, and a limited number of binaries, can be found from 9 | ftp://ftp.cup.hp.com/dist/networking/benchmarks/netperf/ . 10 | 11 | BE SURE TO READ THE MANUAL. EVEN THOUGH IT MAY BE OUTDATED. 12 | 13 | There is a COPYRIGHT file included. It is called COPYING because that 14 | is what autosomethingorother wanted. It is based on what the HP Legal 15 | Eagles gave me. I am not sure if the legalese is clear, but the intent 16 | is to say "Here is a benchmark. Use it in good health. Pass it along, 17 | port it, enhance it. You didn't pay for this tool, so don't expect it 18 | to be perfect ;-)" The rest of it is there to keep the layers happy... 19 | 20 | While the copyright is pretty much in spirit an "open source" one, it 21 | is not in letter - I never took the time to try to get it approved. 22 | If you feel strongly about the license of the code you use and want 23 | something under the GPL, consider netperf4: 24 | 25 | http://www.netperf.org/svn/netperf4/trunk 26 | 27 | Feel free to report netperf results in public forums, but please be 28 | excruciatingly complete in your description of the test envorinment. 29 | The old netperf database at: 30 | 31 | http://www.netperf.org/netperf/NetperfPage.html 32 | 33 | is no more - or rather the utilities for accessing it no longer run. 34 | The data is still present in the tree, albeit _VERY_ old now. 35 | 36 | There is an Internet mailing list devoted to netperf. It is called 37 | netperf-talk and it is hosted on netperf.org. Subscription requests 38 | should go to netperf-talk-request@netperf.org. 39 | 40 | Please DO NOT SEND subscription requests to netperf-talk! 41 | 42 | If you run into severe difficulties, or are just feeling chatty, 43 | please feel free to drop some email to me - Rick Jones 44 | . Be sure to include a meaningful subject lines. 45 | 46 | happy benchmarking, 47 | rick jones 48 | 49 | BE SURE TO READ THE MANUAL. EVEN THOUGH IT MAY BE OUTDATED. 50 | -------------------------------------------------------------------------------- /README.aix: -------------------------------------------------------------------------------- 1 | Pseudo-random things about netperf on AIX: 2 | 3 | While it _should_ not be necessary in the release bits, the rc bits 4 | for netperf 2.4.0 required: 5 | 6 | configure _may_ need: 7 | 8 | CFLAGS="-qcpluscmt -lperfstat" 9 | 10 | until such time as Rick Jones can figure-out or be told how to 11 | automagically add those using the configure script (hint hint :) 12 | 13 | The release bits should be OK without the above. Depending on the 14 | name used to invoke the compiler, the -qmumble option may be implicit. 15 | 16 | AIX include files have a VERY unfortuneate set of #define's in them 17 | for phrases network oriented programs are QUITE likely to have in 18 | their source - "rem_addr" and "rem_size" A "cousin" of the Netperf 19 | Contributing Editor reports this interferes with --enable-dlpi 20 | compilation and that it was also a problem for MySQL compiltion. 21 | While we await IBM's APAR with bated breath, netperf has been kludged 22 | to workaround this bug in IBM's include files. It has been reported 23 | that a "PMR" 34940,212,848 has been submitted to IBM in relation to 24 | this bug in their header files. 25 | 26 | Coutesy of Jan Krueger of TUI Infotec, Germany we have a pointer to 27 | a workaround for problems with compilation on AIX 6.1: 28 | 29 | https://www-304.ibm.com/support/docview.wss?uid=isg1IV01736 30 | 31 | when you get errors like: 32 | config.status: creating src/netperf_version.h 33 | gcc -DHAVE_CONFIG_H -I. -I.. -MT netlib.o -MD -MP -MF .deps/netlib.Tpo -c -o netlib.o netlib.c 34 | In file included from /usr/include/sys/corral.h:25, 35 | from /usr/include/libperfstat.h:28, 36 | from netlib.h:679, 37 | from netlib.c:166: 38 | /usr/include/netinet/in6_var.h:65: error: array type has incomplete element type 39 | -------------------------------------------------------------------------------- /README.hpux: -------------------------------------------------------------------------------- 1 | A note about CPU utilization... 2 | 3 | For HP-UX 11.0 <= system < 11.23 the configure script will select the 4 | "pstat" CPU utilization mechanism. This mechanism is the familiar 5 | HP-UX idle counter mechanism (for all incense and porpoises) and 6 | requires calibration. See src/netcpu_pstat.c for all the details. 7 | 8 | For HP-UX 11.23 >= system, the configure script will select the 9 | "pstatnew" CPU utilization mechanism. 11.23 adds cycle counts for 10 | user, kernel and interrupt modes to the idle cycle counter. As such, 11 | it _should_ be possible to simply take the sum of the four and the 12 | fractions and know how much time was spent in each mode. 13 | HOWEVER... there is a bug in the accounting for interrupt cycles, 14 | where interrupt cycles go missing. SOOO, since there is an accurate 15 | way to know what the total number of cycles should have been over the 16 | interval, and we know (ass-u-me) that the idle cycle counter is good 17 | (since the pstat mechanism has tested that one OK), we will take the 18 | ratio of idle to total cycles to compute CPU util. 19 | 20 | We will still calculate fractions for user, kernel and interrupt, and 21 | report them in debug (-d) output, but with a warning for interrupt 22 | time. See src/netcpu_pstatnew.c for all the details. 23 | 24 | Up through HP-UX 11.23 (aka 11iV2) if you enable burst mode, and 25 | happen to send sub-MSS requests and/or responses you _cannot_ assume 26 | that the packet per second rate on the wire will match the transaction 27 | per second rate reported by netperf, even if you set TCP_NODELAY with 28 | the test-specific -D option. The HP-UX 11.X TCP stack likely will be 29 | generating some immediate 'standalone' ACKnowledgements which may not 30 | be generated by other stacks. This has been reported to the HP-UX TCP 31 | folks, and an announcement will be made when that issue is resolved. 32 | -------------------------------------------------------------------------------- /README.osx: -------------------------------------------------------------------------------- 1 | If you are reading this, it suggests you are using a version of 2 | netperf in which the issue of file/directory name case insensitivity 3 | in OSX has been worked-around by renaming the NetPerf and NetServer 4 | directories to NetPerfDir and NetServerDir respectively. 5 | -------------------------------------------------------------------------------- /README.ovms: -------------------------------------------------------------------------------- 1 | February 11, 2003 2 | 3 | At the time of the initial port, I was not aware of a make facility 4 | for OpenVMS. So, I would just compile and link the various files by 5 | hand: 6 | 7 | $ cc netperf.c 8 | $ cc netlib.c 9 | $ cc netsh.c 10 | $ cc nettest_bsd.c 11 | $ cc netserver.c 12 | $ link/exe=netperf netperf.obj,netsh.obj,netlib.obj,nettest_bsd.obj 13 | $ link/exe=netserver netserver.obj,netsh.obj,netlib.obj,nettest_bsd.obj 14 | 15 | Installation for OpenVMS has a few differences from installation under 16 | say Unix. There is no inetd for VMS - however, there is the concept 17 | of an adding an auxilliary service that seems quite similar. 18 | 19 | To configure netperf for operation as an auxilliary service, you will 20 | need to edit/use the netserver_run.com file and alter the "path" to 21 | netserver accordingly. The version that ships is setup for where Rick 22 | Jones did his initial porting work and most likely is not apropriate 23 | for you :) 24 | 25 | $ define sys$output sys$sysroot:[netperf]hello_service.log 26 | $ define sys$error sys$sysroot:[netperf]hello_service.log 27 | $ run sys$sysroot:[netperf]netserver.exe 28 | 29 | Then it will be necessary to "define" netperf (netserver) as an 30 | auxilliary service. This will need to be customized as apropriate for 31 | your system 32 | 33 | $ tcpip set service netserver - 34 | _$ /port=12865 - 35 | _$ /protocol=tcp - 36 | _$ /user=system - 37 | _$ /limit=48 - 38 | _$ /process_name=netserver - 39 | _$ /file=sys$sysroot:[netperf]netserver_run.com 40 | 41 | And then it is necessary to enable the service: 42 | 43 | $ tcpip enable service netserver 44 | 45 | If you want to disable the service, you can issue the command 46 | 47 | $ tcpip set noservice netserver 48 | 49 | By default, OpenVMS is case-insensitive with commandlines, and will 50 | downshift everything to lower case. This does not interact well with 51 | netperf's use of command-line options like "-H" and "-h" with rather 52 | different meanings. 53 | 54 | To workaround that, the following defines are believed to be 55 | sufficient. 56 | 57 | $ define DECC$ARGV_PARSE_STYLE ENABLE 58 | $ define DECC$EFS_CASE_PRESERVE ENABLE 59 | $ define DECC$POSIX_SEEK_STREAM_FILE ENABLE 60 | $ define DECC$EFS_CHARSET ENABLE 61 | $ set process /parse_style=extended 62 | 63 | I do not know if this will be something one can also do for the 64 | netserver - presumeably one could put these things in the 65 | netserver_run.com file (guessing). At present though I've not tried 66 | that, and I'm also not sure that netserver has any upper-case options. 67 | -------------------------------------------------------------------------------- /README.solaris: -------------------------------------------------------------------------------- 1 | Until the release bits the following was true: 2 | 3 | Until such time as Rick Jones can figure-out or be told how to make it 4 | automagic in the configure script, prior to configure on solaris, you 5 | may need: 6 | 7 | CFLAGS="-lsocket -lnsl -lkstat" 8 | 9 | and if you are trying to compile the SCTP tests: 10 | 11 | CFLAGS="-lxnet -lsocket -lnsl -lkstat -D_XOPEN_SOURCE=500 -D__EXTENSIONS__" 12 | 13 | as the release bits have a "smarter" configure script, and the SCTP 14 | tests use libsctp, the above no longer applies. It should all just be 15 | automagic (although for SCTP you still must --enable-sctp at configure 16 | time) 17 | 18 | Beware CPU util figures on anything before Solaris 10 that does not 19 | say 100%, and still be a triffle cautious with Solaris 10 CPU util 20 | reports. The CPU time accounting mechanisms either do not track time 21 | spent servicing interrupts, or do so in parallel with time spent in 22 | user/kernel/idle which means that some idle time isn't _really_ idle 23 | time. 24 | 25 | And beyond that, it is still not clear if the CPU utilization reported 26 | on systems with hardware threading support (eg UltraSPARC-T1) is 27 | really accurate even ignoring the issue with interrupt time. It is 28 | likely that to be truely accurate, it is necessary to know how much 29 | "real work" any one strand performed. 30 | -------------------------------------------------------------------------------- /README.vmware: -------------------------------------------------------------------------------- 1 | Compiling for VMware is somewhat like compiling for Windows - there is 2 | a separate, standalone makefile one uses. In this case, it is 3 | src/Makefile.uw. So, to build the bits, cd to src/ and make -f 4 | Makefile.uw. 5 | 6 | At present, the makefile is setup to use a number of the "none" files 7 | - in particular netcpu_none.c. When/if we enable the "omni" tests 8 | we'll perhaps see the addition of a number of other "none" files as 9 | well. 10 | 11 | Also, seems the way things are "run" under VMware is enough different 12 | that the scripts, should you chose to use them, will need to be 13 | modified. The initial set of patches make some arbitrary changes that 14 | need to be re-worked with some "To run this under VMware uncomment 15 | this line" or somesuch. 16 | -------------------------------------------------------------------------------- /README.windows: -------------------------------------------------------------------------------- 1 | It has been reported that versions of netperf have configured and 2 | compiled under Cygwin. 3 | 4 | It is also known that netperf has compiled using the Windows DDK. 5 | Here is a skeleton of the instructions to do so: 6 | 7 | Steps are: 8 | 9 | A) Install the Windows driver developer kit (if not already done). 10 | 11 | B) open a Cmd windows (i.e., a DOS box) for the target environment 12 | (target OS version; free vs checked build; x86, AMD64, or IA64). 13 | This is picked from the "Start\Developer Kits" path. 14 | 15 | C) enter the src\NetPerfDir directory 16 | 17 | D) Edit sources to enable any desired optional features (eg 18 | -DWANT_HISTOGRAM) or to remove features which your version of 19 | Windows might not support (eg -DHAVE_STRUCT_SOCKADDR_STORAGE) 20 | 21 | E) while still in the src\NetperfDir directory type "build /cD". 22 | 23 | F) Repeat steps C through E in src\NetServerDir 24 | 25 | G) the target files will be in a directory like: 26 | NetPerfDir\objchk_wnet_IA64\IA64, NetServerDir\objchk_wnet_IA64\IA64 27 | NetPerfDir\objfre_wnet_x86\i386, or NetPerfDir\objfre_wnet_AMD64\amd64 28 | 29 | NOTE: If any components of the path (ie the full names of the files, 30 | including parent directories) contain spaces (eg "My Documents"), 31 | build will charge off into the weeds. 32 | 33 | If you do not want the corresponding features, edit the sources files 34 | and remove the -Ds for WANT_DEMO, WANT_HISTOGRAM and/or WANT_INTERVALS 35 | 36 | And if that weren't enough, it is also known that netperf has been 37 | compiled using MS Visual Studio 2003. Here are the instructions from 38 | the person who made that work (See Authors): 39 | 40 | 1. Under the PROJECT tab, PROPERTIES, LINKER folder, 41 | Select COMMAND LINE and add WS2_32.lib in the whitespace labeled 42 | Additional Options: 43 | 44 | 45 | 2. Under the PROJECT tab, PROPERTIES, C/C++ foleder, 46 | Select Preprocessor, On the right, add DO_IPV6; at the end of the 47 | Preprocessor Definitions whitespace. 48 | 49 | 50 | He goes on to say: 51 | 52 | NOTE: WHEN COMPLING NETSERVER, it works, but I got issued the 53 | foillowing warnigns in my build: 54 | 55 | 56 | ------ Rebuild All started: Project: netserver, Configuration: Debug Win32 ------ 57 | 58 | Deleting intermediate files and output files for project 'netserver', configuration 'Debug|Win32'. 59 | 60 | Compiling... 61 | 62 | nettest_bsd.c 63 | 64 | g:\Program Files\netperf\netperf-2.4.1rc1\src\nettest_bsd.c(846) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 65 | 66 | g:\Program Files\netperf\netperf-2.4.1rc1\src\nettest_bsd.c(1303) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 67 | 68 | g:\Program Files\netperf\netperf-2.4.1rc1\src\nettest_bsd.c(2020) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 69 | 70 | g:\Program Files\netperf\netperf-2.4.1rc1\src\nettest_bsd.c(5080) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 71 | 72 | g:\Program Files\netperf\netperf-2.4.1rc1\src\nettest_bsd.c(5715) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 73 | 74 | g:\Program Files\netperf\netperf-2.4.1rc1\src\nettest_bsd.c(6591) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 75 | 76 | g:\Program Files\netperf\netperf-2.4.1rc1\src\nettest_bsd.c(8013) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 77 | 78 | g:\Program Files\netperf\netperf-2.4.1rc1\src\nettest_bsd.c(11123) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 79 | 80 | netsh.c 81 | 82 | netserver.c 83 | 84 | g:\Program Files\netperf\netperf-2.4.1rc1\src\netserver.c(457) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 85 | 86 | netlib.c 87 | 88 | g:\Program Files\netperf\netperf-2.4.1rc1\src\netlib.c(2470) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 89 | 90 | g:\Program Files\netperf\netperf-2.4.1rc1\src\netlib.c(2480) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data 91 | 92 | netcpu_ntperf.c 93 | 94 | inet_ntop.c 95 | 96 | Generating Code... 97 | 98 | Linking... 99 | 100 | Build log was saved at "file://g:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\netserver\Debug\BuildLog.htm" 101 | 102 | netserver - 0 error(s), 11 warning(s) 103 | 104 | 105 | 106 | ---------------------- Done ---------------------- 107 | 108 | Rebuild All: 1 succeeded, 0 failed, 0 skipped 109 | 110 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | aclocal -I src/missing/m4 \ 4 | && automake --add-missing \ 5 | && autoconf && autoheader 6 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | # what is your philosophy - distribute pre-made .pdf et al in a make dist 2 | # or not? choose your EXTRA_DIST line accordingly 3 | # EXTRA_DIST = netperf.man netserver.man netperf.txt netperf.html netperf.xml netperf_old.ps netperf.pdf netperf.ps netperf.texi examples 4 | 5 | SUBDIRS = examples 6 | 7 | EXTRA_DIST = netperf.man netserver.man netperf_old.ps netperf.texi 8 | man1_MANS = netperf.man netserver.man 9 | info_TEXINFOS = netperf.texi 10 | CLEANFILES = netperf.txt netperf.xml netperf.html 11 | 12 | netperf.html: $(info_TEXINFOS) 13 | $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) --html --no-split -I $(srcdir) \ 14 | -o $@ `test -f '$<' || echo '$(srcdir)/'`$< 15 | 16 | netperf.txt: $(info_TEXINFOS) 17 | $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) --plaintext -I $(srcdir) \ 18 | -o $@ `test -f '$<' || echo '$(srcdir)/'`$< 19 | 20 | netperf.xml: $(info_TEXINFOS) 21 | $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) --xml -I $(srcdir) \ 22 | -o $@ `test -f '$<' || echo '$(srcdir)/'`$< 23 | -------------------------------------------------------------------------------- /doc/examples/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | arr_script \ 3 | packet_byte_script \ 4 | sctp_stream_script \ 5 | snapshot_script \ 6 | tcp_range_script \ 7 | tcp_rr_script \ 8 | tcp_stream_script \ 9 | udp_rr_script \ 10 | udp_stream_script 11 | 12 | -------------------------------------------------------------------------------- /doc/examples/bloat.sh: -------------------------------------------------------------------------------- 1 | # this is a quick and dirty script to run a netperf TCP_RR and 2 | # TCP_STREAM test concurrently to allow one to see the effect of 3 | # buffer bloat on latency. We assume that netperf has been compiled 4 | # with demo-mode enabled via ./configure --enable-demo 5 | 6 | NETPERF=`which netperf` 7 | if [ $? -ne 0 ] 8 | then 9 | echo "Unable to find a netperf binary." 10 | exit -1 11 | fi 12 | 13 | CHUNK=60 14 | 15 | # first, start the TCP_RR test 16 | RR_START=`date +%s` 17 | echo "Starting netperf TCP_RR at $RR_START" | tee bloat.log 18 | # a negative value for the demo interval (-D) will cause netperf to 19 | # make gettimeofday() calls after every transaction. this will result 20 | # in more accurate demo intervals once the STREAM test kicks-in, but a 21 | # somewhat lower transaction rate. not unlike enabling histogram 22 | # mode. 23 | netperf -H $1 -l 7200 -t TCP_RR -D -0.5 -v 2 -- -r 1 2>&1 > netperf_rr.out & 24 | 25 | # sleep CHUNK seconds 26 | sleep $CHUNK 27 | 28 | # now run the TCP_STREAM test 29 | 30 | STREAM_START=`date +%s` 31 | echo "Starting netperf TCP_STREAM test at $STREAM_START" | tee -a bloat.log 32 | netperf -H $1 -l `expr $CHUNK \* 2` -t TCP_STREAM -D 0.25 -v 2 -- -m 1K 2>&1 > netperf_stream.out 33 | STREAM_STOP=`date +%s` 34 | echo "Netperf TCP_STREAM test stopped at $STREAM_STOP" | tee -a bloat.log 35 | 36 | # sleep another CHUNK seconds 37 | sleep $CHUNK 38 | 39 | pkill -ALRM netperf 40 | RR_STOP=`date +%s` 41 | echo "Netperf TCP_RR test stopped at $RR_STOP" | tee -a bloat.log 42 | 43 | RRDTOOL=`which rrdtool` 44 | if [ $? -ne 0 ] 45 | then 46 | echo "Unable to find rrdtool. You will have to post-process the results by hand" 47 | exit 0 48 | fi 49 | 50 | MIN_TIMESTAMP=`grep Interim netperf_rr.out | head -1 | awk '{print int($10)}'` 51 | MAX_TIMESTAMP=`grep Interim netperf_rr.out | tail -1 | awk '{print int($10)}'` 52 | MAX_INTERVAL=`grep Interim netperf_rr.out | awk 'BEGIN{max=0.0} ($6 > max) {max = $6}END{print int(max) + 1}'` 53 | LENGTH=`expr $MAX_TIMESTAMP - $MIN_TIMESTAMP` 54 | 55 | $RRDTOOL create netperf_rr.rrd --step 1 --start $MIN_TIMESTAMP \ 56 | DS:tps:GAUGE:$MAX_INTERVAL:U:U RRA:AVERAGE:0.5:1:$LENGTH 57 | 58 | # now fill it 59 | awk -v rrdtool=$RRDTOOL '($1 == "Interim"){printf("%s update netperf_rr.rrd %.3f:%f\n",rrdtool,$10,$3)}' netperf_rr.out | sh 60 | 61 | # now post process the tcp_stream test. we could use STREAM_START and 62 | # STREAM_STOP but these will be just a bit more accurate 63 | STREAM_MIN_TIMESTAMP=`grep Interim netperf_stream.out | head -1 | awk '{print int($10)}'` 64 | STREAM_MAX_TIMESTAMP=`grep Interim netperf_stream.out | tail -1 | awk '{print int($10)}'` 65 | STREAM_MAX_INTERVAL=`grep Interim netperf_stream.out | awk 'BEGIN{max=0.0} ($6 > max) {max = $6}END{print int(max) + 1}'` 66 | STREAM_LENGTH=`expr $STREAM_MAX_TIMESTAMP - $STREAM_MIN_TIMESTAMP` 67 | 68 | $RRDTOOL create netperf_stream.rrd --step 1 --start $STREAM_MIN_TIMESTAMP \ 69 | DS:mbps:GAUGE:$STREAM_MAX_INTERVAL:U:U RRA:AVERAGE:0.5:1:$STREAM_LENGTH 70 | 71 | # now fill it 72 | awk -v rrdtool=$RRDTOOL '($1 == "Interim"){printf("%s update netperf_stream.rrd %.3f:%f\n",rrdtool,$10,$3)}' netperf_stream.out | sh 73 | 74 | 75 | # now graph it. we want to make sure the chart is at least 800 pixels 76 | # wide, and has enough pixels for every data point 77 | 78 | WIDTH=$LENGTH 79 | if [ $WIDTH -lt 800 ] 80 | then 81 | WIDTH=800 82 | fi 83 | 84 | SIZE="-w $WIDTH -h 400" 85 | 86 | # we want to find the scaling factor for the throughput, with the goal 87 | # being that latency can go to the top of the charts and throughput 88 | # will go half-way up 89 | 90 | MAXLATMAXBPS=`$RRDTOOL graph /dev/null \ 91 | --start $MIN_TIMESTAMP --end $MAX_TIMESTAMP \ 92 | DEF:trans=netperf_rr.rrd:tps:AVERAGE \ 93 | CDEF:latency=1.0,trans,/ \ 94 | VDEF:maxlatency=latency,MAXIMUM \ 95 | DEF:mbps=netperf_stream.rrd:mbps:AVERAGE \ 96 | CDEF:bps=mbps,2000000,\* \ 97 | VDEF:maxbps=bps,MAXIMUM \ 98 | PRINT:maxlatency:"%.20lf" \ 99 | PRINT:maxbps:"%.20lf" | sed 1d` 100 | 101 | # should I check the completion status of the previous command? 102 | # probably :) 103 | 104 | SCALE=`echo $MAXLATMAXBPS | awk '{print $2/$1}'` 105 | 106 | $RRDTOOL graph bloat.svg --imgformat SVG \ 107 | $SIZE \ 108 | --lower-limit 0 \ 109 | --start $MIN_TIMESTAMP --end $MAX_TIMESTAMP \ 110 | -t "Effect of bulk transfer on latency to $1" \ 111 | -v "Seconds" \ 112 | --right-axis $SCALE:0 \ 113 | --right-axis-label "Bits per Second" \ 114 | DEF:trans=netperf_rr.rrd:tps:AVERAGE \ 115 | CDEF:latency=1.0,trans,/ \ 116 | LINE2:latency#00FF0080:"TCP_RR Latency" \ 117 | DEF:mbps=netperf_stream.rrd:mbps:AVERAGE \ 118 | CDEF:bps=mbps,1000000,\* \ 119 | CDEF:sbps=bps,$SCALE,/ \ 120 | LINE2:sbps#0000FFF0:"TCP_STREAM Throughput" \ 121 | VRULE:${STREAM_START}#FF000080:"TCP_STREAM start" \ 122 | VRULE:${STREAM_STOP}#00000080:"TCP_STREAM stop" \ 123 | --x-grid SECOND:10:SECOND:60:SECOND:60:0:%X 124 | -------------------------------------------------------------------------------- /doc/examples/find_max_burst.sh: -------------------------------------------------------------------------------- 1 | # a crude script to try to find the burst size which results in 2 | # something approximating peak transactions per second. once we 3 | # pass the peak, we may want to refine further but for now, this 4 | # should suffice 5 | 6 | LAST_TPS=0 7 | BURST=1 8 | LAST_BURST=0 9 | NETPERF=${NETPERF:="netperf"} 10 | 11 | TMP_TPS=`$NETPERF -t TCP_RR -P 0 -H $1 -- -b $BURST -D -o throughput -s 1M -S 1M` 12 | 13 | if [ $? -ne 0 ] 14 | then 15 | echo -1 16 | exit -1 17 | fi 18 | 19 | CUR_TPS=`echo $TMP_TPS | awk '{print int($1)}'` 20 | 21 | while [ $CUR_TPS -gt $LAST_TPS ] 22 | do 23 | LAST_BURST=$BURST 24 | BURST=`expr $BURST \* 2` 25 | LAST_TPS=$CUR_TPS 26 | 27 | TMP_TPS=`$NETPERF -t TCP_RR -P 0 -H $1 -- -b $BURST -D -o throughput -s 1M -S 1M` 28 | 29 | if [ $? -ne 0 ] 30 | then 31 | echo -1 32 | exit -1 33 | fi 34 | 35 | CUR_TPS=`echo $TMP_TPS | awk '{print int($1)}'` 36 | done 37 | 38 | # if we were going to further refine the estimate we would probably do 39 | # a binary search at this point but for now, just emit the value of 40 | # LAST_BURST and be done with it. 41 | 42 | echo $LAST_BURST 43 | -------------------------------------------------------------------------------- /doc/examples/mins_maxes.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | max_interval = 0.0; 3 | min_timestamp = 9999999999.0; 4 | max_timestamp = 0.0; 5 | } 6 | 7 | NF == 4 { 8 | if ($3 > max_interval) max_interval = $3 9 | if ($4 > max_timestamp) max_timestamp = $4 10 | if ($4 < min_timestamp) min_timestamp = $4 11 | next 12 | } 13 | 14 | END { 15 | max_interval = int(max_interval) + 1 16 | min_timestamp = int(min_timestamp) 17 | max_timestamp = int(max_timestamp) + 1 18 | printf("MAX_INTERVAL=%d\nMAX_TIMESTAMP=%d\nMIN_TIMESTAMP=%d\n", 19 | max_interval, 20 | max_timestamp, 21 | min_timestamp) 22 | } -------------------------------------------------------------------------------- /doc/examples/netperf_interim_to_rrd.sh: -------------------------------------------------------------------------------- 1 | 2 | # set -x 3 | SAMPLE_TIMES="2 5 10 20 30 45 60" 4 | SAMPLE_TIMES="60 45 30 20 10 5 2" 5 | FLOW_RATES="0 200 2000 20000 200000" 6 | NETPERF="/home/raj/netperf2_trunk/src/netperf" 7 | 8 | # these will be switch-specific 9 | CPMIB="SFLOW-MIB::sFlowCpInterval.11.1.3.6.1.2.1.2.2.1.1.27.1" 10 | FSMIB="SFLOW-MIB::sFlowFsPacketSamplingRate.11.1.3.6.1.2.1.2.2.1.1.27.1" 11 | SFLOW_RRD="/tmp/counters/192.168.1.1/1/27/generic.rrd" 12 | 13 | for sample in $SAMPLE_TIMES 14 | do 15 | 16 | LENGTH="300" 17 | XGRID="--x-grid SECOND:5:SECOND:30:SECOND:30:0:%X" 18 | # we want at least 10 sFlow samples 19 | SAMPLES=`expr $LENGTH / $sample` 20 | if [ $SAMPLES -lt 10 ]; then 21 | LENGTH=`expr 10 \* $sample` 22 | XGRID="--x-grid SECOND:10:SECOND:60:SECOND:60:0:%X" 23 | fi 24 | 25 | # configure the switch for the counter sampling interval 26 | snmpset 192.168.1.1 $CPMIB i $sample 27 | TWOXSAMPLE=`expr $sample \* 2` 28 | for flow in $FLOW_RATES 29 | do 30 | # configure the switch for the flow sampling rate which is one per 31 | # N on average, with some randomization if adhering to the sFlow 32 | # spec. 33 | snmpset 192.168.1.1 $FSMIB i $flow 34 | 35 | # setup some variables 36 | FILE_BASE="sample_${sample}_flow_${flow}" 37 | NETPERF_BASE="raw_netperf_${FILE_BASE}" 38 | NETPERF_RAW="${NETPERF_BASE}.out" 39 | NETPERF_RRD="${NETPERF_BASE}.rrd" 40 | 41 | # provide an indication of forward progress and status 42 | echo "sample rate $sample flow rate 1 in $flow" 43 | 44 | # start top 45 | top -b -i > "top_${FILE_BASE}.out" & 46 | TOP_PID=$! 47 | 48 | # run our netperf test long enough to make sure we have as many 49 | # sFlow samples as we wish even after we later skip the first two. 50 | $NETPERF -t UDP_STREAM -H 192.168.1.3 -l `expr $LENGTH + $TWOXSAMPLE`\ 51 | -D 1 -c -C -- -m 1472 -s 64K -S 64K > $NETPERF_RAW 52 | 53 | # stop top 54 | kill -HUP $TOP_PID 55 | 56 | # prepare to shove the interim results into an RRD 57 | grep Interim $NETPERF_RAW > interims.tmp 58 | 59 | # over what time interval do we have netperf interim results? 60 | START=`head -1 interims.tmp | awk '{printf("%d",$10)}'` 61 | END=`tail -1 interims.tmp | awk '{printf("%d",$10)}'` 62 | 63 | # create an rrd for netperf starting at the beginning of that interval 64 | rrdtool create netperf.rrd --step 1 --start $START \ 65 | DS:mbps:GAUGE:2:U:U RRA:AVERAGE:0.5:1:${LENGTH} 66 | 67 | # shove those interim results into the netperf rrd 68 | awk '{printf("rrdtool update netperf.rrd %f:%f\n",$10,$3)}' \ 69 | interims.tmp | sh 70 | mv netperf.rrd $NETPERF_RRD 71 | 72 | # extract the data from the sflow rrd to save it for posterity 73 | rrdtool fetch $SFLOW_RRD AVERAGE --start $START --end $END \ 74 | > sflow_${FILE_BASE}.fetch 75 | 76 | # now make the graph, trim-off the first two sFlow counter samples 77 | # for better automagic scaling. the magic multiplier is how to go 78 | # from mbps from netperf, which counts only payload, to octets on 79 | # the wire assuming 8 bytes of UDP header 20 bytes of IP, 14 bytes 80 | # of ethernet, 4 bytes of FCS and 1472 bytes of user payload 81 | START=`expr $START + $TWOXSAMPLE` 82 | 83 | # we don't like rrdtool's autoscaling 84 | YMIN=`rrdtool graph /dev/null --start $START --end $END \ 85 | DEF:foo=${SFLOW_RRD}:ifOutOctets:AVERAGE \ 86 | CDEF:bar=foo,0.98,\* \ 87 | VDEF:bing=bar,MINIMUM \ 88 | PRINT:bing:"%6.2lf" | sed 1d` 89 | 90 | YMAX=`rrdtool graph /dev/null --start $START --end $END \ 91 | DEF:foo=${SFLOW_RRD}:ifOutOctets:AVERAGE \ 92 | CDEF:bar=foo,1.02,\* \ 93 | VDEF:bing=bar,MAXIMUM \ 94 | PRINT:bing:"%6.2lf" | sed 1d` 95 | 96 | # also consider the neterf results 97 | NMIN=`rrdtool graph /dev/null --start $START --end $END \ 98 | DEF:foo=${NETPERF_RRD}:mbps:AVERAGE \ 99 | CDEF:baz=foo,128906.25,\* \ 100 | CDEF:bar=baz,0.98,\* \ 101 | VDEF:bing=bar,MINIMUM \ 102 | PRINT:bing:"%6.2lf" | sed 1d` 103 | 104 | NMAX=`rrdtool graph /dev/null --start $START --end $END \ 105 | DEF:foo=${NETPERF_RRD}:mbps:AVERAGE \ 106 | CDEF:baz=foo,128906.25,\* \ 107 | CDEF:bar=baz,1.02,\* \ 108 | VDEF:bing=bar,MAXIMUM \ 109 | PRINT:bing:"%6.2lf" | sed 1d` 110 | 111 | # I am certain someone will say dude use perl when they see this 112 | INMIN=`echo $NMIN | awk '{printf("%d",$1)}'` 113 | INMAX=`echo $NMAX | awk '{printf("%d",$1)}'` 114 | IYMIN=`echo $YMIN | awk '{printf("%d",$1)}'` 115 | IYMAX=`echo $YMAX | awk '{printf("%d",$1)}'` 116 | 117 | # we wont sweat the fractional part 118 | if [ $INMIN -lt $IYMIN ]; then 119 | YMIN=$NMIN 120 | fi 121 | 122 | if [ $INMAX -gt $IYMAX ]; then 123 | YMAX=$NMAX 124 | fi 125 | 126 | GRAPH="graph_${FILE_BASE}.svg" 127 | SIZE="-w 1000 -h 400" 128 | rrdtool graph $GRAPH --start $START --end $END \ 129 | --imgformat SVG \ 130 | -t "sFlow counter accuracy, average flow sample rate 1 in ${flow}" \ 131 | -v "Octets/s" \ 132 | $XGRID $SIZE --full-size-mode \ 133 | --upper-limit $YMAX \ 134 | --lower-limit $YMIN \ 135 | --rigid \ 136 | --alt-y-grid \ 137 | DEF:foo=${NETPERF_RRD}:mbps:AVERAGE \ 138 | DEF:bar=${SFLOW_RRD}:ifOutOctets:AVERAGE \ 139 | CDEF:baz=foo,128906.25,\* \ 140 | HRULE:124019607.84#000000:"Theoretical link-rate" \ 141 | LINE2:baz#FF0000:"netperf+headers at 1s intvl" \ 142 | LINE2:bar#00FF0080:"sFlow counters at ${sample}s intvl" 143 | done 144 | done 145 | 146 | -------------------------------------------------------------------------------- /doc/examples/packet_byte_script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script runs a series of netperf tests intended to gather the 4 | # raw material necessary to arrive at estimates for the cost of 5 | # sending and receiving a TCP segment, the cost of each additional byte 6 | # and the cost of each incremental segment. 7 | # 8 | # there are a number of data points gathered by this script - it might 9 | # run for a considerable length of time. 10 | # 11 | # rick jones 4/99 12 | # 13 | # teach it about processor affinity and the TCP_MSS test 14 | # rick jones 2007-11-08 15 | # 16 | 17 | if [ $# -gt 2 ]; then 18 | echo "try again, correctly -> packet_byte_script hostname [CPU]" 19 | exit 1 20 | fi 21 | 22 | if [ $# -eq 0 ]; then 23 | echo "try again, correctly -> packet_byte_script hostname [CPU]" 24 | exit 1 25 | fi 26 | 27 | # where is netperf 28 | NETPERF_DIR=${NETPERF_DIR:=/opt/netperf2/bin} 29 | 30 | 31 | # at what port will netserver be waiting? If you decide to run 32 | # netserver at a differnet port than the default of 12865, then set 33 | # the value of NETPERF_PORT apropriately 34 | # NETPERF_PORT="-p some_other_portnum" 35 | NETPERF_PORT=${NETPERF_PORT:=""} 36 | 37 | 38 | # The test length in seconds 39 | NETPERF_TIME=${NETPERF_TIME:=30} 40 | 41 | # How accurate we want the estimate of performance: 42 | # maximum and minimum test iterations (-i) 43 | # confidence level (99 or 95) and interval (percent) 44 | NETPERF_STATS=${NETPERF_STATS:="-i 30,3 -I 99,5"} 45 | 46 | # The socket sizes that we will be testing - using -1 will let it 47 | # be the system default. 48 | NETPERF_SKTS=${NETPERF_SKTS:="-1"} 49 | 50 | # The CPU affinity to be applied 51 | NETPERF_AFFINITY=${NETPERF_AFFINITY:=""} 52 | 53 | # NETPERF_CMD is an amalgam of previous variables 54 | NETPERF_CMD="${NETPERF_DIR}/netperf ${NETPERF_AFFINITY}" 55 | 56 | # if there are two parms, parm one it the hostname and parm two will 57 | # be a CPU indicator. actually, anything as a second parm will cause 58 | # the CPU to be measured, but we will "advertise" it should be "CPU" 59 | 60 | if [ $# -eq 2 ]; then 61 | REM_HOST=$1 62 | LOC_CPU="-c" 63 | REM_CPU="-C" 64 | fi 65 | 66 | if [ $# -eq 1 ]; then 67 | REM_HOST=$1 68 | fi 69 | 70 | MSS=`$NETPERF_CMD -H $REM_HOST -t TCP_MSS -P 0 -v 0` 71 | 72 | # The request,response sizes that we will be using. The netperf 73 | # command parser will treat "1" the same as "1,1" - I use 1,1 to 74 | # remember that it is "request,response" 75 | 76 | # start at one and multiply by two on our way to the MSS 77 | bar=1 78 | while [ $bar -lt $MSS ] 79 | do 80 | NETPERF_REQS="${NETPERF_REQS} $bar" 81 | bar=`expr $bar \* 2` 82 | done 83 | 84 | # and now multiples of the mss and that plus one 85 | for i in 1 2 3 86 | do 87 | bar=`expr $MSS \* $i` 88 | NETPERF_REQS="${NETPERF_REQS} $bar" 89 | NETPERF_REQS="${NETPERF_REQS} `expr $bar + 1`" 90 | done 91 | 92 | bar=1 93 | while [ $bar -lt $MSS ] 94 | do 95 | NETPERF_RESP="${NETPERF_RESP} $bar" 96 | bar=`expr $bar \* 2` 97 | done 98 | 99 | for i in 1 2 3 100 | do 101 | bar=`expr $MSS \* $i` 102 | NETPERF_RESP="${NETPERF_RESP} $bar" 103 | NETPERF_RESP="${NETPERF_RESP} `expr $bar + 1`" 104 | done 105 | 106 | 107 | 108 | # If we are measuring CPU utilization, then we can save beaucoup 109 | # time by saving the results of the CPU calibration and passing 110 | # them in during the real tests. So, we execute the new CPU "tests" 111 | # of netperf and put the values into shell vars. 112 | case $LOC_CPU in 113 | \-c) LOC_RATE=`$NETPERF_CMD $PORT -t LOC_CPU`;; 114 | *) LOC_RATE="" 115 | esac 116 | 117 | case $REM_CPU in 118 | \-C) REM_RATE=`$NETPERF_CMD $PORT -t REM_CPU -H $REM_HOST`;; 119 | *) REM_RATE="" 120 | esac 121 | 122 | # This disables header display 123 | NO_HDR="-P 0" 124 | NO_HDR="" 125 | 126 | for SOCKET_SIZE in $NETPERF_SKTS 127 | do 128 | echo 129 | echo ------------------------------------------------------ 130 | echo Testing with the following command line: 131 | # we echo the command line for cut and paste to th database 132 | echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST -t TCP_RR \ 133 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\ 134 | -s $SOCKET_SIZE -S $SOCKET_SIZE 135 | echo 136 | echo and these settings for send sizes $NETPERF_REQS 137 | echo 138 | 139 | for REQ in $NETPERF_REQS 140 | do 141 | # since we have the confidence interval stuff, we do not 142 | # need to repeat a test multiple times from the shell 143 | $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST $NO_HDR \ 144 | -t TCP_RR $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\ 145 | -r ${REQ},1 -s $SOCKET_SIZE -S $SOCKET_SIZE 146 | NO_HDR="-P 0" 147 | done 148 | echo 149 | echo ------------------------------------------------------ 150 | NO_HDR="" 151 | echo Testing with the following command line: 152 | # we echo the command line for cut and paste to th database 153 | echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST -t TCP_RR \ 154 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\ 155 | -s $SOCKET_SIZE -S $SOCKET_SIZE 156 | echo and these settings for response sizes $NETPERF_RESP 157 | echo 158 | for RESP in $NETPERF_RESP 159 | do 160 | # since we have the confidence interval stuff, we do not 161 | # need to repeat a test multiple times from the shell 162 | $NETPERF_CMD $PORT -l $NETPERF_TIME -H $REM_HOST $NO_HDR \ 163 | -t TCP_RR $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\ 164 | -r 1,${RESP} -s $SOCKET_SIZE -S $SOCKET_SIZE 165 | NO_HDR="-P 0" 166 | done 167 | echo 168 | echo ------------------------------------------------------ 169 | NO_HDR="" 170 | echo Testing with the following command line: 171 | # we echo the command line for cut and paste to th database 172 | echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_TIME -H $REM_HOST -t TCP_STREAM\ 173 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\ 174 | -s $SOCKET_SIZE -S $SOCKET_SIZE 175 | echo and these settings for response sizes $NETPERF_RESP 176 | echo 177 | for REQ in $NETPERF_REQS 178 | do 179 | # since we have the confidence interval stuff, we do not 180 | # need to repeat a test multiple times from the shell 181 | $NETPERF_CMD $PORT -l $NETPERF_TIME -H $REM_HOST $NO_HDR \ 182 | -t TCP_STREAM $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\ 183 | -m ${REQ} -s $SOCKET_SIZE -S $SOCKET_SIZE -D 184 | NO_HDR="-P 0" 185 | done 186 | done 187 | 188 | # The test length in seconds for the CRR test, which needs to be 189 | # longer for a connect/request/response test 190 | 191 | NETPERF_CRR_TIME=${NETPERF_CRR_TIME:=120} 192 | 193 | # now we do the TCP_CRR test 194 | echo 195 | echo ------------------------------------------------------ 196 | echo $NETPERF_CMD $NETPERF_PORT -l $NETPERF_CRR_TIME -H $REM_HOST -t TCP_CRR\ 197 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\ 198 | -s $SOCKET_SIZE -S $SOCKET_SIZE 199 | echo 200 | $NETPERF_CMD $NETPERF_PORT -l $NETPERF_CRR_TIME -H $REM_HOST -t TCP_CRR\ 201 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $NETPERF_STATS --\ 202 | -s $SOCKET_SIZE -S $SOCKET_SIZE 203 | -------------------------------------------------------------------------------- /doc/examples/post_proc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # find where to put the vertical lines 3 | awk -f vrules.awk $1 > vrules 4 | . ./vrules 5 | 6 | i=0 7 | VRULES="" 8 | while [ $i -lt $NUM_VRULES ] 9 | do 10 | VRULES="$VRULES VRULE:${VRULE_TIME[$i]}#${VRULE_COLR[$i]}:${VRULE_TEXT[$i]}" 11 | i=`expr $i + 1` 12 | done 13 | # echo $VRULES 14 | 15 | if [ -f kitsink ] 16 | then 17 | rm kitsink 18 | fi 19 | 20 | prefix=${1%.log} 21 | echo "Prefix is $prefix" 22 | 23 | 24 | for i in ${prefix}*.out 25 | do 26 | 27 | # find some boundaries for this .out file 28 | awk -F "," -f mins_maxes.awk $i > minsn 29 | 30 | . ./minsn 31 | 32 | #echo "MAX_INTERVAL $MAX_INTERVAL MIN_TIMESTAMP $MIN_TIMESTAMP MAX_TIMESTAMP $MAX_TIMESTAMP" 33 | LENGTH=`expr $MAX_TIMESTAMP - $MIN_TIMESTAMP` 34 | SIZE="-w $LENGTH -h 400" 35 | 36 | 37 | # ooh, rick learns how to strip a suffix 38 | basename=${i%\.out} 39 | # echo "Post-processing ${basename}" 40 | 41 | rrdtool create ${basename}.rrd --step 1 --start $MIN_TIMESTAMP \ 42 | DS:mbps:GAUGE:$MAX_INTERVAL:U:U RRA:AVERAGE:0.5:1:$LENGTH 43 | 44 | # keep in mind that rrd only likes timestamps to milliseconds 45 | # at some point it would be nice to do more than one data point 46 | # at a time 47 | awk -v rrdfile=${basename}.rrd -F "," '(NF == 4){printf("rrdtool update %s %.3f:%f\n",rrdfile,$4,$1)}' \ 48 | $i | sh 49 | 50 | # this and the way things are handled for overall.rrd is massively 51 | # kludgey and I would love to know a better way to do this 52 | rrdtool fetch ${basename}.rrd AVERAGE \ 53 | --start $MIN_TIMESTAMP --end $MAX_TIMESTAMP | \ 54 | awk -F ":" '{printf("%d %f\n",$1,$2)}' | grep -v -e "nan" -e "^0" >> kitsink 55 | 56 | done 57 | 58 | echo Performing overall summary computations 59 | 60 | # find some overall boundaries. at some point we should build this up 61 | # based on what we were doing one file at a time above 62 | awk -F "," -f mins_maxes.awk ${prefix}*.out > minsn 63 | 64 | . ./minsn 65 | 66 | # echo "MAX_INTERVAL $MAX_INTERVAL MIN_TIMESTAMP $MIN_TIMESTAMP MAX_TIMESTAMP $MAX_TIMESTAMP" 67 | LENGTH=`expr $MAX_TIMESTAMP - $MIN_TIMESTAMP` 68 | WIDTH=$LENGTH 69 | if [ $WIDTH -lt 800 ] 70 | then 71 | WIDTH=800 72 | fi 73 | SIZE="-w $WIDTH -h 400" 74 | 75 | 76 | # ok time for the overall results 77 | # by now all the large intervals have been dealt with so we do not 78 | # have to use MAX_INTERVAL 79 | 80 | rrdtool create ${prefix}_overall.rrd --step 1 --start `expr $MIN_TIMESTAMP - 1` \ 81 | DS:mbps:GAUGE:1:U:U RRA:AVERAGE:0.5:1:$LENGTH 82 | 83 | for i in `seq $MIN_TIMESTAMP $MAX_TIMESTAMP` 84 | do 85 | SUM=`grep $i kitsink | awk '{sum += $2}END{print sum}'` 86 | rrdtool update ${prefix}_overall.rrd ${i}:$SUM 87 | done 88 | 89 | # get out labels set correctly 90 | UNITS="bits/s" 91 | MULTIPLIER="1000000" 92 | DIRECTION="Bidirectional" 93 | case $prefix in 94 | *pps* | *tps* ) 95 | UNITS="Trans/s" 96 | MULTIPLIER="1" 97 | ;; 98 | *inbound* ) 99 | DIRECTION="Inbound" 100 | ;; 101 | *outbound* ) 102 | DIRECTION="Outbound" 103 | ;; 104 | esac 105 | 106 | # find the interval with the highest AVERAGE. we can use the 107 | # timestamps in the vrules file to check this. while we are doing so, 108 | # might as well find the average, minimum and maximum for each 109 | # interval and we will chart the interval averages with some 110 | # reasonable transparancy. if someone wants to chart the interval 111 | # mins and maxes hopefully it will be fairly clear what to do 112 | 113 | rrdtool create ${prefix}_intervals.rrd --step 1 \ 114 | --start `expr $MIN_TIMESTAMP - 1` \ 115 | DS:avg:GAUGE:1:U:U RRA:AVERAGE:0.5:1:$LENGTH \ 116 | DS:min:GAUGE:1:U:U RRA:AVERAGE:0.5:1:$LENGTH \ 117 | DS:max:GAUGE:1:U:U RRA:AVERAGE:0.5:1:$LENGTH 118 | 119 | i=0 120 | AVG=0 121 | end=`expr $NUM_VRULES - 1` 122 | while [ $i -lt $end ] 123 | do 124 | start=`expr ${VRULE_TIME[$i]} + 1` 125 | j=`expr $i + 1` 126 | endtime=`expr ${VRULE_TIME[$j]} - 1` 127 | avgminmax=`rrdtool graph /dev/null --start $start --end $endtime \ 128 | DEF:foo=${prefix}_overall.rrd:mbps:AVERAGE \ 129 | VDEF:avg=foo,AVERAGE \ 130 | VDEF:min=foo,MINIMUM \ 131 | VDEF:max=foo,MAXIMUM \ 132 | PRINT:avg:"%6.2lf" \ 133 | PRINT:min:"%6.2lf" \ 134 | PRINT:max:"%6.2lf" | sed 1d ` 135 | # there is probably some clever way to do this without spawning 136 | # processes but I guess I'm just a fan of stone knives and 137 | # bearskins 138 | avg=`echo $avgminmax | awk '{print int($1)}'` 139 | min=`echo $avgminmax | awk '{print int($2)}'` 140 | max=`echo $avgminmax | awk '{print int($3)}'` 141 | # echo "Updating intervals from $start to $endtime with $avg $min $max" 142 | for k in `seq $start $endtime` 143 | do 144 | rrdtool update ${prefix}_intervals.rrd $k:$avg:$min:$max 145 | done 146 | if [ $avg -gt $AVG ] 147 | then 148 | peakintvid=`expr $i / 2` 149 | peakintvid=`expr $peakintvid + 1` 150 | maxstart=$start 151 | maxend=$endtime 152 | AVG=$avg 153 | MIN=$min 154 | MAX=$max 155 | fi 156 | i=`expr $i + 2` 157 | done 158 | 159 | # multiply it by the MULTIPLIER 160 | AVG=`expr $AVG \* $MULTIPLIER` 161 | MIN=`expr $MIN \* $MULTIPLIER` 162 | MAX=`expr $MAX \* $MULTIPLIER` 163 | 164 | # now graph it. if you want the min and max on the graph then add 165 | # HRULE:${MIN}#0F0F0F:"Minimum of peak interval is $MIN" \ 166 | # HRULE:${MAX}#0000FF:"Maximum of peak interval is $MAX" \ 167 | # HRULE:${AVG}#0000FF80:"Average of peak interval (${peakintvid}) is $AVG" \ 168 | # to the rrdtool command though it can make the chart rather busy 169 | 170 | rrdtool graph ${prefix}_overall.png \ 171 | --start $MIN_TIMESTAMP --end $MAX_TIMESTAMP \ 172 | $SIZE \ 173 | --imgformat PNG \ 174 | --font DEFAULT:0:Helvetica \ 175 | -t "Overall ${1%.log}" \ 176 | -v "$DIRECTION $UNITS" \ 177 | DEF:foo=${prefix}_overall.rrd:mbps:AVERAGE \ 178 | CDEF:bits=foo,$MULTIPLIER,\* \ 179 | $VRULES \ 180 | LINE2:bits#00FF0080:"$UNITS" > /dev/null \ 181 | DEF:bar=${prefix}_intervals.rrd:avg:AVERAGE \ 182 | CDEF:intvl=bar,$MULTIPLIER,\* \ 183 | LINE2:intvl#0F0F0F40:"Interval average. Peak of $AVG during interval ${peakintvid}." 184 | 185 | # now we can do the individual run graphs using the same x axis limits 186 | # as the overall graph 187 | for i in ${prefix}*.out 188 | do 189 | basename=${i%\.out} 190 | rrdtool graph ${basename}.png --start $MIN_TIMESTAMP --end $MAX_TIMESTAMP \ 191 | $SIZE \ 192 | --imgformat PNG \ 193 | --font DEFAULT:0:Helvetica \ 194 | -t "$basename ${1%.log}" \ 195 | -v "$DIRECTION $UNITS" \ 196 | DEF:foo=${basename}.rrd:mbps:AVERAGE \ 197 | CDEF:bits=foo,$MULTIPLIER,\* \ 198 | $VRULES \ 199 | LINE2:bits#00FF0080:"$UNITS" > /dev/null 200 | 201 | done 202 | echo "Average of peak interval is $AVG $UNITS from $maxstart to $maxend" 203 | echo "Minimum of peak interval is $MIN $UNITS from $maxstart to $maxend" 204 | echo "Maximum of peak interval is $MAX $UNITS from $maxstart to $maxend" -------------------------------------------------------------------------------- /doc/examples/remote_hosts: -------------------------------------------------------------------------------- 1 | REMOTE_HOSTS[0]=127.0.0.1 2 | REMOTE_HOSTS[1]=127.0.0.1 3 | NUM_REMOTE_HOSTS=2 -------------------------------------------------------------------------------- /doc/examples/runemomni.sh: -------------------------------------------------------------------------------- 1 | # a script to run a set of single-instance netperf tests 2 | # between two machines 3 | 4 | # the length in seconds of each test iteration. the actual 5 | # run time will then be somewhere between that times min 6 | # and max iteration for confidence intervals 7 | length=30 8 | 9 | # unlike the aggregate script, we do not have to worry 10 | # about everyone all running at the same time, so we can 11 | # save some time with a lower minimum iteration count 12 | confidence="-i 30,3" 13 | 14 | # the CPUs to which the netperf process will be bound 15 | # via the -T global option 16 | netperf_CPUs="0 1 2" 17 | 18 | # the CPUs to which the netserver process will be bound 19 | # via the -T global option 20 | netserver_CPUs="0 1 2" 21 | 22 | # the host/IP to use for the control connection 23 | control_host=192.168.0.26 24 | 25 | # the list of host/IP addresses to actually measure over 26 | remote_hosts="192.168.0.26 fe80::207:43ff:fe05:590a%eth0" 27 | 28 | #reqs="128 256 512 1024" 29 | reqs="64 128 256 512 1024 1460 2048 4096 8192" 30 | 31 | # the burst size for bursted RR tests 32 | bursts="0 1 2 4 8 16 32 64 128 256" 33 | 34 | HDR="-P 1" 35 | # -O means "human" -o means "csv" -k means "keyval" 36 | # "all" means emit everything. otherwise, specify a 37 | # list of output selectors directly or a filename with 38 | # them therein. no parameter means a default set will 39 | # be emitted based on the test type 40 | CSV="-o all" 41 | #CSV="-O all" 42 | 43 | # which of the tests should we do? 44 | DO_TCP_STREAM_AUTO=1 45 | DO_TCP_STREAM_SOPT=1 46 | DO_TCP_BIDIR=1 47 | DO_TCP_RR=1 48 | DO_TCP_CC=0 49 | DO_TCP_BIDIR_REQ=0 50 | DO_UDP_BIDIR_REQ=0 51 | DO_UDP_STREAM=1 52 | 53 | # when this is set to 0 then netperf and netserver are bound 54 | # to the same CPU number and we do not walk through all the 55 | # combinations. one can do this when the two systems are 56 | # otherwise identical. when they are not, then running 57 | # through the full matrix may be indicated 58 | FULL_MATRIX=0 59 | 60 | # here you should echo some things about the test and its 61 | # environment and in particular those things not automagically 62 | # determined by netperf 63 | echo I NEED TO EDIT THE SCRIPT 64 | echo interrupts CPU 0 with CPU 1 other socket CPU 2 same socket 65 | echo ad386a in dl380 g5 2x 5160@3GHz to same 66 | 67 | # and away we go 68 | for data in $remote_hosts 69 | do 70 | 71 | if [ $DO_TCP_STREAM_AUTO -eq 1 ] 72 | then 73 | echo TCP_STREAM to $data autotuning 74 | for i in $netperf_CPUs 75 | do 76 | if [ $FULL_MATRIX -eq 1 ] 77 | then 78 | set=$netserver_CPUs 79 | else 80 | set=$i 81 | fi 82 | for j in $set 83 | do 84 | netperf $HDR -T $i,$j -t omni -c -C -H $control_host -l $length $confidence -- $CSV -H $data -m 64K;HDR="-P 0"; 85 | done 86 | done 87 | fi 88 | 89 | if [ $DO_TCP_STREAM_SOPT -eq 1 ] 90 | then 91 | echo TCP_STREAM to $data 92 | HDR="-P 1" 93 | for i in $netperf_CPUs 94 | do 95 | if [ $FULL_MATRIX -eq 1 ] 96 | then 97 | set=$netserver_CPUs 98 | else 99 | set=$i 100 | fi 101 | for j in $set 102 | do 103 | netperf $HDR -T $i,$j -t omni -c -C -H $control_host -l $length $confidence -- $CSV -H $data -s 1M -S 1M -m 64K;HDR="-P 0"; 104 | done 105 | done 106 | fi 107 | 108 | if [ $DO_TCP_BIDIR -eq 1 ] 109 | then 110 | echo bidir TCP_RR MEGABITS to $data 111 | HDR="-P 1" 112 | for i in $netperf_CPUs 113 | do 114 | if [ $FULL_MATRIX -eq 1 ] 115 | then 116 | set=$netserver_CPUs 117 | else 118 | set=$i 119 | fi 120 | for j in $set 121 | do 122 | netperf $HDR -T $i,$j -t omni -f m -c -C -H $control_host -l $length $confidence -- $CSV -H $data -s 1M -S 1M -r 64K -b 12; HDR="-P 0"; 123 | done 124 | done 125 | fi 126 | 127 | if [ $DO_TCP_RR -eq 1 ] 128 | then 129 | echo TCP_RR to $data 130 | HDR="-P 1" 131 | for i in $netperf_CPUs 132 | do 133 | if [ $FULL_MATRIX -eq 1 ] 134 | then 135 | set=$netserver_CPUs 136 | else 137 | set=$i 138 | fi 139 | for j in $set 140 | do 141 | netperf $HDR -T $i,$j -t omni -c -C -H $control_host -l $length $confidence -- $CSV -H $data -r 1; HDR="-P 0"; 142 | done 143 | done 144 | fi 145 | 146 | if [ $DO_TCP_BIDIR_REQ -eq 1 ] 147 | then 148 | echo bidir TCP_RR MEGABITS to $data altering req/rsp size and burst 149 | HDR="-P 1" 150 | for i in $netperf_CPUs 151 | do 152 | for req in $reqs; do 153 | for burst in $bursts; do 154 | netperf $HDR -T $i -t omni -f m -c -C -H $control_host -l $length $confidence -- $CSV -H $data -s 1M -S 1M -r $req -b $burst -D;HDR=-"P 0"; 155 | done 156 | done 157 | done 158 | fi 159 | 160 | if [ $DO_UDP_BIDIR_REQ -eq 1 ] 161 | then 162 | echo bidir UDP_RR MEGABITS to $data altering req/rsp size and burst 163 | HDR="-P 1" 164 | for i in $netperf_CPUs 165 | do 166 | for req in $reqs; do 167 | for burst in $bursts; do 168 | netperf $HDR -T $i -t omni -f m -c -C -H $control_host -l $length $confidence -- $CSV -H $data -s 1M -S 1M -r $req -b $burst -T udp;HDR=-"P 0"; 169 | done 170 | done 171 | done 172 | fi 173 | 174 | if [ $DO_UDP_STREAM -eq 1 ] 175 | then 176 | echo UDP_STREAM MEGABITS to $data altering send size, no confidence intvls 177 | confidence=" " 178 | echo CPUs $netperf_CPUs reqs $reqs 179 | HDR="-P 1" 180 | for i in $netperf_CPUs 181 | do 182 | for req in $reqs; do 183 | netperf $HDR -T $i -t omni -f m -c -C -H $control_host -l $length $confidence -- $CSV -H $data -s 1M -S 1M -m $req -T udp;HDR=-"P 0"; 184 | done 185 | done 186 | fi 187 | 188 | done 189 | 190 | cat /proc/meminfo 191 | cat /proc/cpuinfo 192 | -------------------------------------------------------------------------------- /doc/examples/runemomniagg2.sh: -------------------------------------------------------------------------------- 1 | #set -x 2 | # edit and add to this array as necessary 3 | # the hosts you will use should be contiguous 4 | # starting at index zero 5 | remote_hosts[0]=192.168.2.3 6 | remote_hosts[1]=192.168.3.5 7 | remote_hosts[2]=192.168.4.6 8 | remote_hosts[3]=192.168.5.7 9 | remote_hosts[4]=192.168.2.5 10 | remote_hosts[5]=192.168.3.3 11 | remote_hosts[6]=192.168.4.7 12 | remote_hosts[7]=192.168.5.6 13 | remote_hosts[8]=192.168.2.6 14 | remote_hosts[9]=192.168.3.7 15 | remote_hosts[10]=192.168.4.3 16 | remote_hosts[11]=192.168.5.5 17 | remote_hosts[12]=192.168.2.7 18 | remote_hosts[13]=192.168.3.6 19 | remote_hosts[14]=192.168.4.5 20 | remote_hosts[15]=192.168.5.3 21 | 22 | # this should always be less than or equal to the 23 | # number of valid hosts in the array above 24 | num_cli=16 25 | 26 | # this will be the length of each individual test 27 | # iteration 28 | length=30 29 | 30 | # this will be the settings for confidence intervals 31 | # you can use a smaller number of iterations but 32 | # to ensure that everyone is running at the same time 33 | # the min and max iterations MUST be the same 34 | confidence="-i 30,30" 35 | 36 | # the different number of concurrent sessions to be run 37 | # if you do not start with one concurrent session the 38 | # test headers may not be where one wants them and you 39 | # may need to edit the output to hoist the test header 40 | # up above the first result 41 | concurrent_sessions="1 4 8 16 32 64" 42 | 43 | # the socket buffer sizes - you may need to tweak 44 | # some system settings to allow 1M socket buffers 45 | socket_sizes=" -s 1M -S 1M" 46 | 47 | # the burst sizes in the aggregate request/response tests 48 | #burst_sizes="0 1 4 16 64 256 1024" 49 | burst_sizes="0 1 4 16" 50 | 51 | # this ensures the test header of at least one instance 52 | # is displayed 53 | HDR="-P 1" 54 | 55 | # -O means "human" -o means "csv" and -k means "keyval" 56 | # "all" means emit everything it knows to emit. omit "all" 57 | # and what is emitted will depend on the test. can customize 58 | # with direct output selection or specifying a file with 59 | # output selectors in it 60 | CSV="-o all" 61 | 62 | # should tests outbound relative to this system be run? 63 | DO_STREAM=0 64 | 65 | # should tests inbound relative to this system be run? 66 | DO_MAERTS=0 67 | 68 | # should same connection bidirectional tests be run? 69 | DO_BIDIR=1 70 | 71 | # should aggreagte single-byte request/response be run? 72 | # this can be used to try to get a maximum PPS figure 73 | DO_RRAGG=1 74 | 75 | # here you should echo-out some things about the test 76 | # particularly those things that will not be automagically 77 | # captured by netperf. 78 | echo interrupts spread wherever irqbalanced put them 79 | echo 4xAD386A in DL785 G5 SLES11B6, HP/vendor drivers 80 | echo four dl585 G5 clients rh5.2, each with two AD386A 81 | 82 | # and here we go 83 | if [ $DO_STREAM -eq 1 ]; then 84 | echo TCP_STREAM 85 | for i in $concurrent_sessions; do 86 | j=0; 87 | NETUUID=`netperf -t uuid`; 88 | echo $i concurrent streams id $NETUUID; 89 | while [ $j -lt $i ]; do 90 | client=`expr $j % $num_cli` ; 91 | netperf $HDR -t omni -c -C -H ${remote_hosts[$client]} -l $length $confidence -- $CSV -H ${remote_hosts[$client]} $socket_sizes -m 64K -u $NETUUID & HDR="-P 0"; 92 | j=`expr $j + 1`; 93 | done; 94 | wait; 95 | done 96 | fi 97 | # 98 | if [ $DO_MAERTS -eq 1 ]; then 99 | echo TCP_MAERTS 100 | for i in $concurrent_sessions; do 101 | j=0; 102 | NETUUID=`netperf -t uuid`; 103 | echo $i concurrent streams id $NETUUID; 104 | while [ $j -lt $i ]; do 105 | client=`expr $j % $num_cli` ; 106 | netperf $HDR -t omni -c -C -H ${remote_hosts[$client]} -l $length $confidence -- $CSV -H ${remote_hosts[$client]} $socket_sizes -M ,64K -u $NETUUID & HDR="-P 0"; 107 | j=`expr $j + 1`; 108 | done; 109 | wait; 110 | done 111 | fi 112 | 113 | if [ $DO_BIDIR -eq 1 ]; then 114 | echo bidir TCP_RR MEGABITS 115 | HDR="-P 1" 116 | for i in $concurrent_sessions; 117 | do j=0; 118 | NETUUID=`netperf -t uuid`; 119 | echo $i concurrent streams id $NETUUID; 120 | while [ $j -lt $i ]; do 121 | client=`expr $j % $num_cli` ; 122 | netperf $HDR -t omni -f m -c -C -H ${remote_hosts[$client]} -l $length $confidence -- $CSV -H ${remote_hosts[$client]} -s 1M -S 1M -r 64K -b 12 -u $NETUUID & HDR="-P 0"; 123 | j=`expr $j + 1`; 124 | done; 125 | wait; 126 | done 127 | fi 128 | 129 | if [ $DO_RRAGG -eq 1 ]; then 130 | echo TCP_RR aggregates 131 | HDR="-P 1" 132 | for i in $concurrent_sessions; do 133 | NETUUID=`netperf -t uuid`; 134 | echo $i concurrent streams id $NETUUID; 135 | for b in $burst_sizes; do 136 | echo burst of $b; 137 | j=0; 138 | while [ $j -lt $i ]; do 139 | client=`expr $j % $num_cli` ; 140 | netperf $HDR -t omni -f x -c -C -H ${remote_hosts[$client]} -l $length $confidence -- $CSV -H ${remote_hosts[$client]} -r 1 -b $b -D -u $NETUUID & HDR="-P 0"; 141 | j=`expr $j + 1`; 142 | done; 143 | wait; 144 | done; 145 | done 146 | fi 147 | 148 | cat /proc/meminfo 149 | -------------------------------------------------------------------------------- /doc/examples/runemomniaggdemo.sh: -------------------------------------------------------------------------------- 1 | # this is a quick and dirty migration of runemomniagg2.sh to the 2 | # --enable-demo mode of aggregate testing 3 | function kill_netperfs { 4 | pkill -ALRM netperf 5 | 6 | pgrep -P 1 -f netperf > /dev/null 7 | while [ $? -eq 0 ] 8 | do 9 | sleep 1 10 | pgrep -P 1 -f netperf > /dev/null 11 | done 12 | } 13 | 14 | function run_cmd { 15 | 16 | NOW=`date +%s.%N` 17 | echo "Starting netperfs at $NOW for $TEST" | tee $TESTLOG 18 | i=0; 19 | 20 | # the starting point for our load level pauses 21 | PAUSE_AT=1 22 | 23 | 24 | while [ $i -lt $MAX_INSTANCES ] 25 | do 26 | TARGET=${REMOTE_HOSTS[`expr $i % $NUM_REMOTE_HOSTS`]} 27 | echo "Starting netperfs on localhost targeting ${TARGET} for $TEST" | tee -a $TESTLOG 28 | id=`printf "%.5d" $i` 29 | $NETPERF -H $TARGET $NETPERF_CMD 2>&1 > netperf_${TEST}_${id}_to_${TARGET}.out & 30 | 31 | # give it a moment to get going 32 | sleep 1 33 | 34 | i=`expr $i + 1` 35 | 36 | if [ $i -eq $PAUSE_AT ] && [ $i -ne $MAX_INSTANCES ] 37 | then 38 | NOW=`date +%s.%N` 39 | echo "Pausing for $DURATION seconds at $NOW with $i netperfs running for $TEST" | tee -a $TESTLOG 40 | sleep $DURATION 41 | PAUSE_AT=`expr $PAUSE_AT \* 2` 42 | NOW=`date +%s.%N` 43 | echo "Resuming at $NOW for $TEST" | tee -a $TESTLOG 44 | fi 45 | done 46 | 47 | NOW=`date +%s.%N` 48 | echo "Netperfs started by $NOW for $TEST" | tee -a $TESTLOG 49 | 50 | #wait for our test duration 51 | sleep $DURATION 52 | 53 | #kludgey but this sleep should mean that another interim result will be emitted 54 | sleep 3 55 | 56 | # stop all the netperfs 57 | NOW=`date +%s.%N` 58 | echo "Netperfs stopping $NOW for $TEST" | tee -a $TESTLOG 59 | kill_netperfs 60 | 61 | NOW=`date +%s.%N` 62 | echo "Netperfs stopped $NOW for $TEST" | tee -a $TESTLOG 63 | 64 | } 65 | 66 | # here then is the "main" part 67 | 68 | if [ ! -f ./remote_hosts ] 69 | then 70 | echo "This script requires a remote_hosts file" 71 | exit -1 72 | fi 73 | . ./remote_hosts 74 | 75 | # how many processors are there on this system 76 | NUM_CPUS=`grep processor /proc/cpuinfo | wc -l` 77 | 78 | # the number of netperf instances we will run will be up to 2x the 79 | # number of CPUs 80 | MAX_INSTANCES=`expr $NUM_CPUS \* 2` 81 | 82 | # allow the netperf binary to be used to be overridden 83 | NETPERF=${NETPERF:="netperf"} 84 | 85 | if [ $NUM_REMOTE_HOSTS -lt 2 ] 86 | then 87 | echo "The list of remote hosts is too short. There must be at least 2." 88 | exit -1 89 | fi 90 | 91 | # we assume that netservers are already running on all the load generators 92 | 93 | DURATION=120 94 | # do not have a uuidgen? then use the one in netperf 95 | MY_UUID=`uuidgen` 96 | # with top-of-trunk we could make this 0 and run forever 97 | # but two hours is something of a failsafe if the signals 98 | # get lost 99 | LENGTH="-l 7200" 100 | OUTPUT="-o all" 101 | 102 | DO_STREAM=1; 103 | DO_MAERTS=1; 104 | # NOTE! The Bidir test depends on being able to set a socket buffer 105 | # size greater than 13 * 64KB or 832 KB or there is a risk of the test 106 | # hanging. If you are running linux, make certain that 107 | # net.core.[r|w]mem_max are sufficiently large 108 | DO_BIDIR=1; 109 | DO_RRAGG=1; 110 | 111 | # TCP_RR for TPC/PPS using single-byte transactions and TCP_NODELAY 112 | if [ $DO_RRAGG -eq 1 ]; then 113 | BURST=`./find_max_burst.sh ${REMOTE_HOSTS[0]}` 114 | if [ $BURST -eq -1 ]; then 115 | # use a value that find_max_burst will not have picked 116 | BURST=9 117 | echo "find_max_burst.sh returned -1 so picking a burst of $BURST" 118 | fi 119 | TEST="tps" 120 | TESTLOG="netperf_tps.log" 121 | NETPERF_CMD="-D 0.5 -c -C -f x -P 0 -t omni $LENGTH -v 2 -- -r 1 -b $BURST -D -u $MY_UUID $OUTPUT" 122 | run_cmd 123 | fi 124 | 125 | # Bidirectional using burst-mode TCP_RR and large request/response size 126 | if [ $DO_BIDIR -eq 1 ]; then 127 | TEST="bidirectional" 128 | TESTLOG="netperf_bidirectional.log" 129 | NETPERF_CMD="-D 0.5 -c -C -f m -P 0 -t omni $LENGTH -v 2 -- -r 64K -s 1M -S 1M -b 12 -u $MY_UUID $OUTPUT" 130 | run_cmd 131 | fi 132 | 133 | # TCP_STREAM aka outbound with a 64K send size 134 | # the netperf command is everything but netperf -H mumble 135 | if [ $DO_STREAM -eq 1 ];then 136 | TEST="outbound" 137 | TESTLOG="netperf_outbound.log" 138 | NETPERF_CMD="-D 0.5 -c -C -f m -P 0 -t omni $LENGTH -v 2 -- -m 64K -u $MY_UUID $OUTPUT" 139 | run_cmd 140 | fi 141 | 142 | # TCP_MAERTS aka inbound with a 64K send size - why is this one last? 143 | # because presently when I pkill the netperf of a "MAERTS" test, the 144 | # netserver does not behave well and it may not be possible to get it 145 | # to behave well. but we will still have all the interim results even 146 | # if we don't get the final results, the useful parts of which will be 147 | # the same as the other tests anyway 148 | if [ $DO_MAERTS -eq 1 ]; then 149 | TEST="inbound" 150 | TESTLOG="netperf_inbound.log" 151 | NETPERF_CMD="-D 0.5 -c -C -f m -P 0 -t omni $LENGTH -v 2 -- -m ,64K -u $MY_UUID $OUTPUT" 152 | run_cmd 153 | fi 154 | 155 | -------------------------------------------------------------------------------- /doc/examples/sctp_stream_script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This is an example script for using netperf. Feel free to modify it 4 | # as necessary, but I would suggest that you copy this one first. 5 | # 6 | # This version has been modified to take advantage of the confidence 7 | # interval support in revision 2.0 of netperf. it has also been altered 8 | # to make submitting its resutls to the netperf database easier 9 | # raj 11/94 10 | # 11 | # usage: tcp_stream_script hostname [CPU] 12 | # 13 | 14 | if [ $# -gt 2 ]; then 15 | echo "try again, correctly -> sctp_stream_script hostname [CPU]" 16 | exit 1 17 | fi 18 | 19 | if [ $# -eq 0 ]; then 20 | echo "try again, correctly -> sctp_stream_script hostname [CPU]" 21 | exit 1 22 | fi 23 | 24 | # where the programs are 25 | #NETHOME=/usr/local/netperf 26 | #NETHOME="/opt/netperf" 27 | NETHOME=. 28 | 29 | # at what port will netserver be waiting? If you decide to run 30 | # netserver at a differnet port than the default of 12865, then set 31 | # the value of PORT apropriately 32 | #PORT="-p some_other_portnum" 33 | PORT="" 34 | 35 | # The test length in seconds 36 | TEST_TIME=60 37 | 38 | # How accurate we want the estimate of performance: 39 | # maximum and minimum test iterations (-i) 40 | # confidence level (99 or 95) and interval (percent) 41 | STATS_STUFF="-i 10,2 -I 99,5" 42 | 43 | # The socket sizes that we will be testing 44 | SOCKET_SIZES="57344 32768 8192" 45 | 46 | # The send sizes that we will be using 47 | SEND_SIZES="4096 8192 32768" 48 | 49 | # if there are two parms, parm one it the hostname and parm two will 50 | # be a CPU indicator. actually, anything as a second parm will cause 51 | # the CPU to be measured, but we will "advertise" it should be "CPU" 52 | 53 | if [ $# -eq 2 ]; then 54 | REM_HOST=$1 55 | LOC_CPU="-c" 56 | REM_CPU="-C" 57 | fi 58 | 59 | if [ $# -eq 1 ]; then 60 | REM_HOST=$1 61 | fi 62 | 63 | # If we are measuring CPU utilization, then we can save beaucoup 64 | # time by saving the results of the CPU calibration and passing 65 | # them in during the real tests. So, we execute the new CPU "tests" 66 | # of netperf and put the values into shell vars. 67 | case $LOC_CPU in 68 | \-c) LOC_RATE=`$NETHOME/netperf $PORT -t LOC_CPU`;; 69 | *) LOC_RATE="" 70 | esac 71 | 72 | case $REM_CPU in 73 | \-C) REM_RATE=`$NETHOME/netperf $PORT -t REM_CPU -H $REM_HOST`;; 74 | *) REM_RATE="" 75 | esac 76 | 77 | # this will disable headers 78 | NO_HDR="-P 0" 79 | 80 | for SOCKET_SIZE in $SOCKET_SIZES 81 | do 82 | for SEND_SIZE in $SEND_SIZES 83 | do 84 | echo 85 | echo ------------------------------------ 86 | echo 87 | # we echo the command line for cut and paste 88 | echo $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST -t SCTP_STREAM\ 89 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\ 90 | -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 91 | 92 | echo 93 | # since we have the confidence interval stuff, we do not 94 | # need to repeat a test multiple times from the shell 95 | $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST -t SCTP_STREAM\ 96 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\ 97 | -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 98 | 99 | done 100 | done 101 | -------------------------------------------------------------------------------- /doc/examples/set_affinity.sh: -------------------------------------------------------------------------------- 1 | # one of these days I should make it take a parameter or three 2 | grep eth0 /proc/interrupts | awk -F ":" '{printf("echo 1 > /proc/irq/%d/smp_affinity\n",$1)}' | sh 3 | -------------------------------------------------------------------------------- /doc/examples/tcp_range_script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # stream_range 4 | # 5 | # generate a whole lot of numbers from netperf to see the effects 6 | # of send size on thruput 7 | # 8 | 9 | # 10 | # usage : tcp_stream_range hostname [CPU] 11 | # 12 | 13 | if [ $# -gt 2 ]; then 14 | echo "try again, correctly -> tcp_stream_range hostname [CPU]" 15 | exit 1 16 | fi 17 | 18 | if [ $# -eq 0 ]; then 19 | echo "try again, correctly -> tcp_stream_range hostname [CPU]" 20 | exit 1 21 | fi 22 | 23 | # if there are two parms, parm one it the hostname and parm two will 24 | # be a CPU indicator. actually, anything as a second parm will cause 25 | # the CPU to be measured, but we will "advertise" it should be "CPU" 26 | 27 | if [ $# -eq 2 ]; then 28 | REM_HOST=$1 29 | LOC_CPU="-c" 30 | REM_CPU="-C" 31 | fi 32 | 33 | if [ $# -eq 1 ]; then 34 | REM_HOST=$1 35 | fi 36 | 37 | # at what port will netserver be waiting? If you decide to run 38 | # netserver at a differnet port than the default of 12865, then set 39 | # the value of PORT apropriately 40 | #PORT="-p some_other_portnum" 41 | PORT="" 42 | 43 | # where is netperf, and are there any "constant" options such as 44 | # the netserver port number 45 | #NETHOME=/usr/etc/net_perf 46 | NETHOME="." 47 | NETPERF=$NETHOME/netperf $PORT 48 | 49 | # How accurate we want the estimate of performance: 50 | # maximum and minimum test iterations (-i) 51 | # confidence level (99 or 95) and interval (percent) 52 | STATS_STUFF="-i 10,2 -I 99,3" 53 | 54 | # 55 | # some stuff for the arithmetic 56 | # 57 | # we start at start, and then multiply by MULT and add ADD. by changing 58 | # these numbers, we can double each time, or increase by a fixed 59 | # amount, or go up by 4x, whatever we like... 60 | # 61 | START=1 62 | 63 | END=65536 64 | 65 | MULT=4 66 | 67 | ADD=0 68 | 69 | # If we are measuring CPU utilization, then we can save beaucoup 70 | # time by saving the results of the CPU calibration and passing 71 | # them in during the real tests. So, we execute the new CPU "tests" 72 | # of netperf and put the values into shell vars. 73 | case $LOC_CPU in 74 | \-c) LOC_RATE=`$NETPERF -t LOC_CPU`;; 75 | *) LOC_RATE="" 76 | esac 77 | 78 | case $REM_CPU in 79 | \-C) REM_RATE=`$NETPERF -t REM_CPU -H $REM_HOST`;; 80 | *) REM_RATE="" 81 | esac 82 | 83 | TIME="60" 84 | 85 | # 86 | # the maximum socket buffer size is system dependent. for the 87 | # "cannonical" tests we use 32KB, but this can be altered 88 | # 89 | SOCKET_SIZE="-s 32768 -S 32768" 90 | 91 | MESSAGE=$START 92 | while [ $MESSAGE -le $END ]; do 93 | echo 94 | echo ------------------------------------ 95 | echo Testing with the following command line: 96 | echo $NETPERF -l $TIME -H $REM_HOST -t TCP_STREAM\ 97 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\ 98 | -m $MESSAGE $SOCKET_SIZE 99 | echo 100 | $NETPERF -l $TIME -H $REM_HOST -t TCP_STREAM\ 101 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\ 102 | -m $MESSAGE $SOCKET_SIZE 103 | 104 | MESSAGE=`expr $MESSAGE + $ADD` 105 | MESSAGE=`expr $MESSAGE \* $MULT` 106 | 107 | done 108 | echo 109 | 110 | -------------------------------------------------------------------------------- /doc/examples/tcp_rr_script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This is an example script for using netperf. Feel free to modify it 4 | # as necessary, but I would suggest that you copy this one first. 5 | # 6 | # 7 | # This version has been modified to take advantage of the confidence 8 | # interval support in revision 2.0 of netperf. it has also been altered 9 | # to make submitting its resutls to the netperf database easier 10 | # raj 11/94 11 | # 12 | # usage: tcp_rr_script hostname [CPU] 13 | # 14 | 15 | if [ $# -gt 2 ]; then 16 | echo "try again, correctly -> tcp_rr_script hostname [CPU]" 17 | exit 1 18 | fi 19 | 20 | if [ $# -eq 0 ]; then 21 | echo "try again, correctly -> tcp_rr_script hostname [CPU]" 22 | exit 1 23 | fi 24 | 25 | # where the programs are 26 | #NETHOME=/usr/local/netperf 27 | #NETHOME="/opt/netperf" 28 | NETHOME=. 29 | 30 | # at what port will netserver be waiting? If you decide to run 31 | # netserver at a differnet port than the default of 12865, then set 32 | # the value of PORT apropriately 33 | #PORT="-p some_other_portnum" 34 | PORT="" 35 | 36 | # The test length in seconds 37 | TEST_TIME=60 38 | 39 | # How accurate we want the estimate of performance: 40 | # maximum and minimum test iterations (-i) 41 | # confidence level (99 or 95) and interval (percent) 42 | STATS_STUFF="-i 10,3 -I 99,5" 43 | 44 | # The socket sizes that we will be testing - using zero will let it 45 | # be the system default. 46 | SOCKET_SIZES="0" 47 | 48 | # The request,response sizes that we will be using. The netperf 49 | # command parser will treat "1" the same as "1,1" - I use 1,1 to 50 | # remember that it is "request,response" 51 | RR_SIZES="1,1 64,64 100,200 128,8192" 52 | 53 | # if there are two parms, parm one it the hostname and parm two will 54 | # be a CPU indicator. actually, anything as a second parm will cause 55 | # the CPU to be measured, but we will "advertise" it should be "CPU" 56 | 57 | if [ $# -eq 2 ]; then 58 | REM_HOST=$1 59 | LOC_CPU="-c" 60 | REM_CPU="-C" 61 | fi 62 | 63 | if [ $# -eq 1 ]; then 64 | REM_HOST=$1 65 | fi 66 | 67 | # If we are measuring CPU utilization, then we can save beaucoup 68 | # time by saving the results of the CPU calibration and passing 69 | # them in during the real tests. So, we execute the new CPU "tests" 70 | # of netperf and put the values into shell vars. 71 | case $LOC_CPU in 72 | \-c) LOC_RATE=`$NETHOME/netperf $PORT -t LOC_CPU`;; 73 | *) LOC_RATE="" 74 | esac 75 | 76 | case $REM_CPU in 77 | \-C) REM_RATE=`$NETHOME/netperf $PORT -t REM_CPU -H $REM_HOST`;; 78 | *) REM_RATE="" 79 | esac 80 | 81 | # This disables header display 82 | NO_HDR="-P 0" 83 | 84 | for SOCKET_SIZE in $SOCKET_SIZES 85 | do 86 | for RR_SIZE in $RR_SIZES 87 | do 88 | echo 89 | echo ------------------------------------------------------ 90 | echo Testing with the following command line: 91 | # we echo the command line for cut and paste to th database 92 | echo $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST -t TCP_RR \ 93 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\ 94 | -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 95 | echo 96 | # since we have the confidence interval stuff, we do not 97 | # need to repeat a test multiple times from the shell 98 | $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST -t TCP_RR \ 99 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\ 100 | -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 101 | done 102 | done 103 | echo 104 | -------------------------------------------------------------------------------- /doc/examples/tcp_stream_script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This is an example script for using netperf. Feel free to modify it 4 | # as necessary, but I would suggest that you copy this one first. 5 | # 6 | # This version has been modified to take advantage of the confidence 7 | # interval support in revision 2.0 of netperf. it has also been altered 8 | # to make submitting its resutls to the netperf database easier 9 | # raj 11/94 10 | # 11 | # usage: tcp_stream_script hostname [CPU] 12 | # 13 | 14 | if [ $# -gt 2 ]; then 15 | echo "try again, correctly -> tcp_stream_script hostname [CPU]" 16 | exit 1 17 | fi 18 | 19 | if [ $# -eq 0 ]; then 20 | echo "try again, correctly -> tcp_stream_script hostname [CPU]" 21 | exit 1 22 | fi 23 | 24 | # where the programs are 25 | #NETHOME=/usr/local/netperf 26 | #NETHOME="/opt/netperf" 27 | NETHOME=. 28 | 29 | # at what port will netserver be waiting? If you decide to run 30 | # netserver at a different port than the default of 12865, then set 31 | # the value of PORT apropriately 32 | #PORT="-p some_other_portnum" 33 | PORT="" 34 | 35 | # The test length in seconds 36 | TEST_TIME=60 37 | 38 | # How accurate we want the estimate of performance: 39 | # maximum and minimum test iterations (-i) 40 | # confidence level (99 or 95) and interval (percent) 41 | STATS_STUFF="-i 10,2 -I 99,5" 42 | 43 | # The socket sizes that we will be testing 44 | SOCKET_SIZES="128K 57344 32768 8192" 45 | 46 | # The send sizes that we will be using 47 | SEND_SIZES="4096 8192 32768" 48 | 49 | # if there are two parms, parm one it the hostname and parm two will 50 | # be a CPU indicator. actually, anything as a second parm will cause 51 | # the CPU to be measured, but we will "advertise" it should be "CPU" 52 | 53 | if [ $# -eq 2 ]; then 54 | REM_HOST=$1 55 | LOC_CPU="-c" 56 | REM_CPU="-C" 57 | fi 58 | 59 | if [ $# -eq 1 ]; then 60 | REM_HOST=$1 61 | fi 62 | 63 | # If we are measuring CPU utilization, then we can save beaucoup 64 | # time by saving the results of the CPU calibration and passing 65 | # them in during the real tests. So, we execute the new CPU "tests" 66 | # of netperf and put the values into shell vars. 67 | case $LOC_CPU in 68 | \-c) LOC_RATE=`$NETHOME/netperf $PORT -t LOC_CPU`;; 69 | *) LOC_RATE="" 70 | esac 71 | 72 | case $REM_CPU in 73 | \-C) REM_RATE=`$NETHOME/netperf $PORT -t REM_CPU -H $REM_HOST`;; 74 | *) REM_RATE="" 75 | esac 76 | 77 | # this will disable headers 78 | NO_HDR="-P 0" 79 | 80 | for SOCKET_SIZE in $SOCKET_SIZES 81 | do 82 | for SEND_SIZE in $SEND_SIZES 83 | do 84 | echo 85 | echo ------------------------------------ 86 | echo 87 | # we echo the command line for cut and paste 88 | echo $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST -t TCP_STREAM\ 89 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\ 90 | -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 91 | 92 | echo 93 | # since we have the confidence interval stuff, we do not 94 | # need to repeat a test multiple times from the shell 95 | $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST -t TCP_STREAM\ 96 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE $STATS_STUFF --\ 97 | -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 98 | 99 | done 100 | done 101 | -------------------------------------------------------------------------------- /doc/examples/udp_rr_script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This is an example script for using netperf. Feel free to modify it 4 | # as necessary, but I would suggest that you copy this one first. 5 | # 6 | # 7 | # uncomment the next line if you think the script is broken 8 | #set -x 9 | 10 | 11 | if [ $# -gt 2 ]; then 12 | echo "try again, correctly -> udp_rr_script hostname [CPU]" 13 | exit 1 14 | fi 15 | 16 | if [ $# -eq 0 ]; then 17 | echo "try again, correctly -> udp_rr_script hostname [CPU]" 18 | exit 1 19 | fi 20 | 21 | # where the programs are 22 | 23 | #NETHOME=/usr/local/netperf 24 | #NETHOME="/opt/netperf" 25 | NETHOME="." 26 | 27 | # at what port will netserver be waiting? If you decide to run 28 | # netserver at a differnet port than the default of 12865, then set 29 | # the value of PORT apropriately 30 | #PORT="-p some_other_portnum" 31 | PORT="" 32 | 33 | 34 | # The test length in seconds 35 | 36 | TEST_TIME=60 37 | 38 | # How accurate we want the estimate of performance: 39 | # maximum and minimum test iterations (-i) 40 | # confidence level (99 or 95) and interval (percent) 41 | 42 | STATS_STUFF="-i 10,2 -I 99,10" 43 | 44 | # The socket sizes that we will be testing - -1 means use default 45 | # not much point in changing the socket buffer for a UDP request/ 46 | # response test - unless you want to have requests/responses which 47 | # are larger than the default 48 | 49 | SOCKET_SIZES="-1" 50 | 51 | # The send sizes that we will be using 52 | 53 | RR_SIZES="1,1 64,64 100,200 1024,1024" 54 | 55 | # if there are two parms, parm one it the hostname and parm two will 56 | # be a CPU indicator. actually, anything as a second parm will cause 57 | # the CPU to be measured, but we will "advertise" it should be "CPU" 58 | 59 | if [ $# -eq 2 ]; then 60 | REM_HOST=$1 61 | LOC_CPU="-c" 62 | REM_CPU="-C" 63 | fi 64 | 65 | if [ $# -eq 1 ]; then 66 | LOC_CPU="" 67 | REM_CPU="" 68 | REM_HOST=$1 69 | fi 70 | 71 | # If we are measuring CPU utilization, then we can save beaucoup 72 | # time by saving the results of the CPU calibration and passing 73 | # them in during the real tests. So, we execute the new CPU "tests" 74 | # of netperf and put the values into shell vars. 75 | case $LOC_CPU in 76 | \-c) LOC_RATE=`$NETHOME/netperf $PORT -t LOC_CPU`;; 77 | *) LOC_RATE="" 78 | esac 79 | 80 | case $REM_CPU in 81 | \-C) REM_RATE=`$NETHOME/netperf $PORT -t REM_CPU -H $REM_HOST`;; 82 | *) REM_RATE="" 83 | esac 84 | 85 | # This turns-off the display headers 86 | NO_HDR="-P 0" 87 | 88 | for SOCKET_SIZE in $SOCKET_SIZES 89 | do 90 | for RR_SIZE in $RR_SIZES 91 | do 92 | echo 93 | echo ------------------------------------------------------ 94 | echo Testing with the following command line: 95 | echo $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST $STATS_STUFF \ 96 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_RR --\ 97 | -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 98 | $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST $STATS_STUFF \ 99 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_RR $NO_HDR --\ 100 | -r $RR_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 101 | done 102 | done 103 | echo 104 | -------------------------------------------------------------------------------- /doc/examples/udp_stream_script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This is an example script for using netperf. Feel free to modify it 4 | # as necessary, but I would suggest that you copy this one first. 5 | # This script performs various UDP unidirectional stream tests. 6 | # 7 | 8 | if [ $# -gt 2 ]; then 9 | echo "try again, correctly -> udp_stream_script hostname [CPU]" 10 | exit 1 11 | fi 12 | 13 | if [ $# -eq 0 ]; then 14 | echo "try again, correctly -> udp_stream_script hostname [CPU]" 15 | exit 1 16 | fi 17 | 18 | # where the programs are 19 | 20 | #NETHOME=/usr/local/netperf 21 | #NETHOME="/opt/netperf" 22 | NETHOME="." 23 | 24 | # at what port will netserver be waiting? If you decide to run 25 | # netserver at a differnet port than the default of 12865, then set 26 | # the value of PORT apropriately 27 | #PORT="-p some_other_portnum" 28 | PORT="" 29 | 30 | # The test length in seconds 31 | TEST_TIME=60 32 | 33 | # How accurate we want the estimate of performance: 34 | # maximum and minimum test iterations (-i) 35 | # confidence level (99 or 95) and interval (percent) 36 | 37 | STATS_STUFF="-i 10,2 -I 99,10" 38 | 39 | # The socket sizes that we will be testing. This should be a list of 40 | # integers separated by spaces 41 | 42 | SOCKET_SIZES="32768" 43 | 44 | # The send sizes that we will be using. Using send sizes that result 45 | # in UDP packets which are larger than link size can be a bad thing to do. 46 | # for FDDI, you can tack-on a 4096 data point 47 | 48 | SEND_SIZES="64 1024 1472" 49 | 50 | # if there are two parms, parm one it the hostname and parm two will 51 | # be a CPU indicator. actually, anything as a second parm will cause 52 | # the CPU to be measured, but we will "advertise" it should be "CPU" 53 | 54 | if [ $# -eq 2 ]; then 55 | REM_HOST=$1 56 | LOC_CPU="-c" 57 | REM_CPU="-C" 58 | fi 59 | 60 | if [ $# -eq 1 ]; then 61 | LOC_CPU="" 62 | REM_CPU="" 63 | REM_HOST=$1 64 | fi 65 | 66 | # If we are measuring CPU utilization, then we can save beaucoup 67 | # time by saving the results of the CPU calibration and passing 68 | # them in during the real tests. So, we execute the new CPU "tests" 69 | # of netperf and put the values into shell vars. 70 | case $LOC_CPU in 71 | \-c) LOC_RATE=`$NETHOME/netperf $PORT -t LOC_CPU`;; 72 | *) LOC_RATE="" 73 | esac 74 | 75 | case $REM_CPU in 76 | \-C) REM_RATE=`$NETHOME/netperf $PORT -t REM_CPU -H $REM_HOST`;; 77 | *) REM_RATE="" 78 | esac 79 | 80 | # This will tell netperf that headers are not to be displayed 81 | NO_HDR="-P 0" 82 | 83 | for SOCKET_SIZE in $SOCKET_SIZES 84 | do 85 | for SEND_SIZE in $SEND_SIZES 86 | do 87 | echo 88 | echo ------------------------------------------------------ 89 | echo Testing with the following command line: 90 | echo $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST $STATS_STUFF \ 91 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_STREAM -- \ 92 | -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 93 | 94 | $NETHOME/netperf $PORT -l $TEST_TIME -H $REM_HOST $STATS_STUFF \ 95 | $LOC_CPU $LOC_RATE $REM_CPU $REM_RATE -t UDP_STREAM -- \ 96 | -m $SEND_SIZE -s $SOCKET_SIZE -S $SOCKET_SIZE 97 | 98 | done 99 | done 100 | echo 101 | -------------------------------------------------------------------------------- /doc/examples/vrules.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | count=0 3 | resumes=0 4 | my_index=0 5 | } 6 | 7 | $1 == "Starting" && 8 | $2 == "netperfs" && 9 | $3 == "on" { 10 | count += 1 11 | next 12 | } 13 | 14 | $1 == "Pausing" { 15 | printf("VRULE_TIME[%d]=%d\n",my_index,int($6)) 16 | printf("VRULE_COLR[%d]=\"FF0000\"\n",my_index) 17 | printf("VRULE_TEXT[%d]=\"%d_netperfs_running\"\n",my_index,$8) 18 | my_index += 1 19 | next 20 | } 21 | 22 | $1 == "Resuming" { 23 | printf("VRULE_TIME[%d]=%d\n",my_index,int($3)) 24 | printf("VRULE_COLR[%d]=\"000000\"\n",my_index) 25 | if (resumes) 26 | printf("VRULE_TEXT[%d]=\"\"\n",my_index) 27 | else 28 | printf("VRULE_TEXT[%d]=\"Resuming_ramp\"\n",my_index) 29 | resumes=1 30 | my_index += 1 31 | next 32 | } 33 | 34 | $1 == "Netperfs" && 35 | $2 == "started" { 36 | printf("VRULE_TIME[%d]=%d\n",my_index,int($4)) 37 | printf("VRULE_COLR[%d]=\"FF0000\"\n",my_index) 38 | printf("VRULE_TEXT[%d]=\"All_%d_netperfs_started\"\n",my_index,count) 39 | my_index += 1 40 | next 41 | } 42 | 43 | $1 == "Netperfs" && 44 | $2 == "stopping" { 45 | printf("VRULE_TIME[%d]=%d\n",my_index,int($3)) 46 | printf("VRULE_COLR[%d]=\"000000\"\n",my_index) 47 | printf("VRULE_TEXT[%d]=\"Rampdown_started\"\n",my_index) 48 | my_index += 1; 49 | next 50 | } 51 | 52 | END { 53 | printf("NUM_VRULES=%d\n",my_index) 54 | } -------------------------------------------------------------------------------- /doc/netperf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/multipath-tcp/netperf/1f639fa7e242b81a667c547c78adfb3f8fff3d30/doc/netperf.pdf -------------------------------------------------------------------------------- /doc/netserver.man: -------------------------------------------------------------------------------- 1 | .TH netserver 1 "" 2 | .SH NAME 3 | 4 | netserver \- a network performance benchmark server 5 | 6 | .SH SYNOPSIS 7 | 8 | .B netserver 9 | [-4] 10 | [-6] 11 | [-d] 12 | [-h] 13 | [-L name,family] 14 | [-p portnum] 15 | [-v verbosity] 16 | [-V] 17 | 18 | .SH DESCRIPTION 19 | .B Netserver 20 | listens for connections from a 21 | .B netperf 22 | benchmark, and responds accordingly. 23 | It can either be run from 24 | .B inetd 25 | or as a standalone daemon (with the -p flag). If run from 26 | .B inetd 27 | the -p option should not be used. 28 | 29 | .SS OPTIONS 30 | .TP 31 | .B \-4 32 | Use AF_INET (aka IPv4) addressing for the control and possibly data 33 | connections. 34 | .TP 35 | .B \-6 36 | Use AF_INET6 (aka IPv6) addressing for the control and possibly data 37 | connections. 38 | .TP 39 | .B \-d 40 | Increase the quantity of debugging output displayed during 41 | a test (possibly at the expense of performance). 42 | .TP 43 | .B \-h 44 | Display a usage string, and exit. 45 | .TP 46 | .B \-L name,family 47 | Set the local name and/or address family for the socket used for 48 | the control connection. 49 | .TP 50 | .B \-p portnum 51 | Listen on the specified port. 52 | This is used when running as a standalone daemon. 53 | .TP 54 | .B \-v verbosity 55 | Set the verbosity level for the test. 56 | .TP 57 | .B \-V 58 | Display the netperf version and exit. 59 | 60 | .SH BUGS 61 | No known bugs at this time. If you think you have found a bug, please report it to either netperf-talk@netperf.org or netperf-feedback@netperf.org. 62 | 63 | .SH SEE ALSO 64 | .BR netperf (1) 65 | .br 66 | .I 67 | Netperf: A Network Performance Benchmark 68 | .br 69 | http://www.netperf.org/ 70 | 71 | .SH AUTHORS 72 | HP Information Networks Division - Networking Performance Team. 73 | .br 74 | Rick Jones 75 | .br 76 | Karen Choy HP IND 77 | .br 78 | Dave Shield (man pages) 79 | .br 80 | Others too numerous to mention here - see the AUTHORS file 81 | -------------------------------------------------------------------------------- /inet_ntop.c: -------------------------------------------------------------------------------- 1 | #include "missing\inet_ntop.c" -------------------------------------------------------------------------------- /m4/m4/salen.m4: -------------------------------------------------------------------------------- 1 | dnl Copyright (c) 1995, 1996, 1997, 1998 2 | dnl tising materials mentioning 3 | dnl dnl features or use of this software display the following acknowledgement: 4 | dnl dnl ``This product includes software developed by the University of California, 5 | dnl dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 6 | dnl dnl the University nor the names of its contributors may be used to endorse 7 | dnl dnl or promote products derived from this software without specific prior 8 | dnl dnl written permission. 9 | dnl dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 10 | dnl dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 11 | dnl dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 | dnl dnl 13 | dnl dnl LBL autoconf macros 14 | dnl dnl 15 | dnl 16 | dnl 17 | dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member 18 | dnl borrowed from LBL libpcap 19 | AC_DEFUN(AC_CHECK_SA_LEN, [ 20 | AC_MSG_CHECKING(if sockaddr struct has sa_len member) 21 | AC_CACHE_VAL($1, 22 | AC_TRY_COMPILE([ 23 | # include 24 | # include ], 25 | [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], 26 | $1=yes, 27 | $1=no)) 28 | AC_MSG_RESULT($$1) 29 | if test $$1 = yes ; then 30 | AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[Define if struct sockaddr has the sa_len member]) 31 | fi 32 | ]) 33 | -------------------------------------------------------------------------------- /m4/m4/sockaddrin6.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for struct sockaddr_in6 31 | dnl * 32 | AC_DEFUN([AC_STRUCT_SOCKADDR_IN6], 33 | [AC_CACHE_CHECK(for struct sockaddr_in6, ac_cv_struct_sockaddr_in6, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include 36 | #include 37 | #include ]], [[ 38 | struct sockaddr_in6 address; 39 | ]])],[ac_cv_struct_sockaddr_in6=yes],[ac_cv_struct_sockaddr_in6=no])]) 40 | if test "$ac_cv_struct_sockaddr_in6" = yes; then 41 | AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, 42 | [Define to 1 if defines `struct sockaddr_in6']) 43 | fi]) 44 | 45 | dnl * 46 | dnl * Check for struct sockaddr_storage 47 | dnl * 48 | AC_DEFUN([AC_STRUCT_SOCKADDR_STORAGE], 49 | [AC_CACHE_CHECK(for struct sockaddr_storage, ac_cv_struct_sockaddr_storage, 50 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 51 | #include 52 | #include 53 | #include ]], [[ 54 | struct sockaddr_storage address; 55 | ]])],[ac_cv_struct_sockaddr_storage=yes],[ac_cv_struct_sockaddr_storage=no])]) 56 | if test "$ac_cv_struct_sockaddr_storage" = yes; then 57 | AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, 58 | [Define to 1 if defines `struct sockaddr_storage']) 59 | fi]) 60 | 61 | -------------------------------------------------------------------------------- /m4/m4/sockinttypes.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001, 2003 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for socklen_t. 31 | dnl * 32 | AC_DEFUN([AC_TYPE_SOCKLEN_T], 33 | [AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include 36 | #include ]], [[ 37 | socklen_t socklen; 38 | ]])],[ac_cv_type_socklen_t=yes],[ac_cv_type_socklen_t=no])]) 39 | if test "$ac_cv_type_socklen_t" != yes; then 40 | AC_DEFINE(socklen_t, int, 41 | [Define to `int' if or does not define.]) 42 | fi]) 43 | 44 | dnl * 45 | dnl * Check for in_port_t. 46 | dnl * 47 | AC_DEFUN([AC_TYPE_IN_PORT_T], 48 | [AC_CACHE_CHECK([for in_port_t], ac_cv_type_in_port_t, 49 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 50 | #include 51 | #include 52 | #include ]], [[ 53 | in_port_t in_port; 54 | ]])],[ac_cv_type_in_port_t=yes],[ac_cv_type_in_port_t=no])]) 55 | if test "$ac_cv_type_in_port_t" != yes; then 56 | ac_cv_sin_port_size=unknown 57 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 58 | #include 59 | #include 60 | #include 61 | int main() { 62 | struct sockaddr_in addr; 63 | return (sizeof(addr.sin_port) == sizeof(long)) ? 0 : 1; 64 | } 65 | ]])],[ac_cv_sin_port_size=long],[],[]) 66 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 67 | #include 68 | #include 69 | #include 70 | int main() { 71 | struct sockaddr_in addr; 72 | return (sizeof(addr.sin_port) == sizeof(int)) ? 0 : 1; 73 | } 74 | ]])],[ac_cv_sin_port_size=int],[],[]) 75 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 76 | #include 77 | #include 78 | #include 79 | int main() { 80 | struct sockaddr_in addr; 81 | return (sizeof(addr.sin_port) == sizeof(short)) ? 0 : 1; 82 | } 83 | ]])],[ac_cv_sin_port_size=short],[],[]) 84 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 85 | #include 86 | #include 87 | #include 88 | int main() { 89 | struct sockaddr_in addr; 90 | return (sizeof(addr.sin_port) == sizeof(char)) ? 0 : 1; 91 | } 92 | ]])],[ac_cv_sin_port_size=char],[],[]) 93 | if test "$ac_cv_sin_port_size" = unknown; then 94 | AC_MSG_ERROR([Failed to get size of sin_port in struct sockaddr_in.]) 95 | fi 96 | AC_DEFINE_UNQUOTED(in_port_t, unsigned $ac_cv_sin_port_size, 97 | [Define to `unsigned char', `unsigned short', `unsigned int' or 98 | `unsigned long' according with size of `sin_port' in `struct sockaddr_in', 99 | if , or does not define 100 | `in_port_t'.]) 101 | fi]) 102 | 103 | dnl * 104 | dnl * Check for sa_family_t. 105 | dnl * 106 | AC_DEFUN([AC_TYPE_SA_FAMILY_T], 107 | [AC_CACHE_CHECK([for sa_family_t], ac_cv_type_sa_family_t, 108 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 109 | #include 110 | #include ]], [[ 111 | sa_family_t sa_family; 112 | ]])],[ac_cv_type_sa_family_t=yes],[ac_cv_type_sa_family_t=no])]) 113 | if test "$ac_cv_type_sa_family_t" != yes; then 114 | ac_cv_sa_family_size=unknown 115 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 116 | #include 117 | #include 118 | int main() { 119 | struct sockaddr addr; 120 | return (sizeof(addr.sa_family) == sizeof(long)) ? 0 : 1; 121 | } 122 | ]])],[ac_cv_sa_family_size=long],[],[]) 123 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 124 | #include 125 | #include 126 | int main() { 127 | struct sockaddr addr; 128 | return (sizeof(addr.sa_family) == sizeof(int)) ? 0 : 1; 129 | } 130 | ]])],[ac_cv_sa_family_size=int],[],[]) 131 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 132 | #include 133 | #include 134 | int main() { 135 | struct sockaddr addr; 136 | return (sizeof(addr.sa_family) == sizeof(short)) ? 0 : 1; 137 | } 138 | ]])],[ac_cv_sa_family_size=short],[],[]) 139 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 140 | #include 141 | #include 142 | int main() { 143 | struct sockaddr addr; 144 | return (sizeof(addr.sa_family) == sizeof(char)) ? 0 : 1; 145 | } 146 | ]])],[ac_cv_sa_family_size=char],[],[]) 147 | if test "$ac_cv_sa_family_size" = unknown; then 148 | AC_MSG_ERROR([Failed to get size of sa_family in struct sockaddr.]) 149 | fi 150 | AC_DEFINE_UNQUOTED(sa_family_t, unsigned $ac_cv_sa_family_size, 151 | [Define to `unsigned char', `unsigned short', `unsigned int' or 152 | `unsigned long' according with size of `sa_family' in `struct sockaddr', 153 | if or does not define `sa_family_t'.]) 154 | fi]) 155 | -------------------------------------------------------------------------------- /mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | errstatus=0 8 | dirmode="" 9 | 10 | usage="\ 11 | Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." 12 | 13 | # process command line arguments 14 | while test $# -gt 0 ; do 15 | case $1 in 16 | -h | --help | --h*) # -h for help 17 | echo "$usage" 1>&2 18 | exit 0 19 | ;; 20 | -m) # -m PERM arg 21 | shift 22 | test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } 23 | dirmode=$1 24 | shift 25 | ;; 26 | --) # stop option processing 27 | shift 28 | break 29 | ;; 30 | -*) # unknown option 31 | echo "$usage" 1>&2 32 | exit 1 33 | ;; 34 | *) # first non-opt arg 35 | break 36 | ;; 37 | esac 38 | done 39 | 40 | for file 41 | do 42 | if test -d "$file"; then 43 | shift 44 | else 45 | break 46 | fi 47 | done 48 | 49 | case $# in 50 | 0) exit 0 ;; 51 | esac 52 | 53 | case $dirmode in 54 | '') 55 | if mkdir -p -- . 2>/dev/null; then 56 | echo "mkdir -p -- $*" 57 | exec mkdir -p -- "$@" 58 | fi 59 | ;; 60 | *) 61 | if mkdir -m "$dirmode" -p -- . 2>/dev/null; then 62 | echo "mkdir -m $dirmode -p -- $*" 63 | exec mkdir -m "$dirmode" -p -- "$@" 64 | fi 65 | ;; 66 | esac 67 | 68 | for file 69 | do 70 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 71 | shift 72 | 73 | pathcomp= 74 | for d 75 | do 76 | pathcomp="$pathcomp$d" 77 | case $pathcomp in 78 | -*) pathcomp=./$pathcomp ;; 79 | esac 80 | 81 | if test ! -d "$pathcomp"; then 82 | echo "mkdir $pathcomp" 83 | 84 | mkdir "$pathcomp" || lasterr=$? 85 | 86 | if test ! -d "$pathcomp"; then 87 | errstatus=$lasterr 88 | else 89 | if test ! -z "$dirmode"; then 90 | echo "chmod $dirmode $pathcomp" 91 | lasterr="" 92 | chmod "$dirmode" "$pathcomp" || lasterr=$? 93 | 94 | if test ! -z "$lasterr"; then 95 | errstatus=$lasterr 96 | fi 97 | fi 98 | fi 99 | fi 100 | 101 | pathcomp="$pathcomp/" 102 | done 103 | done 104 | 105 | exit $errstatus 106 | 107 | # Local Variables: 108 | # mode: shell-script 109 | # sh-indentation: 2 110 | # End: 111 | # mkinstalldirs ends here 112 | -------------------------------------------------------------------------------- /netperf.spec.in: -------------------------------------------------------------------------------- 1 | Summary: Network Performance Testing Tool 2 | Name: netperf 3 | Version: @VERSION@ 4 | Release: 1 5 | 6 | Group: System Environment/Base 7 | License: Unknown 8 | URL: http://www.netperf.org/ 9 | Packager: Martin A. Brown 10 | Source: ftp://ftp.netperf.org/netperf/%{name}-%{version}.tar.bz2 11 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root 12 | 13 | BuildRequires: texinfo, texinfo-tex 14 | 15 | # we are not quite ready to make this a requirement but leave 16 | # the line here as a heads up for the attentive :) 17 | # BuildRequires: libsmbios-devel 18 | 19 | # if you want to enable the SCTP tests, append --enable-sctp to the 20 | # configure line, and uncomment the next line 21 | # BuildRequires: lksctp-tools-devel 22 | 23 | %description 24 | Many different network benchmarking tools are collected in this package, 25 | maintained by Rick Jones of HP. 26 | 27 | 28 | %prep 29 | %setup -q 30 | 31 | %build 32 | # gcc 4.4 users may want to disable the strict aliasing warnings 33 | # CFLAGS="$RPM_OPT_FLAGS -Wno-strict-aliasing" 34 | %configure 35 | make %{_smp_mflags} 36 | 37 | %install 38 | rm -rf $RPM_BUILD_ROOT 39 | make install DESTDIR=${RPM_BUILD_ROOT} 40 | 41 | # Convert the main netperf document to other formats 42 | cd doc 43 | make %{name}.txt %{name}.html %{name}.xml pdf 44 | cd .. 45 | 46 | # We don't want to package the Makefile files in the examples directory 47 | rm -f doc/examples/Makefile* 48 | 49 | # Info 50 | rm -f $RPM_BUILD_ROOT/%{_infodir}/dir 51 | 52 | %clean 53 | rm -rf $RPM_BUILD_ROOT 54 | 55 | # %post 56 | 57 | %files 58 | %defattr(-,root,root,-) 59 | %doc README AUTHORS COPYING Release_Notes 60 | %doc doc/netperf.{html,pdf,txt,xml} 61 | %doc doc/examples 62 | %{_mandir}/man1/* 63 | %{_infodir}/* 64 | %{_bindir}/netperf 65 | %{_bindir}/netserver 66 | 67 | 68 | %changelog 69 | * Mon Sep 7 2009 Jose Pedro Oliveira - 2.4.5-1 70 | - Specfile cleanup. 71 | 72 | * Sat Jun 17 2006 Martin A. Brown - 2.4.2-1 73 | - initial contributed specfile for netperf package (v2.4.2) 74 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = missing 2 | 3 | CLEANFILES = netperf_version.h 4 | 5 | bin_PROGRAMS = netperf netserver 6 | 7 | AM_CFLAGS = $(NETPERF_CFLAGS) 8 | 9 | USE_CPU_SOURCE=netcpu_@NETCPU_SOURCE@.c 10 | USE_RT_SOURCE=netrt_@NETRTLKUP_SOURCE@.c 11 | USE_DRV_SOURCE=netdrv_@NETDRVLKUP_SOURCE@.c 12 | USE_SLOT_SOURCE=netslot_@NETSLOTLKUP_SOURCE@.c 13 | USE_SYS_SOURCE=netsys_@NETSYSLKUP_SOURCE@.c 14 | USE_SEC_SOURCE=netsec_@NETSECLKUP_SOURCE@.c 15 | 16 | EXTRA_DIST = netcpu_none.c netcpu_looper.c netcpu_pstat.c netcpu_pstatnew.c netcpu_perfstat.c netcpu_procstat.c netcpu_kstat.c netcpu_kstat10.c netcpu_sysctl.c netcpu_ntperf.c netcpu_osx.c dirs NetPerfDir/* NetServerDir/* netperf_version.h.in netrt_rtnetlink.c netrt_none.c netrt_rtmget.c netdrv_ethtool.c netdrv_none.c netslot_linux.c netslot_none.c netsys_none.c netsys_hpux11i.c netsys_linux.c netsys_solaris.c netdrv_solaris.c netslot_solaris.c netslot_ux1131.c netsec_linux.c netsec_none.c Makefile.uw 17 | 18 | COMMON_SRC = hist.h netlib.c netlib.h netcpu.h netsh.c netsh.h nettest_bsd.c nettest_bsd.h nettest_dlpi.c nettest_dlpi.h nettest_unix.c nettest_unix.h nettest_xti.c nettest_xti.h nettest_sctp.c nettest_sctp.h netperf_version.h nettest_sdp.c nettest_sdp.h nettest_omni.c net_uuid.c dscp.c 19 | 20 | netperf_SOURCES = netperf.c $(COMMON_SRC) $(USE_CPU_SOURCE) $(USE_RT_SOURCE) $(USE_DRV_SOURCE) $(USE_SLOT_SOURCE) $(USE_SYS_SOURCE) $(USE_SEC_SOURCE) 21 | netserver_SOURCES = netserver.c $(COMMON_SRC) $(USE_CPU_SOURCE) $(USE_RT_SOURCE) $(USE_DRV_SOURCE) $(USE_SLOT_SOURCE) $(USE_SYS_SOURCE) $(USE_SEC_SOURCE) 22 | 23 | # if there are any "missing" routines, the libobjs should cover it 24 | if NEED_LIBCOMPAT 25 | netperf_LDADD = missing/libcompat.a 26 | netserver_LDADD = missing/libcompat.ap 27 | endif 28 | -------------------------------------------------------------------------------- /src/Makefile.uw: -------------------------------------------------------------------------------- 1 | # User-world netperf Makefile. 2 | # Copyright 2008, VMware, Inc. 3 | # Portions Copyright 2008, Hewlett-Packard Company. 4 | # 5 | # Assume we're building in a DDK universe. 6 | # 7 | BORA_ROOT = /build/toolchain/lin32 8 | 9 | # 10 | # userworld library paths, relative to bora-root 11 | # 12 | UWGCC_ROOT = $(BORA_ROOT)/gcc-3.3.3 13 | UWGLIBC_TOP_DIR = $(BORA_ROOT)/uwglibc-2.2.5 14 | UWGLIBC_LIB_DIR = $(UWGLIBC_TOP_DIR)/lib 15 | UWGLIBC_USR_DIR = $(UWGLIBC_TOP_DIR)/usr/lib 16 | UWGLIBC_DEST_DIR = /usr/lib/vmware/lib 17 | 18 | # 19 | # userworld include paths 20 | # 21 | GCC_INCLUDES = -isystem $(UWGCC_ROOT)/lib/gcc-lib/i686-linux/3.3.3/include 22 | GLIBC_INCLUDES = -isystem $(BORA_ROOT)/glibc-2.2.5-44/usr/include 23 | 24 | # 25 | # userworld compiler environment 26 | # 27 | CC = GCC_EXEC_PREFIX="$(UWGCC_ROOT)/lib/gcc-lib/" \ 28 | KROOT=$(BORA_ROOT) \ 29 | PATH="$(UWGCC_ROOT)/bin:$(BORA_ROOT)/binutils-2.16.1-vt/bin:/bin:/sbin:/usr/sbin:/usr/bin" \ 30 | $(UWGCC_ROOT)/bin/i686-linux-gcc 31 | 32 | CC_INCLUDES = -nostdinc $(GCC_INCLUDES) $(GLIBC_INCLUDES) $(UWVER_INCLUDES) 33 | 34 | # 35 | # userworld shared libraries 36 | # 37 | UWGLIBC_LDLINUX_SO = ld-linux.so.2 38 | 39 | UWGLIBC_LINK_OPTS = -nostdlib -nostartfiles \ 40 | -Xlinker --dynamic-linker=$(UWGLIBC_DEST_DIR)/$(UWGLIBC_LDLINUX_SO) \ 41 | -Xlinker -z -Xlinker nodefaultlib \ 42 | -Xlinker -rpath -Xlinker $(UWGLIBC_DEST_DIR) \ 43 | -L$(UWGLIBC_USR_DIR) \ 44 | -L$(UWGLIBC_LIB_DIR) 45 | 46 | UWGLIBC_LINK_CRTS = \ 47 | ${UWGLIBC_TOP_DIR}/usr/lib/crt1.o \ 48 | ${UWGLIBC_TOP_DIR}/usr/lib/crti.o \ 49 | ${UWGCC_ROOT}/lib/gcc-lib/i686-linux/3.3.3/crtbegin.o \ 50 | ${UWGCC_ROOT}/lib/gcc-lib/i686-linux/3.3.3/crtend.o \ 51 | ${UWGLIBC_TOP_DIR}/usr/lib/crtn.o 52 | 53 | CFLAGS = -DVMWARE_UW $(CC_INCLUDES) -g -O -mcpu=pentiumpro 54 | CFLAGS += -DDEBUG_LOG_FILE=\"/dev/null\" -DDO_FIRST_BURST -DDO_UNIX 55 | 56 | UWGLIBC_LINK_LIBS = -lm -ldl -lpthread -lresolv -lnss_nis -lnss_nisplus \ 57 | -lnss_files -lnss_compat -lnss_dns -lnsl -lc -lc_nonshared -lgcc 58 | LDFLAGS = $(UWGLIBC_LINK_OPTS) $(UWGLIBC_LINK_CRTS) \ 59 | $(UWGLIBC_LINK_LIBS) ${UWGLIBC_LIB_DIR}/${UWGLIBC_LDLINUX_SO} 60 | 61 | NETSERVER_OBJS = netserver.o nettest_bsd.o nettest_dlpi.o \ 62 | nettest_unix.o netlib.o netsh.o \ 63 | nettest_xti.o nettest_ipv6.o \ 64 | netcpu_none.c \ 65 | nettest_dns.o 66 | 67 | NETPERF_OBJS = netperf.o netsh.o netlib.o nettest_bsd.o \ 68 | nettest_dlpi.o nettest_unix.o \ 69 | nettest_xti.o nettest_ipv6.o \ 70 | netcpu_none.c \ 71 | nettest_dns.o 72 | 73 | all: netperf-uw netserver-uw 74 | 75 | netperf-uw: $(NETPERF_OBJS) 76 | $(CC) -o $@ $(NETPERF_OBJS) $(LDFLAGS) 77 | strip $@ 78 | 79 | netserver-uw: $(NETSERVER_OBJS) 80 | $(CC) -o $@ $(NETSERVER_OBJS) $(LDFLAGS) 81 | strip $@ 82 | 83 | netperf.o: netperf.c netsh.h Makefile.uw 84 | 85 | netsh.o: netsh.c netsh.h nettest_bsd.h netlib.h Makefile.uw 86 | 87 | netlib.o: netlib.c netlib.h netsh.h Makefile.uw 88 | 89 | nettest_bsd.o: nettest_bsd.c nettest_bsd.h netlib.h netsh.h Makefile.uw 90 | 91 | nettest_dlpi.o: nettest_dlpi.c nettest_dlpi.h netlib.h netsh.h Makefile.uw 92 | 93 | nettest_unix.o: nettest_unix.c nettest_unix.h netlib.h netsh.h Makefile.uw 94 | 95 | nettest_xti.o: nettest_xti.c nettest_xti.h netlib.h netsh.h Makefile.uw 96 | 97 | nettest_ipv6.o: nettest_ipv6.c nettest_ipv6.h netlib.h netsh.h Makefile.uw 98 | 99 | nettest_dns.o: nettest_dns.c nettest_dns.h netlib.h netsh.h Makefile.uw 100 | 101 | netcpu_none.o: netcpu_none.c netsh.h netlib.h 102 | 103 | netserver.o: netserver.c nettest_bsd.h netlib.h Makefile.uw 104 | 105 | clean: 106 | rm -f *.o netperf-uw netserver-uw 107 | -------------------------------------------------------------------------------- /src/NetPerfDir/inet_ntop.c: -------------------------------------------------------------------------------- 1 | #if !defined(InetNtop) 2 | 3 | /* +*+ Why isn't this in the winsock headers yet? */ 4 | 5 | #include "..\missing\inet_ntop.c" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/NetPerfDir/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the driver components of the Windows NT DDK 5 | # 6 | 7 | !INCLUDE $(NTMAKEENV)\makefile.def -------------------------------------------------------------------------------- /src/NetPerfDir/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=netperf 2 | TARGETPATH=OBJ 3 | TARGETTYPE=PROGRAM 4 | 5 | LINKLIBS= \ 6 | $(SDK_LIB_PATH)\kernel32.lib \ 7 | $(SDK_LIB_PATH)\ws2_32.lib \ 8 | $(SDK_LIB_PATH)\wsock32.lib \ 9 | $(SDK_LIB_PATH)\Winmm.lib 10 | 11 | USE_MSVCRT=1 12 | UMTYPE=console 13 | 14 | INCLUDES=$(SDK_INC_PATH);. 15 | 16 | MSC_WARNING_LEVEL=/W3 /WX 17 | 18 | C_DEFINES=$(C_DEFINES) -D_CONSOLE_ -DHAVE_STRING_H -DHAVE_STRUCT_SOCKADDR_STORAGE -DHAVE_GETADDRINFO -DHAVE_GETNAMEINFO -DSTDC_HEADERS -DHAVE_STDLIB_H -DHAVE_WS2TCPIP_H -DWANT_OMNI -DWANT_DEMO -DWANT_HISTOGRAM -DWANT_INTERVALS 19 | 20 | #USER_C_FLAGS=$(USER_C_FLAGS) /E 21 | 22 | SOURCES= \ 23 | ..\netcpu_ntperf.c \ 24 | ..\netlib.c \ 25 | ..\netsh.c \ 26 | ..\nettest_bsd.c \ 27 | ..\nettest_omni.c \ 28 | ..\netsec_win.c \ 29 | ..\netdrv_none.c \ 30 | ..\netslot_none.c \ 31 | ..\netsys_none.c \ 32 | ..\netrt_none.c \ 33 | ..\net_uuid.c \ 34 | ..\netperf.c \ 35 | ..\dscp.c \ 36 | ..\inet_ntop.c 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/NetServerDir/inet_ntop.c: -------------------------------------------------------------------------------- 1 | #if !defined(InetNtop) 2 | 3 | /* +*+ Why isn't this in the winsock headers yet? */ 4 | 5 | #include "..\missing\inet_ntop.c" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/NetServerDir/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the driver components of the Windows NT DDK 5 | # 6 | 7 | !INCLUDE $(NTMAKEENV)\makefile.def -------------------------------------------------------------------------------- /src/NetServerDir/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=netserver 2 | TARGETPATH=OBJ 3 | TARGETTYPE=PROGRAM 4 | 5 | LINKLIBS= \ 6 | $(SDK_LIB_PATH)\kernel32.lib \ 7 | $(SDK_LIB_PATH)\ws2_32.lib \ 8 | $(SDK_LIB_PATH)\wsock32.lib \ 9 | $(SDK_LIB_PATH)\Winmm.lib 10 | 11 | USE_MSVCRT=1 12 | UMTYPE=console 13 | 14 | INCLUDES=$(SDK_INC_PATH);.;.. 15 | 16 | MSC_WARNING_LEVEL=/W3 /WX 17 | 18 | C_DEFINES=$(C_DEFINES) -D_CONSOLE_ -DHAVE_STRING_H -DHAVE_STRUCT_SOCKADDR_STORAGE -DHAVE_GETADDRINFO -DHAVE_GETNAMEINFO -DSTDC_HEADERS -DHAVE_STDLIB_H -DHAVE_WS2TCPIP_H -DWANT_OMNI -DWANT_DEMO -DWANT_HISTOGRAM -DWANT_INTERVALS 19 | 20 | #USER_C_FLAGS=$(USER_C_FLAGS) /E 21 | 22 | SOURCES= \ 23 | ..\netcpu_ntperf.c \ 24 | ..\netlib.c \ 25 | ..\netsh.c \ 26 | ..\nettest_bsd.c \ 27 | ..\nettest_omni.c \ 28 | ..\netsec_win.c \ 29 | ..\netdrv_none.c \ 30 | ..\netslot_none.c \ 31 | ..\netsys_none.c \ 32 | ..\netrt_none.c \ 33 | ..\net_uuid.c \ 34 | ..\netserver.c \ 35 | ..\dscp.c \ 36 | ..\inet_ntop.c 37 | 38 | -------------------------------------------------------------------------------- /src/dirs: -------------------------------------------------------------------------------- 1 | DIRS= \ 2 | NetPerfDir \ 3 | NetServerDir -------------------------------------------------------------------------------- /src/dscp.c: -------------------------------------------------------------------------------- 1 | /* dscp lookup routines lifted wholesale from openssh */ 2 | 3 | /* 4 | * Copyright (c) 2000 Markus Friedl. All rights reserved. 5 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if HAVE_CONFIG_H 29 | #include 30 | #endif 31 | 32 | #include 33 | #if HAVE_STRING_H 34 | #include 35 | #endif 36 | #if HAVE_STDLIB_H 37 | #include 38 | #endif 39 | 40 | #if HAVE_INTTYPES_H 41 | #include 42 | #endif 43 | 44 | #ifdef WIN32 45 | #define strcasecmp(a,b) _stricmp(a,b) 46 | #define snprintf _snprintf 47 | #endif 48 | 49 | int parse_ipqos(const char *cp); 50 | const char * iptos2str(int iptos); 51 | 52 | /* 53 | * Definitions for IP type of service (ip_tos) 54 | */ 55 | 56 | #if HAVE_NETINET_IN_SYSTM_H 57 | #include 58 | #endif 59 | #if HAVE_NETINET_IP_H 60 | #include 61 | #endif 62 | 63 | #ifndef IPTOS_LOWDELAY 64 | # define IPTOS_LOWDELAY 0x10 65 | # define IPTOS_THROUGHPUT 0x08 66 | # define IPTOS_RELIABILITY 0x04 67 | # define IPTOS_LOWCOST 0x02 68 | # define IPTOS_MINCOST IPTOS_LOWCOST 69 | #endif /* IPTOS_LOWDELAY */ 70 | 71 | /* 72 | * Definitions for DiffServ Codepoints as per RFC2474 73 | */ 74 | #ifndef IPTOS_DSCP_AF11 75 | # define IPTOS_DSCP_AF11 0x28 76 | # define IPTOS_DSCP_AF12 0x30 77 | # define IPTOS_DSCP_AF13 0x38 78 | # define IPTOS_DSCP_AF21 0x48 79 | # define IPTOS_DSCP_AF22 0x50 80 | # define IPTOS_DSCP_AF23 0x58 81 | # define IPTOS_DSCP_AF31 0x68 82 | # define IPTOS_DSCP_AF32 0x70 83 | # define IPTOS_DSCP_AF33 0x78 84 | # define IPTOS_DSCP_AF41 0x88 85 | # define IPTOS_DSCP_AF42 0x90 86 | # define IPTOS_DSCP_AF43 0x98 87 | # define IPTOS_DSCP_EF 0xb8 88 | #endif /* IPTOS_DSCP_AF11 */ 89 | 90 | #ifndef IPTOS_DSCP_CS0 91 | # define IPTOS_DSCP_CS0 0x00 92 | # define IPTOS_DSCP_CS1 0x20 93 | # define IPTOS_DSCP_CS2 0x40 94 | # define IPTOS_DSCP_CS3 0x60 95 | # define IPTOS_DSCP_CS4 0x80 96 | # define IPTOS_DSCP_CS5 0xa0 97 | # define IPTOS_DSCP_CS6 0xc0 98 | # define IPTOS_DSCP_CS7 0xe0 99 | #endif /* IPTOS_DSCP_CS0 */ 100 | #ifndef IPTOS_DSCP_EF 101 | # define IPTOS_DSCP_EF 0xb8 102 | #endif /* IPTOS_DSCP_EF */ 103 | 104 | static const struct { 105 | const char *name; 106 | int value; 107 | } ipqos[] = { 108 | { "af11", IPTOS_DSCP_AF11 }, 109 | { "af12", IPTOS_DSCP_AF12 }, 110 | { "af13", IPTOS_DSCP_AF13 }, 111 | { "af21", IPTOS_DSCP_AF21 }, 112 | { "af22", IPTOS_DSCP_AF22 }, 113 | { "af23", IPTOS_DSCP_AF23 }, 114 | { "af31", IPTOS_DSCP_AF31 }, 115 | { "af32", IPTOS_DSCP_AF32 }, 116 | { "af33", IPTOS_DSCP_AF33 }, 117 | { "af41", IPTOS_DSCP_AF41 }, 118 | { "af42", IPTOS_DSCP_AF42 }, 119 | { "af43", IPTOS_DSCP_AF43 }, 120 | { "cs0", IPTOS_DSCP_CS0 }, 121 | { "cs1", IPTOS_DSCP_CS1 }, 122 | { "cs2", IPTOS_DSCP_CS2 }, 123 | { "cs3", IPTOS_DSCP_CS3 }, 124 | { "cs4", IPTOS_DSCP_CS4 }, 125 | { "cs5", IPTOS_DSCP_CS5 }, 126 | { "cs6", IPTOS_DSCP_CS6 }, 127 | { "cs7", IPTOS_DSCP_CS7 }, 128 | { "ef", IPTOS_DSCP_EF }, 129 | { "lowdelay", IPTOS_LOWDELAY }, 130 | { "throughput", IPTOS_THROUGHPUT }, 131 | { "reliability", IPTOS_RELIABILITY }, 132 | { NULL, -1 } 133 | }; 134 | 135 | int 136 | parse_ipqos(const char *cp) 137 | { 138 | unsigned int i; 139 | char *ep = NULL; 140 | long val; 141 | 142 | if (cp == NULL) 143 | return -1; 144 | for (i = 0; ipqos[i].name != NULL; i++) { 145 | if (strcasecmp(cp, ipqos[i].name) == 0) 146 | return ipqos[i].value; 147 | } 148 | /* Try parsing as an integer */ 149 | val = strtol(cp, &ep, 0); 150 | if (*cp == '\0' || *ep != '\0' || val < 0 || val > 255) 151 | return -1; 152 | return val; 153 | } 154 | 155 | const char * 156 | iptos2str(int iptos) 157 | { 158 | int i; 159 | static char iptos_str[sizeof "0xff"]; 160 | if (iptos < 0 || iptos > 64) iptos = 0; 161 | for (i = 0; ipqos[i].name != NULL; i++) { 162 | if (ipqos[i].value == iptos) 163 | return ipqos[i].name; 164 | } 165 | snprintf(iptos_str, sizeof iptos_str, "0x%02x", iptos); 166 | return iptos_str; 167 | } 168 | -------------------------------------------------------------------------------- /src/hist.h: -------------------------------------------------------------------------------- 1 | #if TIME_WITH_SYS_TIME 2 | # include 3 | # include 4 | #else 5 | # if HAVE_SYS_TIME_H 6 | # include 7 | # else 8 | # include 9 | # endif 10 | #endif 11 | #ifdef WIN32 12 | # include "missing\stdint.h" 13 | #endif 14 | 15 | /* hist.h 16 | 17 | Given a time difference in microseconds, increment one of 61 18 | different buckets: 19 | 20 | 0 - 9 in increments of 1 usec 21 | 0 - 9 in increments of 10 usecs 22 | 0 - 9 in increments of 100 usecs 23 | 0 - 9 in increments of 1 msec 24 | 0 - 9 in increments of 10 msecs 25 | 0 - 9 in increments of 100 msecs 26 | 0 - 9 in increments of 1 sec 27 | 0 - 9 in increments of 10 sec 28 | > 100 secs 29 | 30 | This will allow any time to be recorded to within an accuracy of 31 | 10%, and provides a compact representation for capturing the 32 | distribution of a large number of time differences (e.g. 33 | request-response latencies). 34 | 35 | Colin Low 10/6/93 36 | Rick Jones 2004-06-15 - extend to 1 and 10 usec 37 | */ 38 | #ifndef _HIST_INCLUDED 39 | #define _HIST_INCLUDED 40 | 41 | #if defined(HAVE_GET_HRT) 42 | #include "hrt.h" 43 | #endif 44 | 45 | #ifndef HIST_NUM_OF_BUCKET 46 | #define HIST_NUM_OF_BUCKET 100 47 | #endif 48 | 49 | struct histogram_struct { 50 | int unit_usec[HIST_NUM_OF_BUCKET]; 51 | int ten_usec[HIST_NUM_OF_BUCKET]; 52 | int hundred_usec[HIST_NUM_OF_BUCKET]; 53 | int unit_msec[HIST_NUM_OF_BUCKET]; 54 | int ten_msec[HIST_NUM_OF_BUCKET]; 55 | int hundred_msec[HIST_NUM_OF_BUCKET]; 56 | int unit_sec[HIST_NUM_OF_BUCKET]; 57 | int ten_sec[HIST_NUM_OF_BUCKET]; 58 | int ridiculous; 59 | int total; 60 | int64_t sum; 61 | double sumsquare; 62 | int hmin; 63 | int hmax; 64 | int limit; 65 | int count; 66 | int producer; 67 | int consumer; 68 | #ifdef HAVE_GETHRTIME 69 | hrtime_t *time_ones; 70 | hrtime_t time_two; 71 | #elif HAVE_GET_HRT 72 | hrt_t *time_ones; 73 | hrt_t time_two; 74 | #elif defined(WIN32) 75 | LARGE_INTEGER *time_ones; 76 | LARGE_INTEGER time_two; 77 | #else 78 | struct timeval *time_ones; 79 | struct timeval time_two; 80 | #endif /* HAVE_GETHRTIME */ 81 | 82 | }; 83 | 84 | typedef struct histogram_struct *HIST; 85 | 86 | /* 87 | HIST_new - return a new, cleared histogram data type 88 | */ 89 | 90 | HIST HIST_new(void); 91 | 92 | /* 93 | HIST_new_n - return a new, cleard histogram data type able to track 94 | at least max_outstanding timestamps 95 | */ 96 | 97 | HIST HIST_new_n(int max_outstanding); 98 | 99 | /* 100 | HIST_clear - reset a histogram by clearing all totals to zero 101 | */ 102 | 103 | 104 | void HIST_clear(HIST h); 105 | 106 | /* 107 | HIST_purge - forget about any remaining outstanding timestamps 108 | being tracked 109 | */ 110 | 111 | void HIST_purge(HIST h); 112 | 113 | /* 114 | HIST_add - add a time difference to a histogram. Time should be in 115 | microseconds. 116 | */ 117 | 118 | void HIST_add(register HIST h, int time_delta); 119 | 120 | /* 121 | HIST_report - create an ASCII report on the contents of a histogram. 122 | Currently printsto standard out 123 | */ 124 | 125 | void HIST_report(HIST h); 126 | 127 | /* 128 | HIST_timestamp - take a timestamp suitable for use in a histogram. 129 | */ 130 | 131 | #ifdef HAVE_GETHRTIME 132 | void HIST_timestamp(hrtime_t *timestamp); 133 | #elif defined(HAVE_GET_HRT) 134 | void HIST_timestamp(hrt_t *timestamp); 135 | #elif defined(WIN32) 136 | void HIST_timestamp(LARGE_INTEGER *timestamp); 137 | #else 138 | void HIST_timestamp(struct timeval *timestamp); 139 | #endif 140 | 141 | /* 142 | HIST_timestamp_start - start a new timestamp 143 | */ 144 | 145 | void HIST_timestamp_start(HIST h); 146 | 147 | /* 148 | HIST_timestamp_stop_add - complete the oldest outstanding timestamp 149 | and add it to the histogram 150 | */ 151 | 152 | void HIST_timestamp_stop_add(HIST h); 153 | 154 | /* 155 | delta_micro - calculate the difference in microseconds between two 156 | timestamps 157 | */ 158 | #ifdef HAVE_GETHRTIME 159 | int delta_micro(hrtime_t *begin, hrtime_t *end); 160 | #elif defined(HAVE_GET_HRT) 161 | int delta_micro(hrt_t *begin, hrt_t *end); 162 | #elif defined(WIN32) 163 | int delta_micro(LARGE_INTEGER *begin, LARGE_INTEGER *end); 164 | #else 165 | int delta_micro(struct timeval *begin, struct timeval *end); 166 | #endif 167 | 168 | #endif 169 | 170 | -------------------------------------------------------------------------------- /src/missing/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = m4 2 | 3 | if NEED_LIBCOMPAT 4 | noinst_LIBRARIES = libcompat.a 5 | libcompat_a_SOURCES = getaddrinfo.h 6 | libcompat_a_LIBADD = $(LIBOBJS) $(ALLOCA) 7 | endif 8 | -------------------------------------------------------------------------------- /src/missing/getaddrinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, 02 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef GETADDRINFO_H 30 | #define GETADDRINFO_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | #include 37 | 38 | #ifdef WIN32 39 | #include 40 | #include 41 | #ifdef DO_IPV6 42 | #include 43 | #endif /* DO_IPV6 */ 44 | #include 45 | #else 46 | #include 47 | #include 48 | #endif 49 | 50 | 51 | /********************************************************************/ 52 | /* 53 | * Undefine all the macros. 54 | * might defines some of them. 55 | */ 56 | #ifdef EAI_ADDRFAMILY 57 | #undef EAI_ADDRFAMILY 58 | #endif 59 | #ifdef EAI_AGAIN 60 | #undef EAI_AGAIN 61 | #endif 62 | #ifdef EAI_BADFLAGS 63 | #undef EAI_BADFLAGS 64 | #endif 65 | #ifdef EAI_FAIL 66 | #undef EAI_FAIL 67 | #endif 68 | #ifdef EAI_FAMILY 69 | #undef EAI_FAMILY 70 | #endif 71 | #ifdef EAI_MEMORY 72 | #undef EAI_MEMORY 73 | #endif 74 | #ifdef EAI_NONAME 75 | #undef EAI_NONAME 76 | #endif 77 | #ifdef EAI_OVERFLOW 78 | #undef EAI_OVERFLOW 79 | #endif 80 | #ifdef EAI_SERVICE 81 | #undef EAI_SERVICE 82 | #endif 83 | #ifdef EAI_SOCKTYPE 84 | #undef EAI_SOCKTYPE 85 | #endif 86 | #ifdef EAI_SYSTEM 87 | #undef EAI_SYSTEM 88 | #endif 89 | 90 | #ifdef AI_PASSIVE 91 | #undef AI_PASSIVE 92 | #endif 93 | #ifdef AI_CANONNAME 94 | #undef AI_CANONNAME 95 | #endif 96 | #ifdef AI_NUMERICHOST 97 | #undef AI_NUMERICHOST 98 | #endif 99 | #ifdef AI_NUMERICSERV 100 | #undef AI_NUMERICSERV 101 | #endif 102 | #ifdef AI_V4MAPPED 103 | #undef AI_V4MAPPED 104 | #endif 105 | #ifdef AI_ALL 106 | #undef AI_ALL 107 | #endif 108 | #ifdef AI_ADDRCONFIG 109 | #undef AI_ADDRCONFIG 110 | #endif 111 | #ifdef AI_DEFAULT 112 | #undef AI_DEFAULT 113 | #endif 114 | 115 | #ifdef NI_NOFQDN 116 | #undef NI_NOFQDN 117 | #endif 118 | #ifdef NI_NUMERICHOST 119 | #undef NI_NUMERICHOST 120 | #endif 121 | #ifdef NI_NAMEREQD 122 | #undef NI_NAMEREQD 123 | #endif 124 | #ifdef NI_NUMERICSERV 125 | #undef NI_NUMERICSERV 126 | #endif 127 | #ifdef NI_NUMERICSCOPE 128 | #undef NI_NUMERICSCOPE 129 | #endif 130 | 131 | #ifdef NI_DGRAM 132 | #undef NI_DGRAM 133 | #endif 134 | #ifdef NI_MAXHOST 135 | #undef NI_MAXHOST 136 | #endif 137 | #ifdef NI_MAXSERV 138 | #undef NI_MAXSERV 139 | #endif 140 | 141 | /* 142 | * Fake struct and function names. 143 | * might declares all or some of them. 144 | */ 145 | #if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO) 146 | #define addrinfo my_addrinfo 147 | #define gai_strerror my_gai_strerror 148 | #define freeaddrinfo my_freeaddrinfo 149 | #define getaddrinfo my_getaddrinfo 150 | #define getnameinfo my_getnameinfo 151 | #endif 152 | 153 | /********************************************************************/ 154 | /* 155 | * Error codes. 156 | */ 157 | #define EAI_ADDRFAMILY 1 158 | #define EAI_AGAIN 2 159 | #define EAI_BADFLAGS 3 160 | #define EAI_FAIL 4 161 | #define EAI_FAMILY 5 162 | #define EAI_MEMORY 6 163 | #define EAI_NONAME 7 164 | #define EAI_OVERFLOW 8 165 | #define EAI_SERVICE 9 166 | #define EAI_SOCKTYPE 10 167 | #define EAI_SYSTEM 11 168 | 169 | /* 170 | * Flags for getaddrinfo(). 171 | */ 172 | #define AI_ADDRCONFIG 0x0001 173 | #define AI_ALL 0x0002 174 | #define AI_CANONNAME 0x0004 175 | #define AI_NUMERICHOST 0x0008 176 | #define AI_NUMERICSERV 0x0010 177 | #define AI_PASSIVE 0x0020 178 | #define AI_V4MAPPED 0x0040 179 | #define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG) 180 | 181 | /* 182 | * Flags for getnameinfo(). 183 | */ 184 | #define NI_DGRAM 0x0001 185 | #define NI_NAMEREQD 0x0002 186 | #define NI_NOFQDN 0x0004 187 | #define NI_NUMERICHOST 0x0008 188 | #define NI_NUMERICSCOPE 0x0010 189 | #define NI_NUMERICSERV 0x0020 190 | 191 | /* 192 | * Maximum length of FQDN and servie name for getnameinfo(). 193 | */ 194 | #define NI_MAXHOST 1025 195 | #define NI_MAXSERV 32 196 | 197 | /* 198 | * Address families and Protocol families. 199 | */ 200 | #ifndef AF_UNSPEC 201 | #define AF_UNSPEC AF_INET 202 | #endif 203 | #ifndef PF_UNSPEC 204 | #define PF_UNSPEC PF_INET 205 | #endif 206 | 207 | /* 208 | * struct addrinfo. 209 | */ 210 | struct addrinfo { 211 | int ai_flags; 212 | int ai_family; 213 | int ai_socktype; 214 | int ai_protocol; 215 | socklen_t ai_addrlen; 216 | char *ai_canonname; 217 | struct sockaddr *ai_addr; 218 | struct addrinfo *ai_next; 219 | }; 220 | 221 | /* 222 | * Functions. 223 | */ 224 | #ifdef __STDC__ 225 | const char *gai_strerror(int); 226 | void freeaddrinfo(struct addrinfo *); 227 | int getaddrinfo(const char *, const char *, const struct addrinfo *, 228 | struct addrinfo **); 229 | int getnameinfo(const struct sockaddr *, socklen_t, char *, 230 | socklen_t, char *, socklen_t, int); 231 | #else 232 | const char *gai_strerror(); 233 | void freeaddrinfo(); 234 | int getaddrinfo(); 235 | int getnameinfo(); 236 | #endif 237 | 238 | #endif /* not GETADDRINFO_H */ 239 | -------------------------------------------------------------------------------- /src/missing/inet_ntop.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/multipath-tcp/netperf/1f639fa7e242b81a667c547c78adfb3f8fff3d30/src/missing/inet_ntop.c -------------------------------------------------------------------------------- /src/missing/m4/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = *.m4 2 | -------------------------------------------------------------------------------- /src/missing/m4/herrno.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for h_errno. 31 | dnl * 32 | AC_DEFUN([AC_DECL_H_ERRNO], 33 | [AC_CACHE_CHECK(for h_errno declaration in netdb.h, ac_cv_decl_h_errno, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include ]], [[ 36 | h_errno = 0; 37 | ]])],[ac_cv_decl_h_errno=yes],[ac_cv_decl_h_errno=no])]) 38 | if test "$ac_cv_decl_h_errno" = yes; then 39 | AC_DEFINE(H_ERRNO_DECLARED, 1, 40 | [Define to 1 if `h_errno' is declared by ]) 41 | fi]) 42 | -------------------------------------------------------------------------------- /src/missing/m4/in6addr.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for struct in6_addr 31 | dnl * 32 | AC_DEFUN([AC_STRUCT_IN6_ADDR], 33 | [AC_CACHE_CHECK(for struct in6_addr, ac_cv_struct_in6_addr, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include 36 | #include 37 | #include ]], [[ 38 | struct in6_addr address; 39 | ]])],[ac_cv_struct_in6_addr=yes],[ac_cv_struct_in6_addr=no])]) 40 | if test "$ac_cv_struct_in6_addr" = yes; then 41 | AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, 42 | [Define to 1 if defines `struct in6_addr']) 43 | fi]) 44 | 45 | dnl * 46 | dnl * Check for in6addr_any. 47 | dnl * 48 | AC_DEFUN([AC_DECL_IN6ADDR_ANY], 49 | [AC_REQUIRE([AC_STRUCT_IN6_ADDR]) 50 | if test $ac_cv_struct_in6_addr = no; then 51 | ac_cv_decl_in6addr_any=no 52 | else 53 | AC_CACHE_CHECK(for in6addr_any declaration in netinet/in.h, 54 | ac_cv_decl_in6addr_any, 55 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 56 | #include 57 | #include 58 | #include ]], [[ 59 | unsigned char *address; 60 | address = (char *)&in6addr_any; 61 | ]])],[ac_cv_decl_in6addr_any=yes],[ac_cv_decl_in6addr_any=no])]) 62 | if test "$ac_cv_decl_in6addr_any" = yes; then 63 | AC_DEFINE(IN6ADDR_ANY_DECLARED, 1, 64 | [Define to 1 if `in6addr_any' is declared by ]) 65 | fi 66 | fi]) 67 | 68 | dnl * 69 | dnl * Check for in6addr_loopback. 70 | dnl * 71 | AC_DEFUN([AC_DECL_IN6ADDR_LOOPBACK], 72 | [AC_REQUIRE([AC_STRUCT_IN6_ADDR]) 73 | if test $ac_cv_struct_in6_addr = no; then 74 | ac_cv_decl_in6addr_loopback=no 75 | else 76 | AC_CACHE_CHECK(for in6addr_loopback declaration in netinet/in.h, 77 | ac_cv_decl_in6addr_loopback, 78 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 79 | #include 80 | #include 81 | #include ]], [[ 82 | unsigned char *address; 83 | address = (char *)&in6addr_loopback; 84 | ]])],[ac_cv_decl_in6addr_loopback=yes],[ac_cv_decl_in6addr_loopback=no])]) 85 | if test "$ac_cv_decl_in6addr_loopback" = yes; then 86 | AC_DEFINE(IN6ADDR_LOOPBACK_DECLARED, 1, 87 | [Define to 1 if `in6addr_loopback' is declared by ]) 88 | fi 89 | fi]) 90 | -------------------------------------------------------------------------------- /src/missing/m4/salen.m4: -------------------------------------------------------------------------------- 1 | dnl Copyright (c) 1995, 1996, 1997, 1998 2 | dnl tising materials mentioning 3 | dnl dnl features or use of this software display the following acknowledgement: 4 | dnl dnl ``This product includes software developed by the University of California, 5 | dnl dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 6 | dnl dnl the University nor the names of its contributors may be used to endorse 7 | dnl dnl or promote products derived from this software without specific prior 8 | dnl dnl written permission. 9 | dnl dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 10 | dnl dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 11 | dnl dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 | dnl dnl 13 | dnl dnl LBL autoconf macros 14 | dnl dnl 15 | dnl 16 | dnl 17 | dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member 18 | dnl borrowed from LBL libpcap 19 | AC_DEFUN([AC_CHECK_SA_LEN], [ 20 | AC_MSG_CHECKING(if sockaddr struct has sa_len member) 21 | AC_CACHE_VAL($1, 22 | AC_TRY_COMPILE([ 23 | # include 24 | # include ], 25 | [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], 26 | $1=yes, 27 | $1=no)) 28 | AC_MSG_RESULT($$1) 29 | if test $$1 = yes ; then 30 | AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[Define if struct sockaddr has the sa_len member]) 31 | fi 32 | ]) 33 | -------------------------------------------------------------------------------- /src/missing/m4/sockaddrin6.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for struct sockaddr_in6 31 | dnl * 32 | AC_DEFUN([AC_STRUCT_SOCKADDR_IN6], 33 | [AC_CACHE_CHECK(for struct sockaddr_in6, ac_cv_struct_sockaddr_in6, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include 36 | #include 37 | #include ]], [[ 38 | struct sockaddr_in6 address; 39 | ]])],[ac_cv_struct_sockaddr_in6=yes],[ac_cv_struct_sockaddr_in6=no])]) 40 | if test "$ac_cv_struct_sockaddr_in6" = yes; then 41 | AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, 42 | [Define to 1 if defines `struct sockaddr_in6']) 43 | fi]) 44 | 45 | dnl * 46 | dnl * Check for struct sockaddr_storage 47 | dnl * 48 | AC_DEFUN([AC_STRUCT_SOCKADDR_STORAGE], 49 | [AC_CACHE_CHECK(for struct sockaddr_storage, ac_cv_struct_sockaddr_storage, 50 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 51 | #include 52 | #include 53 | #include ]], [[ 54 | struct sockaddr_storage address; 55 | ]])],[ac_cv_struct_sockaddr_storage=yes],[ac_cv_struct_sockaddr_storage=no])]) 56 | if test "$ac_cv_struct_sockaddr_storage" = yes; then 57 | AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, 58 | [Define to 1 if defines `struct sockaddr_storage']) 59 | fi]) 60 | 61 | -------------------------------------------------------------------------------- /src/missing/m4/sockinttypes.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001, 2003 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for socklen_t. 31 | dnl * 32 | AC_DEFUN([AC_TYPE_SOCKLEN_T], 33 | [AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include 36 | #include ]], [[ 37 | socklen_t socklen; 38 | ]])],[ac_cv_type_socklen_t=yes],[ac_cv_type_socklen_t=no])]) 39 | if test "$ac_cv_type_socklen_t" != yes; then 40 | AC_DEFINE(socklen_t, int, 41 | [Define to `int' if or does not define.]) 42 | fi]) 43 | 44 | dnl * 45 | dnl * Check for in_port_t. 46 | dnl * 47 | AC_DEFUN([AC_TYPE_IN_PORT_T], 48 | [AC_CACHE_CHECK([for in_port_t], ac_cv_type_in_port_t, 49 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 50 | #include 51 | #include 52 | #include ]], [[ 53 | in_port_t in_port; 54 | ]])],[ac_cv_type_in_port_t=yes],[ac_cv_type_in_port_t=no])]) 55 | if test "$ac_cv_type_in_port_t" != yes; then 56 | ac_cv_sin_port_size=unknown 57 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 58 | #include 59 | #include 60 | #include 61 | int main() { 62 | struct sockaddr_in addr; 63 | return (sizeof(addr.sin_port) == sizeof(long)) ? 0 : 1; 64 | } 65 | ]])],[ac_cv_sin_port_size=long],[],[]) 66 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 67 | #include 68 | #include 69 | #include 70 | int main() { 71 | struct sockaddr_in addr; 72 | return (sizeof(addr.sin_port) == sizeof(int)) ? 0 : 1; 73 | } 74 | ]])],[ac_cv_sin_port_size=int],[],[]) 75 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 76 | #include 77 | #include 78 | #include 79 | int main() { 80 | struct sockaddr_in addr; 81 | return (sizeof(addr.sin_port) == sizeof(short)) ? 0 : 1; 82 | } 83 | ]])],[ac_cv_sin_port_size=short],[],[]) 84 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 85 | #include 86 | #include 87 | #include 88 | int main() { 89 | struct sockaddr_in addr; 90 | return (sizeof(addr.sin_port) == sizeof(char)) ? 0 : 1; 91 | } 92 | ]])],[ac_cv_sin_port_size=char],[],[]) 93 | if test "$ac_cv_sin_port_size" = unknown; then 94 | AC_MSG_ERROR([Failed to get size of sin_port in struct sockaddr_in.]) 95 | fi 96 | AC_DEFINE_UNQUOTED(in_port_t, unsigned $ac_cv_sin_port_size, 97 | [Define to `unsigned char', `unsigned short', `unsigned int' or 98 | `unsigned long' according with size of `sin_port' in `struct sockaddr_in', 99 | if , or does not define 100 | `in_port_t'.]) 101 | fi]) 102 | 103 | dnl * 104 | dnl * Check for sa_family_t. 105 | dnl * 106 | AC_DEFUN([AC_TYPE_SA_FAMILY_T], 107 | [AC_CACHE_CHECK([for sa_family_t], ac_cv_type_sa_family_t, 108 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 109 | #include 110 | #include ]], [[ 111 | sa_family_t sa_family; 112 | ]])],[ac_cv_type_sa_family_t=yes],[ac_cv_type_sa_family_t=no])]) 113 | if test "$ac_cv_type_sa_family_t" != yes; then 114 | ac_cv_sa_family_size=unknown 115 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 116 | #include 117 | #include 118 | int main() { 119 | struct sockaddr addr; 120 | return (sizeof(addr.sa_family) == sizeof(long)) ? 0 : 1; 121 | } 122 | ]])],[ac_cv_sa_family_size=long],[],[]) 123 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 124 | #include 125 | #include 126 | int main() { 127 | struct sockaddr addr; 128 | return (sizeof(addr.sa_family) == sizeof(int)) ? 0 : 1; 129 | } 130 | ]])],[ac_cv_sa_family_size=int],[],[]) 131 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 132 | #include 133 | #include 134 | int main() { 135 | struct sockaddr addr; 136 | return (sizeof(addr.sa_family) == sizeof(short)) ? 0 : 1; 137 | } 138 | ]])],[ac_cv_sa_family_size=short],[],[]) 139 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 140 | #include 141 | #include 142 | int main() { 143 | struct sockaddr addr; 144 | return (sizeof(addr.sa_family) == sizeof(char)) ? 0 : 1; 145 | } 146 | ]])],[ac_cv_sa_family_size=char],[],[]) 147 | if test "$ac_cv_sa_family_size" = unknown; then 148 | AC_MSG_ERROR([Failed to get size of sa_family in struct sockaddr.]) 149 | fi 150 | AC_DEFINE_UNQUOTED(sa_family_t, unsigned $ac_cv_sa_family_size, 151 | [Define to `unsigned char', `unsigned short', `unsigned int' or 152 | `unsigned long' according with size of `sa_family' in `struct sockaddr', 153 | if or does not define `sa_family_t'.]) 154 | fi]) 155 | -------------------------------------------------------------------------------- /src/missing/m4/socklent.m4: -------------------------------------------------------------------------------- 1 | dnl This comes from libcurl's acinclude.m4. it is not clear if this 2 | dnl is original libcurl code, or other code, so we include the libcurl 3 | dnl copyright here 4 | dnl 5 | dnl 6 | dnl Copyright (c) 1996 - 2005, Daniel Stenberg, . 7 | dnl 8 | dnl All rights reserved. 9 | dnl 10 | dnl Permission to use, copy, modify, and distribute this software for any purpose 11 | dnl with or without fee is hereby granted, provided that the above copyright 12 | dnl notice and this permission notice appear in all copies. 13 | dnl 14 | dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN 17 | dnl NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | dnl OR OTHER DEALINGS IN THE SOFTWARE. 21 | dnl 22 | dnl Except as contained in this notice, the name of a copyright holder shall not 23 | dnl be used in advertising or otherwise to promote the sale, use or other dealings 24 | dnl in this Software without prior written authorization of the copyright holder. 25 | 26 | dnl Check for socklen_t: historically on BSD it is an int, and in 27 | dnl POSIX 1g it is a type of its own, but some platforms use different 28 | dnl types for the argument to getsockopt, getpeername, etc. So we 29 | dnl have to test to find something that will work. 30 | 31 | dnl Remove the AC_CHECK_TYPE - on HP-UX it would find a socklen_t, but the 32 | dnl function prototypes for getsockopt et al will not actually use 33 | dnl socklen_t args unless _XOPEN_SOURCE_EXTENDED is defined. so, the 34 | dnl AC_CHECK_TYPE will find a socklen_t and think all is happiness and 35 | dnl joy when you will really get warnings about mismatch types - type 36 | dnl mismatches that would be possibly Bad (tm) in a 64-bit compile. 37 | dnl raj 2005-05-11 this change may be redistributed at will 38 | 39 | dnl also, added "extern" to the "int getpeername" in an attempt to resolve 40 | dnl an issue with this code under Solaris 2.9. this too may be 41 | dnl redistributed at will 42 | 43 | AC_DEFUN([OLD_TYPE_SOCKLEN_T], 44 | [ 45 | AC_MSG_CHECKING([for socklen_t equivalent]) 46 | AC_CACHE_VAL([curl_cv_socklen_t_equiv], 47 | [ 48 | # Systems have either "struct sockaddr *" or 49 | # "void *" as the second argument to getpeername 50 | curl_cv_socklen_t_equiv= 51 | for arg2 in "struct sockaddr" void; do 52 | for t in int size_t unsigned long "unsigned long" socklen_t; do 53 | AC_TRY_COMPILE([ 54 | #ifdef HAVE_SYS_TYPES_H 55 | #include 56 | #endif 57 | #ifdef HAVE_SYS_SOCKET_H 58 | #include 59 | #endif 60 | 61 | extern int getpeername (int, $arg2 *, $t *); 62 | ],[ 63 | $t len; 64 | getpeername(0,0,&len); 65 | ],[ 66 | curl_cv_socklen_t_equiv="$t" 67 | break 68 | ]) 69 | done 70 | done 71 | 72 | if test "x$curl_cv_socklen_t_equiv" = x; then 73 | # take a wild guess 74 | curl_cv_socklen_t_equiv="socklen_t" 75 | AC_MSG_WARN([Cannot find a type to use in place of socklen_t, guessing socklen_t]) 76 | fi 77 | ]) 78 | AC_MSG_RESULT($curl_cv_socklen_t_equiv) 79 | AC_DEFINE_UNQUOTED(netperf_socklen_t, $curl_cv_socklen_t_equiv, 80 | [type to use in place of socklen_t if not defined]) 81 | ]) 82 | -------------------------------------------------------------------------------- /src/missing/m4/type_socklen_t.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis TYPE_SOCKLEN_T 2 | dnl 3 | dnl Check whether sys/socket.h defines type socklen_t. Please note that 4 | dnl some systems require sys/types.h to be included before sys/socket.h 5 | dnl can be compiled. 6 | dnl 7 | dnl @category Misc 8 | dnl @author Lars Brinkhoff 9 | dnl @version 2005-01-11 10 | dnl @license GPLWithACException 11 | 12 | AC_DEFUN([TYPE_SOCKLEN_T], 13 | [AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t, 14 | [ 15 | AC_TRY_COMPILE( 16 | [#include 17 | #include ], 18 | [socklen_t len = 42; return 0;], 19 | ac_cv_type_socklen_t=yes, 20 | ac_cv_type_socklen_t=no) 21 | ]) 22 | if test $ac_cv_type_socklen_t != yes; then 23 | AC_DEFINE(socklen_t, int, [Substitute for socklen_t]) 24 | fi 25 | ]) 26 | -------------------------------------------------------------------------------- /src/netcpu.h: -------------------------------------------------------------------------------- 1 | /* This should define all the common routines etc exported by the 2 | various netcpu_mumble.c files raj 2005-01-26 */ 3 | 4 | extern void cpu_util_init(void); 5 | extern void cpu_util_terminate(void); 6 | extern int get_cpu_method(); 7 | 8 | #ifdef WIN32 9 | /* +*+ temp until I figure out what header this is in; I know it's 10 | there someplace... */ 11 | typedef unsigned __int64 uint64_t; 12 | #endif 13 | 14 | extern void get_cpu_idle(uint64_t *res); 15 | extern float calibrate_idle_rate(int iterations, int interval); 16 | extern float calc_cpu_util_internal(float elapsed); 17 | extern void cpu_start_internal(void); 18 | extern void cpu_stop_internal(void); 19 | 20 | -------------------------------------------------------------------------------- /src/netcpu_none.c: -------------------------------------------------------------------------------- 1 | char netcpu_none_id[]="\ 2 | @(#)netcpu_none.c (c) Copyright 2005-2012 Hewlett-Packard Company, Version 2.6.0"; 3 | 4 | #if HAVE_CONFIG_H 5 | # include 6 | #endif 7 | 8 | #include 9 | 10 | #if HAVE_INTTYPES_H 11 | # include 12 | #else 13 | # if HAVE_STDINT_H 14 | # include 15 | # endif 16 | #endif 17 | 18 | #include "netsh.h" 19 | #include "netlib.h" 20 | 21 | void 22 | cpu_util_init(void) 23 | { 24 | return; 25 | } 26 | 27 | void 28 | cpu_util_terminate(void) 29 | { 30 | return; 31 | } 32 | 33 | int 34 | get_cpu_method(void) 35 | { 36 | return CPU_UNKNOWN; 37 | } 38 | 39 | void 40 | get_cpu_idle(uint64_t *res) 41 | { 42 | return; 43 | } 44 | 45 | float 46 | calibrate_idle_rate(int iterations, int interval) 47 | { 48 | return 0.0; 49 | } 50 | 51 | float 52 | calc_cpu_util_internal(float elapsed_time) 53 | { 54 | return -1.0; 55 | } 56 | 57 | void 58 | cpu_start_internal(void) 59 | { 60 | return; 61 | } 62 | 63 | void 64 | cpu_stop_internal(void) 65 | { 66 | return; 67 | } 68 | -------------------------------------------------------------------------------- /src/netcpu_osx.c: -------------------------------------------------------------------------------- 1 | char netcpu_sysctl_id[]="\ 2 | @(#)netcpu_osx.c Version 2.6.0"; 3 | 4 | #if HAVE_CONFIG_H 5 | # include 6 | #endif 7 | 8 | #include 9 | 10 | #if HAVE_INTTYPES_H 11 | # include 12 | #else 13 | # if HAVE_STDINT_H 14 | # include 15 | # endif 16 | #endif 17 | 18 | #if TIME_WITH_SYS_TIME 19 | # include 20 | # include 21 | #else 22 | # if HAVE_SYS_TIME_H 23 | # include 24 | # else 25 | # include 26 | # endif 27 | #endif 28 | #if HAVE_LIMITS_H 29 | # include 30 | # ifndef LONG_LONG_MAX 31 | # define LONG_LONG_MAX LLONG_MAX 32 | # endif /* LONG_LONG_MAX */ 33 | #endif 34 | 35 | 36 | #include 37 | 38 | #include 39 | #include 40 | /* it would seem that on 10.3.9 mach_msg_type_number_t is in 41 | so we'll see about including that one too. 42 | hopefully it still exists in 10.4. if not, we will need to add some 43 | .h file checks in configure so we can use "HAVE_mumble" ifdefs 44 | here */ 45 | #include 46 | 47 | /* some of this is to make Tiger (10.4), Leopard (10.5) and 48 | SnowLeopard (10.6) happy, we hope it does not anger previous 49 | versions */ 50 | #include 51 | /* #include */ 52 | 53 | #include "netsh.h" 54 | #include "netlib.h" 55 | 56 | #define UNSIGNED_DIFFERENCE(x,y) (x >= y ? x - y : (0 - y) + x ) 57 | 58 | static host_cpu_load_info_data_t lib_start_ticks; 59 | static host_cpu_load_info_data_t lib_end_ticks; 60 | 61 | static mach_port_t lib_host_port; 62 | 63 | void 64 | cpu_util_init(void) 65 | { 66 | lib_host_port = mach_host_self(); 67 | return; 68 | } 69 | 70 | void 71 | cpu_util_terminate(void) 72 | { 73 | mach_port_deallocate(lib_host_port); 74 | return; 75 | } 76 | 77 | int 78 | get_cpu_method(void) 79 | { 80 | return OSX; 81 | } 82 | 83 | void 84 | get_cpu_idle(uint64_t *res) 85 | { 86 | return; 87 | } 88 | 89 | void 90 | get_host_ticks(host_cpu_load_info_t info) 91 | { 92 | mach_msg_type_number_t count; 93 | 94 | count = HOST_CPU_LOAD_INFO_COUNT; 95 | host_statistics(lib_host_port, HOST_CPU_LOAD_INFO, (host_info_t)info, &count); 96 | return; 97 | } 98 | 99 | /* calibrate_sysctl - perform the idle rate calculation using the 100 | sysctl call - typically on BSD */ 101 | 102 | float 103 | calibrate_idle_rate(int iterations, int interval) 104 | { 105 | return (float)0.0; 106 | } 107 | 108 | float 109 | calc_cpu_util_internal(float elapsed_time) 110 | { 111 | float correction_factor; 112 | natural_t userticks, systicks, idleticks, totalticks; 113 | 114 | lib_local_cpu_util = (float)0.0; 115 | /* It is possible that the library measured a time other than the 116 | one that the user want for the cpu utilization calculations - for 117 | example, tests that were ended by watchdog timers such as the udp 118 | stream test. We let these tests tell up what the elapsed time 119 | should be. */ 120 | 121 | if (elapsed_time != 0.0) { 122 | correction_factor = (float) 1.0 + 123 | ((lib_elapsed - elapsed_time) / elapsed_time); 124 | } 125 | else { 126 | correction_factor = (float) 1.0; 127 | } 128 | 129 | if (debug) { 130 | fprintf(where, "correction factor: %f\n", correction_factor); 131 | } 132 | 133 | userticks = UNSIGNED_DIFFERENCE((lib_end_ticks.cpu_ticks[CPU_STATE_USER] + lib_end_ticks.cpu_ticks[CPU_STATE_NICE]), 134 | (lib_start_ticks.cpu_ticks[CPU_STATE_USER] + lib_start_ticks.cpu_ticks[CPU_STATE_NICE])); 135 | systicks = UNSIGNED_DIFFERENCE(lib_end_ticks.cpu_ticks[CPU_STATE_SYSTEM], lib_start_ticks.cpu_ticks[CPU_STATE_SYSTEM]); 136 | idleticks = UNSIGNED_DIFFERENCE(lib_end_ticks.cpu_ticks[CPU_STATE_IDLE], lib_start_ticks.cpu_ticks[CPU_STATE_IDLE]); 137 | totalticks = userticks + systicks + idleticks; 138 | 139 | lib_local_cpu_util = ((float)userticks + (float)systicks)/(float)totalticks * 100.0f; 140 | lib_local_cpu_util *= correction_factor; 141 | 142 | return lib_local_cpu_util; 143 | 144 | } 145 | void 146 | cpu_start_internal(void) 147 | { 148 | get_host_ticks(&lib_start_ticks); 149 | } 150 | 151 | void 152 | cpu_stop_internal(void) 153 | { 154 | get_host_ticks(&lib_end_ticks); 155 | } 156 | -------------------------------------------------------------------------------- /src/netcpu_sysctl.c: -------------------------------------------------------------------------------- 1 | char netcpu_sysctl_id[]="\ 2 | @(#)netcpu_sysctl.c Version 2.6.0"; 3 | 4 | #if HAVE_CONFIG_H 5 | # include 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #if HAVE_INTTYPES_H 12 | # include 13 | #else 14 | # if HAVE_STDINT_H 15 | # include 16 | # endif 17 | #endif 18 | 19 | #if TIME_WITH_SYS_TIME 20 | # include 21 | # include 22 | #else 23 | # if HAVE_SYS_TIME_H 24 | # include 25 | # else 26 | # include 27 | # endif 28 | #endif 29 | #if HAVE_LIMITS_H 30 | # include 31 | # ifndef LONG_LONG_MAX 32 | # define LONG_LONG_MAX LLONG_MAX 33 | # endif /* LONG_LONG_MAX */ 34 | #endif 35 | 36 | #ifdef __NetBSD__ 37 | #define CP_TIME_TYPE uint64_t 38 | #else 39 | #define CP_TIME_TYPE long 40 | #endif 41 | 42 | #include 43 | 44 | /* need to have some sort of check for sys/sysctl.h versus sysctl.h */ 45 | #include 46 | 47 | 48 | /* this has been liberally cut and pasted from on 49 | FreeBSD. in general, this would be a bad idea, but I don't want to 50 | have to do a _KERNEL define to get these and that is what 51 | sys/resource.h seems to want. raj 2002-03-03 */ 52 | #define CP_USER 0 53 | #define CP_NICE 1 54 | #define CP_SYS 2 55 | #define CP_INTR 3 56 | #define CP_IDLE 4 57 | #define CPUSTATES 5 58 | 59 | 60 | #include "netsh.h" 61 | #include "netlib.h" 62 | 63 | static CP_TIME_TYPE lib_start_count[CPUSTATES]; 64 | static CP_TIME_TYPE lib_end_count[CPUSTATES]; 65 | 66 | void 67 | cpu_util_init(void) 68 | { 69 | return; 70 | } 71 | 72 | void 73 | cpu_util_terminate(void) 74 | { 75 | return; 76 | } 77 | 78 | int 79 | get_cpu_method(void) 80 | { 81 | return SYSCTL; 82 | } 83 | 84 | static void 85 | get_cpu_time(CP_TIME_TYPE *cpu_time) 86 | { 87 | size_t cpu_time_len = CPUSTATES * sizeof (cpu_time[0]); 88 | 89 | if (sysctlbyname("kern.cp_time", cpu_time, &cpu_time_len, NULL, 0) == -1) { 90 | fprintf (stderr, "Cannot get CPU time!\n"); 91 | exit (1); 92 | } 93 | } 94 | 95 | /* calibrate_sysctl - perform the idle rate calculation using the 96 | sysctl call - typically on BSD */ 97 | 98 | float 99 | calibrate_idle_rate(int iterations, int interval) 100 | { 101 | return sysconf (_SC_CLK_TCK); 102 | } 103 | 104 | float 105 | calc_cpu_util_internal(float elapsed_time) 106 | { 107 | CP_TIME_TYPE sum_idle, sum_busy; 108 | int i; 109 | 110 | for (sum_busy = 0, i = 0; i < CPUSTATES; i++) { 111 | if (i != CP_IDLE) 112 | sum_busy += lib_end_count[i] - lib_start_count[i]; 113 | } 114 | 115 | sum_idle = lib_end_count[CP_IDLE] - lib_start_count[CP_IDLE]; 116 | lib_local_cpu_util = (float)sum_busy / (float)(sum_busy + sum_idle); 117 | lib_local_cpu_util *= 100.0; 118 | 119 | return lib_local_cpu_util; 120 | 121 | } 122 | void 123 | cpu_start_internal(void) 124 | { 125 | get_cpu_time(lib_start_count); 126 | } 127 | 128 | void 129 | cpu_stop_internal(void) 130 | { 131 | get_cpu_time(lib_end_count); 132 | } 133 | -------------------------------------------------------------------------------- /src/netdrv_ethtool.c: -------------------------------------------------------------------------------- 1 | #if defined(HAVE_CONFIG_H) 2 | #include 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | /* alas, direct inclusion of ethtool.h depends on some types not 17 | normally found in nature, which we must provide or things will be 18 | quite unhappy. newer ethtool.h include files will it seems be happy 19 | with our including linux/types.h which will give us __umumble */ 20 | 21 | #include 22 | 23 | /* older ethtool.h includes want them without the leading underscores */ 24 | typedef unsigned long long u64; 25 | typedef unsigned int u32; 26 | typedef unsigned short u16; 27 | typedef unsigned char u8; 28 | 29 | /* ostensibly at this point we should be covered for any ethtool.h? */ 30 | #include 31 | 32 | void 33 | find_driver_info(char *ifname, char *driver, char *version, char *firmware, char *bus, int len) { 34 | 35 | int s; 36 | int ret; 37 | struct ifreq ifr; 38 | struct ethtool_drvinfo drvinfo; 39 | 40 | if (len < 32) return; 41 | 42 | if (!strcmp(ifname,"lo")) { 43 | /* special case loopback */ 44 | strncpy(driver,"loopback",len); 45 | strncpy(version,"system",len); 46 | strncpy(firmware,"N/A",len); 47 | strncpy(bus,"N/A",len); 48 | driver[len-1] = 0; 49 | version[len-1] = 0; 50 | firmware[len-1] = 0; 51 | bus[len-1] = 0; 52 | return; 53 | } 54 | 55 | s = socket(AF_INET,SOCK_DGRAM,0); 56 | 57 | if (s < 0) { 58 | strncpy(driver,"SocketFailure",len); 59 | strncpy(version,"SocketFailure",len); 60 | strncpy(firmware,"SocketFailure",len); 61 | strncpy(bus,"SocketFailure",len); 62 | driver[len-1] = 0; 63 | version[len-1] = 0; 64 | firmware[len-1] = 0; 65 | bus[len-1] = 0; 66 | return; 67 | } 68 | 69 | memset(&ifr, 0, sizeof(ifr)); 70 | drvinfo.cmd = ETHTOOL_GDRVINFO; 71 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)-1); 72 | ifr.ifr_data = (caddr_t)&drvinfo; 73 | 74 | ret = ioctl(s, SIOCETHTOOL, &ifr); 75 | 76 | if (ret == -1) { 77 | strncpy(driver,"IoctlFailure",len); 78 | strncpy(version,"IoctlFailure",len); 79 | strncpy(firmware,"IoctlFailure",len); 80 | strncpy(bus,"IoctlFailure",len); 81 | driver[len-1] = 0; 82 | version[len-1] = 0; 83 | firmware[len-1] = 0; 84 | bus[len-1] = 0; 85 | close(s); 86 | return; 87 | } 88 | strncpy(driver,drvinfo.driver,len); 89 | strncpy(version,drvinfo.version,len); 90 | strncpy(firmware,drvinfo.fw_version,len); 91 | strncpy(bus,drvinfo.bus_info,len); 92 | driver[len-1] = 0; 93 | version[len-1] = 0; 94 | firmware[len-1] = 0; 95 | bus[len-1] = 0; 96 | 97 | close(s); 98 | 99 | return; 100 | } 101 | 102 | #if defined(NETPERF_STANDALONE_DEBUG) 103 | int 104 | main(int argc, char *argv[]) { 105 | 106 | char driver[32]; 107 | char version[32]; 108 | char firmware[32]; 109 | char businfo[32]; 110 | 111 | if (argc != 2) { 112 | fprintf(stderr,"%s \n",argv[0]); 113 | return -1; 114 | } 115 | p 116 | find_driver_info(argv[1],driver, version, firmware, businfo, 32); 117 | 118 | printf("For %s driver %s version %s firmware %s businfo %s\n", 119 | argv[1],driver, version, firmware, businfo); 120 | 121 | return 0; 122 | } 123 | #endif 124 | -------------------------------------------------------------------------------- /src/netdrv_none.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void 4 | find_driver_info(char *ifname, char *driver, char *version, char *firmware, char *bus, int len) { 5 | 6 | strncpy(driver,"Unavailable",len); 7 | strncpy(version,"Unavailable",len); 8 | strncpy(firmware,"Unavailable",len); 9 | strncpy(bus,"Unavailable",len); 10 | driver[len-1] = 0; 11 | version[len-1] = 0; 12 | firmware[len-1] = 0; 13 | bus[len-1] = 0; 14 | return; 15 | } 16 | -------------------------------------------------------------------------------- /src/netdrv_solaris.c: -------------------------------------------------------------------------------- 1 | #if defined(HAVE_CONFIG_H) 2 | #include 3 | #endif 4 | 5 | #include 6 | #include 7 | 8 | #if defined(NETPERF_STANDALONE_DEBUG) 9 | #include 10 | #include 11 | #endif 12 | 13 | void 14 | find_driver_info(char *ifname, char *driver, char *version, char *firmware, char *bus, int len) { 15 | 16 | /* until something better comes along, we will use the expedient 17 | that the interface name, up to but not including the instance 18 | number is the driver name. raj 2008-03-19 */ 19 | int i; 20 | 21 | strncpy(driver,ifname,len); 22 | driver[len-1] = 0; 23 | 24 | /* work backwards nuking numbers and punctuation */ 25 | for (i = strlen(driver) - 1; ((isdigit(driver[i])) || 26 | (ispunct(driver[i]))) && (i >= 0); i--) { 27 | driver[i] = 0; 28 | } 29 | 30 | /* on the off chance we managed to toast the entire string, we 31 | should probably mention that somehow. raj 2008-03-19 */ 32 | if (strlen(driver) == 0) 33 | strncpy(driver,"NoAlpha",len); 34 | 35 | strncpy(version,"Unavailable",len); 36 | strncpy(firmware,"Unavailable",len); 37 | strncpy(bus,"Unavailable",len); 38 | version[len-1] = 0; 39 | firmware[len-1] = 0; 40 | bus[len-1] = 0; 41 | return; 42 | } 43 | 44 | #if defined(NETPERF_STANDALONE_DEBUG) 45 | int 46 | main(int argc, char *argv[]) { 47 | 48 | #define MYLEN 32 49 | char driver[MYLEN]; 50 | char version[MYLEN]; 51 | char firmware[MYLEN]; 52 | char bus[MYLEN]; 53 | 54 | if (argc != 2) { 55 | fprintf(stderr,"%s \n",argv[0]); 56 | exit(-1); 57 | } 58 | 59 | find_driver_info(argv[1],driver, version, firmware, bus, MYLEN); 60 | 61 | printf("Interface %s driver %s version %s firmware %s bus %s\n", 62 | argv[1], driver, version, firmware, bus); 63 | 64 | return 0; 65 | 66 | } 67 | #endif 68 | -------------------------------------------------------------------------------- /src/netperf_version.h.in: -------------------------------------------------------------------------------- 1 | #define NETPERF_VERSION "@VERSION@" 2 | -------------------------------------------------------------------------------- /src/netrt_none.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #ifdef HAVE_SYS_SOCKET_H 6 | #include 7 | #endif 8 | 9 | #ifdef HAVE_STRING_H 10 | #include 11 | #endif 12 | 13 | #ifdef WIN32 14 | #define strdup _strdup 15 | #endif 16 | 17 | char * 18 | find_egress_interface(struct sockaddr *source, struct sockaddr *dest) { 19 | return strdup("InterfaceUnavailable"); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/netrt_rtnetlink.c: -------------------------------------------------------------------------------- 1 | #if defined(HAVE_CONFIG_H) 2 | #include 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | char * 20 | find_egress_interface(struct sockaddr *source, struct sockaddr *dest) { 21 | 22 | struct sockaddr_nl me,them; 23 | struct sockaddr_in *in4; 24 | struct sockaddr_in6 *in6; 25 | 26 | int interface_index = -1; 27 | char interface_name[IF_NAMESIZE]; 28 | 29 | int s; 30 | 31 | /* so, in our msghdr we will put the address and an iovec pointing 32 | to our request. that request will consist of a netlink message 33 | header, a routing message header and some routing attributes. 34 | the chalice with the palace holds the pellet with the poison, the 35 | vessel with the pestle holds the brew which is true. i guess it 36 | would have been "too easy" to just have a plain old ioctl that 37 | one calls to get the route for a given destination and 38 | source... raj 2008-02-11 */ 39 | 40 | struct msghdr msg; 41 | 42 | struct iovec iov; 43 | 44 | struct { 45 | struct nlmsghdr nl; 46 | struct rtmsg rt; 47 | char buf[1024]; 48 | } request; 49 | 50 | char reply[1024]; 51 | 52 | struct nlmsghdr *nlp; 53 | struct rtmsg *rtp; 54 | struct rtattr *rtap; 55 | int nll,rtl; 56 | 57 | int ret; 58 | 59 | /* create and bind the netlink socket */ 60 | s = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); 61 | 62 | memset(&me, 0, sizeof(me)); 63 | me.nl_family = AF_NETLINK; 64 | me.nl_pid = getpid(); 65 | 66 | /* probably should be checking a return value... */ 67 | bind(s, (struct sockaddr *)&me, sizeof(me)); 68 | 69 | /* create the message we are going to send */ 70 | 71 | memset(&request, 0, sizeof(request)); 72 | request.nl.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); 73 | request.nl.nlmsg_flags = NLM_F_REQUEST; 74 | request.nl.nlmsg_type = RTM_GETROUTE; 75 | 76 | /* time to add the destination attribute to the request */ 77 | if (dest) { 78 | in4 = (struct sockaddr_in *)dest; 79 | in6 = (struct sockaddr_in6 *)dest; 80 | request.rt.rtm_family = in4->sin_family; 81 | rtap = (struct rtattr *)request.buf; 82 | rtap->rta_type = RTA_DST; 83 | if (AF_INET == in4->sin_family) { 84 | /* while a sin_addr is a multiple of 4 bytes in length, we 85 | should still use RTA_SPACE rather than RTA_LENGTH. kudos to 86 | Thomas Graf for pointing that out */ 87 | rtap->rta_len = RTA_SPACE(sizeof(in4->sin_addr)); 88 | memcpy(RTA_DATA(rtap), &(in4->sin_addr), sizeof(in4->sin_addr)); 89 | } 90 | else if (AF_INET6 == in6->sin6_family) { 91 | rtap->rta_len = RTA_SPACE(sizeof(in6->sin6_addr)); 92 | memcpy(RTA_DATA(rtap), &(in6->sin6_addr), sizeof(in6->sin6_addr)); 93 | } 94 | else { 95 | close(s); 96 | return strdup("UnknownAddressFamily"); 97 | } 98 | } 99 | else { 100 | /* there must always be a destination */ 101 | printf("No destination specified.\n"); 102 | close(s); 103 | return strdup("NoDestination"); 104 | } 105 | 106 | /* add the length of our request to our overall message length. it 107 | should already be suitably padded by the previous RTA_SPACE */ 108 | request.nl.nlmsg_len += rtap->rta_len; 109 | 110 | /* now the src */ 111 | if (source) { 112 | /* the source goes after the dest, so we can just increment by the 113 | current value of rta_len */ 114 | in4 = (struct sockaddr_in *)source; 115 | in6 = (struct sockaddr_in6 *)source; 116 | 117 | /* pointer math is fun. silly me initially tried to to rtap += 118 | rtap->rta_len but since rtap isn't pointing at bytes... again 119 | kudos to Thomas Graf for finding that mistake */ 120 | rtap = (struct rtattr *)((char *)rtap + (rtap->rta_len)); 121 | rtap->rta_type = RTA_SRC; 122 | if (AF_INET == in4->sin_family) { 123 | rtap->rta_len = RTA_SPACE(sizeof(in4->sin_addr)); 124 | memcpy(RTA_DATA(rtap), &(in4->sin_addr), sizeof(in4->sin_addr)); 125 | } 126 | else if (AF_INET6 == in6->sin6_family) { 127 | rtap->rta_len = RTA_SPACE(sizeof(in6->sin6_addr)); 128 | memcpy(RTA_DATA(rtap), &(in6->sin6_addr), sizeof(in6->sin6_addr)); 129 | } 130 | else { 131 | close(s); 132 | return strdup("UnknownAddressFamily"); 133 | } 134 | 135 | 136 | /* add the length of the just added attribute to the overall 137 | message length. it should already be suitably padded by the 138 | previous RTA_SPACE */ 139 | request.nl.nlmsg_len += rtap->rta_len; 140 | } 141 | 142 | /* address it */ 143 | memset(&them, 0, sizeof(them)); 144 | them.nl_family = AF_NETLINK; 145 | 146 | memset(&msg, 0, sizeof(msg)); 147 | msg.msg_name = (void *)&them; 148 | msg.msg_namelen = sizeof(them); 149 | 150 | iov.iov_base = (void *) &request.nl; 151 | iov.iov_len = request.nl.nlmsg_len; 152 | 153 | msg.msg_iov = &iov; 154 | msg.msg_iovlen = 1; 155 | 156 | /* send it */ 157 | ret = sendmsg(s, &msg, 0); 158 | 159 | if (ret < 0) { 160 | close(s); 161 | return strdup("SendmsgFailure"); 162 | } 163 | 164 | memset(reply,0,sizeof(reply)); 165 | ret = recv(s, reply, sizeof(reply), 0); 166 | 167 | if (ret < 0) { 168 | close(s); 169 | return strdup("RecvmsgFailure"); 170 | } 171 | 172 | nll = ret; 173 | 174 | /* Since we are looking for a single route, one has to wonder if 175 | this is really necessary, but since all the examples I could find 176 | seemed to be doing it, I'll simply follow along. raj 177 | 2008-02-11 */ 178 | 179 | for (nlp = (struct nlmsghdr *)reply; 180 | NLMSG_OK(nlp,nll); 181 | nlp = NLMSG_NEXT(nlp, nll)) { 182 | /* where oh where might the route header be? */ 183 | rtp = (struct rtmsg *) NLMSG_DATA(nlp); 184 | 185 | #if 0 186 | /* we will ass-u-me we are only interested in results for the main 187 | routing table */ 188 | if (RT_TABLE_MAIN != rtp->rtm_table) { 189 | printf("skipping table %d\n",rtp->rtm_table); 190 | continue; 191 | } 192 | #endif 193 | 194 | for (rtap = (struct rtattr *) RTM_RTA(rtp), rtl = RTM_PAYLOAD(nlp); 195 | RTA_OK(rtap, rtl); 196 | rtap = RTA_NEXT(rtap,rtl)) { 197 | if (RTA_OIF == rtap->rta_type) { 198 | if (-1 == interface_index){ 199 | interface_index = *((int *) RTA_DATA(rtap)); 200 | } 201 | else { 202 | close(s); 203 | return strdup("MultipleInterfacesFound"); 204 | } 205 | } 206 | } 207 | } 208 | 209 | if (interface_index == -1) { 210 | /* we didn't find it */ 211 | return strdup("InterfaceNotFound"); 212 | } 213 | else { 214 | if (NULL == if_indextoname(interface_index,interface_name)) { 215 | close(s); 216 | return strdup("IfIndexToNameFailure"); 217 | } 218 | else { 219 | close(s); 220 | return strdup(interface_name); 221 | } 222 | } 223 | } 224 | #if defined(NETPERF_STANDALONE_DEBUG) 225 | int 226 | main(int argc, char *argv[]) { 227 | 228 | struct sockaddr_storage source,destination; 229 | struct sockaddr_in *sin; 230 | int ret; 231 | char *egress_if; 232 | 233 | if ((argc < 2) || (argc > 3)) { 234 | fprintf(stderr,"%s [srcip]\n",argv[0]); 235 | return -1; 236 | } 237 | 238 | sin = (struct sockaddr_in *)&destination; 239 | sin->sin_family = AF_INET; 240 | sin->sin_addr.s_addr = inet_addr(argv[1]); 241 | 242 | printf("destination address is %s\n",inet_ntoa(sin->sin_addr)); 243 | 244 | sin = NULL; 245 | 246 | if (argc == 3) { 247 | sin = (struct sockaddr_in *)&source; 248 | sin->sin_family = AF_INET; 249 | sin->sin_addr.s_addr = inet_addr(argv[2]); 250 | } 251 | 252 | egress_if = find_egress_interface((struct sockaddr *)sin,(struct sockaddr *)&destination); 253 | 254 | printf("egress interface %p %s\n",egress_if,egress_if); 255 | 256 | } 257 | #endif 258 | -------------------------------------------------------------------------------- /src/netsec_linux.c: -------------------------------------------------------------------------------- 1 | #if defined(HAVE_CONFIG_H) 2 | #include "config.h" 3 | #endif 4 | 5 | #if defined(HAVE_STRING_H) 6 | #include 7 | #endif 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | void *messiah; /* Handel's... */ 17 | 18 | /* for the NSEC_mumble defines */ 19 | #include "netlib.h" 20 | 21 | 22 | void 23 | find_security_info_selinux(int *enabled, int *type, char **specific){ 24 | 25 | int ret; 26 | int enforcing; 27 | 28 | /* at some point we should probably get these from 29 | selinux/selinux.h? */ 30 | int (*getenforce)(int *); 31 | int (*getpolicy)(char **); 32 | 33 | *enabled = NSEC_UNKNOWN; 34 | *type = NSEC_TYPE_SELINUX; 35 | 36 | getenforce = dlsym(messiah, "selinux_getenforcemode"); 37 | if (NULL == getenforce) { 38 | dlclose(messiah); 39 | *specific = strdup("no getenforcemode"); 40 | return; 41 | } 42 | 43 | ret = (*getenforce)(&enforcing); 44 | #if defined(NETPERF_STANDALONE_DEBUG) 45 | printf("after selinux_getenforcemode() ret is %d\n",ret); 46 | #endif 47 | 48 | switch(enforcing) { 49 | case -1: 50 | *enabled = NSEC_DISABLED; 51 | break; 52 | case 0: 53 | *enabled = NSEC_PERMISSIVE; 54 | break; 55 | case 1: 56 | *enabled = NSEC_ENFORCING; 57 | break; 58 | default: 59 | *enabled = NSEC_UNKNOWN; 60 | } 61 | 62 | getpolicy = dlsym(messiah, "selinux_getpolicytype"); 63 | if (NULL == getpolicy) { 64 | dlclose(messiah); 65 | *specific = strdup("no getpolicytype"); 66 | return; 67 | } 68 | 69 | ret = (*getpolicy)(specific); 70 | #if defined(NETPERF_STANDALONE_DEBUG) 71 | printf("after selinux_getpolicytype ret is %d\n",ret); 72 | #endif 73 | 74 | return; 75 | } 76 | 77 | /* presently we only know about SELinux or nothing. at some point we 78 | probably need to learn about AppArmor and the like. raj 79 | 20081020 */ 80 | 81 | void 82 | find_security_info(int *enabled, int *type, char **specific) { 83 | 84 | /* first, might it be selinux? */ 85 | messiah = dlopen("libselinux.so", RTLD_LAZY); 86 | if (NULL != messiah) { 87 | dlerror(); 88 | return find_security_info_selinux(enabled, type, specific); 89 | } 90 | else { 91 | *enabled = NSEC_UNKNOWN; 92 | *type = NSEC_TYPE_UNKNOWN; 93 | *specific = "unknown"; 94 | return; 95 | } 96 | } 97 | 98 | #if defined(NETPERF_STANDALONE_DEBUG) 99 | 100 | /* these are normally found in src/netlib.c but we put copies here for 101 | the nefaious popoise of standalone debugging */ 102 | 103 | char * 104 | nsec_enabled_to_str(int enabled) { 105 | switch (enabled) { 106 | case NSEC_UNKNOWN: 107 | return("Unknown"); 108 | case NSEC_DISABLED: 109 | return("Disabled"); 110 | case NSEC_PERMISSIVE: 111 | return("Permissive"); 112 | case NSEC_ENFORCING: 113 | return("Enforcing"); 114 | default: 115 | return("UNKNOWN MODE"); 116 | } 117 | } 118 | 119 | char * nsec_type_to_str(int type) { 120 | switch (type) { 121 | case NSEC_TYPE_UNKNOWN: 122 | return("Unknown"); 123 | case NSEC_TYPE_SELINUX: 124 | return("SELinux"); 125 | default: 126 | return("UNKNOWN TYPE"); 127 | } 128 | } 129 | 130 | int 131 | main(int argc, char *argv[]) { 132 | 133 | char *specific; 134 | int enabled; 135 | int type; 136 | 137 | find_security_info(&enabled, &type, &specific); 138 | 139 | printf("Security info: enabled %s (%d) type %s (0x%x) specific %s\n", 140 | nsec_enabled_to_str(enabled), 141 | enabled, 142 | nsec_type_to_str(type), 143 | type, 144 | specific); 145 | 146 | return 0; 147 | } 148 | #endif 149 | -------------------------------------------------------------------------------- /src/netsec_none.c: -------------------------------------------------------------------------------- 1 | #if defined(HAVE_CONFIG_H) 2 | #include "config.h" 3 | #endif 4 | 5 | #if defined(HAVE_STRING_H) 6 | #include 7 | #endif 8 | 9 | #include 10 | 11 | #include "netlib.h" 12 | 13 | void 14 | find_security_info(int *enabled, int *type, char **specific){ 15 | *enabled = NSEC_UNKNOWN; 16 | *type = NSEC_TYPE_UNKNOWN; 17 | *specific = strdup("N/A"); 18 | return; 19 | } 20 | 21 | #if defined(NETPERF_STANDALONE_DEBUG) 22 | int 23 | main(int argc, char *argv[]) { 24 | 25 | char *specific; 26 | int enabled; 27 | int type; 28 | 29 | find_security_info(&enabled, &type, &specific); 30 | 31 | printf("Security info: enabled %d type 0x%x specific %s\n", 32 | enabled, 33 | type, 34 | specific); 35 | 36 | return 0; 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /src/netsec_win.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define strdup _strdup 3 | 4 | void 5 | find_security_info(int *enabled, int *type, char **specific){ 6 | *enabled = -1; 7 | *type = -1; 8 | *specific = strdup("N/A"); 9 | return; 10 | } 11 | -------------------------------------------------------------------------------- /src/netsh.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1993-2012 Hewlett-Packard Company 3 | */ 4 | 5 | /* libraried performance include file */ 6 | /* the define NOPERFEXTERN tels us not to re-define all the */ 7 | 8 | /* defines and defaults */ 9 | #define HOSTNAMESIZE 255 10 | #define PORTBUFSIZE 10 11 | #define DEFAULT_SIZE 32768 12 | #define HOST_NAME "127.0.0.1" 13 | #define TEST_PORT "12865" 14 | 15 | /* output controlling variables */ 16 | #define DEBUG 0 /* debugging level */ 17 | #define VERBOSITY 0 /* verbosity level */ 18 | 19 | /* the end-test conditions for the tests - either transactions, bytes, */ 20 | /* or time. different vars used for clarity - space is cheap ;-) */ 21 | #define TEST_TIME 10 /* test ends by time */ 22 | #define TEST_BYTES 0 /* test ends on byte count */ 23 | #define TEST_TRANS 0 /* test ends on tran count */ 24 | 25 | /* the alignment conditions for the tests */ 26 | #define LOC_RECV_ALIGN 4 /* alignment for local receives */ 27 | #define LOC_SEND_ALIGN 4 /* alignment for local sends */ 28 | #define REM_RECV_ALIGN 4 /* alignment for remote receive */ 29 | #define REM_SEND_ALIGN 4 /* alignment for remote sends */ 30 | 31 | /* which way are we going and what are we doing in this handbasket?-) */ 32 | #define NETPERF_XMIT 0x2 33 | #define NETPERF_RECV 0x4 34 | 35 | #define NETPERF_IS_RR(x) (((x & NETPERF_XMIT) && (x & NETPERF_RECV)) || \ 36 | (!((x & NETPERF_XMIT) || (x & NETPERF_RECV)))) 37 | 38 | #define NETPERF_RECV_ONLY(x) ((x & NETPERF_RECV) && !(x & NETPERF_XMIT)) 39 | 40 | #define NETPERF_XMIT_ONLY(x) ((x & NETPERF_XMIT) && !(x & NETPERF_RECV)) 41 | 42 | #define NETPERF_CC(x) (!(x & NETPERF_XMIT) && !(x & NETPERF_RECV)) 43 | 44 | 45 | /* misc defines for the hell of it */ 46 | #ifndef MAXLONG 47 | #define MAXLONG 4294967295UL 48 | #endif /* MAXLONG */ 49 | 50 | #ifdef WANT_DCCP 51 | 52 | /* include netinet/in.h to see if SOCK_DCCP and IPPROTO_DCCP are there */ 53 | #include 54 | 55 | #ifndef SOCK_DCCP 56 | #define DCCP_WARNING 57 | #define SOCK_DCCP 6 58 | #endif 59 | 60 | #ifndef IPPROTO_DCCP 61 | #define DCCP_WARNING 62 | #define IPPROTO_DCCP 33 /* defined by the IANA */ 63 | #endif 64 | 65 | #ifndef SOL_DCCP 66 | #define DCCP_WARNING 67 | #define SOL_DCCP 269 68 | #endif 69 | 70 | #ifdef DCCP_WARNING 71 | #warning This platform is missing one of sock_dccp ipproto_dccp or sol_dccp 72 | #endif 73 | 74 | #endif 75 | 76 | #ifndef NETSH 77 | extern char *program; /* program invocation name */ 78 | extern char *command_line; /* how we were invoked */ 79 | 80 | extern char *passphrase; 81 | 82 | /* stuff to say where this test is going */ 83 | extern char host_name[HOSTNAMESIZE];/* remote host name or ip addr */ 84 | extern char local_host_name[HOSTNAMESIZE]; 85 | extern char test_port[PORTBUFSIZE]; /* where is the test waiting */ 86 | extern char local_test_port[PORTBUFSIZE]; 87 | extern int address_family; 88 | extern int local_address_family; 89 | extern int parse_address_family(char family_string[]); 90 | extern int parse_socket_type(char socket_string[]); 91 | extern int parse_protocol(char protocol_string[]); 92 | extern int parse_direction(char direction_string[]); 93 | extern void set_defaults(); 94 | extern void scan_cmd_line(int argc, char *argv[]); 95 | extern void dump_globals(); 96 | extern void break_args(char *s, char *arg1, char *arg2); 97 | extern void break_args_explicit(char *s, char *arg1, char *arg2); 98 | extern void break_args_explicit_sep(char *s, int sep, char *arg1, char *arg2); 99 | extern void print_netserver_usage(); 100 | 101 | /* output controlling variables */ 102 | extern int 103 | debug, /* debugging level */ 104 | print_headers, /* do/don't print test headers */ 105 | verbosity, /* verbosity level */ 106 | keep_histogram, /* do we keep a histogram of interesting times? */ 107 | keep_statistics; /* do we keep/calculate expensive statistics? */ 108 | 109 | /* the end-test conditions for the tests - either transactions, bytes, */ 110 | /* or time. different vars used for clarity - space is cheap ;-) */ 111 | extern int 112 | test_time, /* test ends by time */ 113 | test_len_ticks, 114 | test_bytes, /* test ends on byte count */ 115 | test_trans; /* test ends on tran count */ 116 | 117 | /* wait time between control/data connection establishment and start 118 | of data traffic */ 119 | extern int wait_time_secs; 120 | 121 | /* the alignment conditions for the tests */ 122 | extern int 123 | local_recv_align, /* alignment for local receives */ 124 | local_send_align, /* alignment for local sends */ 125 | remote_recv_align, /* alignment for remote receives */ 126 | remote_send_align, /* alignment for remote sends */ 127 | local_send_offset, 128 | local_recv_offset, 129 | remote_send_offset, 130 | remote_recv_offset, 131 | remote_send_width, 132 | remote_recv_width; 133 | 134 | /* hoist these above the #if to deal with either netperf or netserver 135 | configured for it */ 136 | 137 | extern int interval_usecs; 138 | extern int interval_wate; 139 | extern int interval_burst; 140 | extern int remote_interval_usecs; 141 | extern int remote_interval_burst; 142 | 143 | 144 | #ifdef DIRTY 145 | extern int rem_dirty_count; 146 | extern int rem_clean_count; 147 | extern int loc_dirty_count; 148 | extern int loc_clean_count; 149 | #endif /* DIRTY */ 150 | 151 | /* stuff for confidence intervals */ 152 | 153 | extern int confidence_level; 154 | extern int iteration_min; 155 | extern int iteration_max; 156 | extern int result_confidence_only; 157 | extern double interval; 158 | extern double interval_pct; 159 | 160 | extern int cpu_binding_requested; 161 | 162 | /* stuff to control the bufferspace "width" */ 163 | extern int send_width; 164 | extern int recv_width; 165 | 166 | /* control the socket priority */ 167 | extern int local_socket_prio; 168 | extern int remote_socket_prio; 169 | 170 | extern int local_socket_tos; 171 | extern int remote_socket_tos; 172 | 173 | /* address family */ 174 | extern int af; 175 | 176 | /* different options for other things */ 177 | extern int 178 | local_cpu_usage, 179 | remote_cpu_usage; 180 | 181 | extern float 182 | local_cpu_rate, 183 | remote_cpu_rate; 184 | 185 | extern int 186 | shell_num_cpus; 187 | 188 | extern char 189 | test_name[BUFSIZ]; 190 | 191 | extern char 192 | local_fill_file[BUFSIZ], 193 | remote_fill_file[32]; 194 | 195 | extern char * 196 | result_brand; 197 | 198 | extern int 199 | no_control; 200 | 201 | #ifdef WANT_DLPI 202 | 203 | extern int 204 | loc_ppa, 205 | rem_ppa; 206 | 207 | extern int 208 | dlpi_sap; 209 | 210 | #endif /* WANT_DLPI */ 211 | 212 | #endif 213 | 214 | extern int parse_ipqos(const char *cp); 215 | extern const char * iptos2str(int iptos); 216 | 217 | -------------------------------------------------------------------------------- /src/netslot_linux.c: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 500 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static char interface_match[32]; 8 | static char interface_address[13]; 9 | static char interface_slot[13]="not found"; 10 | 11 | static int 12 | find_slot(const char *fpath, const struct stat *sb, 13 | int tflag, struct FTW *ftwbuf) 14 | { 15 | char slot_address[11]; 16 | int ret; 17 | FILE *address_file; 18 | char *myfpath; 19 | char *this_tok; 20 | char *last_tok = NULL; 21 | 22 | /* so, are we at a point in the tree where the basename is 23 | "address" ? */ 24 | if (strcmp("address",fpath + ftwbuf->base) == 0) { 25 | address_file = fopen(fpath,"r"); 26 | if (address_file == NULL) { 27 | strcpy(interface_slot,"fopen"); 28 | return 0; 29 | } 30 | /* we make the simplifying assumption that PCI domain, bus, slot 31 | and function, with associated separators, are 10 characters or 32 | less */ 33 | ret = fread(slot_address,1,10,address_file); 34 | if (ret != 10) { 35 | strcpy(interface_slot,"fread"); 36 | fclose(address_file); 37 | return 0; 38 | } 39 | slot_address[ret] = 0; 40 | /* the slot address will be a substring of the full bus address of 41 | the interface we seek */ 42 | if (strstr(interface_address,slot_address)) { 43 | myfpath = strdup(fpath); 44 | if (myfpath == NULL) { 45 | strcpy(interface_slot,"strcpy"); 46 | return 1; 47 | } 48 | 49 | this_tok = strtok(myfpath,"/"); 50 | while (strcmp(this_tok,"address")) { 51 | last_tok = this_tok; 52 | this_tok = strtok(NULL,"/"); 53 | } 54 | if (last_tok != NULL) 55 | strcpy(interface_slot,last_tok); 56 | else 57 | strcpy(interface_slot,"last_tok"); 58 | free(myfpath); 59 | fclose(address_file); 60 | return 1; 61 | } 62 | fclose(address_file); 63 | } 64 | return 0; 65 | } 66 | 67 | static int 68 | find_interface(const char *fpath, const struct stat *sb, 69 | int tflag, struct FTW *ftwbuf) 70 | { 71 | char *myfpath; 72 | char *this_tok; 73 | char *last_tok = NULL; 74 | 75 | if (strcmp(interface_match,fpath + ftwbuf->base) == 0) { 76 | myfpath = strdup(fpath); 77 | if (myfpath == NULL) { 78 | strcpy(interface_address,"strcpy"); 79 | return 1; 80 | } 81 | this_tok = strtok(myfpath,"/"); 82 | while (strcmp(this_tok,interface_match)) { 83 | last_tok = this_tok; 84 | this_tok = strtok(NULL,"/"); 85 | } 86 | if (last_tok != NULL) 87 | strcpy(interface_address,last_tok); 88 | else 89 | strcpy(interface_address,"last_tok"); 90 | free(myfpath); 91 | return 1; 92 | } 93 | return 0; 94 | } 95 | 96 | char * 97 | find_interface_slot(char *interface_name) { 98 | 99 | int flags = 0; 100 | int ret; 101 | 102 | flags |= FTW_PHYS; /* don't follow symlinks for they will lead us 103 | off the path */ 104 | ret = snprintf(interface_match,31,"net:%s",interface_name); 105 | interface_match[31]=0; 106 | /* having setup the basename we will be seeking, go find it and the 107 | corresponding interface_address */ 108 | nftw("/sys/devices", find_interface, 20, flags); 109 | /* now that we ostensibly have the pci address of the interface 110 | (interface_address, lets find that slot shall we? */ 111 | nftw("/sys/bus/pci/slots", find_slot, 20, flags); 112 | return strdup(interface_slot); 113 | } 114 | 115 | static int 116 | get_val_from_file(char *valsource) { 117 | FILE *valfile; 118 | char buffer[6]; /* 0xabcd */ 119 | int ret; 120 | 121 | valfile = fopen(valsource,"r"); 122 | if (valfile == NULL) return -1; 123 | 124 | ret = fread(buffer,1,sizeof(buffer), valfile); 125 | if (ret != sizeof(buffer)) { 126 | fclose(valfile); 127 | return -1; 128 | } 129 | 130 | ret = (int)strtol(buffer,NULL,0); 131 | 132 | fclose(valfile); 133 | return ret; 134 | 135 | } 136 | 137 | void 138 | find_interface_ids(char *interface_name, int *vendor, int *device, int *sub_vend, int *sub_dev) { 139 | 140 | int ret; 141 | 142 | char sysfile[128]; /* gotta love constants */ 143 | 144 | /* first the vendor id */ 145 | ret = snprintf(sysfile,128,"/sys/class/net/%s/device/vendor",interface_name); 146 | *vendor = get_val_from_file(sysfile); 147 | 148 | /* next the device */ 149 | ret = snprintf(sysfile,128,"/sys/class/net/%s/device/device",interface_name); 150 | *device = get_val_from_file(sysfile); 151 | 152 | /* next the subsystem vendor */ 153 | ret = snprintf(sysfile,128,"/sys/class/net/%s/device/subsystem_vendor",interface_name); 154 | *sub_vend = get_val_from_file(sysfile); 155 | 156 | /* next the subsystem device */ 157 | ret = snprintf(sysfile,128,"/sys/class/net/%s/device/subsystem_device",interface_name); 158 | *sub_dev = get_val_from_file(sysfile); 159 | 160 | } 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /src/netslot_none.c: -------------------------------------------------------------------------------- 1 | #if defined(HAVE_CONFIG_H) 2 | #include 3 | #endif 4 | 5 | #if defined(HAVE_STRING_H) 6 | #include 7 | #endif 8 | 9 | #if defined(NETPERF_STANDALONE_DEBUG) 10 | #include 11 | #endif 12 | 13 | #ifdef WIN32 14 | #define strdup _strdup 15 | #endif 16 | 17 | char * 18 | find_interface_slot(char *interface_name) { 19 | return strdup("Not Implemented"); 20 | } 21 | 22 | void 23 | find_interface_ids(char *interface_name, int *vendor, int *device, int *sub_vend, int *sub_dev) { 24 | *vendor = 0; 25 | *device = 0; 26 | *sub_vend = 0; 27 | *sub_dev = 0; 28 | return; 29 | } 30 | 31 | #if defined(NETPERF_STANDALONE_DEBUG) 32 | int 33 | main(int argc, char *argv[]) { 34 | 35 | char *slot; 36 | int vendor; 37 | int device; 38 | int subvendor; 39 | int subdevice; 40 | 41 | if (argc != 2) { 42 | fprintf(stderr,"%s \n",argv[0]); 43 | return -1; 44 | } 45 | 46 | slot = find_interface_slot(argv[1]); 47 | 48 | find_interface_ids(argv[1], &vendor, &device, &subvendor, &subdevice); 49 | 50 | printf("%s in in slot %s: vendor %4x device %4x subvendor %4x subdevice %4x\n", 51 | argv[1], 52 | slot, 53 | vendor, 54 | device, 55 | subvendor, 56 | subdevice); 57 | 58 | return 0; 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /src/netslot_ux1131.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2010, Hewlett-Packard Company */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | /* 12 | * No OLAR headerfile on target system! ;-( Yes, this means that these 13 | * interfaces are NOT DOCUMENTED FOR PUBLIC USE, which means you don't 14 | * really see what you are reading here, and if you attempt to use it 15 | * elsewhere, no one will profess any knowledge of what you are doing. 16 | * You will be utterly and completely on your own. 17 | */ 18 | typedef uint64_t olar_io_slot_t; 19 | 20 | typedef struct olar_error_info { 21 | int oe_err; 22 | char oe_hwpath[MAX_HW_PATH_STR]; 23 | } olar_err_t; 24 | 25 | #define MAX_SLOT_ID_LEN 30 26 | 27 | char * get_hw_path_from_if(char *if_name); 28 | 29 | char * 30 | find_interface_slot(char *interface_name) { 31 | 32 | char *hw_str; 33 | olar_io_slot_t slot_id; 34 | olar_err_t oe; 35 | char slot_str[MAX_SLOT_ID_LEN]; 36 | 37 | /* Open dev_config for libIO communication */ 38 | if ( io_init(O_RDONLY) == IO_ERROR ) { 39 | return strdup("io_init"); 40 | } 41 | 42 | hw_str = get_hw_path_from_if(interface_name); 43 | 44 | /* close dev_config */ 45 | io_end(); 46 | 47 | slot_id = 0; 48 | if ( olar_path_to_id(hw_str,&slot_id,&oe) == -1 ) { 49 | /* since the call failed, lets give them the HW path as a 50 | consolation prize. we will ass-u-me that the caller will be 51 | freeing the string we give him anyway. */ 52 | if (debug) { 53 | fprintf(where, 54 | "%s olar_path_to_id hw_str %s oe_err %d path %s\n", 55 | __func__, 56 | hw_str, 57 | oe.oe_err, 58 | oe.oe_hwpath); 59 | fflush(where); 60 | } 61 | return hw_str; 62 | } 63 | 64 | if ( olar_slot_id_to_string(slot_id,slot_str,30) == -1 ) { 65 | /* do the same thing here, give them the hw path if this call 66 | fails */ 67 | if (debug) { 68 | fprintf(where, 69 | "%s olar_slot_id_to_string slot_id %" PRId64 "\n", 70 | slot_id); 71 | fflush(where); 72 | } 73 | return hw_str; 74 | } 75 | 76 | /* we can give them the honest to goodness slot id as a string now, 77 | so let us free that which we should free */ 78 | free(hw_str); 79 | 80 | return strdup(slot_str); 81 | } 82 | 83 | /* 84 | * Returns the H/W path string corresponding to the lan if name 85 | * 86 | * Assumption: if_name is of type lan%ppid 87 | * Not known to work with Logical,Vlan etc.. 88 | * 89 | */ 90 | char * get_hw_path_from_if(char *if_name) 91 | { 92 | int instance; 93 | io_token_t tok; 94 | hw_path_t hw; 95 | char *hwstr; 96 | 97 | sscanf(if_name,"lan%d",&instance); 98 | 99 | if ( (tok = io_search(NULL,S_IOTREE_EXT,0,"class", "lan", 100 | "instance", &instance, NULL)) == NULL ) { 101 | /* we don't want extraneous output on netserver side - at some 102 | point we can teach it about "where" */ 103 | /* io_error("Could not find H/w path"); */ 104 | return(NULL); 105 | } 106 | 107 | if ( io_node_to_hw_path(tok, &hw) != IO_SUCCESS ) { 108 | /* io_error("io_node_to_hw_path failed"); */ 109 | return NULL; 110 | } 111 | 112 | hwstr = (char *) malloc (MAX_HW_PATH_STR * sizeof(char)); 113 | if (hwstr == NULL ) { 114 | /* perror("malloc failed in get_hw_path_from_if"); */ 115 | return NULL; 116 | } 117 | 118 | if (io_hw_path_to_str(hwstr,&hw) == IO_ERROR ) { 119 | /* io_error("io_hw_path_to_str failed"); */ 120 | free(hwstr); 121 | return NULL; 122 | } 123 | 124 | return hwstr; 125 | } 126 | 127 | void 128 | find_interface_ids(char *interface_name, int *vendor, int *device, int *sub_vend, int *sub_dev) { 129 | *vendor = 0; 130 | *device = 0; 131 | *sub_vend = 0; 132 | *sub_dev = 0; 133 | return; 134 | } 135 | -------------------------------------------------------------------------------- /src/netsys_hpux11i.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | /* tusc can be a very useful thing... */ 8 | 9 | #ifndef _SI_MACHINE_MODEL 10 | #define _SI_MACHINE_MODEL 5 11 | #endif 12 | 13 | extern int sysinfo(int info, char *buffer, ssize_t len); 14 | 15 | 16 | void 17 | find_system_info(char **system_model, char **cpu_model, int *cpu_frequency) { 18 | char model_str[64]; 19 | int ret; 20 | struct pst_processor processor_info; 21 | 22 | /* first the system model name */ 23 | ret = sysinfo(_SI_MACHINE_MODEL,model_str,64); 24 | model_str[63] = 0; 25 | *system_model = strdup(model_str); 26 | 27 | /* now lets try to find processor frequency. we will for now 28 | ass-u-me that an index of zero will always get us something, 29 | which may not actually be the case but lets see how long it takes 30 | to be noticed :) raj 2008-03-07 */ 31 | ret = pstat_getprocessor(&processor_info, 32 | sizeof(processor_info), 33 | 1, /* one processor, one processor only please */ 34 | 0); 35 | 36 | if (ret > 0) { 37 | #ifdef PSP_MAX_CACHE_LEVELS 38 | /* we can get it "directly" but to help make things reconcile with 39 | what other tools/platforms support, we shouldn't do a simple 40 | integer divide - instead, we should do our division in floating 41 | point and then round */ 42 | *cpu_frequency = rint((double)processor_info.psp_cpu_frequency / 43 | 1000000.0); 44 | #else 45 | /* older OSes were "known" to be on CPUs where the itick was 46 | 1to1 here */ 47 | *cpu_frequency = rint(((double)processor_info.psp_iticksperclktick * 48 | (double)sysconf(_SC_CLK_TCK)) / 1000000.0); 49 | #endif 50 | } 51 | else 52 | *cpu_frequency = -1; 53 | 54 | *cpu_model = strdup("Unknown CPU Model"); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/netsys_linux.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #ifdef NETPERF_STANDALONE_DEBUG 6 | #include 7 | #endif 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | static void 15 | find_cpu_model(char **cpu_model) { 16 | char linebuf[256]; 17 | char *cret; 18 | 19 | FILE *proccpu; 20 | 21 | proccpu = fopen("/proc/cpuinfo","r"); 22 | 23 | if (NULL == proccpu) { 24 | *cpu_model = strdup("fopen"); 25 | return; 26 | } 27 | 28 | do { 29 | cret = fgets(linebuf,256,proccpu); 30 | if (NULL != cret) { 31 | char *target; 32 | /* OK, so does it start with "model name" ? */ 33 | if (strstr(linebuf,"model name") != NULL) { 34 | /* one for the money "model name" */ 35 | target = strtok(linebuf,":"); 36 | /* two for the show (the actual model name) */ 37 | target = strtok(NULL,":"); 38 | /* three to get ready - strip the eol */ 39 | target[strlen(target)-1] = 0; 40 | /* and four to go! */ 41 | *cpu_model = strdup(target+1); 42 | fclose(proccpu); 43 | return; 44 | } 45 | } 46 | } while (!feof(proccpu)); 47 | *cpu_model = strdup("model_name"); 48 | fclose(proccpu); 49 | } 50 | 51 | static int 52 | find_cpu_freq() { 53 | char linebuf[256]; 54 | char *cret; 55 | 56 | FILE *proccpu; 57 | 58 | proccpu = fopen("/proc/cpuinfo","r"); 59 | 60 | if (NULL == proccpu) { 61 | return -1; 62 | } 63 | 64 | do { 65 | cret = fgets(linebuf,256,proccpu); 66 | if (NULL != cret) { 67 | char *target; 68 | /* OK, so does it start with "model name" ? */ 69 | if (strstr(linebuf,"cpu MHz") != NULL) { 70 | target = strtok(linebuf,":"); 71 | target = strtok(NULL,":"); 72 | fclose(proccpu); 73 | return rint(strtod(target+1,NULL)); 74 | } 75 | } 76 | } while (!feof(proccpu)); 77 | fclose(proccpu); 78 | return -1; 79 | } 80 | 81 | static void 82 | find_system_model(char **system_model) { 83 | #if defined(HAVE_LIBSMBIOS) 84 | #if defined(HAVE_SMBIOS_SYSTEMINFO_H) 85 | #include 86 | #else 87 | /* take our best shot - the interface seems simple and stable enough 88 | that we don't have to require the -dev package be installed */ 89 | extern const char *SMBIOSGetSystemName(); 90 | #endif 91 | 92 | char *temp_model; 93 | 94 | /* SMBIOSGetSystemModel allocated */ 95 | temp_model = (char *) SMBIOSGetSystemName(); 96 | if (temp_model) 97 | *system_model = temp_model; 98 | else 99 | *system_model = strdup("SMBIOSGetSystemModel"); 100 | 101 | #else 102 | /* we do not even have the library so there isn't much to do here 103 | unless someone wants to teach netperf how to find and parse 104 | SMBIOS all by its lonesome. raj 2008-03-13 */ 105 | *system_model = strdup("Teach Me SMBIOS"); 106 | #endif 107 | return; 108 | } 109 | 110 | void 111 | find_system_info(char **system_model, char **cpu_model, int *cpu_frequency) { 112 | 113 | find_system_model(system_model); 114 | find_cpu_model(cpu_model); 115 | *cpu_frequency = find_cpu_freq(); 116 | 117 | } 118 | 119 | #ifdef NETPERF_STANDALONE_DEBUG 120 | int 121 | main(int argc, char *argv[]) { 122 | 123 | char *system_model; 124 | char *cpu_model; 125 | int frequency; 126 | 127 | find_system_info(&system_model,&cpu_model,&frequency); 128 | printf("system_model %s, cpu_model %s, frequency %d\n", 129 | system_model, 130 | cpu_model, 131 | frequency); 132 | 133 | return 0; 134 | 135 | } 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /src/netsys_none.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef WIN32 4 | #define strdup _strdup 5 | #endif 6 | 7 | void 8 | find_system_info(char **system_model, char **cpu_model, int *cpu_frequency) { 9 | *system_model = strdup("Unknown System Model"); 10 | *cpu_model = strdup("Unknown CPU Model"); 11 | *cpu_frequency = -1; 12 | } 13 | -------------------------------------------------------------------------------- /src/netsys_solaris.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | static kstat_ctl_t *kc = NULL; 13 | static kid_t kcid = 0; 14 | 15 | static void 16 | find_cpu_model_freq(char **cpu_model, int *frequency) { 17 | 18 | kstat_t *ksp; 19 | kid_t nkcid; 20 | kstat_named_t *knp; 21 | int i,found_brand,found_freq; 22 | 23 | 24 | found_brand = 0; 25 | found_freq = 0; 26 | 27 | kc = kstat_open(); 28 | 29 | if (NULL == kc) { 30 | *cpu_model = strdup("kstat_open"); 31 | *frequency = -1; 32 | return; 33 | } 34 | 35 | ksp = kstat_lookup(kc, "cpu_info", 0, NULL); 36 | 37 | if ((NULL == ksp) || 38 | ((ksp) && (KSTAT_TYPE_NAMED != ksp->ks_type))) { 39 | *cpu_model = strdup("kstat_lookup"); 40 | *frequency = -1; 41 | kstat_close(kc); 42 | return; 43 | } 44 | 45 | nkcid = kstat_read(kc, ksp, NULL); 46 | 47 | if (-1 == nkcid) { 48 | *cpu_model = strdup("kstat_read"); 49 | *frequency = -1; 50 | kstat_close(kc); 51 | return; 52 | } 53 | 54 | for (i = ksp->ks_ndata, knp = ksp->ks_data; 55 | i > 0; 56 | knp++, i--) { 57 | if (!strcmp("brand", knp->name)) { 58 | *cpu_model = strdup(KSTAT_NAMED_STR_PTR(knp)); 59 | found_brand = 1; 60 | } 61 | else if (!strcmp("clock_MHz",knp->name)) { 62 | *frequency = (int)knp->value.ui32; 63 | found_freq = 1; 64 | } 65 | } 66 | if (!found_brand) 67 | *cpu_model = strdup("CPU Not Found"); 68 | if (!found_freq) 69 | *frequency = -1; 70 | 71 | kstat_close(kc); 72 | } 73 | 74 | static void 75 | find_system_model_sysinfo(char **system_model) { 76 | 77 | #include 78 | char model_str[37]; 79 | char *token1,*token2; 80 | long ret; 81 | /* sysinfo is kind enough to zero-terminate for us. we will be 82 | ignoring the leading SUNW, if present so use 37 instead of 35 in 83 | case the platform name is long */ 84 | ret = sysinfo(SI_PLATFORM,model_str,37); 85 | if (-1 != ret) { 86 | /* however, it seems to shove potentially redundant information at 87 | us and include a comma, which we have no desire to include, so 88 | we will ass-u-me we can do a couple strtok calls to be rid of 89 | that */ 90 | token1 = strtok(model_str,","); 91 | token2 = strtok(NULL,","); 92 | if (token2) 93 | *system_model = strdup(token2); 94 | else 95 | *system_model = strdup(model_str); 96 | } 97 | else 98 | *system_model = strdup("sysinfo"); 99 | 100 | } 101 | 102 | static void 103 | find_system_model(char **system_model) { 104 | 105 | /* the .h file will be there even on a SPARC system, so we have to 106 | check for both the .h and the libarary... */ 107 | #if defined(HAVE_SYS_SMBIOS_H) && defined(HAVE_LIBSMBIOS) 108 | #include 109 | smbios_hdl_t *smbios_handle; 110 | smbios_info_t info; 111 | 112 | int error; 113 | int ret; 114 | id_t ret_id_t; 115 | 116 | /* much of this is wild guessing based on web searches, sys/smbios.h, and 117 | experimentation. my thanks to a helpful person familiar with libsmbios 118 | who got me started. feel free to make yourself known as you see fit :) 119 | rick jones 2008-03-12 */ 120 | smbios_handle = smbios_open(NULL,SMB_VERSION,0,&error); 121 | if (NULL == smbios_handle) { 122 | /* fall-back on sysinfo for the system model info, we don't really 123 | care why we didn't get a handle, just that we didn't get one */ 124 | #if defined(NETPERF_STANDALONE_DEBUG) 125 | printf("smbios_open returned NULL, error %d errno %d %s\n", 126 | error,errno,strerror(errno)); 127 | #endif 128 | find_system_model_sysinfo(system_model); 129 | return; 130 | } 131 | ret = smbios_info_common(smbios_handle,256,&info); 132 | if (0 == ret) 133 | *system_model = strdup(info.smbi_product); 134 | else { 135 | /* we ass-u-me that while there was smbios on the system it didn't 136 | have the smbi_product information we seek, so once again we 137 | fallback to sysinfo. this is getting tiresome isn't it?-) raj 138 | 2008-03-12 */ 139 | #if defined(NETPERF_STANDALONE_DEBUG) 140 | printf("smbios_info_common returned %d errno %d %s\n", 141 | ret,errno,strerror(errno)); 142 | #endif 143 | find_system_model_sysinfo(system_model); 144 | } 145 | smbios_close(smbios_handle); 146 | 147 | #else 148 | 149 | find_system_model_sysinfo(system_model); 150 | 151 | #endif 152 | 153 | return; 154 | } 155 | 156 | void 157 | find_system_info(char **system_model, char **cpu_model, int *cpu_frequency) { 158 | int ret; 159 | 160 | find_system_model(system_model); 161 | find_cpu_model_freq(cpu_model,cpu_frequency); 162 | 163 | } 164 | 165 | #if defined(NETPERF_STANDALONE_DEBUG) 166 | int 167 | main(int argc, char *argv[]) { 168 | char *system_model; 169 | char *cpu_model; 170 | int frequency; 171 | 172 | find_system_info(&system_model,&cpu_model,&frequency); 173 | printf("system_model %s, cpu_model %s, frequency %d\n", 174 | system_model, 175 | cpu_model, 176 | frequency); 177 | } 178 | #endif 179 | 180 | -------------------------------------------------------------------------------- /src/nettest_sctp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1993-2003 Hewlett-Packard Company 3 | */ 4 | 5 | /* This file contains the test-specific definitions for netperf's BSD */ 6 | /* sockets tests */ 7 | 8 | 9 | struct sctp_stream_request_struct { 10 | int send_buf_size; 11 | int recv_buf_size; /* how big does the client want it - the */ 12 | /* receive socket buffer that is */ 13 | int receive_size; /* how many bytes do we want to receive at one */ 14 | /* time? */ 15 | int recv_alignment; /* what is the alignment of the receive */ 16 | /* buffer? */ 17 | int recv_offset; /* and at what offset from that alignment? */ 18 | int no_delay; /* do we disable the nagle algorithm for send */ 19 | /* coalescing? */ 20 | int measure_cpu; /* does the client want server cpu utilization */ 21 | /* measured? */ 22 | float cpu_rate; /* do we know how fast the cpu is already? */ 23 | int test_length; /* how long is the test? */ 24 | int so_rcvavoid; /* do we want the remote to avoid copies on */ 25 | /* receives? */ 26 | int so_sndavoid; /* do we want the remote to avoid send copies? */ 27 | int dirty_count; /* how many integers in the receive buffer */ 28 | /* should be made dirty before calling recv? */ 29 | int clean_count; /* how many integers should be read from the */ 30 | /* recv buffer before calling recv? */ 31 | int port; /* the to port to which recv side should bind 32 | to allow netperf to run through firewalls */ 33 | int ipfamily; /* address family of ipaddress */ 34 | int non_blocking; /* run the test in non-blocking mode */ 35 | }; 36 | 37 | struct sctp_stream_response_struct { 38 | int recv_buf_size; /* how big does the client want it */ 39 | int receive_size; 40 | int no_delay; 41 | int measure_cpu; /* does the client want server cpu */ 42 | int test_length; /* how long is the test? */ 43 | int send_buf_size; 44 | int data_port_number; /* connect to me here */ 45 | float cpu_rate; /* could we measure */ 46 | int so_rcvavoid; /* could the remote avoid receive copies? */ 47 | int so_sndavoid; /* could the remote avoid send copies? */ 48 | int non_blocking; /* run the test in non-blocking mode */ 49 | }; 50 | 51 | struct sctp_stream_results_struct { 52 | double bytes_received; 53 | unsigned int recv_calls; 54 | float elapsed_time; /* how long the test ran */ 55 | float cpu_util; /* -1 if not measured */ 56 | float serv_dem; /* -1 if not measured */ 57 | int cpu_method; /* how was cpu util measured? */ 58 | int num_cpus; /* how many CPUs had the remote? */ 59 | }; 60 | 61 | struct sctp_rr_request_struct { 62 | int recv_buf_size; /* how big does the client want it */ 63 | int send_buf_size; 64 | int recv_alignment; 65 | int recv_offset; 66 | int send_alignment; 67 | int send_offset; 68 | int request_size; 69 | int response_size; 70 | int no_delay; 71 | int measure_cpu; /* does the client want server cpu */ 72 | float cpu_rate; /* do we know how fast the cpu is? */ 73 | int test_length; /* how long is the test? */ 74 | int so_rcvavoid; /* do we want the remote to avoid receive */ 75 | /* copies? */ 76 | int so_sndavoid; /* do we want the remote to avoid send copies? */ 77 | int port; /* the to port to which recv side should bind 78 | to allow netperf to run through firewalls */ 79 | int ipfamily; /* address family of ipaddress */ 80 | int non_blocking; /* run the test in non-blocking mode */ 81 | }; 82 | 83 | struct sctp_rr_response_struct { 84 | int recv_buf_size; /* how big does the client want it */ 85 | int no_delay; 86 | int measure_cpu; /* does the client want server cpu */ 87 | int test_length; /* how long is the test? */ 88 | int send_buf_size; 89 | int data_port_number; /* connect to me here */ 90 | float cpu_rate; /* could we measure */ 91 | int so_rcvavoid; /* could the remote avoid receive copies? */ 92 | int so_sndavoid; /* could the remote avoid send copies? */ 93 | int non_blocking; /* run the test in non-blocking mode */ 94 | }; 95 | 96 | struct sctp_rr_results_struct { 97 | unsigned int bytes_received; /* ignored initially */ 98 | unsigned int recv_calls; /* ignored initially */ 99 | unsigned int trans_received; /* not ignored */ 100 | float elapsed_time; /* how long the test ran */ 101 | float cpu_util; /* -1 if not measured */ 102 | float serv_dem; /* -1 if not measured */ 103 | int cpu_method; /* how was cpu util measured? */ 104 | int num_cpus; /* how many CPUs had the remote? */ 105 | }; 106 | 107 | #define SCTP_SNDRCV_INFO_EV 0x01 108 | #define SCTP_ASSOC_CHANGE_EV 0x02 109 | #define SCTP_PEERADDR_CHANGE_EV 0x04 110 | #define SCTP_SND_FAILED_EV 0x08 111 | #define SCTP_REMOTE_ERROR_EV 0x10 112 | #define SCTP_SHUTDOWN_EV 0x20 113 | #define SCTP_PD_EV 0x40 114 | #define SCTP_ADAPT_EV 0x80 115 | 116 | typedef enum sctp_disposition { 117 | SCTP_OK = 1, 118 | SCTP_CLOSE, 119 | } sctp_disposition_t; 120 | 121 | extern void scan_sctp_args( int argc, char *argv[] ); 122 | 123 | extern void send_sctp_stream( char remote_host[] ); 124 | extern void send_sctp_stream_1toMany( char remote_host[] ); 125 | extern void send_sctp_rr( char remote_host[] ); 126 | extern void send_sctp_rr_1toMany( char remote_host[] ); 127 | 128 | extern void recv_sctp_stream( void ); 129 | extern void recv_sctp_stream_1toMany( void ); 130 | extern void recv_sctp_rr( void ); 131 | extern void recv_sctp_rr_1toMany( void ); 132 | 133 | extern void loc_cpu_rate(); 134 | extern void rem_cpu_rate(); 135 | -------------------------------------------------------------------------------- /src/nettest_sdp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2007 Hewlett-Packard Company 3 | */ 4 | 5 | /* This file contains the test-specific definitions for netperf's SDP */ 6 | /* sockets tests */ 7 | 8 | /* one of these days, this should not be required */ 9 | #ifndef AF_INET_SDP 10 | #define AF_INET_SDP 27 11 | #define PF_INET_SDP AF_INET_SDP 12 | #endif 13 | 14 | struct sdp_stream_request_struct { 15 | int send_buf_size; 16 | int recv_buf_size; /* how big does the client want it - the */ 17 | /* receive socket buffer that is */ 18 | int receive_size; /* how many bytes do we want to receive at one */ 19 | /* time? */ 20 | int recv_alignment; /* what is the alignment of the receive */ 21 | /* buffer? */ 22 | int recv_offset; /* and at what offset from that alignment? */ 23 | int no_delay; /* do we disable the nagle algorithm for send */ 24 | /* coalescing? */ 25 | int measure_cpu; /* does the client want server cpu utilization */ 26 | /* measured? */ 27 | float cpu_rate; /* do we know how fast the cpu is already? */ 28 | int test_length; /* how long is the test? */ 29 | int so_rcvavoid; /* do we want the remote to avoid copies on */ 30 | /* receives? */ 31 | int so_sndavoid; /* do we want the remote to avoid send copies? */ 32 | int dirty_count; /* how many integers in the receive buffer */ 33 | /* should be made dirty before calling recv? */ 34 | int clean_count; /* how many integers should be read from the */ 35 | /* recv buffer before calling recv? */ 36 | int port; /* the to port to which recv side should bind 37 | to allow netperf to run through firewalls */ 38 | int ipfamily; /* address family of ipaddress */ 39 | int non_blocking; /* run the test in non-blocking mode */ 40 | }; 41 | 42 | struct sdp_stream_response_struct { 43 | int recv_buf_size; /* how big does the client want it */ 44 | int receive_size; 45 | int no_delay; 46 | int measure_cpu; /* does the client want server cpu */ 47 | int test_length; /* how long is the test? */ 48 | int send_buf_size; 49 | int data_port_number; /* connect to me here */ 50 | float cpu_rate; /* could we measure */ 51 | int so_rcvavoid; /* could the remote avoid receive copies? */ 52 | int so_sndavoid; /* could the remote avoid send copies? */ 53 | int non_blocking; /* run the test in non-blocking mode */ 54 | }; 55 | 56 | struct sdp_stream_results_struct { 57 | double bytes_received; 58 | unsigned int recv_calls; 59 | float elapsed_time; /* how long the test ran */ 60 | float cpu_util; /* -1 if not measured */ 61 | float serv_dem; /* -1 if not measured */ 62 | int cpu_method; /* how was cpu util measured? */ 63 | int num_cpus; /* how many CPUs had the remote? */ 64 | }; 65 | 66 | struct sdp_rr_request_struct { 67 | int recv_buf_size; /* how big does the client want it */ 68 | int send_buf_size; 69 | int recv_alignment; 70 | int recv_offset; 71 | int send_alignment; 72 | int send_offset; 73 | int request_size; 74 | int response_size; 75 | int no_delay; 76 | int measure_cpu; /* does the client want server cpu */ 77 | float cpu_rate; /* do we know how fast the cpu is? */ 78 | int test_length; /* how long is the test? */ 79 | int so_rcvavoid; /* do we want the remote to avoid receive */ 80 | /* copies? */ 81 | int so_sndavoid; /* do we want the remote to avoid send copies? */ 82 | int port; /* the to port to which recv side should bind 83 | to allow netperf to run through firewalls */ 84 | int ipfamily; /* address family of ipaddress */ 85 | int non_blocking; /* run the test in non-blocking mode */ 86 | }; 87 | 88 | struct sdp_rr_response_struct { 89 | int recv_buf_size; /* how big does the client want it */ 90 | int no_delay; 91 | int measure_cpu; /* does the client want server cpu */ 92 | int test_length; /* how long is the test? */ 93 | int send_buf_size; 94 | int data_port_number; /* connect to me here */ 95 | float cpu_rate; /* could we measure */ 96 | int so_rcvavoid; /* could the remote avoid receive copies? */ 97 | int so_sndavoid; /* could the remote avoid send copies? */ 98 | int non_blocking; /* run the test in non-blocking mode */ 99 | }; 100 | 101 | struct sdp_rr_results_struct { 102 | unsigned int bytes_received; /* ignored initially */ 103 | unsigned int recv_calls; /* ignored initially */ 104 | unsigned int trans_received; /* not ignored */ 105 | float elapsed_time; /* how long the test ran */ 106 | float cpu_util; /* -1 if not measured */ 107 | float serv_dem; /* -1 if not measured */ 108 | int cpu_method; /* how was cpu util measured? */ 109 | int num_cpus; /* how many CPUs had the remote? */ 110 | }; 111 | 112 | struct sdp_maerts_request_struct { 113 | int send_buf_size; 114 | int recv_buf_size; /* how big does the client want it - the */ 115 | /* receive socket buffer that is */ 116 | int send_size; /* how many bytes do we want netserver to send 117 | at one time? */ 118 | int send_alignment; /* what is the alignment of the send */ 119 | /* buffer? */ 120 | int send_offset; /* and at what offset from that alignment? */ 121 | int no_delay; /* do we disable the nagle algorithm for send */ 122 | /* coalescing? */ 123 | int measure_cpu; /* does the client want server cpu utilization */ 124 | /* measured? */ 125 | float cpu_rate; /* do we know how fast the cpu is already? */ 126 | int test_length; /* how long is the test? */ 127 | int so_rcvavoid; /* do we want the remote to avoid copies on */ 128 | /* receives? */ 129 | int so_sndavoid; /* do we want the remote to avoid send copies? */ 130 | int dirty_count; /* how many integers in the send buffer */ 131 | /* should be made dirty before calling recv? */ 132 | int clean_count; /* how many integers should be read from the */ 133 | /* recv buffer before calling recv? */ 134 | int port; /* the port to which the recv side should bind 135 | to allow netperf to run through those evil 136 | firewall things */ 137 | int ipfamily; 138 | }; 139 | 140 | struct sdp_maerts_response_struct { 141 | int recv_buf_size; /* how big does the client want it */ 142 | int send_size; 143 | int no_delay; 144 | int measure_cpu; /* does the client want server cpu */ 145 | int test_length; /* how long is the test? */ 146 | int send_buf_size; 147 | int data_port_number; /* connect to me here */ 148 | float cpu_rate; /* could we measure */ 149 | int so_rcvavoid; /* could the remote avoid receive copies? */ 150 | int so_sndavoid; /* could the remote avoid send copies? */ 151 | }; 152 | 153 | struct sdp_maerts_results_struct { 154 | double bytes_sent; 155 | unsigned int send_calls; 156 | float elapsed_time; /* how long the test ran */ 157 | float cpu_util; /* -1 if not measured */ 158 | float serv_dem; /* -1 if not measured */ 159 | int cpu_method; /* how was cpu util measured? */ 160 | int num_cpus; /* how many CPUs had the remote? */ 161 | }; 162 | 163 | extern void send_sdp_stream(); 164 | extern void send_sdp_rr(); 165 | 166 | extern void recv_sdp_stream(); 167 | extern void recv_sdp_rr(); 168 | 169 | extern void loc_cpu_rate(); 170 | extern void rem_cpu_rate(); 171 | --------------------------------------------------------------------------------