Author Topic: TIMESTAMPS - do we really need 'em ?  (Read 5590 times)

Karo

  • Guest
TIMESTAMPS - do we really need 'em ?
« on: March 14, 2006, 12:31:41 PM »
Hello,

i have managed to write a flexible code of server handling up to 100 players simultanously.

A quick overview:

Client connects with TCP, gets level data, then reconnects over UDP and :

- every 4 seconds he gets other players PDU
- calculates other players movement by getting only the speed/heading/position packet and stop packet

This works great!
I was testing it with 100 players on my LAN, there were no lags, no 'differences' inp layers locations.

Finally i would like to play over internet only, but this is a case of a dedicated host somewhere with a good bandwith.

Why do i need to include timestamps to my packets, if all works okay?  -any good reason?

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: TIMESTAMPS - do we really need 'em ?
« Reply #1 on: March 14, 2006, 01:34:41 PM »
Because on a LAN you have 0 ping while on the internet you do not.

Karo

  • Guest
Re: TIMESTAMPS - do we really need 'em ?
« Reply #2 on: March 14, 2006, 02:56:55 PM »
Rak'Kar,

mhm, but what do we use them for ?

i mean any good example of using those timestamps ?

i would like to implement them, but can't think of - what should i consider in implementation

Scorch

  • Jr. Member
  • **
  • Posts: 55
  • Karma: 2
    • View Profile
Re: TIMESTAMPS - do we really need 'em ?
« Reply #3 on: March 14, 2006, 05:46:55 PM »
Basic example,
Player a and player b are looking at each other in a 3d world.
Player a sends a message to player B that he is at position 5,5,5, and headed in a direction of 1,0,0 at a volocity of 5/second.
Player b receives the message and displays player a at 5,5,5 headed 1,0,0 ... problem is, player A sent the message 5 seconds ago, so really player a has allready moved 25 units in that direction and b doesn't know.  but if B used the time stamp to see that the message is 5 seconds old, then he could make some ajustments to the position to make it *more* accurate.

I think this is also known as dead reconing ??

If you want to simulate this problem, put your raknet thread sleep at like 3000 instead of 0 or 30, that should give you some horrible ping rates and demonstrate the problem in your game.  (although not exactly, you will experience bursts of data instead of slow flows)



Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: TIMESTAMPS - do we really need 'em ?
« Reply #4 on: March 14, 2006, 06:16:03 PM »
Use the SetNetworkSimulator (or whatever it is I called it) to do that.

Karo

  • Guest
Re: TIMESTAMPS - do we really need 'em ?
« Reply #5 on: March 14, 2006, 06:17:24 PM »
Now i get it!

So, basically.

player1 sends a MOVE packet with a timestamp at (for example) packet_move[3]=timestamp;
but what about time differences on clients PCs ? Should i use some kind of a NTP ?



Scorch

  • Jr. Member
  • **
  • Posts: 55
  • Karma: 2
    • View Profile
Re: TIMESTAMPS - do we really need 'em ?
« Reply #6 on: March 14, 2006, 07:33:21 PM »
I havn't used it yet, but I think raknet has methods to do alot of that for you.

Karo

  • Guest
Re: TIMESTAMPS - do we really need 'em ?
« Reply #7 on: March 14, 2006, 08:44:16 PM »
Scorch: I am not sure i got you? What does RakNet have for me ?

Is there any good document describing the implementation of d.reckoning ?

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: TIMESTAMPS - do we really need 'em ?
« Reply #8 on: March 14, 2006, 09:06:41 PM »
The whole point of the timestamp system is to handle the time difference between PCs for you.  I'm pretty sure without checking that there is a section in the manual that describes this.

Scorch

  • Jr. Member
  • **
  • Posts: 55
  • Karma: 2
    • View Profile
Re: TIMESTAMPS - do we really need 'em ?
« Reply #9 on: March 14, 2006, 11:15:23 PM »
There is a timestamping example in

\RakkarSoft\Samples\Code Samples\Timestamping

Rakkar can correct me if i'm wrong but My understanding of what it does is it sends pings between the rakpeers to find out how many ms off they are from each other, then they ask each other what time the other one has.  Then it takes their local time, minus half of the ping time (for one way travel) and then remembers the difference between the two clocks.  Then it can use this difference and the ping times to convert one machines time stamp to the others as needed. all automaticly.