Hello my dear community!
I have weird performance drops with udp - huge packet loss.
Simple receiver and sender:
####################################################################
#coding: utf-8
require “socket”
httpd=Socket.new(Socket::AF_INET,Socket::SOCK_DGRAM,0)
httpd.bind(Socket.pack_sockaddr_in(20000,“0.0.0.0”))
i=0
#httpd.setsockopt(:SOCKET,:SO_SNDBUF,1024000)
loop{
data=httpd.recvfrom(32768)
i+=1
p “#”+(i.to_s)+": received “+(data[0].size.to_s)+” bytes from
"+data[1].inspect_sockaddr
}
#####################################################################
#coding: utf-8
require “socket”
httpd=Socket.new(Socket::AF_INET,Socket::SOCK_DGRAM,0)
bin=File.new("…",“rb”)
httpd.setsockopt(:SOCKET,:SO_SNDBUF,1024000)
#p httpd.getsockopt(:SOCKET,:SO_SNDBUF)
ip=“127.0.0.1”
10000.times{|i|
httpd.send(bin.sysread(1024),0,Socket.pack_sockaddr_in(20000,ip))
#(sleep 0.001) if i%1==0
}
######################################################################
The main thing is that even with some dummy packets (and more threads -
more loss) i have huge loss.
For example: this sender sends 10000 packets without delays, but
receiver gets 2095 of packets. I tried to play with buffers but no luck.
With delays in 1 ms I have stable transmit rate but this is slow - 8
mbits. I’m able to run two such threads but more than that = huge loss
in packets.
Maybe someone also has this issue?
p.s. ruby 1.9.2 32 bit, windows