1.\" $OpenBSD: tcpbench.1,v 1.32 2024/11/06 06:40:16 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: November 6 2024 $ 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 46cDRUuv 28.Op Fl B Ar buf 29.Op Fl b Ar sourceaddr 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 keyword 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 46cDUuv 43.Op Fl B Ar buf 44.Op Fl C Ar certfile Fl K Ar keyfile 45.Op Fl k Ar kvars 46.Op Fl p Ar port 47.Op Fl r Ar interval 48.Op Fl S Ar space 49.Op Fl T Ar keyword 50.Op Fl V Ar rtable 51.Op Ar hostname 52.Ek 53.Sh DESCRIPTION 54.Nm 55is a small tool that performs throughput benchmarking and concurrent 56sampling of kernel network variables. 57.Pp 58.Nm 59is run as a client/server pair. 60The server must be invoked with the 61.Fl s 62flag, which will cause it to listen for incoming connections. 63The client must be invoked with the 64.Ar hostname 65of a listening server to connect to. 66.Pp 67Once connected, the client will send TCP or UDP traffic as fast as possible to 68the server. 69Both the client and server will periodically compute and display throughput 70statistics. 71The server starts computing these for UDP on receipt of the first datagram, 72and stops for TCP when it has no connections. 73This display also includes any kernel variables the user has selected to 74sample (using the 75.Fl k 76option, which is only available in TCP mode). 77A list of available kernel variables may be obtained using the 78.Fl l 79option. 80.Pp 81A summary over the periodic throughput statistics is displayed on exit. 82Its accuracy may be increased by decreasing the 83.Ar interval . 84The summary bytes and duration cover the interval from transfer start 85to process exit. 86The summary information can also be displayed while 87.Nm 88is running by sending it a 89.Dv SIGINFO 90signal (see the 91.Cm status 92argument of 93.Xr stty 1 94for more information). 95.Pp 96The options are as follows: 97.Bl -tag -width Ds 98.It Fl 4 99Force 100.Nm 101to use IPv4 addresses only. 102.It Fl 6 103Force 104.Nm 105to use IPv6 addresses only. 106.It Fl B Ar buf 107Specify the size of the internal read/write buffer used by 108.Nm . 109The default is 262144 bytes for TCP client/server and UDP server. 110In UDP client mode this may be used to specify the packet size on the test 111stream. 112.It Fl b Ar sourceaddr 113Specify the IP address to send the packets from, 114which is useful on machines with multiple interfaces. 115.It Fl C Ar certfile 116Load the public key part of the TLS peer certificate from 117.Ar certfile , 118in PEM format. 119Requires 120.Fl s 121and 122.Fl c . 123.It Fl c 124Use TLS to connect or listen. 125.It Fl D 126Enable debugging on the socket. 127.It Fl K Ar keyfile 128Load the TLS private key from 129.Ar keyfile , 130in PEM format. 131Requires 132.Fl s 133and 134.Fl c . 135.It Fl k Ar kvars 136Specify one or more kernel variables to monitor; multiple variables must be 137separated with commas. 138This option is only valid in TCP mode. 139The default is not to monitor any variables. 140.It Fl l 141List the name of kernel variables available for monitoring and exit. 142.It Fl n Ar connections 143Use the given number of TCP connections (default: 1). 144UDP is connectionless so this option isn't valid. 145.It Fl p Ar port 146Specify the port used for the test stream (default: 12345). 147.It Fl R 148In client mode the write buffer size is randomized up to the size specified via 149.Fl B . 150.It Fl r Ar interval 151Specify the statistics interval reporting rate in milliseconds (default: 1000). 152If set to 0, nothing is printed. 153.It Fl S Ar space 154Set the size of the socket buffer used for the test stream. 155On the client this option will resize the send buffer; 156on the server it will resize the receive buffer. 157.It Fl s 158Place 159.Nm 160in server mode, where it will listen on all interfaces for incoming 161connections. 162It defaults to using TCP if 163.Fl u 164is not specified. 165.It Fl T Ar keyword 166Change the IPv4 TOS or IPv6 TCLASS value. 167.Ar keyword 168may be one of 169.Ar critical , 170.Ar inetcontrol , 171.Ar lowdelay , 172.Ar netcontrol , 173.Ar throughput , 174.Ar reliability , 175or one of the DiffServ Code Points: 176.Ar ef , 177.Ar af11 ... af43 , 178.Ar cs0 ... cs7 ; 179or a number in either hex or decimal. 180.Pp 181For TLS options, 182.Ar keyword 183specifies a value in the form of a 184.Ar key Ns = Ns Ar value 185pair: 186.Cm ciphers , 187which allows the supported TLS ciphers to be specified (see 188.Xr tls_config_set_ciphers 3 189for further details) or 190.Cm protocols , 191which allows the supported TLS protocols to be specified (see 192.Xr tls_config_parse_protocols 3 193for further details). 194Specifying TLS options requires 195.Fl c . 196.It Fl t Ar secs 197Stop after 198.Ar secs 199seconds. 200.It Fl U 201Use AF_UNIX sockets instead of IPv4 or IPv6 sockets. 202In client and server mode 203.Ar hostname 204is used as the path to the AF_UNIX socket. 205.It Fl u 206Use UDP instead of TCP; this must be specified on both the client 207and the server. 208Transmitted packets per second (TX PPS) will be accounted on the client 209side, while received packets per second (RX PPS) will be accounted on the 210server side. 211UDP has no Protocol Control Block (PCB) so the 212.Fl k 213flags don't apply. 214.It Fl V Ar rtable 215Set the routing table to be used. 216.It Fl v 217Display verbose output. 218If specified more than once, increase the detail of information displayed. 219.El 220.Sh SEE ALSO 221.Xr netstat 1 , 222.Xr pstat 8 223.Sh HISTORY 224The 225.Nm 226program first appeared in 227.Ox 4.4 . 228.Sh AUTHORS 229.An -nosplit 230The 231.Nm 232program was written by 233.An Damien Miller Aq Mt djm@openbsd.org . 234.Pp 235UDP mode and libevent port by 236.An Christiano F. Haesbaert Aq Mt haesbaert@haesbaert.org . 237