P4 | |
---|---|
Paradigm | compiled, ___domain-specific, imperative |
Developer | The P4 Language Consortium |
First appeared | 2013 |
Stable release | version 1.0.2[1]
/ 17 February 2015 |
License | Apache-style |
Filename extensions | .p4 |
Website | www |
P4 is a programming language designed to allow programming of packet forwarding dataplanes. In contrast to a general purpose language such as C or python, P4 is a ___domain-specific language with a number of constructs optimized around network data forwarding. P4 is an open-source, permissively-licenced language and is maintained by a non-profit organization called the P4 Language Consortium. The language was originally described in a SIGCOMM paper in 2014 titled “Programming Protocol-Independent Packet Processors”[2] – the alliterative name shortens to “P4”.
Language overview and design considerations
As the language is specifically targeted at packet forwarding applications, the list of requirements or design choices is somewhat unique to those use cases. The language is designed to meet a number of these goals:
Target independence
P4 programs are designed to be implementation-independent, meaning they can be compiled against many different types of execution machines such as general-purpose CPUs, FPGAs, system(s)-on-chip, network processors, and ASICs. These different types of machines are known as P4 targets, and each target must be provided along with a compiler that converts the P4 source code into an executable format. As many of the initial targets for P4 programs were used for simple packet switching it is very common to hear the term “P4 switch” used, even though “P4 target” is more formally correct.
Protocol independence
P4 is designed to be protocol-independent, meaning that the language has no native support even for common protocols such as IP, Ethernet, TCP, VxLAN, or MPLS. Instead, the P4 programmer describes the header formats and field names of the required protocols in the program, which are in turn interpreted and processed by the compiled program and target device.
Reconfigurability
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. Although within the language there is nothing to prevent a given target from optimizing around a certain set of protocols, these optimizations are invisible to the language author and may ultimately reduce the system’s flexibility and reconfigurability goals.
External links
References
- ^ "P4.org code". Retrieved 7 April 2015.
- ^ "P4: Programming Protocol-Independent Packet Processors". July 2014. Retrieved 7 April 2015.