xdp

所属分类:Linux/Unix编程
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2023-02-25 07:48:50
上 传 者sh-1993
说明:  Package-xdp允许使用Go编程语言中的xdp套接字。
(Package xdp allows one to use XDP sockets from the Go programming language.)

文件列表:
LICENSE (1531, 2022-02-12)
examples/ (0, 2022-02-12)
examples/dumpframes/ (0, 2022-02-12)
examples/dumpframes/dumpframes.go (3735, 2022-02-12)
examples/dumpframes/ebpf/ (0, 2022-02-12)
examples/dumpframes/ebpf/Dockerfile (528, 2022-02-12)
examples/dumpframes/ebpf/Makefile (128, 2022-02-12)
examples/dumpframes/ebpf/include/ (0, 2022-02-12)
examples/dumpframes/ebpf/include/Makefile (224, 2022-02-12)
examples/dumpframes/ebpf/include/bpf/ (0, 2022-02-12)
examples/dumpframes/ebpf/include/bpf/bpf_endian.h (3750, 2022-02-12)
examples/dumpframes/ebpf/include/bpf/bpf_helper_defs.h (121588, 2022-02-12)
examples/dumpframes/ebpf/include/bpf/bpf_helpers.h (1875, 2022-02-12)
examples/dumpframes/ebpf/ipproto.go (946, 2022-02-12)
examples/dumpframes/ebpf/ipproto_bpfeb.go (48969, 2022-02-12)
examples/dumpframes/ebpf/ipproto_bpfel.go (48975, 2022-02-12)
examples/dumpframes/ebpf/single_protocol_filter.c (2058, 2022-02-12)
examples/dumpframes/ebpf/single_protocol_filter.go (1069, 2022-02-12)
examples/l2fwd/ (0, 2022-02-12)
examples/l2fwd/l2fwd.go (6068, 2022-02-12)
examples/l2fwd/vagrant/ (0, 2022-02-12)
examples/l2fwd/vagrant/client/ (0, 2022-02-12)
examples/l2fwd/vagrant/client/Vagrantfile (743, 2022-02-12)
examples/l2fwd/vagrant/client/setup_experiment.sh (186, 2022-02-12)
examples/l2fwd/vagrant/l2fwd/ (0, 2022-02-12)
examples/l2fwd/vagrant/l2fwd/50-memlock.conf (20, 2022-02-12)
examples/l2fwd/vagrant/l2fwd/Vagrantfile (1246, 2022-02-12)
examples/l2fwd/vagrant/l2fwd/setup_experiment.sh (277, 2022-02-12)
examples/l2fwd/vagrant/server/ (0, 2022-02-12)
examples/l2fwd/vagrant/server/Vagrantfile (710, 2022-02-12)
examples/l2fwd/vagrant/server/setup_experiment.sh (186, 2022-02-12)
examples/rebroadcast/ (0, 2022-02-12)
examples/rebroadcast/rebroadcast.go (4571, 2022-02-12)
examples/senddnsqueries/ (0, 2022-02-12)
... ...

# xdp [![Go Reference](https://pkg.go.dev/badge/github.com/asavie/xdp.svg)](https://pkg.go.dev/github.com/asavie/xdp) Package github.com/asavie/xdp allows one to use [XDP sockets](https://lwn.net/Articles/750845/) from the Go programming language. For usage examples, see the [documentation](https://pkg.go.dev/github.com/asavie/xdp) or the [examples/](https://github.com/asavie/xdp/tree/master/examples) directory. ## Performance ### examples/sendudp With the default UDP payload size of 1400 bytes, running on Linux kernel 5.1.20, on a [tg3](https://github.com/torvalds/linux/blob/master/drivers/net/ethernet/broadcom/tg3.c) (so no native XDP support) gigabit NIC, [sendudp.go](https://github.com/asavie/xdp/blob/master/examples/sendudp/sendudp.go) does around 980 Mb/s, so practically line rate. ### examples/senddnsqueries TL;DR: in the same environment, sending a pre-generated DNS query using an ordinary UDP socket yields around 30 MiB/s whereas sending it using the [senddnsqueries.go](https://github.com/asavie/xdp/blob/master/examples/senddnsqueries/senddnsqueries.go) example program yields around 77 MiB/s. Connecting a PC with Intel Core i7-7700 CPU running Linux kernel 5.0.17 and igb driver to a laptop with Intel Core i7-5600U CPU running Linux kernel 5.0.9 with e1000e with a cat 5E gigabit ethernet cable and using the following program ```go package main import ( "net" "github.com/miekg/dns" ) func main() { query := new(dns.Msg) query.SetQuestion(dns.Fqdn("asavie.com"), dns.TypeA) payload, err := query.Pack() if err != nil { panic(err) } conn, err := net.ListenPacket("udp", ":0") if err != nil { panic(err) } defer conn.Close() dst, err := net.ResolveUDPAddr("udp", "192.168.111.10:53") if err != nil { panic(err) } for { _, err = conn.WriteTo(payload, dst) if err != nil { panic(err) } } } ``` which uses an ordinary UDP socket to send a pre-generated DNS query from PC to laptop as quickly as possible - I get about 30 MiB/s at laptop side. Using the [senddnsqueries.go](https://github.com/asavie/xdp/blob/master/examples/senddnsqueries/senddnsqueries.go) example program - I get about 77 MiB/s at laptop side.

近期下载者

相关文件


收藏者