Content deleted Content added
Turing4242 (talk | contribs) |
Turing4242 (talk | contribs) No edit summary |
||
Line 43:
==== Parsing Logic ====
P4 allows the specification of custom packet header parsing logic <ref>{{cite web |title=P4-16 Specification |url=https://p4.org/p4-spec/p4-14/v1.0.4/tex/p4.pdf |website=P4 Official Website}}</ref> including but not limited to parsing typical headers used in the TCP/IP protocol suite and application specific headers.
====Headers====▼
Header definitions describe packet formats and provide names for the fields within the packet. The language allows customized header names and fields of arbitrary length, although many header definitions use widely known protocol names and fields widths. For example, an [[IEEE 802.3|802.3]] Ethernet header definition might be called “Ethernet” and consist of the a 48-bit field named “dest” followed by a 48-bit “src” field, followed by a 16-bit “type” field. The names in a header definition are used later in the P4 program to reference these fields.▼
====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 50 ⟶ 58:
The primary component of a P4 program is a set of user-defined match action tables. P4 treats all match action tables as generic, leaving the user to add their match-action rules via the control plane. <ref>{{cite web |title=P4-16 Specification |url=https://p4.org/p4-spec/p4-14/v1.0.4/tex/p4.pdf |website=P4 Official Website}}</ref>
===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” 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 API”.
====Tables====▼
▲===Headers===
▲Header definitions describe packet formats and provide names for the fields within the packet. The language allows customized header names and fields of arbitrary length, although many header definitions use widely known protocol names and fields widths. For example, an [[IEEE 802.3|802.3]] Ethernet header definition might be called “Ethernet” and consist of the a 48-bit field named “dest” followed by a 48-bit “src” field, followed by a 16-bit “type” field. The names in a header definition are used later in the P4 program to reference these fields.
▲===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://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.
|