Skip to content

minmit/p4-exercises

Repository files navigation

P4 Assignment

This assignment will help you get familiar with some of the main concepts and constructs of the P4 programming language.

Obtaining required software

To complete the exercises, you will need to either build a virtual machine or install several dependencies.

To build the virtual machine:

  • Install VirtualBox

    Apple Silicon Users: Follow this guide

  • Install Vagrant
  • Clone the repository
  • Before proceeding, ensure that your system has at least 12 Gbytes of free disk space, otherwise the installation can fail in unpredictable ways.
  • cd vm-ubuntu-20.04
  • vagrant up - The time for this step to complete depends upon your computer and Internet access speeds, but for example with a 2015 MacBook pro and 50 Mbps download speed, it took a little less than 20 minutes. It requires a reliable Internet connection throughout the entire process.
  • When the machine reboots, you should have a graphical desktop machine with the required software pre-installed. There are two user accounts on the VM, vagrant (password vagrant) and p4 (password p4). The account p4 is the one you are expected to use.
  • Clone this repository in $HOME.

Note: Before running the vagrant up command, make sure you have enabled virtualization in your environment; otherwise you may get a "VT-x is disabled in the BIOS for both all CPU modes" error. Check this for enabling it in virtualbox and/or BIOS for different system configurations.

You will need the script to execute to completion before you can see the p4 login on your virtual machine's GUI. In some cases, the vagrant up command brings up only the default vagrant login with the password vagrant. Dependencies may or may not have been installed for you to proceed with running P4 programs. Please refer the existing issues to help fix your problem or create a new one if your specific problem isn't addressed there.

If you need to install dependencies by hand, please contact the instructor as soon as possible.

Warm-up: Forwarding

In the forwarding folder, you will find an example of implementing destination-based IPv4 forwarding on a network topology that we will use in this assignment. You do not need to add anything to the code in this folder. Simply run the instructions in its README file to get familiar with the topology and the different pieces of software that work together to emulate and program the network.

The Assignment: Filtering suspicious traffic

In the filter folder, you will see instructions on how to extend the forwarding functionality to detect and mark suspicious packets. To submit the assignment, email your filter.p4 and mycontroller.py files to the instructor.

P4 Documentation and Extra Resources

The documentation for P4_16 and P4Runtime is available here

All excercises in this repository use the v1model architecture, the documentation for which is available at:

  1. The BMv2 Simple Switch target document accessible here talks mainly about the v1model architecture.
  2. The include file v1model.p4 has extensive comments and can be accessed here.

There are also some slides from a P4 tutorial event and a P4 Cheat Sheet in the repository that you can feel free to refer to as your are completing the assignment.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published