A simple ping test program in a linux container to test the low ttl bug in .NET '7.0.100-preview.6.22352.1'
The PING TTL is set in sequence from one to 30 to seek each hop to 8.8.8.8 in order to discover the route to 8.8.8.8
On Windows and Apple Mac running froom the IDE natively, PING works as expected, with most responding with TtlExpired and some with Timdeout. This is as per OS standard ping utilties.
When running inside a Linux container on either development host type. The results are unexpected with EVERY hop leading to the destination returning Timedout.
Using wireshark on the host and tcpdump on the linux container, it has been established that the ICMP packets exit and return from the container OS via the host, out to and back from the remote node as expected, being recieved within the linux container OS.
Using another experiment it has been established that in the linux container environment the PING partial classes inside System.Net.NetworkInformation.Ping, the run time code is working down through the layer that uses Sockets, and NOT the call out externally to use the OS version of Ping.
Assumption: Something either in the Sockets implemntation or the Ping use of sockets is not 'seeing' the returned ICMP messages for some reason and leads the Ping code to 'assume' a Timedout status in a scenario where a message was recieved by the OS.
One of the .NET team has already identified already that the call to the socket to receive the returning ICMP message returns nothing.
int bytesReceived = socket.ReceiveFrom(receiveBuffer, SocketFlags.None, ref socketConfig.EndPoint);
Perhaps this is a sockets issue on linux containers rather than a Ping issue?
Clone this repo and use as you desire.
git clone https://github.com/IainStevenson/pingfixtest.git
cd pingfixtest
dotnet build pingfixtest.csproj
docker build -t pingfixtest .
docker run -t pingfixtest
And you will see
Hop: 1 Status: TimedOut Address: 0.0.0.0
Hop: 2 Status: TimedOut Address: 0.0.0.0
Hop: 3 Status: TimedOut Address: 0.0.0.0
Hop: 4 Status: TimedOut Address: 0.0.0.0
Hop: 5 Status: TimedOut Address: 0.0.0.0
Hop: 6 Status: TimedOut Address: 0.0.0.0
Hop: 7 Status: TimedOut Address: 0.0.0.0
Hop: 8 Status: TimedOut Address: 0.0.0.0
Hop: 9 Status: TimedOut Address: 0.0.0.0
Hop: 10 Status: TimedOut Address: 0.0.0.0
Hop: 11 Status: TimedOut Address: 0.0.0.0
Hop: 12 Status: TimedOut Address: 0.0.0.0
Hop: 13 Status: TimedOut Address: 0.0.0.0
Hop: 14 Status: TimedOut Address: 0.0.0.0
Hop: 15 Status: Success Address: 8.8.8.8
Open 'PingFixTest.sln' in Visual studio 2022 or any IDE that supports .NET 7 Preview 6
Run the Docker profile for the docker container test. This requries linux containers in docker for your environment. This behaves the same in Windows and Mac hosts.
You will see this in your Debug view.
Hop: 1 Status: TimedOut Address: 0.0.0.0
Hop: 2 Status: TimedOut Address: 0.0.0.0
Hop: 3 Status: TimedOut Address: 0.0.0.0
Hop: 4 Status: TimedOut Address: 0.0.0.0
Hop: 5 Status: TimedOut Address: 0.0.0.0
Hop: 6 Status: TimedOut Address: 0.0.0.0
Hop: 7 Status: TimedOut Address: 0.0.0.0
Hop: 8 Status: TimedOut Address: 0.0.0.0
Hop: 9 Status: TimedOut Address: 0.0.0.0
Hop: 10 Status: TimedOut Address: 0.0.0.0
Hop: 11 Status: TimedOut Address: 0.0.0.0
Hop: 12 Status: TimedOut Address: 0.0.0.0
Hop: 13 Status: TimedOut Address: 0.0.0.0
Hop: 14 Status: TimedOut Address: 0.0.0.0
Hop: 15 Status: Success Address: 8.8.8.8
Now: Run the PingFixTest profile to run it natively on your host.
You will see this (similar according to your location) in your console/terminal.
Hop: 1 Status: TtlExpired Address: 192.168.0.1
Hop: 2 Status: TtlExpired Address: 192.168.1.1
Hop: 3 Status: TimedOut Address: 8.8.8.8
Hop: 4 Status: TtlExpired Address: 10.248.28.65
Hop: 5 Status: TtlExpired Address: 10.247.87.25
Hop: 6 Status: TimedOut Address: 8.8.8.8
Hop: 7 Status: TtlExpired Address: 10.247.87.9
Hop: 8 Status: TtlExpired Address: 10.247.87.18
Hop: 9 Status: TtlExpired Address: 87.237.20.218
Hop: 10 Status: TtlExpired Address: 87.237.20.67
Hop: 11 Status: TtlExpired Address: 72.14.242.70
Hop: 12 Status: TtlExpired Address: 74.125.242.97
Hop: 13 Status: TtlExpired Address: 172.253.66.101
Hop: 14 Status: Success Address: 8.8.8.8