UDP broadcasting

For the past 2 days I’ve been investigating why my RUDP protocol has a waay worse ping than the one in iperf. I found numerous bugs and optimizations during this time but I was never able to get the ping below 100ms while iperf in udp mode was getting 3-7ms…

It turns out that using broadcasting increases the RTT a lot and causes some packet loss. Maybe it’s just my network that behaves like this with broadcasting but after I removed it my ping was a solid 4ms. Not too bad for wifi going through 3 walls..

So the culprit was this line:
m_send_socket.set_option(socket_base::broadcast(true));

I did this a few days back when I got too lazy to implement proper discovery so I made all comms broadcast.

 

Advertisements

3 thoughts on “UDP broadcasting

    1. It makes sense now, yes. But initially I kept thinking I either have a bug in how packets are prioritized or in how I track the rtt duration. I rewrote both parts multiple times and I managed to optimize the code quite a bit. I guess it’s a nice consequence of looking at the same piece of code for 2 straight days.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s