-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class Ping not reading response when ICMP Time-to-live exceeded #61465
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescriptionHi, I've already tried to run my software from my user account and from the root account (using sudo) without any luck. Reproduction StepsI've used a simple code that is based on the Expected behaviorThe Actual behaviorThe Regression?I've tried the code on .NET 5.0 and on .NET 6.0. Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
cc: @filipnavara |
My local testing on macOS / .NET 6 shows that I get the using System.Net.NetworkInformation;
var ping = new Ping();
var reply = ping.Send("8.8.8.8", 5000, new byte[32], new PingOptions(1, false)); // Remove PingOptions to make is succeed
Console.WriteLine($"Status: {reply.Status} Address: {reply.Address}"); |
Hi @filipnavara , if you need more information about this, please ask. I also did a little of debugging and the network part is perfectly working. I used Wireshark, the ICMP packets are correctly send with the TTL lowered, and the ICMP Time-to-live exceeded messages are arriving to my machine. I write a small workaround using raw sockets, it works but requires privileged access to the machine (sudo). |
I can also see the packets correctly sent and received in Wireshark. They are just not passed or processed by the application. I'd need to dig in deeper with a debugger but the problem is reproducible. However, in the original description you didn't mention whether you receive the |
@wfurt It fails here: runtime/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.RawSocket.cs Lines 132 to 137 in a3b186b
The received message has type |
Actually, I've never checked (till now). I ran the exact same traceroute code as the original issue. I see you find where the packet is ignored, but if it is so, why on Windows it works? |
It looks like the pings over the raw socket don't correctly handle the The response in Wireshark looks like this:
The code examines the first ICMP header which has no identifier and type |
I was struggling over this. Thanks for the clarification. Moreover, beware of the
so it is not the whole packet in all cases. That could be a truncated packet if you send a ICMP Echo Request packet too big (e.g specifying a "big" message in the |
Most of the (interesting) messages in RFC 792 follow the pattern of returning the original IP header + 64 bits of the original datagram (which conveniently fits the ICMP header). In my case it seems to return the original data in addition to that. ICMP reply is actually an exception where the data follow right after the first ICMP header. It should not be difficult to update the code but it's a bit tricky to fix up all the buffer sizes to ensure everything will fit in case of an error. Thanks for filing the report. |
I suspect Linux may have same problem. |
Triage: We are getting different response format than we expect. |
I am currently without access to IPv6 infrastructure so if anyone can give the PR a try it would expedite the fix. Something like this would be reasonable code to test: using System.Net.NetworkInformation;
var ping = new Ping();
var reply = ping.Send("2001:4860:4860::8888", 5000, new byte[32], new PingOptions(1, false)); // Remove PingOptions to make is succeed
Console.WriteLine($"Status: {reply.Status} Address: {reply.Address}"); |
I will try it @filipnavara. I also skimmed through the change and it generally looks OK to me. |
LGTM. I posted reply with suggestion for test on #61592 |
Description
Hi,
I've wrote a small program to run traceroutes, based on the Ping (System.Net.NetworkInformation) class.
The software works like a charm on Windows but if I execute the same code on a MacOS it does not give the IP addresses of the returned ICMP Time-to-live exceeded messages.
I've already tried to run my software from my user account and from the root account (using sudo) without any luck.
Reproduction Steps
I've used a simple code that is based on the
System.Net.NetworkInformation.Ping
class and uses theSendPingAsync
function.I specify a
PingOptions
class to manually set the TTL.Expected behavior
The
PingReply
class returned should have theAddress
property set with the correct IP Address.Actual behavior
The
PingReply
class returned has the IP Address set to "0.0.0.0".Regression?
I've tried the code on .NET 5.0 and on .NET 6.0.
With both versions on Windows is perfectly working while on MacOS it gives the bug.
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: