项目作者: asavie

项目描述 :
Package xdp allows one to use XDP sockets from the Go programming language.
高级语言: Go
项目地址: git://github.com/asavie/xdp.git
创建时间: 2019-06-18T11:50:24Z
项目社区:https://github.com/asavie/xdp

开源协议:BSD 3-Clause "New" or "Revised" License

下载


The project is continued here: https://github.com/slavc/xdp

https://github.com/asavie/xdp is now archived.


xdp

Go Reference

Package github.com/asavie/xdp allows one to use XDP sockets from the Go programming language.

For usage examples, see the documentation or the examples/ directory.

Performance

examples/sendudp

With the default UDP payload size of 1400 bytes, running on Linux kernel
5.1.20, on a
tg3
(so no native XDP support) gigabit NIC,
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
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

  1. package main
  2. import (
  3. "net"
  4. "github.com/miekg/dns"
  5. )
  6. func main() {
  7. query := new(dns.Msg)
  8. query.SetQuestion(dns.Fqdn("asavie.com"), dns.TypeA)
  9. payload, err := query.Pack()
  10. if err != nil {
  11. panic(err)
  12. }
  13. conn, err := net.ListenPacket("udp", ":0")
  14. if err != nil {
  15. panic(err)
  16. }
  17. defer conn.Close()
  18. dst, err := net.ResolveUDPAddr("udp", "192.168.111.10:53")
  19. if err != nil {
  20. panic(err)
  21. }
  22. for {
  23. _, err = conn.WriteTo(payload, dst)
  24. if err != nil {
  25. panic(err)
  26. }
  27. }
  28. }

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
example program - I get about 77 MiB/s at laptop side.