xdp-trafficgen(8)
π xdp-trafficgen(8) β An XDP-based traffic generator π
okay bestie, sit down, hydrate, because we're about to talk about xdp-trafficgen β the little packet generator that could, and honestly did. It's an XDP-based traffic generator and it is so much faster than whatever you were using before, I promise.
β¨ NAME β¨
xdp-trafficgen β an XDP-based traffic generator π¦
β¨ SYNOPSIS β¨
XDP-trafficgen is a packet generator that uses the XDP kernel subsystem to make packets and yeet them out a network interface. The packets get generated dynamically and transmitted inside the kernel, which is the whole reason it's got that millions of packets per second per core energy. No cap. π₯
It supports generating UDP traffic with fixed or dynamic destination ports, and it also has basic support for generating dummy TCP traffic on a single flow (that's the whole TCP situation, don't get your hopes up, it's giving "basic").
π 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
Every command and its options are explained down below, bestie. Or honestly, if you want the options for just one command, hit it with xdp-trafficgen COMMAND --help and it'll spill everything for that one. π
πΈ The UDP command πΈ
The udp command generates UDP traffic to a destination IP you pick, and either a fixed destination port or a range of port numbers. Heads up though: only IPv6 traffic is supported, and the generated packets get their IP hop limit set to 1, so like... they cannot be routed. They live and die locally. It's giving homebody. π
The syntax for the udp command is:
xdp-trafficgen udp [options] <ifname>
Where <ifname> is the name of the destination interface the packets get transmitted on. And bestie, listen: the network driver of this interface must support being the target of XDP redirects β it has to implement the ndo_xdp_xmit driver operation. If it doesn't, this whole thing is a no. π«Ά
The supported options are:
β OPTIONS (UDP) β
-m,--dst-mac <mac addr>β sets the destination MAC address on the generated packets. Default vibe: all-zero destination MAC. π-M,--src-mac <mac addr>β sets the source MAC address on the generated packets. Default is to just use the MAC address of the interface the packets go out on. Efficient, honestly.-a,--dst-addr <addr>β the destination IP address of the generated packets. Defaults to the link-localfe80::2address. π-A,--src-addr <addr>β the source IP address of the generated packets. Defaults to the link-localfe80::1address.-p,--dst-port <port>β destination UDP port of the generated packets, or the first port in the range if you're running with--dyn-portsset. Defaults to1.-P,--src-port <port>β source UDP port of the generated packets. Defaults to1.-d,--dyn-ports <num ports>β turns on dynamic port mode, where the destination port varies across a range of<num ports>starting from whatever you passed to--dst-port. Iconic.-n,--num-packets <num packets>β how many packets to send before exiting. If you don't supply it,xdp-trafficgenjust keeps going forever until you interrupt it. It will simply not stop. Periodt. π-s,--pkt-size <bytes>β size of each UDP packet being sent, including the Ethernet header and checksum. Sincexdp-trafficgengenerates IPv6 traffic, the minimum size β which is also the default β is66bytes.
β οΈ Lore drop: older versions ofxdp-trafficgenfailed to account for the four-byte ethernet checksum that gets added at the end of the packet, which meant64was allowed (and was the default) for the size, even though it actually generated 68-byte packets on the wire. To fix this bug without breaking existing users, values of64or65get clamped to the actual minimum value of66with a warning, instead of throwing an error. So you get a little scolding, not a crash. π
-t,--threads <threads>β number of simultaneous threads to transmit from. Each thread gets pinned to its own CPU core if possible. Defaults to1.-I,--interval <s>β output transmission statistics at this interval, in seconds. π-v,--verboseβ enable verbose logging. Pass it twice (-vv) for more verbose.--versionβ display version information and exit. bye! π-h,--helpβ display a summary of the available options.
π¦ The XSK-UDP command π¦
The xsk-udp command also generates UDP traffic, but it does it using an AF_XDP socket and generates the traffic in userspace. So if you want to test and benchmark AF_XDP sockets for transmitting, this is your girl. πΈ
The code for this command is derived from the xdpsock utility that used to live in the kernel sources, and more recently in the bpf-examples repository. This command corresponds to the --txonly option of xdpsock. So like, it has ancestors. Slay. π
The syntax for this command is:
xdp-trafficgen xsk-udp [options] <ifname>
The supported options are:
β OPTIONS (XSK-UDP) β
-m,--dst-mac <mac addr>β sets the destination MAC address of the generated packets. Default is all-zero destination MAC, as always. π-M,--src-mac <mac addr>β sets the source MAC address of the generated packets. Default is to use the MAC address of the interface the packets are transmitted on.-y,--timestampβ adds a timestamp to each packet, using the exact same header format the kernelpktgenutility uses. β¨-V,--vlan-tagβ adds a vlan tag to packets, using the ID and PRI you specify with the--vlan-idand--vlan-prioptions.-J,--vlan-idβ sets the vlan ID used for packets. Only does anything when--vlan-tagis set. Default:1.-K,--vlan-priβ sets the vlan PRI used for packets. Only does anything when--vlan-tagis set. Default:0.-P,--fill-pattern <pattern>β use this pattern to fill the packet data. The pattern is given as a 32-bit hex value, and defaults to0.-T,--tx-cycle-time <us>β sets an interval between packet bursts, in microseconds. Each interval, a burst of--batch-sizepackets gets sent. Default is0β which means send as fast as humanly (machine-ly?) possible. π₯-q,--queue <queue>β selects the hardware receive queue to use for the test. The AF_XDP socket is bound to this queue, which meansxdp-trafficgenwill process all packets arriving on it. Default is queue0.-i,--interval <seconds>β sets the polling interval for collecting all the statistics and printing them to the output. Default interval is2seconds.-O,--retries <number>β sets the maximum number of retries when completing the last packets of a test run. When ending a run,xdp-trafficgentries 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-countis set.-f,--frame-size <size>β sets the size of the memory frames used to transmit packets. Packets always use a memory chunk of this size, no matter how big the packet actually is on the wire. The size has to be a power of two, unless you're using--unaligned. Default is4096bytes, which corresponds to the page size on most systems. π-s,--pkt-size <size>β sets the size of the packets being transmitted. Has to be between64and9728bytes, and defaults to64.-d,--duration <seconds>β sets the test duration in seconds. Default is0, which means run forever, or until--pkt-countpackets have been sent. π-c,--pkt-count <number>β sets the total number of packets to transmit before exiting. Default is0, which means run forever, or until--durationis reached.-b,--batch-size <packets>β sets the batch size for the packet processing loop. This is how many packets get sent at once each time the loop runs. Default is64packets. Also go peek at--tx-cycle-time. π-I,--irq-string <irq-string>β enables printing of interrupt statistics for the interrupt number associated with irq-string in/proc/interrupts. The string finds a matching IRQ number by simple substring matching. No default, which means no IRQ statistics get printed.-p,--pollβ use thepoll()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. Rest, bestie. π«Ά-m,--no-need-wakeupβ don't set theXDP_USE_NEED_WAKEUPflag when binding the AF_XDP socket. The flag is set by default, and it makes the kernel driver occasionally go to sleep and yield the CPU to the userspace application while processing packets.-u,--unalignedβ support sending unaligned packets, i.e., packets that aren't aligned to the beginning of a data frame. When set,xdp-trafficgenenables huge pages for the userspace memory buffer that holds the packet data being transmitted. Setting this option also enables frame sizes that are not a power of two (see--frame-size).-M,--shared-umemβ enable shared userspace memory across multiple AF_XDP sockets. When this is set,xdp-trafficgencreates four sockets that share the same userspace memory buffer, and packets get 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 it to one ofauto,copy, orzero-copy. Default isauto, 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 used for all timer events in the application. Valid values areMONOTONIC,REALTIME,TAIandBOOTTIME, and the default isMONOTONIC.-W,--policy <policy>β set the scheduler policy for the application before running. Valid values areSCHED_OTHERandSCHED_FIFO, and the default isSCHED_OTHER.-U,--schpri <priority>β set the scheduler priority when usingSCHED_FIFO. Defaults to0.-A,--attach-mode <mode>β set the XDP program attach mode (nativeorskb) of the XDP program thatxdp-trafficgenattaches to the interface to enable XDP support. Default is native mode. Note that zero-copy can only be used in native mode. π-v,--verboseβ enable verbose logging. Supply it twice to also get verbose logging from the underlyinglibxdpandlibbpflibraries.--versionβ show the application version and exit.-h,--helpβ display a summary of the available options.
okay and that's part one, bestie β there's more coming, so don't go anywhere π
π« The TCP command π«
okay so this is the one where things get real: the TCP command generates dummy TCP traffic in a single TCP flow π. But β and this is the tea β β it can't just do it by itself. It 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 done, the XDP program literally takes over and starts generating traffic on that flow tuple. main character behaviour, fr fr π
And the ingress XDP program? It intercepts ACK packets coming back from the receiver and keeps track of the receive window. Very hands-on. Very attentive. π«Ά
Now the part you need to know before you fall in love: this traffic generator has no congestion control, and only very basic retransmit tracking. Like, in essence: any duplicate ACKs from the receiver make the sender reset its send sequence number to the last ACKed value and restart from there. The exact same thing happens if no progress on the window is made within two seconds π. So yeah β it can generate a huge amount of dummy traffic, but if there's packet loss, a lot of what you're sending can just be retransmissions. Not a scam, just literally how it works π
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, iykyk π).
β οΈ heads up bestie: the network driver of this network interface must support being the target of XDP redirects β it has to implement thendo_xdp_xmitdriver operation. Nondo_xdp_xmit, no traffic. periodt.
β¨ The supported options β¨
-p,--dst-port <port>β connect to destination<port>. Default is10000. π-m,--mode <mode>β load the ingress XDP program in<mode>; the default isnative. Valid values:native,skb,hw.-n,--num-packets <port>β the number of packets to send before exiting. If you don't supply it,xdp-trafficgenwill keep sending packets until it's interrupted. Forever girlie πΈ-I,--interval <s>β output transmission statistics with this interval (in seconds). So you can watch the numbers go up. obsessed π-v,--verboseβ enable verbose logging (-vvfor even more verbose). Spill the details π₯--versionβ display version information and exit.-h,--helpβ display a summary of the available options.
π The PROBE command π
bestie, this one is a vibe check for your kernel π§. The PROBE command probes the kernel to discover whether it supports the features needed to run xdp-trafficgen. So you can find out whether the running kernel is compatible with xdp-trafficgen, and whether a particular interface supports sending packets generated by xdp-trafficgen. Two birds, one probe π¦
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. Simple as that π
β οΈ real talk though: the probing relies on the kernel XDP feature reporting, which was added after the XDP support itself. Which means that with some older kernel versions, the probing may fail even though xdp-trafficgen would in fact be able to transmit packets. So a fail here isn't always the whole story, ok?! Don't let it gaslight you π
β¨ The supported options β¨
-i,--ifname <ifname>β probe the supplied interface name, in addition to doing the general kernel probing. π-v,--verboseβ enable verbose logging (-vvfor even more verbose).--versionβ display version information and exit.-h,--helpβ display a summary of the available options.
π BUGS π
found a bug? spill it, bestie β 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. an absolute icon, we stan π«Άβ¨
and that's the whole page babes β this was xdp-trafficgen(8) version V1.6.3, dated FEBRUARY 19, 2026. slay, go generate some traffic, and stay hydrated π
πΈπ
π¦ where this page comes from
- arch rolling: xdp-tools 1.6.3-2 Β· GPL AND LGPL AND BSD2
- ubuntu stonking: xdp-tools 1.6.3-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms