runtime
runtime copied to clipboard
System.Net.Ping assumes fixed size IPv4 header for Unix
When SendIcmpEchoRequestOverRawSocket() is used for ping in Linux, it assumes size of IPv4 header is fixed 20 bytes at Ping.Unix.cs:19. In reality, size of IPv4 header can vary from 20 bytes to 60 bytes.
Therefore SendIcmpEchoRequestOverRawSocket() works incorrectly when IPv4 header is larger than 20 bytes and fails to find a correct echoed packet due to wrong interpretation of a received packet.
This failure is observed when running System.Net.Ping.Functional.Tests.dll on environment where IPv4 header is larger than 20 bytes and 12 tests are failed as below.
<test name="System.Net.NetworkInformation.Tests.PingTest.Sends_ReuseInstance_Hostname" type="System.Net.NetworkInformation.Tests.PingTest" method="Sends_ReuseInstance_Hostname" time="6.288208" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPingAsyncWithHostAndTimeoutAndBuffer_Unix" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPingAsyncWithHostAndTimeoutAndBuffer_Unix" time="10.0747374" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPings_ReuseInstance_Hostname" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPings_ReuseInstance_Hostname" time="5.0161132" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPingAsyncWithHostAndTimeout" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPingAsyncWithHostAndTimeout" time="10.0464476" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendAsyncs_ReuseInstance_Hostname" type="System.Net.NetworkInformation.Tests.PingTest" method="SendAsyncs_ReuseInstance_Hostname" time="5.0883178" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPingAsyncWithHost" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPingAsyncWithHost" time="5.0319823" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPingAsyncWithIPAddressAndTimeoutAndBuffer_Unix" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPingAsyncWithIPAddressAndTimeoutAndBuffer_Unix" time="10.0632629" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPingAsyncWithIPAddress" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPingAsyncWithIPAddress" time="5.0283813" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPingAsyncWithIPAddressAndTimeout" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPingAsyncWithIPAddressAndTimeout" time="10.0208434" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPingAsyncWithIPAddressAndTimeoutAndBufferAndPingOptions_Unix" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPingAsyncWithIPAddressAndTimeoutAndBufferAndPingOptions_Unix" time="10.0248107" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPingAsyncWithIPAddress_AddressAsString" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPingAsyncWithIPAddress_AddressAsString" time="5.0307922" result="Fail">
<test name="System.Net.NetworkInformation.Tests.PingTest.SendPingAsyncWithHostAndTimeoutAndBufferAndPingOptions_Unix" type="System.Net.NetworkInformation.Tests.PingTest" method="SendPingAsyncWithHostAndTimeoutAndBufferAndPingOptions_Unix" time="10.0245666" result="Fail">
I'm not expert in network implementation and looking forward any advice and comments on this issue.