P4 (programming language): Difference between revisions

Content deleted Content added
WikiCleanerBot (talk | contribs)
m v2.04b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation)
Note foundation hosting by the ONF; flesh out a reference, format and link to publication; MOS:NOBOLD fixes; other ce
Line 17:
}}
 
'''P4''' is a [[programming language]] for controlling [[Network packet|packet]] [[forwarding plane]]s in networking devices, such as routers and switches. In contrast to a general purpose language such as [[C (programming language)|C]] or [[Python (programming language)|Python]], P4 is a [[___domain-specific language]] with a number of constructs optimized for [[Packet forwarding|network data forwarding]]. P4 is distributed as [[Open-source software|open-source]], [[Permissive free software licence|permissively licensed]] code, and is maintained by the P4 Language Consortium, a not-for-profit organization hosted by the [[Open Networking Foundation]].
 
== History ==
P4 was originally described in a 2014 [[Computer Communication Review|SIGCOMM ''CCR'']] paper titled “Programming Protocol-Independent Packet Processors”<ref>{{cite web
The programming language P4 was originally described in a SIGCOMM CCR paper in 2014 titled “Programming Protocol-Independent Packet Processors”<ref>{{cite web|url=http://www.sigcomm.org/node/3503|title=P4: Programming Protocol-Independent Packet Processors|date=July 2014|accessdate=7 April 2015}}</ref> – the alliterative name shortens to “P4”. The first P4 workshop took place in June, 2015<ref>{{cite web |title=1st P4 Workshop |url=https://p4.org/events/2015-06-04-p4-workshop/ |website=P4 Official Website |accessdate=1 August 2019}}</ref> at [[Stanford University]]. An updated specification of P4, called P4-16, was released between 2016 and 2017<ref name="P4-16">{{cite web |title=P4-16 Specification |url=https://p4.org/p4-spec/docs/P4-16-v1.2.0.html |website=P4 Official Website |accessdate=23 October 2019}}</ref> replacing original specification of P4, called P4-14.
|url=http://www.sigcomm.org/node/3503
|title=P4: Programming Protocol-Independent Packet Processors
|author1=P. Bosshart
|author2=D. Daly
|author3=G. Gibb
|author4=M. Izzard
|author5=N. McKeown
|author6=J. Rexford
|author7=C. Schlesinger
|author8=D. Talayco
|author9=A. Vahdat
|author10=G. Varghese
|author11=D. Walker
|date=July 2014
|work=[[Computer Communication Review]]
|access-date=7 April 2015
The programming language P4 was originally described in a SIGCOMM CCR paper in 2014 titled “Programming Protocol-Independent Packet Processors”<ref>{{cite web|url=http://www.sigcomm.org/node/3503|title=P4: Programming Protocol-Independent Packet Processors|date=July 2014|accessdate=7 April 2015}}</ref> – the—the alliterative name shortens to “P4”"P4". The first P4 workshop took place in June, 2015 at [[Stanford University]].<ref>{{cite web |title=1st P4 Workshop |url=https://p4.org/events/2015-06-04-p4-workshop/ |website=P4 Official Website |accessdate=1 August 2019}}</ref> at [[Stanford University]]. An updated specification of P4, called P4-16, was released between 2016 and 2017,<ref name="P4-16">{{cite web |title=P4-16 Specification |url=https://p4.org/p4-spec/docs/P4-16-v1.2.0.html |website=P4 Official Website |accessdate=23 October 2019}}</ref> replacing P4-14, the original specification of P4, called P4-14.
 
==Design==
Line 26 ⟶ 43:
 
===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, [[Field-programmable gate array|FPGAs]], [[System on a chip|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 maps the P4 source code into a target switch model. The compiler may be embedded in the target device, an externally running software, or even a cloud service. As many of the initial targets for P4 programs were used for simple packet switching it is very common to hear the term “P4"P4 switch”switch" used, even though “P4"P4 target”target" is more formally correct.
 
===Protocol independence===
P4 is designed to be '''protocol-independent''', meaning that: the language has no native support for even for common protocols such as IP, Ethernet, TCP, [[Virtual Extensible LAN|VxLAN]], or [[Multiprotocol Label Switching|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''' – P4reconfigurability–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 [[History of general-purpose CPUs|general-purpose CPUs]] or [[network processor]]s, rather than the fixed function [[Application-specific integrated circuit|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.
 
==Components==
Line 44 ⟶ 61:
 
===Parsers===
The P4 '''parser''' is a finite state machine that walks an incoming byte-stream and extracts headers based on the programmed parse graph. A simple example would be a parser that extracts the Ethernet source and destination and type fields, then performs a further extraction based on the value in the type field (common values might be ipv4, ipv6, or MPLS).
 
===Stateful processing===
Line 53 ⟶ 70:
 
====Match-action processing====
Fundamental to P4 is the concept of '''match-action pipelines'''. Conceptually, forwarding network packets or frames can be broken down into a series of table lookups and corresponding header manipulations. In P4 these manipulations are known as “actions”''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. P4 addresses only the data plane of a packet forwarding device. It does not specify the control plane nor any exact protocol for communicating state between the control and data planes. Instead, P4 uses the concept of tables to represent forwarding plane state. An interface between the control plane and the various P4 tables must be provided to allow the control plane to inject/modify state in the program. This interface is generally referred to as the “program''program API”API''.
 
====Tables====
P4 '''tables''' contain the state used to forward packets. Tables are composed of lookup keys and a corresponding set of actions and their parameters. A trivial example might be to store a set of destination MAC addresses as the lookup keys, and the corresponding action could set the output port on the device, and/or increment a counter. Tables and their associated actions are almost always chained together in sequence to realize the full packet forwarding logic, although in the abstract it is possible to build a single table that includes all the lookup key information and the full output action set.
 
====Actions====
'''Actions''' in P4 describe packet field and [[metadata]] manipulations. In P4 context, metadata is information about a packet that is not directly derived from the parser, such as the input interface that the frame arrived on. English descriptions of an example action might be “decrement"decrement the IPv4 [[Time to live|TTL]] field by one”one" or “copy"copy the MAC address from the output port table into the outgoing packet header."<ref>{{cite web |url=http://lists.p4.org |title=P4 Mailing Lists |date=July 2015 |accessdate=15 July 2015}}</ref> P4 defines both standard metadata that must be provided by all targets as well as target-specific metadata, which is provided by the author of specific targets.
 
==Control flow==