P4: Programming Protocol-independent Packet Processors

Programming Protocol-independent Packet Processors (P4) is a powerful domain-specific language designed for network devices. It provides a flexible way to specify how data plane devices, including switches, NICs, routers, and filters, process packets.

P4 programs prioritize implementation independence, enabling compilation against diverse execution machines, such as general-purpose CPUs, FPGAs, system-on-chip devices, network processors, and ASICs.

A gentle introduction to the P4 programming language is available at https://cylab.be/publications/62/2024-p4-language-a-practical-introduction

Project Goals

This project aims to explore the capabilities of the P4 language, particularly in the realm of security. We are looking at the implementation of filtering or detection systems directly on programmable switches or routers using P4.

P4 Implementations

Explore various P4 implementations to gain insights into the language's capabilities. Each example addresses specific network scenarios.

BMv2 - V1Model Architecture

L3 Forwading

VXLAN, MPLS & VLAN

Counters, Meters & Registers

Multicast

Queue Management Algorithms

Tofino P4-16 - TNA Architecture ( In development... )

Template

Forwarding & Counter

Installation & Dependencies

We use the p4-utils project for network creation and switch programming. Ensure you have the following dependencies installed:

Dependency Installation Command
P4C & BMv2 Find installation commands below
Mininet sudo apt-get -y install mininet
Other dependencies sudo apt-get install -y packer xterm help2man python3-pip
Scapy pip3 install --pre scapy[complete]

P4C & BMv2

source /etc/lsb-release
echo "deb http://download.opensuse.org/repositories/home:/p4lang/xUbuntu_${DISTRIB_RELEASE}/ /" | sudo tee /etc/apt/sources.list.d/home:p4lang.list
curl -fsSL https://download.opensuse.org/repositories/home:p4lang/xUbuntu_${DISTRIB_RELEASE}/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_p4lang.gpg > /dev/null
sudo apt-get update -y
sudo apt-get install -y p4lang-p4c p4lang-bmv2

P4-Utils Installation

This version of p4-utils has been slightly modified to address log errors. The official p4-utils version from their Git repository was found to be incompatible. Follow the steps below to install the modified version:

cd p4-utils/
sudo bash ./install.sh

Once p4-utils and all its dependencies have been installed, you can add, remove and modify P4 switches and other switch types, as well as hosts.

Learning Materials

Publications and slides found are not pushed on Gitlab. Please ask me directly if you want me to provide you with everything.

Below you'll find links to some learning materials.

Cylab blog posts

Documentation

Slides

Exercices

Architectures