Rust AF_XDP demo using Aya for high-performance packet processing. Includes AWS setup via Ansible and containerized deployment options.
rust-afxdp-demo
provides a complete solution for:
- High-performance packet processing using Rust + eBPF
- AF_XDP zero-copy networking
- AWS EC2 automation with Ansible
- Container-based deployment
It uses the Rust Aya library for writing safe Rust eBPF programs, avoiding unsafe C code.
rust-afxdp-demo/
├── ansible/
│ ├── inventory/
│ │ └── hosts.ini
│ ├── playbooks/
│ │ ├── 01-create-vpc.yml
│ │ ├── 02-launch-ec2.yml
│ │ ├── 03-setup-instance.yml
│ │ └── 04-install-ebpf-tools.yml
│ └── README.md # Overview for Ansible roles/playbooks
│
├── aya-ebpf/ # Rust Aya XDP program
│ ├── Cargo.toml
│ └── src/
│ ├── main.rs
│ ├── xdp_filter.rs
│ └── common.rs
│
├── udp-bench/ # Custom UDP benchmarking tool
│ ├── Cargo.toml
│ └── src/
│ ├── main.rs # CLI entry point
│ ├── sender.rs # Windows → EC2 packet generator
│ ├── receiver.rs # EC2-side packet receiver (for stats)
│ └── stats.rs # Stats utilities
│
├── container/
│ ├── Dockerfile
│ └── entrypoint.sh
│
├── diagrams/
│ ├── architecture.puml # PlantUML file
│ └── architecture.png # Rendered diagram
│
├── scripts/
│ ├── build.sh
│ ├── run-test.sh
│ └── cleanup.sh
│
├── docs/
│ ├── AWS_SETUP.md
│ ├── EBPF_AYA_AF_XDP.md
│ ├── CONTAINER_SETUP.md
│ ├── TESTING_GUIDE.md
│ └── UDP_BENCHMARK.md # Guide for using custom UDP tool
│
├── .github/
│ └── workflows/
│ └── ci.ymll
│
├── LICENSE
└── README.md
- AWS CLI and credentials configured
- Ansible installed locally
- Rust 1.74+, cargo xtask, bpf-linker
- Linux kernel headers on EC2 instance
- Podman (optional for container tests)
Step 1: Provision AWS Infrastructure
- Creates VPC, subnets, Internet Gateway, security groups
- Deploys an ENA-enabled EC2 instance (e.g.,
c5n.large
) - Sets up SSH access and Ansible inventory
Run:
cd ansible
ansible-playbook playbooks/01-create-vpc.yml
ansible-playbook playbooks/02-launch-ec2.yml