P4DDG: Data-Dependent Grammars for Packet Specification and Parsing in P4

Open Access
Authors
Publication date 2025
Host editors
  • Amir Shaikhha
  • Sebastian Erdweg
  • Nada Amin
Book title GPCE '25
Book subtitle Proceedings of the 24th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences : July 3-4, 2025, Bergen, Norway
ISBN (electronic)
  • 9798400719950
Event 24th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, GPCE 2025
Pages (from-to) 54-66
Number of pages 13
Publisher New York, NY: Association for Computing Machinery
Organisations
  • Faculty of Science (FNWI) - Informatics Institute (IVI)
Abstract

In software-defined networking, the domain-specific language P4 allows developers to program the behavior of networking devices at a comparatively high level of abstraction. A P4 program defines a state machine to parse incoming packets. The parsers are flexible and efficient but may be sensitive to bugs and difficult to maintain. As a possible alternative, data-dependent grammars (DDGs) can describe both packet structure and parser at a higher level of abstraction. 

In this work, we investigate the use of DDGs in P4 programs. In particular, we demonstrate how DDGs can be used to simultaneously define packets and parsers. We describe a DDG to P4 compiler and evaluate our approach empirically. Input to our evaluation is a collection of P4 programs with for each: the original (handwritten) parser, the (handwritten) DDG alternative, and the compiler-generated parser. The handwritten and generated parsers are compared for equivalence and performance. 

Our results show that the generated parsers are three times slower for grammars that do not utilize features distinguishing DDGs from context-free grammars. When parameterized nonterminals are used, a key feature of DDGs, the generated parsers are around six times slower.

Document type Conference contribution
Language English
Published at https://doi.org/10.1145/3742876.3742879
Other links https://www.scopus.com/pages/publications/105013053853
Downloads
3742876.3742879 (Final published version)
Permalink to this page
Back