Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 8186 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:

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:
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 Opiop
« Reply #5 - Posted 2013-10-30 22:18:51 »

Why would you ever open multiple sockets on one client.
Pages: [1]
  ignore  |  Print  

EgonOlsen (42 views)
2018-06-10 19:43:48

EgonOlsen (22 views)
2018-06-10 19:43:44

EgonOlsen (43 views)
2018-06-10 19:43:20

DesertCoockie (198 views)
2018-05-13 18:23:11

nelsongames (124 views)
2018-04-24 18:15:36

nelsongames (123 views)
2018-04-24 18:14:32

ivj94 (864 views)
2018-03-24 14:47:39

ivj94 (125 views)
2018-03-24 14:46:31

ivj94 (768 views)
2018-03-24 14:43:53

Solater (140 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!