Programming Protocol-Independent Packet Processors (P4)

Objectives

  • Reconfigurable.

    • Data Plane program can be changed in the field.

  • Protocol-Independence.

    • No knowledge of low-level hardware organization is required.

    • Compiler compiles the program for the target device.

    • Architecture dependente – e.g. v1model.p4, p4c-xdp.p4, psa.p4.

  • Switch/vendor Independence.

  • Consistent Control Plane Interface.

    • Control plane APIs are automatically generated by the compiler.

  • Community-driven design.

Benefits

  • New features: add new protocols.

  • Reduce complexity: remove unused protocols.

  • Efficient use of resources – flexible use of tables.

  • Greater visibility – new diagnostic techniques, telemetry, etc.

  • Software style development – rapid design cycle, fast Innovation, fix data plane bugs in the field.

P4 program is a high-level programm that configures forwarding behavior (abstract forwarding model).

P4 compiler generates the low-level code to be executed by the desired target.

OpenFlow can still be used to install and query rules once forwarding model is defined.

Allows the definition of arbitrary headers and fields.

The architecture of a programmable switch

Header and Fields

Fields have a bit width and other attributes.

Headers are collections of fields.

  • Like an instantiated class in Java.

Parser

Extracts header instances.

Selects a next “state” by returning another parser function.

Match + Action table

Parsed representation of headers gives context for processing the packets

An action function consists of several primitive actions.

Programming a target

P4Runtime

Framework for runtime control of P4-defined data planes.

  • Open-source API and a server implementation.

P4 program-independent.

  • API doesn’t change with the P4 program.

Enables field-reconfigurability.

  • Ability to push new P4 programs without recompiling the software stack of target switches.

API based on protobuf (serialization) and gRPC (client/server transport).

  • Makes it easy to implement a P4Runtime client/server by auto-generating code for different languages.

P4Info as a contract between the control and data plane.

  • Generated by P4 compiler.

  • Needed by the control plane to format the body of P4Runtime messages.

P4 and P4Runtime are two different things

P4

  • Programming language used to define how a switch processes packets.

  • Specifies the switch pipeline.

    • Which fields does it match upon?

    • What actions does it perform on the packets?

    • In which order does it perform the matches and actions.

  • Specify the behavior of an existing device.

  • Specify a logical abstraction for the device.

P4Runtime

  • An API used to control switches whose behavior has already been specified in the P4 language.

  • Works for different types of switches.

    • Fixed.

    • Semi-programmable.

    • Fully programmable.

P4Runtime

P4 compiler generates 2 outputs:

  • Target specific binary.

    • Used to realize switch pipeline (i.e., binary config for specific target/switch).

  • P4Info file.

    • “Schema” of pipeline for tuntime control.

      • Captures P4 program attributes such as tables, actions, parameters, etc.

    • Protobuf-based format.

    • Target-independent compiler output.

      • Same P4Info for different targets.

The p4info file is used by a remote or local control plane.

This capability takes advantage of the fact that the p4info generates the same target-independent protobuf format.

  • API between client and server.

Forwarding Model / Runtime

Last updated