Advertisement

TCP/IP latency over wifi

Started by July 30, 2013 08:25 PM
5 comments, last by SillyCow 11 years, 3 months ago

I wrote my own multi-player server. Everything is functioning fine.

It's amazing to get to play my game against others..

However, I have a serious latency issue.

The biggest problem so far:

I am using TCP/IP over WIFI.

The clients are Android-Java, and the server is JAVA-Windows.

I do not think I want to resort to using UDP, as I am doing Lock-Step so I need a reliable & ordered stream.

My bandwidth requirements are trivial ( < 1kbps )

I have noticed that latency is a bit high (hundreds of milliseconds over WiFi LAN). As I am new to this I am wondering, is there anything I can do to reduce TCP latency?

Right now I am calling flush() after every write() to the outputstream. It is not good enough.

My implementation is very naive (this is my first time), so I am probably overlooking some very simple solutions here.

Any suggestions?

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

Have you compared the latency over wifi to latency over ethernet, or the latency over a virtual network in your VM test-environment?

As far as I know, you should not see >10ms RTT (round-trip-time) latency over a wifi LAN. If you do, something is wrong, e.g. congestion, or some other operational problem.

Wifi does do implicit retransmissions and other algorithms, however, because of the relatively high speed (normally at least 10mbit/s), it should still not normally delay any packet > 10ms.

The latency caused by a wifi network is usually very small compared to even fairly fast nearby (same continent) links, which could be 50ms RTT even for "good" connections.

Advertisement

could this somehow be caused by TCP/IP windowing?

In my past experience, when I flooded the connection with NOP messages, the latency actually went down.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

My guess is that you haven't turned off TCP nagle-ing. In C, it's the TCP_NODELAY socket option.

enum Bool { True, False, FileNotFound };

My guess is that you haven't turned off TCP nagle-ing. In C, it's the TCP_NODELAY socket option.

Thanks hplus, that did the trick. I knew I missed something simple. It's Socket.setNoDelay(true) in java.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

I'm surprised you don't see more slowdowns. My experience is that in the outer wifi ranges, latency can shoot through the roof due to the occasional dropped packet. Consider if an occasional 2s latency would be a problem or not.

Advertisement
Nah, it's not a problem. This is an RTS. I just wanted to understand why I was getting 500ms delays in a good connection.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

This topic is closed to new replies.

Advertisement