P4Pi (pronounced papi or puppy) allows to design and deploy network data planes written in P4 using the Raspberry Pi platform.
Please refer to the P4Pi Wiki Pages.
The following instructions are for experts looking to build their own image. We recommend starting from the generated P4Pi images, as detailed in the wiki.
To setup your Raspberry Pi for the first time, follow the instructions on the Raspberry Pi Website, using the operating system noted below.
Start from the latest(at the time of writing) 64 bit Raspberry Pi OS lite
Update packages
sudo apt-get update && sudo apt-get full-upgrade -y
sudo apt-get install -y git
To use pcap poll mode driver install libpcap-dev
before compiling dpdk
sudo apt-get install -y libpcap-dev
Add kernel parameters for cpu isolation in /boot/cmdline.txt
eg:
isolcpus=2
Install bridge-utils
sudo apt-get install -y bridge-utils
Use --vdev net_tap0
in opts_dpdk.cfg
Start basic_mirror to create dtap0 then bridge it to eth0/wlan0:
sudo brctl addbr br0
sudo brctl addif br0 <eth0/wlan0> dtap0
sudo ifconfig br0 up
Connect pi to pc with ethernet
The pi should have something like 169.254.146.157/16
as ip(, assigned automatically without dhcp).
Configure static ip in the same subnet for the pc and add manual arp entry for a non-existant destination
sudo ip ad add 169.254.146.158/16 dev <eno0>
sudo arp -s 169.254.146.159 00:50:ba:85:85:ca
Start basic_mirror on the pi. On the pc run the iperf server and client(targeting the non-existant destination) as well eg:
iperf3 -s 169.254.146.158
iperf3 -t 120 -c 169.254.146.159
sudo apt-get install -y hostapd dnsmasq
sudo systemctl unmask hostapd
Append to /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant
Replace /etc/dnsmasq.conf
with
interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
Edit /etc/hostapd/hostapd.conf
: (fiddle with channel if needed, unfortunately the auto channel scan is not supported by the hardware)
country_code=HU
interface=wlan0
ssid=<NameOfNetwork>
hw_mode=a
channel=48
ieee80211d=1
ieee80211n=1
ieee80211ac=1
wmm_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=<Password>
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
sudo systemctl start hostapd # or enable and restart
On the pc add a manual arp entry for a non-existant destination in the same subnet and run iperf with that as a destination eg
sudo arp -s 192.168.4.10 00:50:ba:85:85:ca
export P4PI=/root/t4p4s/pi
export GRPC=/root/t4p4s/grpc
export GRPCPP=/root/t4p4s/P4Runtime_GRPCPP
By default the following command is executed on start-up by p4pi-setup.service
.
sudo p4pi-setup
It creates two virtual Ethernet devices pairs and two bridge interfaces are used in T4P4S examples to process packets.
In order to add the wireless access point interface to a bridge used T4P4S,
uncomment the following line in /etc/hostapd/hostapd.conf
:
#bridge=br0
With pcap PMD
baseline:
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-120.00 sec 13.1 GBytes 941 Mbits/sec 1 sender
[ 5] 0.00-120.00 sec 13.1 GBytes 941 Mbits/sec receiver
bmv2:
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-120.00 sec 639 MBytes 44.7 Mbits/sec 19456 sender
[ 5] 0.00-120.00 sec 639 MBytes 44.7 Mbits/sec receiver
dpdk (with hugepages and isolated cpu core)
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-120.00 sec 1.18 GBytes 84.6 Mbits/sec 2478 sender
[ 5] 0.00-120.01 sec 1.18 GBytes 84.5 Mbits/sec receiver
T4P4S:
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-120.00 sec 973 MBytes 68.0 Mbits/sec 2965 sender
[ 5] 0.00-120.02 sec 970 MBytes 67.8 Mbits/sec receiver
T4P4S with Tap PMD:
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-120.00 sec 2.57 GBytes 184 Mbits/sec 522 sender
[ 5] 0.00-120.04 sec 2.57 GBytes 184 Mbits/sec receiver
Baseline:
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-120.00 sec 827 MBytes 57.8 Mbits/sec 0 sender
[ 5] 0.00-120.02 sec 824 MBytes 57.6 Mbits/sec receiver
T4P4s:
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-120.00 sec 396 MBytes 27.7 Mbits/sec 401 sender
[ 5] 0.00-120.06 sec 393 MBytes 27.5 Mbits/sec receiver
T4P4S with Tap PMD:
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-120.00 sec 415 MBytes 29.0 Mbits/sec 1 sender
[ 5] 0.00-120.09 sec 413 MBytes 28.8 Mbits/sec receiver