1.\" $OpenBSD: tcpbench.1,v 1.22 2016/07/21 10:42:49 jmc Exp $ 2.\" 3.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: July 21 2016 $ 18.Dt TCPBENCH 1 19.Os 20.Sh NAME 21.Nm tcpbench 22.Nd TCP/UDP benchmarking and measurement tool 23.Sh SYNOPSIS 24.Nm 25.Fl l 26.Nm 27.Op Fl 46RUuv 28.Op Fl B Ar buf 29.Op Fl b Ar addr 30.Op Fl k Ar kvars 31.Op Fl n Ar connections 32.Op Fl p Ar port 33.Op Fl r Ar interval 34.Op Fl S Ar space 35.Op Fl T Ar toskeyword 36.Op Fl t Ar secs 37.Op Fl V Ar rtable 38.Ar hostname 39.Nm 40.Bk -words 41.Fl s 42.Op Fl 46Uuv 43.Op Fl B Ar buf 44.Op Fl k Ar kvars 45.Op Fl p Ar port 46.Op Fl r Ar interval 47.Op Fl S Ar space 48.Op Fl T Ar toskeyword 49.Op Fl V Ar rtable 50.Op Ar hostname 51.Ek 52.Sh DESCRIPTION 53.Nm 54is a small tool that performs throughput benchmarking and concurrent 55sampling of kernel network variables. 56.Pp 57.Nm 58is run as a client/server pair. 59The server must be invoked with the 60.Fl s 61flag, which will cause it to listen for incoming connections. 62The client must be invoked with the 63.Ar hostname 64of a listening server to connect to. 65.Pp 66Once connected, the client will send TCP or UDP traffic as fast as possible to 67the server. 68Both the client and server will periodically display throughput 69statistics along with any kernel variables the user has selected to 70sample (using the 71.Fl k 72option, which is only available in TCP mode). 73A list of available kernel variables may be obtained using the 74.Fl l 75option. 76.Pp 77The options are as follows: 78.Bl -tag -width Ds 79.It Fl 4 80Forces 81.Nm 82to use IPv4 addresses only. 83.It Fl 6 84Forces 85.Nm 86to use IPv6 addresses only. 87.It Fl B Ar buf 88Specify the size of the internal read/write buffer used by 89.Nm . 90The default is 262144 bytes for TCP client/server and UDP server. 91In UDP client mode this may be used to specify the packet size on the test 92stream. 93.It Fl b Ar addr 94Specifies the IP address of the interface which is used to send the packets. 95.It Fl k Ar kvars 96Specify one or more kernel variables to monitor; multiple variables must be 97separated with commas. 98This option is only valid in TCP mode. 99The default is not to monitor any variables. 100Using this option requires read access to 101.Pa /dev/kmem . 102.It Fl l 103List the name of kernel variables available for monitoring and exit. 104.It Fl n Ar connections 105Use the given number of TCP connections (default: 1). 106UDP is connectionless so this option isn't valid. 107.It Fl p Ar port 108Specify the port used for the test stream (default: 12345). 109.It Fl R 110In client mode the write buffer size is randomized up to the size specified via 111.Fl B . 112.It Fl r Ar interval 113Specify the statistics interval reporting rate in milliseconds (default: 1000). 114.It Fl S Ar space 115Set the size of the socket buffer used for the test stream. 116On the client this option will resize the send buffer; 117on the server it will resize the receive buffer. 118.It Fl s 119Place 120.Nm 121in server mode, where it will listen on all interfaces for incoming 122connections. 123It defaults to using TCP if 124.Fl u 125is not specified. 126.It Fl T Ar toskeyword 127Change the IPv4 TOS or IPv6 TCLASS value. 128.Ar toskeyword 129may be one of 130.Ar critical , 131.Ar inetcontrol , 132.Ar lowdelay , 133.Ar netcontrol , 134.Ar throughput , 135.Ar reliability , 136or one of the DiffServ Code Points: 137.Ar ef , 138.Ar af11 ... af43 , 139.Ar cs0 ... cs7 ; 140or a number in either hex or decimal. 141.It Fl t Ar secs 142Stop after 143.Ar secs 144seconds. 145.It Fl U 146Use AF_UNIX sockets instead of IPv4 or IPv6 sockets. 147In client and server mode 148.Ar hostname 149is used as the path to the AF_UNIX socket. 150.It Fl u 151Use UDP instead of TCP; this must be specified on both the client 152and the server. 153Transmitted packets per second (TX PPS) will be accounted on the client 154side, while received packets per second (RX PPS) will be accounted on the 155server side. 156UDP has no Protocol Control Block (PCB) so the 157.Fl k 158flags don't apply. 159.It Fl V Ar rtable 160Set the routing table to be used. 161.It Fl v 162Display verbose output. 163If specified more than once, increase the detail of information displayed. 164.El 165.Sh SEE ALSO 166.Xr netstat 1 , 167.Xr pstat 8 168.Sh HISTORY 169The 170.Nm 171program first appeared in 172.Ox 4.4 . 173.Sh AUTHORS 174.An -nosplit 175The 176.Nm 177program was written by 178.An Damien Miller Aq Mt djm@openbsd.org . 179.Pp 180UDP mode and libevent port by 181.An Christiano F. Haesbaert Aq Mt haesbaert@haesbaert.org . 182