Thanks to visit codestin.com
Credit goes to github.com

Skip to content

System.Net.NetworkInformation.Ping: Xamarin Mono Returning Wrong PingReply.Address #12684

@OneVideo

Description

@OneVideo

[N.B.: manual copy of https://developercommunity.visualstudio.com/content/problem/417428/systemnetnetworkinformationping-xamarin-mono-retur.html after 30 days of no propagation/update]

Upon TtlExpired reported in Ping Class's Reply, the Reply Address is not reported as belonging to the intermediate router where the ICMP message was dropped.

      • Calling C# Code Demonstrating Unexpected Result - - -
IPAddress[] addresses = Dns.GetHostAddresses(HostNameOrIPAddress);
_destination = addresses[0];

_options = new PingOptions(1, true);

_ping = new Ping();
_ping.PingCompleted += new PingCompletedEventHandler(OnPingCompleted);
_ping.SendAsync(_destination, _timeout, this.Buffer, _options, null);

void OnPingCompleted(object sender, PingCompletedEventArgs e)
{

var address = e.Reply.Address;

// Returning destination address requested in originally issued .SendAsync

// though e.Reply.Status == System.Net.NetworkInformation.IPStatus.TtlExpired

// Expect address of the responding IP router situated between requesting Android runtime and

// host at the requested destination address.

// Network packet sniffer confirms ICMP message is sent from requesting host with Ttl == 1 and reply is made to the requesting host. Expected results can be seen in a Windows 10 host on the same Wi-Fi subnet using tracert in a command shell.

}

Compiled for Android runtime: 8.1
Using Visual Studio 2017 version 15.9.4, Xamarin.Android SDK 9.1.4.2, Xamarin 4.12.3.77

Multiple runtimes tested on Wi-Fi network segment with same unexpected behaviors/results: Samsung SM-G920V API 24, Google Pixel 3 API 28

N.B.: Project References

to System.Core at

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll

to Mono.Android at

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v8.1\Mono.Android.dll

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions