Search Unity

  1. We have added sub-forums for the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice
  2. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  3. Dismiss Notice

Bug NetworkInformation.Ping with small TTL don't return network node information (ip)

Discussion in 'Multiplayer' started by danBourquin, Dec 1, 2020.

  1. danBourquin


    Nov 16, 2016
    Hi everyone.

    I'm trying to ping an IP with different TTL. The purpose is to ping different node between two client in p2p. And to be sure we get a ping regardless the box, firewall, ... , I want to ping with a tll that I increase on a loop.

    But when I do it on Unity I only get a ping info and ip when the ping (and the corresponding TTL) reach the ip. With smaller TTL I don't get any information from node between.

    On a .net projet outside Unity it work fine. On Unity the status of the request is timeout and I don't get any ip when TTL is smaller.

    Here's a example of what code I used:

    Code (CSharp):
    1.     [ContextMenu("Ping1")]
    2.     private void Ping1(int TTL = 3)
    3.     {
    4.         Debug.Log($"Ping ttl {TTL}");
    6.         var ping = new Ping();
    8.         var pingOptions = new PingOptions(TTL, fragment);
    10.         byte[] result = new byte[bufferSize];
    12.         var ip = new System.Net.IPAddress(new byte[] { 8, 8, 8, 8 });
    14.         PingReply reply = ping.Send(ip, timeOut, result, pingOptions);
    16.         Debug.Log($"result {reply.Status} - {reply.Address} - {reply.RoundtripTime} -buffer {result}");
    17.     }
    I try to test it on a different thread / coroutine / editor-mode / runtime-mode / build . Nothing work. With not enought TTL to reach the ip, I always get a timeout status and no addresse.

    I expect to get node addresse and RoundTripTime from the client to the node.

    Do you have any clues why Unity behave this way?