Search Unity

RPC wire format

Discussion in 'Multiplayer' started by tylerwilson, Jan 14, 2010.

  1. tylerwilson

    tylerwilson

    Joined:
    Sep 22, 2009
    Posts:
    7
    Good day,

    I would like to write some third-party tools (in Python most likely) to interact with a running Unity3D game (standalone Windows). I think one of the simplest solutions would be to use the RPC mechanism built into Unity3D.

    Is the wire format for the RPC known, or based on some existing standards that I can program to?

    Thank you,
    Tyler
     
  2. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    280
    Unity uses the RakNet networking library and it's built in RPC functionality. The source code for this library is freely available if you want to delve into those details. I believe there is even a python wrapper available for the RakNet library although I don't know what state that project is in.
     
  3. tylerwilson

    tylerwilson

    Joined:
    Sep 22, 2009
    Posts:
    7
    Excellent. Thank you for the link to the RakNet library. I browsed through it a bit, and it looks pretty reasonable.

    So that I do not have to use a packet analyzer, can you tell me whether you use the AutoRPC or the RPC3 module? I am not yet sure if the wire format varies between these two, but if I could focus on studying just one of them, that would be a big help.

    The other bit I would need to know is if there are any special ways that Unity uses the RakNet library. That is, are the uniqueIdentifiers for the RPC calls mangled in any way, etc.

    Thank you,
    Tyler
     
  4. tylerwilson

    tylerwilson

    Joined:
    Sep 22, 2009
    Posts:
    7
    Updated information wrt my research on this. I downloaded the latest RakNet source (3.7 I think) for reference. That is, to see what the expected wire format is for the AutoRPC and RPC3 protocols.

    I also created a very simple Unity3D 'server' and Unity3D 'client' and used the Networking built into Unity3D (Network.InitializeServer and the OnServerInitialized and OnPlayerConnected functions) to connect the client and server.

    Using wireshark to capture all the network packets, I was able to see quite a bit of conversation when the client does a simple connection. The problem is that I could only align the first two packets: Connection Request and Connection Reply.

    After those first two packets, I cannot match anything with the message types within RakNet. So I suspect that there is a bunch of Unity3D specific messaging going on.

    So I am left with more questions that answers:

    1. Is there a specific version of RakNet I ought to be looking at (a different message on the forum mentioned that perhaps 3.0 is what Unity 2.6.1 is using).

    2. Is Unity3D using the AutoRPC or RPC3 functionality built into RakNet, or neither.

    3. Is the Unity wire format compatible with the 'vanilla' RakNet? That is, do we expect that a standard RakNet client (C++, Python RakNet wrapper, etc.) can be compatible enough to call RPC functions in a Unity3D application?

    Thank you,
    Tyler
     
  5. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    280
    Yes, you must use 3.0 or the version whose source code is included with the master server downloadable from http://unity3d.com/master-server. The latest RakNet version is not backwards compatible with 3.0 so as you saw, communication breaks down real quick. This is the reason we haven't been able to update the version used by Unity recently.

    Neither exist in the 3.0 version we have. All network view rpc functions calls are handled by the RakNet static rpc functionality with some custom handling on our side as it is received from RakNet.

    Nothing in the internal RPC functionality was changed and the RakNet protocol for it is the same, but how the functions are handled is a bit custom.