{"id":19454588,"url":"https://github.com/p4lang/p4pi","last_synced_at":"2025-04-25T05:30:36.056Z","repository":{"id":39564500,"uuid":"381155979","full_name":"p4lang/p4pi","owner":"p4lang","description":"P4 on Raspberry Pi for Networking Education","archived":false,"fork":false,"pushed_at":"2024-05-08T13:19:39.000Z","size":6243,"stargazers_count":126,"open_issues_count":8,"forks_count":33,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-03T16:41:35.961Z","etag":null,"topics":["p4","raspberry-pi","wifi"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p4lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-28T20:39:39.000Z","updated_at":"2024-11-27T17:55:28.000Z","dependencies_parsed_at":"2024-11-10T17:10:26.384Z","dependency_job_id":"43c98754-85ff-434d-8b05-ca2b7aaa6cbd","html_url":"https://github.com/p4lang/p4pi","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2Fp4pi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2Fp4pi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2Fp4pi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2Fp4pi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p4lang","download_url":"https://codeload.github.com/p4lang/p4pi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250760551,"owners_count":21482826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["p4","raspberry-pi","wifi"],"created_at":"2024-11-10T17:10:22.125Z","updated_at":"2025-04-25T05:30:33.564Z","avatar_url":"https://github.com/p4lang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"P4Pi Logo\" width=\"256px\" src=\"docs/images/logo.png\"\u003e\n\u003c/p\u003e\n\n-------------------------------------------------------------------------------\n\nP4Pi (pronounced papi or puppy) allows to design and deploy network data planes\nwritten in P4 using the Raspberry Pi platform.\n\n# Getting Started\n\nPlease refer to the [P4Pi Wiki Pages](https://github.com/p4lang/p4pi/wiki).\n\nThe following instructions are for experts looking to build their own image. We recommend starting from the generated P4Pi images, as detailed in the wiki.\n\n# Common\n\nTo setup your Raspberry Pi for the first time, follow the instructions on [the Raspberry Pi Website](https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up), using the operating system noted below.\n\nStart from the latest(_at the time of writing_) [64 bit Raspberry Pi OS lite](https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2021-04-09/2021-03-04-raspios-buster-arm64-lite.zip)\n\nUpdate packages\n```bash\nsudo apt-get update \u0026\u0026 sudo apt-get full-upgrade -y\nsudo apt-get install -y git\n```\n\nTo use pcap poll mode driver install `libpcap-dev` before compiling dpdk\n```bash\nsudo apt-get install -y libpcap-dev\n```\n\n# Performance tuning\n\n## Isolate CPU core(s)\nAdd kernel parameters for cpu isolation in `/boot/cmdline.txt` eg:\n```\nisolcpus=2\n```\n\n## Tap Poll Mode Driver\nInstall `bridge-utils`\n```bash\nsudo apt-get install -y bridge-utils\n```\nUse `--vdev net_tap0` in `opts_dpdk.cfg`\nStart basic_mirror to create dtap0 then bridge it to eth0/wlan0:\n```bash\nsudo brctl addbr br0\nsudo brctl addif br0 \u003ceth0/wlan0\u003e dtap0\nsudo ifconfig br0 up\n```\n\n## Pi as WiFi AP\n\n[Based on this](https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md)\n\n### Install hostapd and dnsmasq\n```bash\nsudo apt-get install -y hostapd dnsmasq\nsudo systemctl unmask hostapd\n```\n\n### Configure static ip for the pi\nAppend to `/etc/dhcpcd.conf`\n```bash\ninterface wlan0\n    static ip_address=192.168.4.1/24\n    nohook wpa_supplicant\n```\n### Configure dhcp\nReplace `/etc/dnsmasq.conf` with\n```bash\ninterface=wlan0\ndhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h\n```\n### Configure hostapd\nEdit `/etc/hostapd/hostapd.conf`:  (fiddle with channel if needed, unfortunately the auto channel scan is not supported by the hardware)\n```bash\ncountry_code=HU\ninterface=wlan0\nssid=\u003cNameOfNetwork\u003e\nhw_mode=a\nchannel=48\nieee80211d=1\nieee80211n=1\nieee80211ac=1\nwmm_enabled=1\nmacaddr_acl=0\nauth_algs=1\nignore_broadcast_ssid=0\nwpa=2\nwpa_passphrase=\u003cPassword\u003e\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=TKIP\nrsn_pairwise=CCMP\n```\n\n### Start hostapd\n```bash\nsudo systemctl start hostapd # or enable and restart\n```\n\nOn 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\n```bash\nsudo arp -s 192.168.4.10 00:50:ba:85:85:ca\n```\n\n# Configuration settings\n\n## Environmental variables\n\n```\nexport P4PI=/root/t4p4s/pi\nexport GRPC=/root/t4p4s/grpc\nexport GRPCPP=/root/t4p4s/P4Runtime_GRPCPP\n```\n\n## Creating veth pairs\n\nBy default the following command is executed on start-up by `p4pi-setup.service`.\n\n```bash\nsudo p4pi-setup\n```\nIt creates two virtual Ethernet devices pairs and two bridge interfaces\nare used in T4P4S examples to process packets.\n\nIn order to add the wireless access point interface to a bridge used T4P4S,\nuncomment the following line in `/etc/hostapd/hostapd.conf`:\n\n```\n#bridge=br0\n```\n\n\n# Results\n\nWith pcap PMD\n\n## Ethernet\n\nbaseline:\n```\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-120.00 sec  13.1 GBytes   941 Mbits/sec    1             sender\n[  5]   0.00-120.00 sec  13.1 GBytes   941 Mbits/sec                  receiver\n\n```\n\nbmv2:\n```\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-120.00 sec   639 MBytes  44.7 Mbits/sec  19456             sender\n[  5]   0.00-120.00 sec   639 MBytes  44.7 Mbits/sec                  receiver\n```\ndpdk (with hugepages and isolated cpu core)\n```\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-120.00 sec  1.18 GBytes  84.6 Mbits/sec  2478             sender\n[  5]   0.00-120.01 sec  1.18 GBytes  84.5 Mbits/sec                  receiver\n```\n\nT4P4S:\n```\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-120.00 sec   973 MBytes  68.0 Mbits/sec  2965             sender\n[  5]   0.00-120.02 sec   970 MBytes  67.8 Mbits/sec                  receiver\n\n```\n\nT4P4S with Tap PMD:\n```\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-120.00 sec  2.57 GBytes   184 Mbits/sec  522             sender\n[  5]   0.00-120.04 sec  2.57 GBytes   184 Mbits/sec                  receiver\n\n```\n\n## WiFi\n\nBaseline:\n```\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-120.00 sec   827 MBytes  57.8 Mbits/sec    0             sender\n[  5]   0.00-120.02 sec   824 MBytes  57.6 Mbits/sec                  receiver\n```\n\nT4P4s:\n```\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-120.00 sec   396 MBytes  27.7 Mbits/sec  401             sender\n[  5]   0.00-120.06 sec   393 MBytes  27.5 Mbits/sec                  receiver\n\n```\nT4P4S with  Tap PMD:\n```\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-120.00 sec   415 MBytes  29.0 Mbits/sec    1             sender\n[  5]   0.00-120.09 sec   413 MBytes  28.8 Mbits/sec                  receiver\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4lang%2Fp4pi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp4lang%2Fp4pi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4lang%2Fp4pi/lists"}