P4 comprises five major components that support such a high level of abstraction:
- Headers: This defines the sequence and structure of a series of fields. It includes the specification of field names, widths, and constraints on field values.
- Parsers: This defines how headers and valid header sequences within packets are identified.
- Tables: This is where the header fields are matched to the actions for packet processing. The P4 program defines the fields on which a table may match and the actions it may execute.
- Actions: P4 supports the construction of complex actions from simpler protocol-independent primitives. These complex actions are available within match and action tables.
- Control programs: This determines the order in which match action tables are applied to a packet. A simple imperative program describes the flow of control between match action tables.