Table of Contents
Fetching ...

Prose-to-P4: Leveraging High Level Languages

Mihai-Valentin Dumitru, Vlad-Andrei Bădoiu, Costin Raiciu

TL;DR

The paper addresses the difficulty of programming dataplanes in P4/NPL by proposing a pipeline that uses large language models to translate natural language prompts into high-level dataplane code. It argues for no-resource, short, linear dataplane programs as favorable targets for LLM-based generation and investigates grammar prompting as a method to generate code in non-mature languages like Lucid. The authors present a preliminary evaluation with Lucid, showing that grammar prompting improves syntactic alignment and compilability compared to naive prompts, but also reveal limitations related to grammar adherence and training-data leakage. The work demonstrates the potential to enable rapid prototyping of dataplane functionality from natural language while outlining concrete steps for broader validation, extension to other languages, and template generation. Overall, this approach could lower the barrier to prototyping and testing dataplane ideas, accelerating experimentation in programmable networks while highlighting the need for robust prompt design and language-agnostic tooling.

Abstract

Languages such as P4 and NPL have enabled a wide and diverse range of networking applications that take advantage of programmable dataplanes. However, software development in these languages is difficult. To address this issue, high-level languages have been designed to offer programmers powerful abstractions that reduce the time, effort and domain-knowledge required for developing networking applications. These languages are then translated by a compiler into P4/NPL code. Inspired by the recent success of Large Language Models (LLMs) in the task of code generation, we propose to raise the level of abstraction even higher, employing LLMs to translate prose into high-level networking code. We analyze the problem, focusing on the motivation and opportunities, as well as the challenges involved and sketch out a roadmap for the development of a system that can generate high-level dataplane code from natural language instructions. We present some promising preliminary results on generating Lucid code from natural language.

Prose-to-P4: Leveraging High Level Languages

TL;DR

The paper addresses the difficulty of programming dataplanes in P4/NPL by proposing a pipeline that uses large language models to translate natural language prompts into high-level dataplane code. It argues for no-resource, short, linear dataplane programs as favorable targets for LLM-based generation and investigates grammar prompting as a method to generate code in non-mature languages like Lucid. The authors present a preliminary evaluation with Lucid, showing that grammar prompting improves syntactic alignment and compilability compared to naive prompts, but also reveal limitations related to grammar adherence and training-data leakage. The work demonstrates the potential to enable rapid prototyping of dataplane functionality from natural language while outlining concrete steps for broader validation, extension to other languages, and template generation. Overall, this approach could lower the barrier to prototyping and testing dataplane ideas, accelerating experimentation in programmable networks while highlighting the need for robust prompt design and language-agnostic tooling.

Abstract

Languages such as P4 and NPL have enabled a wide and diverse range of networking applications that take advantage of programmable dataplanes. However, software development in these languages is difficult. To address this issue, high-level languages have been designed to offer programmers powerful abstractions that reduce the time, effort and domain-knowledge required for developing networking applications. These languages are then translated by a compiler into P4/NPL code. Inspired by the recent success of Large Language Models (LLMs) in the task of code generation, we propose to raise the level of abstraction even higher, employing LLMs to translate prose into high-level networking code. We analyze the problem, focusing on the motivation and opportunities, as well as the challenges involved and sketch out a roadmap for the development of a system that can generate high-level dataplane code from natural language instructions. We present some promising preliminary results on generating Lucid code from natural language.
Paper Structure (6 sections, 3 figures, 1 table)

This paper contains 6 sections, 3 figures, 1 table.

Figures (3)

  • Figure 1: Proposed pipeline of going from prose to concrete dataplane applications on actual switches. Some languages may require network configurations or other extra information, grouped here under "input artifacts". Compilation produces one or more dataplane programs, perhaps together with program-to-device mappings or other information, grouped here as "output artifacts".
  • Figure 2: Sample of prompt engineering for Lucid
  • Figure 3: ChatGPT response for the query: "a stateful NAT".