I was contacted by a friend who was having some issues with Test-Connection when using TimeToLive
Test-Connection -ComputerName www.google.ie -Count 1 -TimeToLive 3
Test-Connection : Testing connection to computer ‘www.google.ie’ failed: Problem with some part of the filterspec or providerspecific buffer in general
At line:1 char:1
Test-Connection -ComputerName www.google.ie -TimeToLive 3
+ CategoryInfo : ResourceUnavailable: (www.google.ie:String) [Test-Connection], PingException
+ FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand
So I fired fired up Reflector to see what Test-Connection actually does, and it is using WMI and the Win32_PingStatus class, I have not been able to reproduce the error calling the class directly, so I was wondering where the problem could be.
So I did a trace command to see if that would give me anything, one thing I noticed in the return value there was a value called 11013, shortly thereafter this was written in the trace.
MemberResolution Information: 0 : “writeErrorStream” NOT present in type table.
MemberResolution Information: 0 : Adapted member: not found.
This made me think that there might be an error in converting the Errorcode from its numerical value into text
So I looked up the errorcode from ICMP_ECHO_REPLY32 structure, which has an error code called 11013 which is:
The time to live (TTL) expired in transit.
Which seems fair because TTL is relatively low, then I looked a bit deeper to try and find what 11013 also could mean
In Winsock Error Codes I found:
Then I did some additional testing.
If you look at the WMI Win32_PingStatus error codes 11010 corresponds to:
The request timed out.
Which you can confirm using ping from the command prompt: