P4 (programming language)

P4 is distributed as open-source, permissively licensed code, and is maintained by the P4 Project (formerly the P4 Language Consortium), a not-for-profit organization hosted by the Open Networking Foundation.

P4 was originally described in a 2014 SIGCOMM CCR paper titled “Programming Protocol-Independent Packet Processors”[2]—the alliterative name shortens to "P4".

P4 is designed to be protocol-independent: the language has no native support for even common protocols such as IP, Ethernet, TCP, VxLAN, or MPLS.

Protocol independence and the abstract language model allow for reconfigurability–P4 targets should be able to change the way they process packets (perhaps multiple times) after they are deployed.

This capability is traditionally associated with forwarding planes built on general-purpose CPUs or network processors, rather than the fixed function ASICs.

The P4 parser is a finite state machine that walks an incoming byte-stream and extracts headers based on the programmed parse graph.

In P4 these manipulations are known as actions and generally consist of things such as copying byte fields from one location to another based on the lookup results on learned forwarding state.

English descriptions of an example action might be "decrement the IPv4 TTL field by one" or "copy the MAC address from the output port table into the outgoing packet header.