From: Brian Candler Date: 2009-11-20T18:29:50+09:00 Subject: Re: UDP Proxy Randy General wrote: > I attempted to play a game through the proxy, and it > was exceptionally slow. Can you measure what you mean by 'slow', in terms of the elapsed time between a packet coming in and a packet going out? You can do this externally using tcpdump -ttt, or you can add some timing into the code itself. It's possible that Ruby is doing reverse DNS lookups for every incoming packet when your C code isn't. tcpdump will show that. You can disable it using: Socket.do_not_reverse_lookup = true at the top of your code. > Here's my code so far: > > http://pastie.org/707258.txt Why are you using a raw socket? You could just forward using a UDP socket. Then you wouldn't need to build an IP header, nor a UDP header, nor calculate the UDP checksum, since this is all taken care of for you by the kernel. Are you trying to send out a packet with a source address which doesn't belong to the sending machine? (which isn't proxying) > Is the poor performance of the script a result of poor coding on my > part? Or is an interpreted language like Ruby incapable of efficiently > doing this sort of task? Stuff like the checksum calculation is going to be a lot slower in Ruby than in C. But you should use the profiler to find out exactly where the majority of time is being spent. -- Posted via http://www.ruby-forum.com/.