Jump to content

  • Log In with Google      Sign In   
  • Create Account

TCP/IP latency over wifi


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 SillyCow   Members   -  Reputation: 899

Like
0Likes
Like

Posted 30 July 2013 - 02:25 PM

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?


Edited by SillyCow, 30 July 2013 - 02:26 PM.

My new android game : Enemies of the Crown

My previous android game : Killer Bees


Sponsor:

#2 markr   Crossbones+   -  Reputation: 1653

Like
0Likes
Like

Posted 30 July 2013 - 02:45 PM

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.


Edited by markr, 30 July 2013 - 02:51 PM.


#3 SillyCow   Members   -  Reputation: 899

Like
0Likes
Like

Posted 30 July 2013 - 02:57 PM

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 new android game : Enemies of the Crown

My previous android game : Killer Bees


#4 hplus0603   Moderators   -  Reputation: 5725

Like
4Likes
Like

Posted 30 July 2013 - 03:10 PM

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 };

#5 SillyCow   Members   -  Reputation: 899

Like
0Likes
Like

Posted 30 July 2013 - 03:23 PM

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 new android game : Enemies of the Crown

My previous android game : Killer Bees


#6 lerno   Members   -  Reputation: 233

Like
0Likes
Like

Posted 03 August 2013 - 01:27 AM

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.



#7 SillyCow   Members   -  Reputation: 899

Like
0Likes
Like

Posted 03 August 2013 - 08:45 AM

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 new android game : Enemies of the Crown

My previous android game : Killer Bees





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS