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