1.\" $OpenBSD: tcpbench.1,v 1.29 2021/02/04 18:46:25 bluhm 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: February 4 2021 $ 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 46DRUuv 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 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 46DUuv 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 compute and display throughput 69statistics. 70The server starts computing these for UDP on receipt of the first datagram, 71and stops for TCP when it has no connections. 72This display also includes any kernel variables the user has selected to 73sample (using the 74.Fl k 75option, which is only available in TCP mode). 76A list of available kernel variables may be obtained using the 77.Fl l 78option. 79.Pp 80A summary over the periodic throughput statistics is displayed on exit. 81Its accuracy may be increased by decreasing the 82.Ar interval . 83The summary bytes and duration cover the interval from transfer start 84to process exit. 85The summary information can also be displayed while 86.Nm 87is running by sending it a 88.Dv SIGINFO 89signal (see the 90.Cm status 91argument of 92.Xr stty 1 93for more information). 94.Pp 95The options are as follows: 96.Bl -tag -width Ds 97.It Fl 4 98Force 99.Nm 100to use IPv4 addresses only. 101.It Fl 6 102Force 103.Nm 104to use IPv6 addresses only. 105.It Fl B Ar buf 106Specify the size of the internal read/write buffer used by 107.Nm . 108The default is 262144 bytes for TCP client/server and UDP server. 109In UDP client mode this may be used to specify the packet size on the test 110stream. 111.It Fl b Ar sourceaddr 112Specify the IP address to send the packets from, 113which is useful on machines with multiple interfaces. 114.It Fl D 115Enable debugging on the socket. 116.It Fl k Ar kvars 117Specify one or more kernel variables to monitor; multiple variables must be 118separated with commas. 119This option is only valid in TCP mode. 120The default is not to monitor any variables. 121Using this option requires read access to 122.Pa /dev/kmem , 123which may be restricted based upon the value of the 124.Ar kern.allowkmem 125.Xr sysctl 8 . 126.It Fl l 127List the name of kernel variables available for monitoring and exit. 128.It Fl n Ar connections 129Use the given number of TCP connections (default: 1). 130UDP is connectionless so this option isn't valid. 131.It Fl p Ar port 132Specify the port used for the test stream (default: 12345). 133.It Fl R 134In client mode the write buffer size is randomized up to the size specified via 135.Fl B . 136.It Fl r Ar interval 137Specify the statistics interval reporting rate in milliseconds (default: 1000). 138If set to 0, nothing is printed. 139.It Fl S Ar space 140Set the size of the socket buffer used for the test stream. 141On the client this option will resize the send buffer; 142on the server it will resize the receive buffer. 143.It Fl s 144Place 145.Nm 146in server mode, where it will listen on all interfaces for incoming 147connections. 148It defaults to using TCP if 149.Fl u 150is not specified. 151.It Fl T Ar toskeyword 152Change the IPv4 TOS or IPv6 TCLASS value. 153.Ar toskeyword 154may be one of 155.Ar critical , 156.Ar inetcontrol , 157.Ar lowdelay , 158.Ar netcontrol , 159.Ar throughput , 160.Ar reliability , 161or one of the DiffServ Code Points: 162.Ar ef , 163.Ar af11 ... af43 , 164.Ar cs0 ... cs7 ; 165or a number in either hex or decimal. 166.It Fl t Ar secs 167Stop after 168.Ar secs 169seconds. 170.It Fl U 171Use AF_UNIX sockets instead of IPv4 or IPv6 sockets. 172In client and server mode 173.Ar hostname 174is used as the path to the AF_UNIX socket. 175.It Fl u 176Use UDP instead of TCP; this must be specified on both the client 177and the server. 178Transmitted packets per second (TX PPS) will be accounted on the client 179side, while received packets per second (RX PPS) will be accounted on the 180server side. 181UDP has no Protocol Control Block (PCB) so the 182.Fl k 183flags don't apply. 184.It Fl V Ar rtable 185Set the routing table to be used. 186.It Fl v 187Display verbose output. 188If specified more than once, increase the detail of information displayed. 189.El 190.Sh SEE ALSO 191.Xr netstat 1 , 192.Xr pstat 8 193.Sh HISTORY 194The 195.Nm 196program first appeared in 197.Ox 4.4 . 198.Sh AUTHORS 199.An -nosplit 200The 201.Nm 202program was written by 203.An Damien Miller Aq Mt djm@openbsd.org . 204.Pp 205UDP mode and libevent port by 206.An Christiano F. Haesbaert Aq Mt haesbaert@haesbaert.org . 207