xdp-trafficgen(8)

NAME
XDP-trafficgen - an XDP-based traffic generator

SYNOPSIS

XDP-trafficgen is a packet generator utilising the XDP kernel subsystem to generate packets transmit them through a network interface. Packets are dynamically generated and transmitted in the kernel, allowing for high performance (millions of packets per second per core).

XDP-trafficgen supports generating UDP traffic with fixed or dynamic destination ports, and also has basic support for generating dummy TCP traffic on a single flow.

  Running xdp-traffigen

The syntax for running xdp-trafficgen is:

    Usage: xdp-trafficgen COMMAND [options]

    COMMAND can be one of:
           udp         - run in UDP mode
           xsk-udp     - run in UDP mode (using AF_XDP sockets)
           tcp         - run in TCP mode
           probe       - probe kernel support

Each command, and its options are explained below. Or use xdp-trafficgen COMMAND --help to see the options for each command.

The UDP command

The UDP command generates UDP traffic to a given destination IP and either a fixed destination port, or a range of port numbers. Only IPv6 traffic is supported, and the generated packets will have their IP hop limit set to 1, so they can't be routed.

The syntax for the udp command is:

xdp-trafficgen udp [options] <ifname>

Where <ifname> is the name of the destination interface that packets will be transmitted on. Note that the network driver of this network interface must support being the target of XDP redirects (it must implement the ndo_xdp_xmit driver operation).

The supported options are:

  -m, --dst-mac <mac addr>

Set the destination MAC address of generated packets. The default is to generate packets with an all-zero destination MAC.

  -M, --src-mac <mac addr>

Set the source MAC address of the generated packets. The default is to use the MAC address of the interface packets are transmitted on.

  -a, --dst-addr <addr>

Destination IP address of generated packets. The default is the link-local fe80::2 address.

  -A, --src-addr <addr>

Source IP address of generated packets. The default is the link-local fe80::1 address.

  -p, --dst-port <port>

Destination UDP port of generated packets, or the first port in the range if running with --dyn-ports set. Defaults to 1.

  -P, --src-port <port>

Source UDP port of generated packets. Defaults to 1.

  -d, --dyn-ports <num ports>

Enable dynamic port mode where the destination port is varied over a range of <num ports> starting from the --dst-port.

  -n, --num-packets <num packets>

Number of packets to send before exiting. If not supplied, xdp-trafficgen will keep sending packets until interrupted.

  -s, --pkt-size <bytes>

Size of each UDP packet being sent, including the Ethernet header and checksum. Since xdp-trafficgen generates IPv6 traffic, the minimum size, which is also the default, is 66 bytes.

Older versions of xdp-trafficgen failed to account for the four-byte ethernet checksum that is added at the end of packet, which meant that 64 was allowed (and the default) for size, even though this really generated 68-byte packets on the wire. To be able to fix this bug without breaking existing users, values of 64 or 65 will be clamped to the actual minimum value of 66 with a warning, instead of producing an error.

  -t, --threads <threads>

Number of simultaneous threads to transmit from. Each thread will be pinned to a separate CPU core if possible. Defaults to 1.

  -I, --interval <s>

Output transmission statistics with this interval (in seconds).

  -v, --verbose

Enable verbose logging (-vv: more verbose).

  --version

Display version information and exit.

  -h, --help

Display a summary of the available options

The XSK-UDP command

The xsk-udp command also generates UDP traffic, but does so using an AF_XDP socket generates the traffic in userspace. This can be used to test and benchmark AF_XDP sockets for transmitting.

The code for this commands is derived from the xdpsock utility previously part of the kernel sources, and more recently the bpf-examples repository. This command corresponds to the --txonly option of xdpsock.

The syntax for this command is:

xdp-trafficgen xsk-udp [options] <ifname>

The supported options are:

  -m, --dst-mac <mac addr>

Set the destination MAC address of generated packets. The default is to generate packets with an all-zero destination MAC.

  -M, --src-mac <mac addr>

Set the source MAC address of the generated packets. The default is to use the MAC address of the interface packets are transmitted on.

  -y, --timestamp

Add a timestamp to each packet, using the same header format used by the kernel pktgen utility.

  -V, --vlan-tag

Add a vlan tag to packets, using the ID and PRI specified using the --vlan-id and --vlan-pri options.

  -J, --vlan-id

Set the vlan ID used for packets. Only has an effect when the --vlan-tag option is set. Default: 1.

  -K, --vlan-pri

Set the vlan PRI used for packets. Only has an effect when the --vlan-tag option is set. Default: 0.

  -P, --fill-pattern <pattern>

Use this pattern to fill the packet data. The data pattern is specified as a 32-bit hex value, and defaults to 0.

  -T, --tx-cycle-time <us>

Specify an interval between packet bursts, in microseconds. Each interval, a burst of --batch-size packets are sent. The default is 0 (send packets as fast as possible).

  -q, --queue <queue>

Select the hardware receive queue to use for the test. The AF_XDP socket is bound to this queue, which means that xdp-trafficgen will process all packets arriving on it. The default is to use queue 0.

  -i, --interval <seconds>

Set the polling interval for collecting all statistics and displaying them to the output. The default interval is 2 seconds.

  -O, --retries <number>

Set the maximum number retries when completing the last packets of a test run. When ending a test run, xdp-trafficgen will try to release the last packet ring descriptors before exiting, retrying this many times with a 1-second interval in-between. This is only used when --pkt-count is set.

  -f, --frame-size <size>

Set the size of the memory frames used to transmit packets. Packets will always use a memory chunk of this size, regardless of the size of the packet on the wire. The size must be a power of two, unless the --unaligned flag is used. The default is 4096 bytes (which corresponds to the page size on most systems).

  -s, --pkt-size <size>

Set the size of the packets being transmitted. This must be between 64 and 9728 bytes, and defaults to 64.

  -d, --duration <seconds>

Set the test duration, in seconds. The default is 0 (run forever, or until --pkt-count packets have been sent).

  -c, --pkt-count <number>

Set the total number of packets to transmit before exiting. The default is 0 (which means run forever, or until --duration is reached).

  -b, --batch-size <packets>

Set the batch size for the packet processing loop. This is the number of packets sent at once each time the loop runs. The default is 64 packets. See also --tx-cycle-time.

  -I, --irq-string <irq-string>

Enable printing of interrupt statistics for the interrupt number associated with irq-string in /proc/interrupts. The string is used to find a matching IRQ number by simple substring matching. No default (which means no IRQ statistics are printed).

  -p, --poll

Use the poll() system call to get notifications for when a socket is ready to transmit new packets, instead of running in a loop constantly attempting to transmit.

  -m, --no-need-wakeup

Don't set the XDP_USE_NEED_WAKEUP flag when binding the AF_XDP socket. The flag is set by default, and causes the kernel driver to occasionally go to sleep and yield the CPU to the userspace application when processing packets.

  -u, --unaligned

Support sending unaligned packets, i.e., packets that are not aligned to the beginning of a data frame. When set, xdp-trafficgen will enable huge pages for the userspace memory buffer used to hold the packet data being transmitted. Setting this option enables frame sizes that are not a power of two (see the --frame-size option).

  -M, --shared-umem

Enable shared userspace memory across multiple AF_XDP sockets. When this option is set, xdp-trafficgen will create four sockets that share the same userspace memory buffer, and packets will be sent on each socket in a round-robin fashion.

  -x, --extra-stats

Print extra packet statistics at each output interval.

  -Q, --quiet

Don't print any statistics at each output interval.

  -a, --app-stats

Print additional application-level statistics at each output interval.

  -C, --copy-mode <mode>

Select the copying mode for the packets. Set to one of auto, copy, or zero-copy. The default is auto, which lets the kernel pick. Using zero-copy requires kernel and driver support, and can only be used when attaching the XDP program in native mode (see --attach-mode).

  -w, --clock <clock>

Choose the clock that will be used for all timer events in the application. The valid values are MONOTONIC, REALTIME, TAI and BOOTTIME, and the default is MONOTONIC.

  -W, --policy <policy>

Set the scheduler policy for the application before running. Valid values are SCHED_OTHER and SCHED_FIFO, and the default is SCHED_OTHER.

  -U, --schpri <priority>

Set the scheduler priority when using SCHED_FIFO. Defaults to 0.

  -A, --attach-mode <mode>

Set the XDP program attach mode (native or skb) of the XDP program that xdp-trafficgen attaches to the interface to enable XDP support. The default is native mode. Note that zero-copy can only be used in native mode.

  -v, --verbose

Enable verbose logging. Supply twice to enable verbose logging from the underlying libxdp and libbpf libraries.

  --version

Show the application version and exit.

  -h, --help

Display a summary of the available options

The TCP command

The TCP command generates dummy TCP traffic in a single TCP flow. This relies on first installing an ingress XDP program on the interface used to transmit on. Then, a regular TCP socket connection is established from userspace, and once the handshake is completed, the XDP program will take over and start generating traffic on that flow tuple. The ingress XDP program will intercept ACK packets from the receiver, and keep track of the receive window.

The traffic generator has no congestion control, and only very basic retransmit tracking: in essence, any duplicate ACKs from the receiver will cause the sender to reset its send sequence number to the last ACKed value and restart from there. The same thing happens if no progress on the window is made within two seconds. This means that the traffic generator can generate a large amount of dummy traffic, but if there's packet loss a lot of this can be retransmissions.

The syntax for the tcp command is:

xdp-trafficgen tcp [options] -i <ifname> <hostname>

Where <ifname> is the name of the destination interface that packets will be transmitted on and <hostname> is the peer hostname or IP address to connect to (only IPv6 is supported). Note that the network driver of this network interface must support being the target of XDP redirects (it must implement the ndo_xdp_xmit driver operation).

The supported options are:

  -p, --dst-port <port>

Connect to destination <port>. Default 10000.

  -m, --mode <mode>

Load ingress XDP program in <mode>; default native (valid values: native,skb,hw)

  -n, --num-packets <port>

Number of packets to send before exiting. If not supplied, xdp-trafficgen will keep sending packets until interrupted.

  -I, --interval <s>

Output transmission statistics with this interval (in seconds).

  -v, --verbose

Enable verbose logging (-vv: more verbose).

  --version

Display version information and exit.

  -h, --help

Display a summary of the available options

The PROBE command

The PROBE command probes the kernel to discover whether it supports the features needed to run xdp-trafficgen. This can be used to discover whether the running kernel is compatible with xdp-trafficgen, as well as to discover whether a particular interface supports sending packets generated by xdp-trafficgen.

The syntax for the probe command is:

xdp-trafficgen probe [options]

After probing, xdp-trafficgen will print the results of the probing of the kernel, and (if an interface name is supplied), whether the interface supports sending packets generated by xdp-trafficgen. The exit code will be 0 if all probes succeed, and 1 otherwise.

Note that the probing relies on the kernel XDP feature reporting, which was added after the XDP support itself. This means that with some older kernel versions, the probing may fail even though xdp-trafficgen would in fact be able to transmit packets.

The supported options are:

  -i, --ifname <ifname>

Probe the supplied interface name, in addition to doing the general kernel probing.

  -v, --verbose

Enable verbose logging (-vv: more verbose).

  --version

Display version information and exit.

  -h, --help

Display a summary of the available options

BUGS

Please report any bugs on Github: https://github.com/xdp-project/xdp-tools/issues

AUTHOR

xdp-trafficgen and this man page were written by Toke Høiland-Jørgensen.