Giter Site home page Giter Site logo

p4lang / p4pi Goto Github PK

View Code? Open in Web Editor NEW
122.0 19.0 31.0 6.1 MB

P4 on Raspberry Pi for Networking Education

License: Apache License 2.0

Makefile 0.54% P4 13.19% C 2.14% Meson 0.04% Dockerfile 0.05% Shell 5.91% sed 0.03% Python 9.68% CSS 31.05% JavaScript 33.34% HTML 4.04%
raspberry-pi p4 wifi

p4pi's Introduction

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

p4pi's People

Contributors

dependabot[bot] avatar dingdamu avatar icephoenx avatar levaitamas avatar noaz avatar robertsoule avatar rst0git avatar slaki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

p4pi's Issues

Using a custom kernel version

Hii!

Is there a minimum kernel version required to run p4pi?

I'm planning to run a custom wifi firmware which supports only versions 5.4 and 4.19, whereas p4pi iso ships with 5.10. So I would like to either downgrade the kernel or fork the repo and create an ISO with kernel 5.4 (any advice for which would be greately appreciated too :)

Thanks :)

Cannot boot a new kernel

Hi,

I am working on compiling a kernel with BPF modules included for tc and the p4c-ebpf. I am stuck at booting a new kernel.

I was following the p4pi kernel compilation guide at https://github.com/p4lang/p4pi/tree/master/p4pi-kernel/README.md with the current raspberrypi-linux version (5.10.60) taken from https://github.com/raspberrypi/linux.

I have the deb packages compiled:

-rw-r--r--  1 pi pi  7562092 Aug 24 09:06 p4pi-linux-headers-5.10.60-v8+_5.10.60-v8+-1_arm64.deb
-rw-r--r--  1 pi pi 22517552 Aug 24 09:07 p4pi-linux-image-5.10.60-v8+_5.10.60-v8+-1_arm64.deb
-rw-r--r--  1 pi pi  1118852 Aug 24 09:06 p4pi-linux-libc-dev_5.10.60-v8+-1_arm64.deb

However, after installing the image and header packages, the system still boots the old kernel:

pi@p4pi:~$ uname -a
Linux p4pi 5.10.52-v8+ #1 SMP PREEMPT Sat Aug 7 03:52:12 UTC 2021 aarch64 GNU/Linux

Do you have any ideas which step is missing?

Thanks,
Tamas

About the broadcast port.

This P4 program uses 9w100 as the value for the broadcast port.
Why does P4 recognize this value as a broadcast port?
Where is it defined?

lwSwitch is not starting

[�[1;32mRUN SWITCH�[0m] �[1;33m./build/last/build/l2switch�[0m
.echo_tmp: 2: cannot create /sys/devices/system/node/node?/hugepages/hugepages-2048kB/nr_hugepages: Directory nonexistent
�[0m
�[1;31mError�[0m: Needed to reserve �[1;32m1024�[0m hugepages, got �[1;31monly 278�[0m (error code: �[1;36m8�[0m)

Simple L2 Switch - stuck on launching P4Runtime-shell

I get this error while running example L2 Switch.
pi@p4pi:~$ sudo t4p4s-p4rtshell l2switch
Generating P4Runtime files...
~/t4p4s/examples/p4rt_files /home/pi
/home/pi
Launching P4Runtime-shell...
CRITICAL:root:StreamChannel error, closing stream
CRITICAL:root:P4Runtime RPC error (UNAVAILABLE): failed to connect to all addresses
CRITICAL:root:Failed to establish session with server

compiling failure

Compiling error by following the tutorial in the youtube video 'T4P4S: Translator for P4 Switches' from the time mark 11:37 to time mark 14:49.
The error code shown in our terminal is "Error: Was asked to reserve 1024 hugepages, got only 693 (error code: 1)".

Eth Wlan Bridge Not Working

I attempted to follow the steps to create an eth wlan bridge here, but the bridge did not work properly. I receive no errors in the setup, but when I connect to the pi access point I do not have access to the internet.

Testing over Ethernet

Hello, I'm new to P4PI.
I would like to test P4 applications over Ethernet as I noticed some issues with WiFi access point.
A simple ping (ping the P4PI over Ethernet) or loopback example (send Ethernet frame to P4 program and the P4 program sends it back to original PC )
Can you please guide me through the needed steps to connect the P4 program to the Ethernet port?

Traffic filter does not stop Netcat between wifi-connected devices

What we tried to do

Hi guys,
We tried changing the traffic filter example in the examples section from a block-list to an allow-list.
To do so, we changed the default action of the tables to be drop, instead of NoAction. We then run the program with no rules applied, to see if every packet is indeed dropped.

The problem

When we run in verbose mode, the compiler states that every received packet is dropped.
The problem is that when we open a Netcat connection between 2 laptops connected to the p4pi network, or when we open a Netcat connection between a connected laptop and the p4pi itself, the messages get through and reach the other side, even though all the packets seem to be dropped.

We tried writing a simpler program that just calls drop on every packet in MyIngress' apply, and again it states that every packet is dropped, but the connection goes through.

What we think / don't understand

The example shows the capability of the firewall by running an iperf server inside the gigport namespace. This does work for us.
The problem is when we use Netcat outside of the gigport namespace - between 2 laptops or a laptop and the p4pi.
Do we need to run something inside the gigport namespace?
Can we expend the firewall capabilities to support blocking communication between 2 connected devices?

Thank you for your help.

is P4Pi support multiplication?

Hello,

It is possible to run the BMv2 software switch on the Raspberry Pi platform.
In the BMv2, the multiplication operation is supported.
So does it mean P4Pi also supports multiplication operations?

ethernet doesn't work

The ethernet cable is connected to the Raspberry Pi 4. But there is no internet and the first line of code from the 'Direct Ethernet Connection' tutorial doesn't work. The error code shown is "Syntax error near unexpected token 'new line'".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.