bpf echo
1.0.0
bpf-echo is a blazing fast TCP & UDP echo server that supports IPv4 and IPv6 traffic. Its implementation leverages extended Berkeley Packet Filter and BPF Compiler Collection in order to redirect outgoing packets straight back to the sending socket's receive queue. It's perfect for benchmarking proxy servers, or network libraries, where you want to make sure that the upstream server is not a bottleneck.
The requirements for running bpf-echo
are:
pip3 install pyroute2
python3-bpfcc
in Ubuntu package repositories.
Check out bcc's INSTALL.md for more details4.1
$ sudo ./bpf-echo --ipv4 127.0.0.1 --port 1122 # run in different terminal
$ echo "hello" | nc -W1 127.0.0.1 1122
hello
usage: bpf-echo.py [-h] [--ipv4 IPV4] [--ipv6 IPV6] [--port PORT]
[--ifname IFNAME]
optional arguments:
-h, --help show this help message and exit
--ipv4 IPV4 IPv4 address that will reflect packets. Disabled if empty
string. (default: 127.0.0.1)
--ipv6 IPV6 IPv6 address that will reflect packets. Disabled if empty
string. (default: )
--port PORT TCP/UDP destination port that will reflect packets.
(default: 12345)
--ifname IFNAME Interface the eBPF classifier will be loaded on. (default:
lo)
The BPF implementation is rather simple, and thus it makes some compromises: