I've been playing with AMD's P4 Behavioral Model, and I'm stashing my progress here.
Things mostly progress as documented here. In some cases I found the docs confusing, but basically I got through it.
Requirements
The P4 program you wish to simulate. In our case, default.p4 under progs/default/.
The PCAP of traffic you wish to simulate. In our case, traffic_in.pcap under progs/default/.
A text file that is essentially a script you wish to run against the BM's CLI. This is also where you would populate match-action tables in the control plane. In our case this is simple, just running the BM CLI command run_traffic while specifying the PCAP file above, and then exiting. See cli_commands.txt under progs/default/.
Running
The command is run-p4bm-vitisnet -j default.json -s cli_commands.txt. The result is a new file, traffic_out.pcap.
Other info
Instead of a PCAP, it is also possible to provide packet info in a different, human-readable format with extension .user. See traffic_in.user under progs/default/. If the BM does not see a PCAP with the correct name, it uses the .user file if there is one. This also means that the result is a .user file. You can see an example of this under progs/five_tuple.
Both the compiler and the behavioral model CLI programs need to be executed from within a Vivado context. The following example illustrates this using the supplied FiveTuple example design with the command:
vivado -mode batch -source cli_example.tcl
along with instructions on how to write this .tcl file. This did not work for me; I got an "Inappropriate ioctl for device" error. Besides, I was just able to make it work without doing anything to get into a "Vivado context". Please let me know if this divergence is of interest, and I'll make an issue with a minimal example!
Above I have described the "script" style of working with the BM, which rolls together the "control plane" and "data plane" of the simulated network. It is possible to work with these separately, as described here. Below I reproduce the commands that worked for me.
Run p4bm-vitisnet default.json & to launch the control plane process as a background task.
Run p4bm-vitisnet-cli. In the CLI now presented, run:
run_traffic ./traffic
exit
As before, a new file called traffic_out.pcap will be created. If you had no traffic_in.pcap but did have a traffic_in.user sitting around, then traffic_out.user will be created.
I've been playing with AMD's P4 Behavioral Model, and I'm stashing my progress here.
Things mostly progress as documented here. In some cases I found the docs confusing, but basically I got through it.
Requirements
default.p4
underprogs/default/
.traffic_in.pcap
underprogs/default/
.run_traffic
while specifying the PCAP file above, and then exiting. Seecli_commands.txt
underprogs/default/
.Running
The command is
run-p4bm-vitisnet -j default.json -s cli_commands.txt
. The result is a new file,traffic_out.pcap
.Other info
.user
. Seetraffic_in.user
underprogs/default/
. If the BM does not see a PCAP with the correct name, it uses the.user
file if there is one. This also means that the result is a.user
file. You can see an example of this underprogs/five_tuple
.The instructions mention:
along with instructions on how to write this
.tcl
file. This did not work for me; I got an "Inappropriate ioctl for device" error. Besides, I was just able to make it work without doing anything to get into a "Vivado context". Please let me know if this divergence is of interest, and I'll make an issue with a minimal example!p4bm-vitisnet default.json &
to launch the control plane process as a background task.p4bm-vitisnet-cli
. In the CLI now presented, run:run_traffic ./traffic
exit
traffic_out.pcap
will be created. If you had notraffic_in.pcap
but did have atraffic_in.user
sitting around, thentraffic_out.user
will be created.