Hi All, Sorry for the delay.
I remembered I got better UDP performance in another system. So I had to track it. First, please find the code at the end of this mail. - Version: I used go 1.7.1 - Platform: Ubuntu 16.10 on x86_64 (I used two setups. In one, I used i7 Skull Canyon NUC and in the other the two systems are E5-2650 v4 based 2U servers with 10Gb and 1Gb links) - Model: One side just sends and the other side just receives pkts. - I didnt profile the code yet. Now, based on my tests, this is what I see: - in the Xeon based servers, I get about 2.6Gbps (0.0Kbps reverse comm). - The same setup has 1Gb links. I get about 956Mbps. This is good too! - With localhost, I get about 2.7Gbps. Now, in i7 NUC: - With localhost, I get about 4.6Gbps. - With a peer IP address, I get only about 220Mbps. This is where I got stuck. There are some things to note. First, there is no peer. It just sends to the other side. This leads to ICMP packets in the reverse side, though low (5kbps). What is more, I simply sent the packets to 192.168.1.1 which is my home router/gateway, Linksys WRT610N. Probably, this is my bottleneck. I still dont have proof that the ethernet port on the NUC is good enough. I will connect a Mac soon and find it out. Hope this helps. Thanks dharani ------------------------------------------ package main import ( "fmt" "net" "os" "time" ) var buffer []byte var displayReq bool var pkts int var bytes int var dest string func send() { conn, err := net.Dial("udp", dest) if err != nil { fmt.Printf("Dial() failed. Error %s\n", err) os.Exit(1) } defer conn.Close() pkts = 0 bytes = 0 for { n, err := conn.Write(buffer[0:1472]) if err != nil { //fmt.Printf("Write failed! Error: %s\n", err) //os.Exit(1) } pkts++ bytes += n } } func recv() { pc, err := net.ListenPacket("udp", ":45000") if err != nil { fmt.Printf("Read failed! Error: %s\n", err) os.Exit(1) } defer pc.Close() pkts = 0 bytes = 0 for { n, addr, err := pc.ReadFrom(buffer) if err != nil { fmt.Printf("Read failed! Error: %s\n", err) os.Exit(1) } if false { fmt.Printf("Got a pkt from addr: %s\n", addr) } pkts++ bytes += n } } func main() { if len(os.Args) != 3 { fmt.Printf("Usage: %s [send|recv] addr:port\n", os.Args[0]) os.Exit(1) } mode := os.Args[1] dest = os.Args[2] buffer = make([]byte, 1600) go displayTimerProc() if mode == "send" { send() } else { recv() } } func displayTimerProc() { for { displayReq = true time.Sleep(time.Second) fmt.Printf("Pkts %d, Bytes %d, rate %d mbps\n", pkts, bytes, bytes*8/(1000*1000)) pkts = 0 bytes = 0 } } ------------------------------------------ On Tue, Feb 21, 2017 at 3:51 AM, Konstantin Khomoutov < flatw...@users.sourceforge.net> wrote: > On Mon, 20 Feb 2017 13:02:15 -0800 > Tharaneedharan Vilwanathan <vdhar...@gmail.com> wrote: > > > Hi All, > > > > I am trying to send a lot of UDP packets from Go code but I realized > > UDP performance is too low. The max I was able to do is about > > 160Mbps. This is in Ubuntu 16.10 on x86_64 (i7-6700HQ). > > > > I tried to google on this and it looks like this is about the > > performance we can get. I am a bit surprised. > > > > Am I missing something? Any suggestions on how to improve the > > performance? > > You could estimate what a "dumb sender written in C" could produce: > > On the receiver box, do: > > # apt install netcat-openbsd > $ nc -k -u -l 6666 >/dev/null > > On the sender box, do: > > # apt install netcat-openbsd pv > $ pv </dev/zero | nc -u receiver_ip 6666 > > and see what speed pv will show to you. > > On my old Intel E8400 Core2Duo machine I get circa 900MiB when > transferring between a two endpoints on the localhost using a pair of > netcats. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.