Architecture: Ping from the clients to de Server

Hi all!

First of all, sorry for my English, I am a native Spanish and write very bad English: disappointed:

We have a simple multiplayer game, 4 players (clients) with 4 characters in the same arena. For our synchronization algorithm we need to know the shipping time of each package to different clients.

We thought Pun Photon architecture is client-server, where each client sends data to the server and it sends this information to each client.

However, we noticed something strange.

A client C1 has a ping to the server (PhotonNetwork.GetPing ()) equal to 90 ms.

A client C2 has a ping to the server (PhotonNetwork.GetPing ()) equal to 80 ms.


When we send a packet between C1 and C2 and send the initial PhotonNetwork.time compared with end PhotonNetwork.time. The difference is 120 ms instead of 170 ms (90 + 80).

We have also done a ping (cmd in Windows) to calculate ping between C1 and C2 outside Photon and is equal to 120 ms.

This is just an example, but have made many tests of this type. The question is:

After clients connect to the server, they send each packet between them without going through the server?


Thanks for your time.

Kind Regards.

Comments

  • Hi,

    Clients never contact each other directly. All communications go via server.
    GetPing() returns time required for packed to reach server and return back, So in theory delay when sending packet from client to client should be 80/2 + 90/2 = 95.
    PhotonNetwork.time is not absolutely precise since it needs to build current value basing on periodical updates from server corrected with current ping to server.
    PhotonNetwork.time also accounts processing times on server and client. To eliminate the latter, try to call SendOutgoinCommands right after measuring time and raising an event on sender side, If commands are sent automatically 10 times per sec, this may add 50 ms in average for measurements.
  • Thanks so much!

    Now we understand the results. Really a quickly answer!



  • Sorry, but we have a new question over this topic!

    We use the OnPhotonSerializeView for sincronize the position, if PhotonNetWrok.time is not precise. How can we know de trip time of every package?

    We search about SendOutgoingCommands, but we dont understand the documentation. Is this method for serializeView or for RPC?

  • I would say that PhotonNetWrok.time is as precise as possible for remote clients. You hardly can do better,

    SendOutgoingCommands is the method for immediate sending of all buffered commands which otherwise will be sent in the next service call triggered each 50ms by default
  • Ok, for the serializeView we use the SendOutGoingCommand here:

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
    if (stream.isWriting)
    {
    stream.SendNext(step);
    stream.SendNext(PhotonNetwork.timeFloat);
    stream.SendNext(delayTime);
    stream.SendNext(targetPosition);
    stream.SendNext(lastDirection);
    stream.SendNext(lastDashing);
    PhotonNetwork.SendOutgoingCommands();
    }
    else ...

    For a RPC:

    public void SendJump(float clock, float delayExpected)
    {
    photonView.RPC("RpcJump", PhotonTargets.Others, clock, delayExpected);
    PhotonNetwork.SendOutgoingCommands();
    }

    It's right?
  • Does it work? Did you notice or measure any advantages of such approach? If yes than it's right.
    For OnPhotonSerializeView it would be more appropriate to set PhotonNetwork.sendRateOnSerialize to higher values instead of calling SendOutgoingCommands().
  • Hi sorry for my late answer!

    Using the SendOutgoingCommands(), we are winning 30-50ms in the RPC send.

    Thank you for your help!