Repository navigation
Expand file tree
/
Copy pathINSTALL
More file actions
496 lines (382 loc) · 19.3 KB
/
Copy pathINSTALL
File metadata and controls
496 lines (382 loc) · 19.3 KB
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2014 Free Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Advanced Installation
=====================
Visit http://tcpreplay.appneta.com/wiki/installation.html
Basic Installation
==================
./configure
make
sudo make install
Alternatively, with CMake (3.16 or higher):
cmake -B build
cmake --build build
sudo cmake --install build
The CMake build mirrors every `configure' option and is primarily aimed
at IDE users (VS Code, CLion) and out-of-tree developer builds; the
autotools build remains the canonical release build. See "CMake
Installation" below for details and examples.
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
How to make Tcpreplay go fast
=============================
1) netmap
------
This feature will detect netmap capable network drivers on Linux and
BSD systems. If detected, the network driver is bypassed for the
execution duration of tcpreplay and tcpreplay-edit, and network buffers
will be written to directly. This will allow you to achieve full 10GigE
line rates on commodity 10GigE network adapters, similar to rates
achieved by commercial network traffic generators.
Note that bypassing the network driver will disrupt other applications
connected through the test interface. Use caution when testing on the
same interface you ssh'ed into.
Ensure that you have supported NICs installed. Most Intel and nForce
(nVidia) adapters will work. Some virtual adapters are supported.
FreeBSD 10 and higher already contains netmap capabilities and should
be detected automatically by "configure". But first you must enable
netmap on the system by adding 'device netmap' to your kernel config
and rebuilding the kernel. When complete, /dev/netmap will be
available.
For Linux, download latest netmap sources from http://info.iet.unipi.it/~luigi/netmap/
or run 'git clone https://code.google.com/p/netmap/'. You will also need to have
kernel sources installed so the build system can patch the sources and build
netmap-enabled drivers. If kernel sources are in /a/b/c/linux-A.B.C/ , then you
should do:
cd netmap/LINUX
make KSRC=/a/b/c/linux-A.B.C/ # builds the kernel modules
make KSRC=/a/b/c/linux-A.B.C/ apps # builds sample applications
You can omit KSRC if your kernel sources are in a standard place.
Once you load the netmap.lin.ko module on your Linux machine, /dev/netmap
will be available. You will also need to replace your existing network drivers
(beyond the scope of this document).
Building netmap-aware Tcpreplay suite is relatively straight forward. For
FreeBSD, build normally. For Linux, if you extracted netmap into /usr/src/ you
can also build normally. Otherwise you will have to specify the netmap source
directory, for example:
./configure --with-netmap=/home/fklassen/git/netmap
make
sudo make install
or with CMake:
cmake -B build -DWITH_NETMAP=/home/fklassen/git/netmap
cmake --build build
sudo cmake --install build
2) AF_XDF
------
This feature will detect AF_XDP capable network drivers on Linux. If detected,
the `--xdp` option becomes available, allowing eBPF enabled adapters to be
written to directly.
This feature requires `libxdp-dev` and `libbpf-dev` packages to be installed.
For example:
$ sudo apt install -y libxdp-dev libbpf-dev
$ ./configure | tail
Linux/BSD netmap: no
Tuntap device support: yes
LIBXDP for AF_XDP socket: yes
$ make
$ sudo make install
$ tcpreplay -i eth0 --xdp test/test.pcap
If you want to compile a version that only uses AF_XDP, use the `--enable-force-libxdp`
configure option, e.g.
$ ./configure --enable-force-libxdp | tail
Linux/BSD netmap: no
Tuntap device support: yes
LIBXDP for AF_XDP socket: yes
$ make
$ sudo make install
$ tcpreplay -i eth0 test/test.pcap
3) io_uring
--------
This feature is detected on Linux systems that have the `liburing-dev`
package installed and a kernel with io_uring support. If detected, the
`--io-uring` option becomes available. Packets are still sent through a
PF_PACKET raw socket, but sends are submitted asynchronously through an
io_uring submission queue, reducing per-packet syscall overhead. For
example:
$ sudo apt install -y liburing-dev
$ ./configure | tail
LIBXDP for AF_XDP socket: no
liburing for io_uring: yes
$ make
$ sudo make install
$ tcpreplay -i eth0 --io-uring test/test.pcap
If you want to compile a version that only uses io_uring, use the
`--enable-force-liburing` configure option.
4) PF_INET raw IP sockets
-----------------------
By default tcpreplay injects packets with PF_PACKET, which writes directly
to the network driver below the IP stack - so locally-configured
netfilter/iptables rules never see the traffic, even when replaying on the
same host those rules are configured on (#465). This feature is detected
on Linux systems that support PF_INET/SOCK_RAW sockets with SO_BINDTODEVICE
(essentially all of them), enabling the `--raw` option, which instead sends
each packet's IP header and payload through a raw IP socket bound to the
outbound interface, so the kernel's normal IP stack - including
netfilter/iptables - processes it like any other locally-generated packet.
The trade-off is L2 fidelity: the kernel builds its own Ethernet framing,
so the captured source/destination MAC addresses are not reproduced, and
only IPv4 is currently supported. For example:
$ ./configure | tail
liburing for io_uring: yes
PF_INET SOCK_RAW (--raw): yes
$ make
$ sudo make install
$ tcpreplay -i eth0 --raw test/test.pcap
5) libtcpreplay C library
----------------------
Both build systems install libtcpreplay.a, the tcpreplay_api.h headers
(under include/tcpreplay/) and a libtcpreplay.pc pkg-config file, letting
applications embed the replay engine directly:
$ cc myapp.c $(pkg-config --cflags --libs --static libtcpreplay) -o myapp
See examples/replay_stats.c for a complete program and examples/README.md
for details.
CMake Installation
==================
As of version 4.6 the suite can also be built with CMake (3.16 or
higher). The CMake build mirrors configure.ac feature-for-feature:
every `--enable-FEATURE' and `--with-PACKAGE' flag has a CMake cache
variable equivalent. The full mapping table is in the header comment
of the top-level CMakeLists.txt. Summary:
./configure flag CMake equivalent
-------------------------- ----------------------------------
--enable-debug -DENABLE_DEBUG=ON
--enable-extra-debug -DENABLE_EXTRA_DEBUG=ON
--enable-asan -DENABLE_ASAN=ON
--enable-tsan -DENABLE_TSAN=ON
--enable-dmalloc -DENABLE_DMALLOC=ON
--enable-efence -DENABLE_EFENCE=ON
--enable-gprof -DENABLE_GPROF=ON
--enable-pedantic -DENABLE_PEDANTIC=ON
--enable-pcapconfig -DENABLE_PCAPCONFIG=ON
--disable-64bits -DENABLE_64BITS=OFF
--disable-tuntap -DENABLE_TUNTAP=OFF
--enable-static-link -DENABLE_STATIC_LINK=ON
--enable-test-hexdump -DENABLE_TEST_HEXDUMP=ON
--enable-force-libxdp -DFORCE_INJECT_LIBXDP=ON
(other --enable-force-*) -DFORCE_INJECT_<METHOD>=ON
--with-libpcap=DIR -DWITH_LIBPCAP=DIR
--with-netmap=DIR -DWITH_NETMAP=DIR
--with-pfring-lib=LIB -DWITH_PFRING_LIB=LIB
--with-libdnet=DIR -DWITH_LIBDNET=DIR
--with-tcpdump=FILE -DWITH_TCPDUMP=FILE
--with-testnic=NIC -DWITH_TESTNIC=NIC
--with-testnic2=NIC -DWITH_TESTNIC2=NIC
--with-macos-sdk=VER -DCMAKE_OSX_SYSROOT=<sdk path>
--prefix=PREFIX -DCMAKE_INSTALL_PREFIX=PREFIX
Examples:
# standard build
cmake -B build
cmake --build build
sudo cmake --install build
# debug build with AddressSanitizer
cmake -B build-asan -DENABLE_DEBUG=ON -DENABLE_ASAN=ON
cmake --build build-asan
# netmap from an out-of-tree checkout, custom libpcap
cmake -B build -DWITH_NETMAP=/usr/local/src/netmap \
-DWITH_LIBPCAP=/usr/local/opt/libpcap
# render man pages (requires asciidoctor)
cmake --build build --target manpages
Configure presets for common configurations (default, debug, asan,
tsan) are provided in CMakePresets.json; IDEs such as VS Code (with the
CMake Tools extension) and CLion pick these up automatically, e.g.
cmake --preset debug
cmake --build --preset debug
Notes:
- The AutoOpts-generated option parsers (*_opts.c/h) are NOT committed to
git - they're ordinary build products, matching this project's original
convention for generated files. scripts/autoopts (python3) regenerates
them at configure time from the .def files, but only if they're
missing or stale, so python3 is required to build from a git checkout
but not from a tarball that already ships them (see below). Man pages
(*.adoc/*.1) work differently: neither is needed to compile, so their
generation is wired into the build graph instead of happening eagerly
at configure time - a plain `cmake --build` never touches man pages at
all; only `cmake --build build --target manpages` above does,
regenerating *.adoc (python3) and rendering *.1 (asciidoctor) as
needed. GNU autogen (EOL) is only still needed for
src/tcpedit/tcpedit_stub.h, which does stay committed - see
scripts/autoopts/README.md.
- Release tarballs (`make dist`/`make dist-xz`) are produced by autotools
but buildable with either build system: they ship the already-built
*_opts.c/h and pre-built *.1 (matching the pre-#895 behavior of
shipping pre-built man pages, not autogen's separate mdoc source - see
docs/CHANGELOG), plus every CMakeLists.txt/CMakePresets.json/cmake/*
file, so building from a tarball needs none of
autogen/python3/asciidoctor with either build system. *.adoc is a
git-checkout-only build artifact and is never distributed.
- `make test' remains autotools-driven. The CMake build generates
test/config so the test fixtures can be used, but running the test
suite still requires the autotools flow described above.
- CMake is the primary, recommended way to build the suite; autotools
remains required to produce release tarballs and to run `make test`.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.