-
Notifications
You must be signed in to change notification settings - Fork 1
/
udpbench.1
277 lines (277 loc) · 7.59 KB
/
udpbench.1
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
.\" $OpenBSD$
.\"
.\" Copyright (c) 2022 Alexander Bluhm <[email protected]>
.\"
.\" 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$
.Dt UDPBENCH 1
.Os
.Sh NAME
.Nm udpbench
.Nd udp network benchmarking tool
.Sh SYNOPSIS
.Nm
.Bk -words
.Op Fl DH
.Op Fl B Ar bitrate
.Op Fl b Ar bufsize
.Op Fl d Ar delay
.Op Fl i Ar idle
.Op Fl l Ar length
.Op Fl m Ar mmsglen
.Op Fl N Ar repeat
.Op Fl P Ar packetrate
.Op Fl p Ar port
.Op Fl R Ar remoteprog
.Op Fl r Ar remotessh
.Op Fl t Ar timeout
.Cm send | recv
.Op Ar hostname
.Ek
.Sh DESCRIPTION
The
.Nm
benchmark tool sends or receives UDP packets between two IP end points.
It measures the thoughput on both sides.
The local action has to be given as
.Cm send
or
.Cm recv .
.Ar hostname
is the IP address for
.Xr connect 2
when sending
or
.Xr bind 2
when receiving.
In the latter case it is optional, then the unspecified address is
used.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl B Ar bitrate
The value specifies the number of bits to send over the wire within
a second.
The size of the ethernet frame is calculaed from UDP payload length.
This adds a small delay between
.Xr send 2
system calls if packets would be generated too fast otherwise.
.It Fl b Ar bufsize
Set size of send or receive socket buffer.
.It Fl D
.Ox
.Xr pf 4
.Ic divert-packet
is used to receive packets on divert socket.
The pf rule has to be configured manually, the option only changes
the socket type on the
.Cm recv
side.
In
.Cm send
mode this option has no effect on local sending.
With dynamic
.Ic ssh
the option is passed to the remote process.
.It Fl d Ar delay
Sleep some seconds before sending packets with payload.
This is useful to wait for setup of multiple processes via ssh.
An initial empty packet is sent before delay to trigger setup.
Default is 0 seconds which disables the feature.
.It Fl H
Use IPv6 hop-by-hop option by adding a router alert when sending.
.It Fl i Ar idle
After a period of not receiving any packets, the recv side will stop.
Default is 1 second, 0 will ignore idle periods.
.It Fl l Ar length
Set length of the UDP payload for sending, or length of the userland
buffer for receiving the packet.
By default the payload is empty.
.It Fl m Ar mmsglen
Use
.Xr recvmmsg 2
and
.Xr sendmmsg 2
and set the amount of simultaneously handled messages.
Default is to use
.Xr recv 2
and
.Xr send 2 .
This can be explicity enforced by setting
.Ar mmsglen
to 0.
.It Fl N Ar repeat
Fork multiple processes to send or receive in parallel.
For each process the IP address is incremented by one to get load
balancing.
.It Fl P Ar packetrate
The value specifies the number of packets to send within a second.
This adds a small delay between
.Xr send 2
system calls if packets would be generated too fast otherwise.
.It Fl p Ar port
The destination UDP port is 12345 by default.
When set to 0, a random port is used.
.It Fl R Ar remoteprog
When the remote side is started dynamically via
.Ic ssh ,
use this path for the
.Nm
program.
By default the remote program is invoked the same way as the local
.Nm .
.It Fl r Ar remotessh
The receiving and sending process can be started manually or
dynamically.
If the
.Ar remotessh
location is given as
.Cm user@host ,
an
.Nm
process is started on the remote machine with the
.Cm send
and
.Cm recv
parameter excanged.
.It Fl t Ar timeout
Set the duration for sending packets.
When receiving, all packets have to arrive within this timeout plus
two seconds.
Disable timeout with 0 and run forever.
Default is 1 second.
.El
.Sh EXAMPLES
Receive UDP packets on any address and port 12345.
Run for 12 seconds to process all input.
.D1 Nm Fl t Ar 10 Cm recv
.Pp
Send empty UDP packets to local host port 12345.
Run for 10 seconds and process as much as possible.
.D1 Nm Fl t Ar 10 Cm send Ar 127.0.0.1
.Pp
Test throughput of loopback interface for one second.
Two
.Nm
processes are started, one with
.Cm send
and one dynamically with
.Cm recv .
As the destination port is random, but is the same for both sides,
multiple instances can be started in parallel.
.D1 Nm Fl r Ar localhost Fl p Ar 0 Cm send Ar 127.0.0.1
.Pp
Log into remove host and receive packets from there.
The address of the receiving side is not optional.
.D1 Nm Fl r Ar root@remotehost Cm recv Ar localip
.Pp
This sends the traffic in the opposite direction of the previous
example.
.D1 Nm Fl r Ar root@remotehost Cm send Ar remoteip
.Pp
Receive packets from remote host and divert them to local socket.
This needs configuration in
.Xr pf.conf 5 .
.D1 Ic pass Ic proto Ic udp Ic to Ar localip Ic port Ar 1234 Ic divert-packet Ic port Ar 1234
.D1 Nm Fl D Fl p Ar 1234 Fl r Ar root@remotehost Cm recv Ar localip
.Sh DIAGNOSTICS
.Bl -diag
.It "udpbench recv: recv 1: Interrupted system call"
While the receiver was waiting for the first packet, the timeout
triggered.
Check connectivity, start sender quickly after receiver, increase
.Fl t Ar timeout .
.It "udpbench recv: not enough idle time"
For the receiving side the stream of packets finishes after 1 second
idle time.
If the receive timeout happens earlier, the measurement is incomplete.
Increase
.Fl t Ar timeout .
.It "send: syscalls 812635, packets 812635, frame 1, payload 1452, ip 1500, ether 1538, begin 1706272739.464771, end 1706272749.464692, duration 9.999921, bit/s 9.99874e+08, start 1706272738.464447, stop 1706272749.464716"
.Pp
Summary of
.Nm
sending side.
Status is printed as single line just before exit.
.Bl -tag -width 8
.It syscalls
Number of
.Xr send 2
or
.Xr sendmmsg 2
system calls made.
.It packets
Number of packets sent.
.It frame
Number of ethernet frames for each packet.
.It payload
Bytes in the UDP payload.
.It ip
Length of IP packet.
.It ether
Length of ethernet frame.
.It begin
Time stamp when the first packet with payload was sent.
If
.Fl d Ar delay
is set, this is after the sleeping delay.
.It end
Time stamp after the final packet was sent.
.It duration
Time between begin and end.
.It bit/s
Bits of all packets in ethernet size during duration per second.
.It start
Time stamp after socket is connected.
.It stop
Time stamp before socket is closed.
.El
.It "recv: syscalls 374484, packets 374431, frame 1, payload 1452, ip 1500, ether 1538, begin 1706272739.464876, end 1706272749.473193, duration 10.008317, bit/s 4.60317e+08, start 1706272738.024436, stop 1706272754.024705"
.Pp
Summary of
.Nm
receiving side, only difference to send is explained.
.Bl -tag -width 8
.It syscalls
Number of
.Xr recv 2
or
.Xr recvmmsg 2
system calls made.
.It packets
Number of packets received.
.It begin
Time stamp when the first packet with payload was received.
If
.Fl d Ar delay
is set, this is after the empty packet starting the delay.
.It end
Time stamp after the final packet was received.
If
.Fl i Ar idle
is set, end is the time before idle timed out.
.It start
Time stamp after socket is bound.
.El
.El
.Sh SEE ALSO
.Xr tcpbench 1
.Sh AUTHORS
The
.Nm
program was written by
.An Alexander Bluhm Aq Mt [email protected] .
.Sh BUGS
The number of ethernet frames and their size is calculated.
With vlan or jumbo it will be wrong.