Skip to content

gvenancioluz/p4-tutorials

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

P4 Tutorial

Introduction

Welcome to the P4 Tutorial! We've prepared a set of exercises to help you get started with P4 programming, organized into several modules:

  1. Introduction and Language Basics
  1. P4Runtime and the Control Plane
  1. Monitoring and Debugging
  1. Recursive Processing
  1. Advanced Behavior

Presentation

The slides are available online and in the P4_tutorial.pdf in the tutorial directory.

A P4 Cheat Sheet is also available online which contains various examples that you can refer to.

Obtaining required software

If you are starting this tutorial at the Spring 2018 P4 Developer Day, then we've already provided you with a virtual machine that has all of the required software installed.

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

To build the virtual machine:

  • Install Vagrant and VirtualBox
  • Clone the repository
  • Option A: server (headless method) with X11-Forwarding enabled:
    • Run the following:
      cd vm/server
      vagrant up
      vagrant ssh
      
    • The machine will be running in the back, whilst you can work via a remote or terminal connection
    • Move to the exercises folders to select your example and follow instructions in their respective README files
      cd tutorials/exercises
      
  • Option B: desktop with GUI capabilities:
    • Run the following:
      cd vm/desktop
      vagrant up
      
    • Log in with username p4 and password p4 and issue the command sudo shutdown -r now
    • When the machine reboots, you should have a graphical desktop machine with the required software pre-installed.

*Note 1: 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.*

Note 2: Upon running vagrant up, the tutorial directories will be copied into the VM. If you perform any change in the directories outside the VM, changes will not be synchronized with those in the VM.

To install dependencies by hand, please reference the vm installation scripts. They contain the dependencies, versions, and installation procedure. You should be able to run them directly on an Ubuntu 16.04 machine:

  • sudo ./root-bootstrap.sh
  • sudo ./user-bootstrap.sh

About

Extension of P4 language tutorials

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 46.5%
  • P4 38.7%
  • Emacs Lisp 4.8%
  • Shell 4.3%
  • Vim Script 2.9%
  • TeX 2.1%
  • Makefile 0.7%