/p4pktgen

Automatic test case generator for P4 programs

Primary LanguagePythonOtherNOASSERTION

p4pktgen

Introduction

p4pktgen is a tool for generating input packets and table entries for P4 programs that cover all paths of the program.

It supports programs written in either the P4_14 or P4_16 variants of the language, as long as the program can be compiled using the open source p4c-bm2-ss compiler (part of the p4c repository), compiled to a bmv2 JSON file for use with the simple_switch software switch (part of the behavioral-model repository).

It currently covers all combinations of execution paths through the parser and ingress control block, but ignores the egress control block. It runs the test cases in simple_switch to check that the packet follows the expected path of execution, and also writes out a data file describing the test cases, which should be useful in executing the test cases on other P4 implementations (additional work is required to adapt the test cases to run on other implementations).

Prerequisites

For installing p4c and simple_switch, there is a script by Andy Fingerhut. Make sure that simple_switch is in your path before running p4pktgen.

Note: this software has been developed and tested on Ubuntu 16.04 and likely requires changes to run on other operating systems.

Installing and running p4pktgen

Run p4pktgen's install script as follows:

% ./tools/install.sh

The basic command to run p4pktgen is as follows:

% p4pktgen <json file>

The flag -d prints additional debug information. The -h option gives help on other command line options available.