• Troubleshooting Test-Connection

    I was contacted by a friend who was having some issues with Test-Connection  when using TimeToLive

    Example:

    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:

    http://msdn.microsoft.com/en-us/library/windows/desktop/bb540657(v=vs.85).aspx

    IP_TTL_EXPIRED_TRANSIT
    11013

    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:

    http://msdn.microsoft.com/en-us/library/windows/desktop/bb540657(v=vs.85).aspx

    WSA_QOS_BAD_OBJECT
    11013
    QoS bad object.

    A problem was encountered with some part of the filterspec or the provider-specific buffer in general.

    Then I did some additional testing.

    PingPowerShell
    If you do a Trace-Command on the example with TimeToLive = 11 which gives the error: Error due to lack of ressources, you will see that the error code is 11010 which corresponds to:

    WSA_QOS_ADMISSION_FAILURE
    11010
    QoS admission error.

    A QoS error occurred due to lack of resources.

    If you look at the WMI Win32_PingStatus error codes 11010 corresponds to:

    IP_REQ_TIMED_OUT
    11010

    The request timed out.

    Which you can confirm using ping from the command prompt:

    PingDOS