- 📑 Table of Contents
- 📝 Overview
- 🚀 Installation & Quick Start
- 🤖 Test Automation
- 🔄 Update Guide
- 📚 Documentation
- 🛠️ Development
- 🖼️ Preview
- 📖 Cite
P4TG (P4-based Traffic Generator) is a programmable traffic generator built on the Intel Tofino™ ASIC.
It enables reproducible experiments with Ethernet/IP traffic at high data rates while providing precise in-data-plane measurements.
P4TG combines a P4 data plane program, a Rust-based control plane, and a React-based configuration GUI.
📖 Related publications:
- P4TG: 1 Tb/s Traffic Generation for Ethernet/IP Networks (v1.0.0)
- Enhancements to P4TG: Protocols, Performance, and Automation (v2.3.2)
- Enhancements to P4TG: Histogram-Based RTT Monitoring in the Data Plane (v2.4.0)
- Tofino 1: Up to 1 Tb/s across 10 × 100 Gb/s ports, or 40 × 10/25 Gb/s
- Tofino 2: Up to 4 Tb/s across 10 × 400 Gb/s ports, or 40 × 10/25 Gb/s
Generated packet headers can be fully customized, including:
- Ethernet
- IPv4 (full address randomization)
- IPv6 (address randomization of 48 LSB)
- MPLS (up to 15 LSEs)
- VLAN
- QinQ
- VxLAN
- SRv6 (up to 3 SIDs, Tofino2 only)
Traffic may be looped back (directly or through other equipment) to measure:
- TX/RX rates
- Packet loss
- Packet reordering
- Inter-arrival times (IATs)
- Round-trip times (RTTs)
- Frame types
- Frame sizes
directly in the data plane to ensure accurate results.
See the full Changelog.
| Feature | Status |
|---|---|
| Statistics | ✅ Available |
| Tofino 1 & 2 support | ✅ Available |
| Web frontend (React) | ✅ Available |
| Rust backend | ✅ Available |
| Ethernet, IPv4, IPv6 | ✅ Available |
| VLAN, QinQ, MPLS, VxLAN, SRv6 | ✅ Available |
| ARP replies | ✅ Available |
| Dark mode | ✅ Available |
| RTT histogram & percentiles | ✅ Available |
| Automated testing | ✅ Available |
| File reporting | ✅ Available |
| Test profiles | |
| Localization | |
| NDP | ⏳ Planned |
| NETCONF | ⏳ Planned |
P4TG requires a fully set up SDE with $SDE and $SDE_INSTALL environment variables set.
A detailed installation guide for open-p4studio and P4TG can be found here.
The provided p4tg.sh script automates the installation of the data and control plane on Debian- / Ubuntu-based systems, provided that the SDE is installed correctly.
Make sure that the environment variables $SDE and $SDE_INSTALL are set. Run with sudo -E to pass environment variables.
Usage: ./p4tg.sh [install|update|start|stop|restart|status]Clone P4TG into /opt/P4TG and simply run sudo -E ./p4tg.sh install (tested on Debian-based systems). Change the paths at the top of p4tg.sh if needed.
The install command will:
- Compile the data plane and copy it in place.
- Pull the docker image and start it.
- Copy the
p4tg.shscript to/usr/local/bin. - Copy the
p4tg.servicefile to/etc/systemd/system/p4tg.service. This service file can be used to autostart P4TG on boot.
The start command will:
- Load all required kernel modules to operate the Tofino.
- Start the data plane and wait for it to become ready.
- Start the control plane docker image.
cd P4-Implementation- Tofino 1:
make compile TARGET=tofino make start TARGET=tofino
- Tofino 2:
make compile TARGET=tofino2 make start TARGET=tofino2
Tested on:
- SDE 9.9.0 (up to v2.0.0)
- SDE 9.13.{0,...,4}
cd Controller
docker compose up- Starts a REST-API server on port
P4TG_PORT(default:8000) at/api - Serves the React GUI at
/ - Access GUI:
http://<tofino-controller-ip>:P4TG_PORT - Access API:
http://<tofino-controller-ip>:P4TG_PORT/api
Docker compose file Controller/docker-compose.yaml
SAMPLE=1→ IAT sampling mode (default:0, data plane measurement)LOOPBACK=true→ enable loopback testing modeP4TG_PORT=8000→ changes the controller portNUM_PORTS=32→ set number of front panel ports of your device
Config file: Controller/config.json
- Specify ports for traffic generation. Per default, front panel ports 1 - 10 are configured automatically.
- Configure MAC address for ARP replies, breakout mode, and port settings. Port settings can further be changed during runtime through the API or the GUI.
Example:
{
"tg_ports": [
{
"port": 1,
"mac": "00:d0:67:a2:a9:42",
"speed": "BF_SPEED_100G"
},
{
"port": 2,
"mac": "fa:a6:68:e0:3d:70",
"breakout_mode": true,
"speed": "BF_SPEED_100G"
},
{
"port": 3,
"mac": "00:d0:67:a2:a9:42",
"speed": "BF_SPEED_100G",
"fec": "BF_FEC_TYP_NONE",
"auto_negotiation": "PM_AN_FORCE_DISABLE"
},
]
}| Option | Valid Values |
|---|---|
mac |
Any valid MAC address |
speed |
BF_SPEED_10G · BF_SPEED_25G · BF_SPEED_40G · BF_SPEED_100G · BF_SPEED_400G |
auto_negotiation |
PM_AN_DEFAULT · PM_AN_FORCE_ENABLE · PM_AN_FORCE_DISABLE |
fec |
BF_FEC_TYP_NONE · BF_FEC_TYP_FC · BF_FEC_TYP_REED_SOLOMON |
breakout_mode |
true · false (can be combined with 40G / 100G speeds) |
Each front panel port requires two recirculation ports. They are configured automatically. However, on the 64-port Tofino devices, you may have to manually set internal TX/RX recirculation ports to match your device. Below is an example:
{
"tg_ports": [
{
"port": 49,
"mac": "fa:a6:68:e0:3d:70",
"speed": "BF_SPEED_100G",
"recirculation_ports": {
"tx_port": 50,
"rx_port": 51
}
}
]
}This uses front panel port 49 as a port for traffic generation and port 50 and 51 for internal recirculation. Ensure that the recirculation ports support the same line rate as the TG port.
Automation scripts in p4tg_test_automation:
- Python script for starting/stopping tests, fetching stats, and rendering plots
- Quick start:
python run.py --payload payloads/your_test.json
- Example payloads included
See README for details.
- Rebuild the data plane as described above.
- Update controller:
docker compose pull docker compose up -d
- If GUI issues occur, clear browser storage.
- REST-API docs: P4TG API Docs
- Or via controller:
/api/docs
For development instructions, please see here
If you use P4TG in any of your publications, please cite the following papers:
- S. Lindner, Marco Häberle, and M. Menth: P4TG: 1 Tb/s Traffic Generation for Ethernet/IP Networks, in IEEE Access, vol. 11, p. 17525 – 17535, Feb. 2023, IEEE
- F. Ihle, E. Zink, S. Lindner, and M. Menth: Enhancements to P4TG: Protocols, Performance, and Automation, in KuVS Workshop on Network Softwarization (KuVS NetSoft), online, Apr. 2025
- F. Ihle, E. Zink, M. Menth: Enhancements to P4TG: Histogram-Based RTT Monitoring in the Data Plane, in Workshop on Resilient Networks and Systems (ReNeSys), Jul. 2025, Ilmenau, Germany
@article{LiHae23,
title = {{P4TG: 1 Tb/s Traffic Generation for Ethernet/IP Networks}},
author = {Steffen Lindner and Marco Häberle and Michael Menth},
journal = {{IEEE Access}},
year = 2023,
month = feb,
volume = 11,
pages = {17525--17535}
}
@article{IhZi25,
title = {{Enhancements to P4TG: Protocols, Performance, and Automation}},
author = {Fabian Ihle and Etienne Zink and Steffen Lindner and Michael Menth},
journal = {{KuVS Workshop on Network Softwarization (KuVS NetSoft)}},
year = 2025,
month = apr
}
@article{IhZi25_2,
title = {{Enhancements to P4TG: Histogram-Based RTT Monitoring in the Data Plane}},
author = {Fabian Ihle and Etienne Zink and Michael Menth},
journal = {{Workshop on Resilient Networks and Systems (ReNeSys)}},
year = 2025,
month = sep
}