Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Android / libGDX: High ping times in simple TCP connection  (Read 1893 times)
0 Members and 1 Guest are viewing this topic.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Posted 2013-08-10 11:48:43 »

Using libGDX's network library I have to android phones connected via tcp sockets over a local LAN. Surprisingly this results in a ping of about 300ms. This seems crazy high for a LAN connection.

tcpNoDelay is on (on both ends), and the socket hints are set to low latency preferred. Sockets are polled in the main loop and handled immediately if a message comes in.

The same test between one android phone and a desktop version gives a ping of about 160ms, and running two instances locally on a desktop gives a ping of somewhere between 16ms and 33ms (a frame's worth of lag at either end I'd say).

So the android stack seems to add about 100-150ms of latency at both ends before it even hits the network. This seems crazy high to me - does anyone know if this is normal, or if there's anything that I can do to bring it down?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2013-08-10 13:17:13 »

Hmm, disappointingly WIFI_MODE_FULL_HIGH_PERF doesn't get me a lower ping. Sad

http://developer.android.com/reference/android/net/wifi/WifiManager.html#WIFI_MODE_FULL_HIGH_PERF

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline jonjava
« Reply #2 - Posted 2013-08-10 19:45:15 »

Seems high for LAN but then again I wouldn't expect smartphones/tablets to be capable of any kind of real time networking without WiFi and even then expect an average 500ms.

Do you really need low latency on smartphones/tablets?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2013-08-10 23:34:23 »

I wouldn't expect smartphones/tablets to be capable of any kind of real time networking without WiFi and even then expect an average 500ms.
This is a local lan via wifi - I'm not sure why you'd expect such bad ping times? Mobile phones are pretty much full computers now, just with a locked down OS. With a wifi laptop on the same lan I can ping google and get ~20ms response times, and that includes going over the internet to google's server and back.

Poking around in the options there's 'power savings' settings which seem to affect the wifi, but with everything off the ping time remains unchanged.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline jonjava
« Reply #4 - Posted 2013-08-10 23:55:23 »

They really are quite alike full computers but at the same time they really aren't. And they come in a lot of different shapes and sizes. To be honest this looks like tcp nodelay isn't really working like it's supposed to or it's incapable because of some hidden limits. I don't know.

If you don't mind me asking, why would you need such real-time networking anyway?

All of that nonsense being said however, I work for a company that makes its living on real-time information carried out by smartphones (HTC Android running a java application to be exact.). I don't know the full networking details but we can get some pretty decent pings (~100ms or less as far as I can tell*) quite constantly on 3G networks (lag spikes occur and even disconnections occur from time to time). I'm pretty sure the companies packets are throttled with higher priority than most, though. And the average time between messages sent is around 10 sec (mostly in short bursts).

*These numbers aren't measured accurately. The ping just "looks instant", if that makes sense? E.g. Press send, get immediate response. Whatever ping suffices that criteria.

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #5 - Posted 2013-08-11 11:02:23 »

If you don't mind me asking, why would you need such real-time networking anyway?

For a real-time multiplayer game, of course.

Obviously I need client prediction and latency hiding and all that jazz, but when my baseline, best possible conditions ping turns up at 300ms then that's really worrying.

I may knock up a udp test and see how the latency compares (annoyingly libGDX doesn't support UDP from what I can tell. Sad ).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (24 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (33 views)
2014-08-08 02:01:56

Norakomi (42 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!