Skip to content
Joe Antony edited this page Aug 29, 2018 · 3 revisions

What is P4?

P4 is a declarative language for telling forwarding-plane devices (switches, NICs, firewalls, filters, etc) how to process packets.

Why is designing a piece of high-performance networking equipment a really painful task today?

  • First, you decide what features you need.
  • Then you try to find a fixed-function switch chip with roughly the features you want.
  • You sign a non-disclosure agreement to get access to a software-development kit (SDK), and start crawling up the learning curve.
  • Using the closed, proprietary API, you try to force fit your system requirements into the fixed capabilities of the chip. This generally requires a few unnatural acts.
  • At the end of the day, you have a system with top-down aspirations, but really defined (and constrained in peculiar ways) from the bottom up. And you are locked in to that chip set, because your system and your expertise hinge on that SDK.

How does P4 change the conventional process of network systems' design?

With P4 you start from your system design requirements, write a P4 program to describe how your system needs packets to be processed, and then compile your program to tell the forwarding elements what to do. Essentially, P4 allows us to bring all the benefits we're familiar with from software engineering (composing programs, debugging, code coverage, provable behavior, model checking, etc.) to the design of network systems, all the way down to the wire.

What are the advantages of P4?

  • P4 programs can be used to add custom packet processing or analytics as a value-add for your network; or to reduce the number of protocols your network has to support.
  • You can quickly deploy new protocols and header formats in days, without having to wait years for a chip vendor to support a new feature.
  • You can customize the data plane to match the scale of your network.
  • You can publish your P4 programs or keep them private, which means you retain ownership of your IP and no longer need to share new features with your chip vendor and all their customers, too.

How does P4 relate to SDN and OpenFlow?

P4 lets you tell the switch how to process packets and auto-generates an API connecting the control plane and the forwarding plane. So, a P4 program could configure a switch to look like an OpenFlow 1.0 switch, or an OpenFlow 1.4 switch, or something else entirely. And the control plane that populates the match-action rules at runtime could be centralized or distributed, running on a separate controller or directly on the switch. The main point of P4 is to free the network from low-level, proprietary interfaces to fixed-function chip-sets, to enable protocol-independent packet processing across a range of target platforms.

P4 tutorial setup

  • Install VirtualBox:
    sudo apt-get install virtualbox
  • Install Vagrant:
    sudo apt-get install vagrant
  • Clone the repo:
    git clone https://github.com/p4lang/tutorials.git
  • Go to the subfolder vm:
    cd tutorials/vm/
  • Create and configure Vagrant machine according to Vagrantfile:
    vagrant up
  • If the error "GnuTLS recv error (-9): A TLS packet with unexpected length was received" occurs, run the following command:
    git config --global http.sslVerify false
Clone this wiki locally