Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
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  
  Best way to measure latency between a client and a server  (Read 1771 times)
0 Members and 1 Guest are viewing this topic.
Offline Tinhorn

Senior Devvie


Medals: 1
Projects: 3



« Posted 2013-10-10 19:53:10 »

The reason i ask is the way i have been doing it is just measure how long it takes for the initial message to reach the server ONCE
What if the signal get better over or worse over time.

What is the best way to measure changing latency.
Should i take the 3 latest packets and see how long it took them to get here and average them.

I would really appreciate some help

Thank you for your help

Offline Troncoso

JGO Coder


Medals: 20



« Reply #1 - Posted 2013-10-10 20:08:22 »

You could use an external program like Wireshark or Fiddler to monitor network traffic. This is what you can see with Fiddler:

ACTUAL PERFORMANCE
--------------
ClientConnected:   16:11:10.534
ClientBeginRequest:   16:11:10.700
GotRequestHeaders:   16:11:10.700
ClientDoneRequest:   16:11:10.958
Determine Gateway:   0ms
DNS Lookup:       0ms
TCP/IP Connect:   0ms
HTTPS Handshake:   0ms
ServerConnected:   16:11:10.567
FiddlerBeginRequest:   16:11:10.958
ServerGotRequest:   16:11:10.958
ServerBeginResponse:   16:11:11.004
GotResponseHeaders:   16:11:11.255
ServerDoneResponse:   16:11:11.256
ClientBeginResponse:   16:11:11.255
ClientDoneResponse:   16:11:11.256
Offline deathpat
« Reply #2 - Posted 2013-10-10 21:05:43 »

Don't know if it's the best way but for Daedalus I measure it every 4 seconds and update the current ping by doing:
1  
ping = ping*0.3f + newPing*0.7f;

0.3f and 0.7f depends on how you want to be reactive to a ping change Smiley

work in progress : D A E D A L U S
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Tinhorn

Senior Devvie


Medals: 1
Projects: 3



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

Thank you.
This was what i need.

And i need to measure it in the code Troncoso

Offline cobolfoo

Junior Newbie





« Reply #4 - Posted 2013-10-30 21:54:01 »

When my game client connect to the server I exchange 5-10 UDP sockets in less than a second to sync both machines. The client run with the same clock as the server. After that, you could always guess the RTT during the game but is it less necessary since server send packets with the real timestamp when the event is happening (moving objects, damages, etc.). The client would know if it is in the past or not Smiley
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #5 - Posted 2013-10-30 22:18:51 »

Why would you ever open multiple sockets on one client.

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.

trollwarrior1 (33 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (65 views)
2014-11-07 19:57:14

TehJavaDev (69 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (82 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!