• Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

P4 on Raspberry Pi for Networking Education

P4Pi Logo


P4Pi (pronounced papi or puppy) allows to design and deploy network data planes written in P4 using the Raspberry Pi platform.

Getting Started

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.

Common

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

Performance tuning

Isolate CPU core(s)

Add kernel parameters for cpu isolation in /boot/cmdline.txt eg:

isolcpus=2

Tap Poll Mode Driver

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

Pi as WiFi AP

Based on this

Install hostapd and dnsmasq

sudo apt-get install -y hostapd dnsmasq
sudo systemctl unmask hostapd

Configure static ip for the pi

Append to /etc/dhcpcd.conf

interface wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant

Configure dhcp

Replace /etc/dnsmasq.conf with

interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h

Configure hostapd

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

Start hostapd

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

Configuration settings

Environmental variables

export P4PI=/root/t4p4s/pi
export GRPC=/root/t4p4s/grpc
export GRPCPP=/root/t4p4s/P4Runtime_GRPCPP

Creating veth pairs

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

Results

With pcap PMD

Ethernet

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

WiFi

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

More Repositories

1

tutorials

P4 language tutorials
P4
1,332
star
2

p4c

P4_16 reference compiler
C++
671
star
3

behavioral-model

The reference P4 software switch
C++
536
star
4

p4-spec

TeX
175
star
5

p4factory

Compile P4 and run the P4 behavioral simulator
C
174
star
6

p4app-switchML

Switch ML Application
C++
167
star
7

PI

An implementation framework for a P4Runtime server
C++
165
star
8

switch

Consolidated switch repo (API, SAI and Nettlink)
C
152
star
9

p4runtime

Specification documents for the P4Runtime control-plane API
Rust
146
star
10

ptf

Packet Test Framework
Python
144
star
11

p4app

Python
112
star
12

p4-applications

P4 Applications WG repo
P4
107
star
13

p4runtime-shell

An interactive Python shell for P4Runtime
Python
76
star
14

p4-dpdk-target

P4 driver SW for P4 DPDK target.
C++
56
star
15

pna

Portable NIC Architecture
P4
54
star
16

tdi

Table-Driven Interface (TDI) for a P4-programmable backend device.
C++
39
star
17

papers

Repository for papers related to P4
C
38
star
18

ntf

Network Test Framework
Python
37
star
19

education

P4 for Education
36
star
20

scapy-vxlan

A scapy clone, with support for additional packet headers
Python
36
star
21

p4-hlir

Python
32
star
22

p4ofagent

Openflow agent on a P4 dataplane
C
27
star
23

p4c-bm

Generates the JSON configuration for the behavioral-model (bmv2), as well as the C/C++ PD code
Python
24
star
24

p4lang.github.io

Deprecated P4.org website
HTML
23
star
25

p4analyzer

A Language Server Protocol (LSP) compliant analyzer for the P4 language
Rust
19
star
26

p4c-behavioral

[deprecated] P4 compiler for the behavioral model
C
18
star
27

p4app-TCP-INT

C
18
star
28

p4-constraints

Constraints on P4 objects enforced at runtime
C++
14
star
29

p4-build

Infrastructure needed to generate, build and install the PD library for a given P4 program
C++
12
star
30

gsoc

P4.org's Participation in Google Summer of Code
9
star
31

third-party

Third-party dependencies for p4lang software
Dockerfile
8
star
32

project-ideas

Ideas for P4 Projects.
6
star
33

target-utils

C
4
star
34

target-syslibs

C
3
star
35

hackathons

P4
2
star
36

governance

1
star