runtime: Class Ping not reading response when ICMP Time-to-live exceeded
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 the SendPingAsync
function.
I specify a PingOptions
class to manually set the TTL.
Expected behavior
The PingReply
class returned should have the Address
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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (12 by maintainers)
I will try it @filipnavara. I also skimmed through the change and it generally looks OK to me.
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.