Search Unity

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

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

  1. danBourquin

    danBourquin

    Joined:
    Nov 16, 2016
    Posts:
    34
    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}");
    5.  
    6.         var ping = new Ping();
    7.        
    8.         var pingOptions = new PingOptions(TTL, fragment);
    9.  
    10.         byte[] result = new byte[bufferSize];
    11.  
    12.         var ip = new System.Net.IPAddress(new byte[] { 8, 8, 8, 8 });
    13.  
    14.         PingReply reply = ping.Send(ip, timeOut, result, pingOptions);
    15.  
    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?
     
  2. zhangli-fotoable

    zhangli-fotoable

    Joined:
    Nov 19, 2021
    Posts:
    1
    Do you report a issue?