{"id":23908196,"url":"https://github.com/adithaker/xdp_sfu","last_synced_at":"2026-05-02T17:39:04.051Z","repository":{"id":268625833,"uuid":"904974268","full_name":"ADIthaker/XDP_SFU","owner":"ADIthaker","description":"🖲️Selective Forwarding Unit Implementation using XDP and TC hooks","archived":false,"fork":false,"pushed_at":"2025-01-04T10:28:00.000Z","size":2666,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T15:15:36.936Z","etag":null,"topics":["c","ebpf","ebpf-tc","ebpf-xdp","linux-kernel","rtp-streaming","webrtc","wireshark"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ADIthaker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-12-17T22:57:17.000Z","updated_at":"2025-01-04T10:32:57.000Z","dependencies_parsed_at":"2024-12-17T23:38:41.975Z","dependency_job_id":null,"html_url":"https://github.com/ADIthaker/XDP_SFU","commit_stats":null,"previous_names":["adithaker/xdp_sfu"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADIthaker%2FXDP_SFU","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADIthaker%2FXDP_SFU/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADIthaker%2FXDP_SFU/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADIthaker%2FXDP_SFU/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ADIthaker","download_url":"https://codeload.github.com/ADIthaker/XDP_SFU/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240331361,"owners_count":19784646,"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":["c","ebpf","ebpf-tc","ebpf-xdp","linux-kernel","rtp-streaming","webrtc","wireshark"],"created_at":"2025-01-05T04:26:49.587Z","updated_at":"2026-05-02T17:39:04.012Z","avatar_url":"https://github.com/ADIthaker.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Implementing SFU in XDP\n\n## Overview\n\nThis project explores implementing a Selective Forwarding Unit (SFU) for video conferencing using **XDP (eXpress Data Path)** and **Traffic Control (TC)** in the Linux kernel. By leveraging **eBPF (Extended Berkeley Packet Filter)** technology, the project aims to enhance the performance of packet processing by bypassing the traditional Linux networking stack.\n\n## Motivation\n\n- **Video Conferencing Challenges**:  \n  SFU servers process and forward media streams, but they face inefficiencies due to the need to traverse the entire Linux stack.\n- **eBPF Advantages**:  \n  eBPF programs can run at the driver level, improving packet processing speed.\n- **Goals**:  \n  - Enable forwarding packets with flexibility in quality and format.  \n  - Optimize performance for multi-participant video conferencing.  \n\n## About XDP and TC\n\n- **XDP**:  \n  A high-performance framework for packet processing at the link layer.  \n  - **Advantages**: Fast and efficient.  \n  - **Limitations**: Limited memory and restricted packet access.\n  \n- **TC**:  \n  Operates within the Linux network stack, allowing full packet modification.  \n  - **Advantages**: Packet cloning and extended manipulation capabilities.  \n  - **Limitations**: Slower than XDP.\n\n## About SFU\n\nAn SFU is a specialized network architecture for video conferencing that:  \n- Receives all participant streams.  \n- Processes and forwards streams based on participants' needs.  \n- Utilizes RTP (Real-time Transport Protocol) for media streams and control packets (e.g., SDP, RTCP, ICE).\n\n## Progress\n\n- Implemented SFU for 2 participants using XDP and TC.\n- eBPF maps used to store participant IPs and ports.\n- Scapy scripts created to generate RTP packets for testing.\n- Utilized tools for debugging and analysis:\n  - `bpf_printk` for tracing.\n  - `llvm-objdump` for compiler inspection.\n  - `tcpdump` and `xdpdump` for packet monitoring.\n  - `bpftool` for map visualization.\n\n## Challenges\n\n- **XDP Limitations**:  \n  - Restricted stack memory (512 bytes).  \n  - Single packet in/out framework.  \n- **TC Limitations**:  \n  - Slower than XDP.  \n- **Documentation Gaps**:  \n  - Sparse resources for pointer arithmetic and data types.  \n- **Control Plane Integration**:  \n  - Requires application-layer modifications via AF_XDP sockets.  \n- **Debugging**:  \n  - Minimal support for meaningful debug outputs.\n\n## Resources\n\n1. [Supercharge WebRTC with eBPF/XDP (T. Lévai et al., 2023)](https://doi.org/10.1145/3609021.3609296)\n2. [XDP Project - Tutorials](https://github.com/xdp-project/xdp-tutorial)\n3. [Debugging XDP Packet Issues](https://fedepaol.github.io/blog/2023/09/11/xdp-ate-my-packets-and-how-i-debugged-it)\n4. [WebRTC for the Curious](https://webrtcforthecurious.com)\n\n## Setup dependencies\n\nBefore you can start completing step in this tutorial, you will need to\ninstall a few dependencies on your system. These are described in\n[setup](./setup_dependencies.org).\n### Runnning the programs\n\n - XDP:\n    ```\n    # /sfu/sfu\n    make\n    ./xdp-loader load -m skb lo xdp_prog_kern.o -p /sys/fs/bpf/lo -vv   # load bpf with pin path to map to loopback\n    ./xdp-loader unload lo --all                                        # unload program\n    ./xdp-loader clean lo                                               # clean all links\n\n\n    # Debugging/Outpu\n\n    xdpdump -i lo --rx-capture exit\n    cat /sys/kernel/debug/tracing/trace-pipe\n\n    ```\n - TC:\n    ```\n    # /sfu/sfu\n    clang -O2 -emit-llvm -g -c tc_prog_kern.c -o- | llc -march=bpf -mcpu=probe -filetype=obj tc_prog_kern.o\n\n    tc qdisc add dev lo clsact                               # create a qdisc\n    tc filter add dev lo ingress bpf da obj tc_prog_kern.o   # load bpf \n    tc qdisc del dev lo clsact                               # remove bpf chain\n\n    # Debugging/Output\n\n    tcpdump -i lo \n    cat /sys/kernel/debug/tracing/trace-pipe\n\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadithaker%2Fxdp_sfu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadithaker%2Fxdp_sfu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadithaker%2Fxdp_sfu/lists"}