Documentation/networking/pktgen.rst

Source file repositories/reference/linux-study-clean/Documentation/networking/pktgen.rst

File Facts

System
Linux kernel
Corpus path
Documentation/networking/pktgen.rst
Extension
.rst
Size
12820 bytes
Lines
423
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

.. SPDX-License-Identifier: GPL-2.0

====================================
HOWTO for the linux packet generator
====================================

Enable CONFIG_NET_PKTGEN to compile and build pktgen either in-kernel
or as a module.  A module is preferred; modprobe pktgen if needed.  Once
running, pktgen creates a thread for each CPU with affinity to that CPU.
Monitoring and controlling is done via /proc.  It is easiest to select a
suitable sample script and configure that.

On a dual CPU::

    ps aux | grep pkt
    root       129  0.3  0.0     0    0 ?        SW    2003 523:20 [kpktgend_0]
    root       130  0.3  0.0     0    0 ?        SW    2003 509:50 [kpktgend_1]


For monitoring and control pktgen creates::

	/proc/net/pktgen/pgctrl
	/proc/net/pktgen/kpktgend_X
	/proc/net/pktgen/ethX


Tuning NIC for max performance
==============================

The default NIC settings are (likely) not tuned for pktgen's artificial
overload type of benchmarking, as this could hurt the normal use-case.

Specifically increasing the TX ring buffer in the NIC::

 # ethtool -G ethX tx 1024

A larger TX ring can improve pktgen's performance, while it can hurt
in the general case, 1) because the TX ring buffer might get larger
than the CPU's L1/L2 cache, 2) because it allows more queueing in the
NIC HW layer (which is bad for bufferbloat).

One should hesitate to conclude that packets/descriptors in the HW
TX ring cause delay.  Drivers usually delay cleaning up the
ring-buffers for various performance reasons, and packets stalling
the TX ring might just be waiting for cleanup.

This cleanup issue is specifically the case for the driver ixgbe
(Intel 82599 chip).  This driver (ixgbe) combines TX+RX ring cleanups,
and the cleanup interval is affected by the ethtool --coalesce setting
of parameter "rx-usecs".

For ixgbe use e.g. "30" resulting in approx 33K interrupts/sec (1/30*10^6)::

 # ethtool -C ethX rx-usecs 30


Kernel threads
==============
Pktgen creates a thread for each CPU with affinity to that CPU.
Which is controlled through procfile /proc/net/pktgen/kpktgend_X.

Example: /proc/net/pktgen/kpktgend_0::

 Running:
 Stopped: eth4@0
 Result: OK: add_device=eth4@0

Most important are the devices assigned to the thread.

The two basic thread commands are:

Annotation

Implementation Notes