How to measure internet latency?

HectorOrmeoHectorOrmeo USMember ✭✭

With xamarin essential (IsRemoteReachable) I cannot measure or know if a web page is available

Is there any alternative to know that?

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited December 3

    IsReachable is not implemented in Xamarin.Essentials as each device handles this very different and was never 100% reliable. That will actually slow your app down by pinging and then making the request. See the link.

    I cannot measure or know if a web page is available

    To check if an end point is available, try to use Xam.Plugin.Connectivity plugin.

    var connectivity = CrossConnectivity.Current;
    if(!connectivity.IsConnected)
          return false;
    
    var reachable = await connectivity.IsRemoteReachable("host");
    

    Tutorial: https://jamesmontemagno.github.io/ConnectivityPlugin/PingaHost.html

  • HectorOrmeoHectorOrmeo USMember ✭✭

    @Jarvan said:
    IsReachable is not implemented in Xamarin.Essentials as each device handles this very different and was never 100% reliable. That will actually slow your app down by pinging and then making the request. See the [link]

    I cannot measure or know if a web page is available

    To check if an end point is available, try to use [Xam.Plugin.Connectivity]
    ```
    var connectivity = CrossConnectivity.Current;
    if(!connectivity.IsConnected)
    return false;

    var reachable = await connectivity.IsRemoteReachable("host");

    The cross connectivity method did not work :(.

    Is there a way to measure latency?

  • JohnHardmanJohnHardman GBUniversity mod
    edited December 3

    @HectorOrmeo said:

    With xamarin essential (IsRemoteReachable) I cannot measure or know if a web page is available

    Is there any alternative to know that?

    Just to clarify - do you want to:
    (a) know if a remote address is reachable (if so, does reachable mean that you can make a TCP connection to it, or is ICMP enough?)
    or
    (b) measure latency? If latency, at what level in the network stack do you want to measure it? Will a round-trip time do? Given the variability when it comes to mobile devices, it would be useful to know what you are trying to achieve.

  • HectorOrmeoHectorOrmeo USMember ✭✭

    @JohnHardman said:

    @HectorOrmeo said:

    With xamarin essential (IsRemoteReachable) I cannot measure or know if a web page is available

    Is there any alternative to know that?

    Just to clarify - do you want to:
    (a) know if a remote address is reachable (if so, does reachable mean that you can make a TCP connection to it, or is ICMP enough?)
    or
    (b) measure latency? If latency, at what level in the network stack do you want to measure it? Will a round-trip time do? Given the variability when it comes to mobile devices, it would be useful to know what you are trying to achieve.

    Hi, I need to measure latency, a round trip

  • JohnHardmanJohnHardman GBUniversity mod
    edited December 4

    @JohnHardman said:
    (b) measure latency? If latency, at what level in the network stack do you want to measure it? Will a round-trip time do? Given the variability when it comes to mobile devices, it would be useful to know what you are trying to achieve.

    At what level in the network stack?
    What are you trying to achieve? (what's the use case / user requirement?)

  • HectorOrmeoHectorOrmeo USMember ✭✭
    edited December 4

    @JohnHardman said:

    @JohnHardman said:
    (b) measure latency? If latency, at what level in the network stack do you want to measure it? Will a round-trip time do? Given the variability when it comes to mobile devices, it would be useful to know what you are trying to achieve.

    At what level in the network stack?
    What are you trying to achieve? (what's the use case / user requirement?)

    I need to know if the connection is optimal to send information to the rest service and wait for an answer!> @JohnHardman

    example: send pictures

  • JohnHardmanJohnHardman GBUniversity mod

    @HectorOrmeo said:
    I need to know if the connection is optimal to send information to the rest service and wait for an answer!
    example: send pictures

    In the absence of a precise definition of what constitutes optimal, and given the variability of connection quality when using a mobile device, my suggestion would be to simply implement a timeout when posting a byte array to the REST host. Even if some metrics were generated before posting the byte array, those metrics are just a snapshot, so even if the metrics looked good, the posting of the byte array just afterwards might be really slow (or not succeed at all). So, you might as well just post the byte array and timeout if it takes longer than you deem acceptable.

    If you disagree, I can suggest some alternative options, but I'm not convinced that they would add value beyond what a timeout would do.

Sign In or Register to comment.