Content deleted Content added
No edit summary |
clean up, replaced: licenced → licensed using AWB |
||
Line 1:
{{Two other uses| the P4 programming language|the perforce version control system|Perforce|other uses|P4}}▼
{{more footnotes|date=May 2015}}
▲{{Two other uses| the P4 programming language|the perforce version control system|Perforce|other uses|P4}}
{{Infobox programming language
Line 15 ⟶ 14:
}}
'''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|open-source]], [[Permissive free software licence|permissively-
== Language overview and design considerations ==
Line 37 ⟶ 36:
==Language components==
===Headers===
Line 43:
===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).
===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 the IPv4 TTL field by one” or “copy the MAC address from the output port table into the outgoing packet header.” <ref>{{cite web|url=http://mail.p4.org/pipermail/p4-dev_p4.org/|title=P4 developers mailing list|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===
The control flow in P4 determines the relative sequence of tables, and allows for [[Conditional (computer programming)|conditional execution]] of tables based on if/then/else constructions.
==External links==
|