Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying out the Behavioral Model #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Trying out the Behavioral Model #1

wants to merge 5 commits into from

Conversation

anshumanmohan
Copy link
Contributor

@anshumanmohan anshumanmohan commented Mar 14, 2024

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

  1. The P4 program you wish to simulate. In our case, default.p4 under progs/default/.
  2. The PCAP of traffic you wish to simulate. In our case, traffic_in.pcap under progs/default/.
  3. 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

  1. 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.

  2. The instructions mention:

    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!

  3. 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.

    1. Run p4bm-vitisnet default.json & to launch the control plane process as a background task.
    2. Run p4bm-vitisnet-cli. In the CLI now presented, run:
      1. run_traffic ./traffic
      2. exit
    3. 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.

Command is `p4c-vitisnet default.p4 -o default.json`
Command was `run-p4bm-vitisnet -j default.json -s cli_commands.txt`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant