P4 Replay (P4R): Reproducing Packet Traces and Stateful Connections at Line-Rate on Your P4-based Switch
[Update 05/May]: The code will be published next week, we are resolving minor issues regarding the user interface.
P4 Replay (P4R) is as a high-end traffic generation tool able to reproduce real world traffic scnearios. P4R benefits from the Tofino traffic generation capabilities to replicate real-world traffic patterns while maintaining high performance and accuracy. The user/network tester can use P4R to reproduce pre-captured traces (i.e., PCAPs) and create stateful TCP connections at the Tofino line rate.
P4R can be used in three configuration modes: client, server, or internal (See Figure Below). In client mode , P4R can reproduce PCAPs or establish TCP connections with a connected server; in server mode, P4R responds to TCP connections from connected clients; and in internal mode , P4R can send packet traces or TCP connections to test.
In this mode, P4R can instantiate clients to send traffic (i.e., packet traces) or establish stateful TCP connections with external servers.
In this mode, P4R will act as a stateful TCP server (e.g., iperf) and establish connections with multiple clients.
In this mode, the traffic generated by P4R is internally routed to a user’s P4 code running in parallel in another pipeline. In this mode, the user’s P4 code is responsible for correctly processing and routing the generated traffic.
- git
- python3
- Tofino Switch™, SDE version 9.12+.
$ git clone https://github.com/ntrig-unicamp/P4R/.git
After clone our repository, you should acess the P4R directory and modify the file main.py. In this file you can configure you traffic patterns, desired output ports, and all other necessary parameters to start the traffic generation. P4R will use your definitions to generate all configuration files and execution scripts, and after that you can start the traffic generation. Below we provide a description of available commands, parameters and how to use them.
NameTrafficGenerator = P4RGenerator()
#instatiate the traffic generator with the name "NameTrafficGenerator"
NameTrafficGenerator.addGenerationPort(port)
#port (generation port on Tofino)
NameTrafficGenerator.addOutputPort(port, channel, bw)
#port (physical port)
#channel (port ID(D_P))
#bw (portBW)
Next we provide some simple examples how to use P4R.
myTG = P4RGenerator() #instatiate the traffic generator
myTG.addGenerationPort(68) #define the generation port
myTG.addOutputPort(5, 160, "100G") #physical port, port ID(D_P), portBW
myTG.generationMode("Client")
myTG.setPCAP("myPCAP_example.pcap")
myTG.setThroughput("30000")