P4 Open Source Programming Language

Programming Protocol-independent Packet Processors (P4) is a domain-specific language for network devices, specifying how data plane devices (switches, NICs, routers, filters, etc.) process packets.

Before P4, vendors had total control over the functionality supported in the network. And since networking silicon determined much of the possible behavior, silicon vendors controlled the rollout of new features (e.g., VXLAN), and rollouts took years.

P4 turns the traditional model on its head. Application developers and network engineers can now use P4 to implement specific behavior in the network, and changes can be made in minutes instead of years.

Play Video

Why P4?

Industry luminaries share their perspectives

P4 Workflow

P4 programs and compilers are target-specific. The target can be hardware-based (FPGA, Programmable ASICs) or software (running on x86).

A P4 program (prog.p4) classifies packets by header and the actions to take on incoming packets (e.g., forward, drop).

A P4 compiler generates the runtime mapping metadata to allow the control and data planes to communicate using P4Runtime (prog.p4info).

A P4 compiler also generates an executable for the target data plane (target_prog.bin), specifying the header formats and corresponding actions for the target device.

control ingress () {
     table routing {
          key = { hdr.ipv4.dstAddr : lpm; }
          actions = { drop; route; }
          size = 2048;
      apply {

Ready to try programming in P4?

Try it out in our P4 Sandbox!