I wanted to share a small utility that I wrote a while ago, allowing you to run a non-interactive ‘ping’ to a tcp port (e.g. from within a script).

This could for example allow you to bring up a VPN tunnel from a script (by generating traffic to a target host), to determine whether a tcp port is open or not and so on… I’m sure all of you are creative enough to see the wide range of possibilities and applications for this utility.

The tool is a command-line utility, should run on Windows 32bit and 64bit, and requires .Net framework 2.0.

Usage :

Unzip the file and place the file pvetcpping.exe somewhere on your harddrive, preferable in a folder that is part of your PATH variable (e.g. c:windowssystem32)

If you run the utility without parameters, this is what you’ll get :

---------------------------------
PVE TCP Ping Utility
Written by Peter Van Eeckhoutte
http://www.corelan.be:8800
Version 1.0.0.1
---------------------------------

Usage :
pvetcpping.exe <host> <port> [<number of pings>]

Both the <host> and <port> parameters are mandatory.
The <number of pings> parameter is optional.
Set this parameter to 0 to launch a continuous ping.

As you can see, there are 3 possible parameters. The target host and target port number are mandatory, the number of pings is optional. If you don’t specify a number of pings, then 4 pings will be performed.

If you run the utility with correct parameters, this is what you should get :

c:> pvetcpping.exe www.google.com 80
---------------------------------
PVE TCP Ping Utility
Written by Peter Van Eeckhoutte
http://www.corelan.be:8800
Version 1.0.0.1
---------------------------------

[+] Connecting to tcp port 80 on host www.google.com...
[+] Number of pings : 4
[+] Started probing at 20:33:32
[+] Probing host www.google.com on port tcp/80 - Connect OK - 84ms.
[+] Probing host www.google.com on port tcp/80 - Connect OK - 17ms.
[+] Probing host www.google.com on port tcp/80 - Connect OK - 19ms.
[+] Probing host www.google.com on port tcp/80 - Connect OK - 18ms.

TCP Ping statistics for www.google.com port tcp/80
Connects : 4, Success : 4, Failed : 0 (0% loss)
Approximate round trip times in milli-seconds:
Minimum = 17ms, Maximum = 84ms, Average = 34ms

Starting from version 1.0.0.1, timestamps are added to the output of the utility

  • when the probes start
  • when the status changes
---------------------------------
 PVE TCP Ping Utility
 Written by Peter Van Eeckhoutte
 http://www.corelan.be:8800
 Version 1.0.0.1
---------------------------------

 [+] Connecting to tcp port 22 on host 192.168.0.116...
 [+] Number of pings : Unlimited
 [+] Started probing at 20:33:32
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 30ms.
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 0ms.
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 0ms.
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 0ms.
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 0ms.
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 0ms.
 [-] Probe status changed at 20:33:59
 [-] Probing host 192.168.0.116 on port tcp/22 - Connect failed
 [-] Probing host 192.168.0.116 on port tcp/22 - Connect failed
 [-] Probing host 192.168.0.116 on port tcp/22 - Connect failed
 [+] Probe status changed at 20:34:44
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 0ms.
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 0ms.
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 0ms.
 [+] Probing host 192.168.0.116 on port tcp/22 - Connect OK - 0ms.

 TCP Ping statistics for 192.168.0.116 port tcp/22
     Connects : 13,  Success : 10, Failed : 3  (0% loss)
 Approximate round trip times in milli-seconds:
     Minimum = 30ms, Maximum = 30ms, Average = 2ms

 

Version history

1.0.0.1 : April 2009 : Added timestamps to output

1.0 : Initial release

 

Known issues

The statistics at the end of the probe sequence may report an incorrect loss percentage.

 

Download

Note : before downloading the utility, you must be logged on to this blog.

Registration is free, you can register here

You can download the utility from the link(s) below :

  PVE TCP Ping (Log in before downloading this file ! ) - Downloaded 85 times

© 2008 – 2009, Peter Van Eeckhoutte. All rights reserved. Terms of Use are applicable to all content on this blog. If you want to use/reuse parts of the content on this blog, you must provide a link to the original content on this blog.

Related Posts:

6 Responses to “Free tool – PVE TCP Ping Utility – v1.0.0.1”

  • werner werner says:

    Hello,
    the downloadlink isn’t aktive, only the message “download#11#image” displays.
    Please can you send me a link to the tool pvetcpping.
    Thank you.
    Greeting,
    Werner

  • Hello Werner,

    the download link problem should be fixed now – please try again

    Peter

  • brownj00 brownj00 says:

    Hi, great tool – I really like it.

    One question – I am getting some results of “0 ms” mixed in with 30’s and 40’s. I doubt the “0″ is accurate so I assume there is a minimal resonse threshold that is accurately reported. I’ve seen exactly that with other similar utilities as well… anything under 16ms for example is just reported as zero.

    do you know what is the lowest time in ms that will be accurately reported?

  • good question. In the code that connects to the tcp port, I’m
    - getting the current time, in milliseconds (begintime)
    - connecting & reading the returning packets
    - getting the current time, in milliseconds (endtime)
    - calculating the delta (endtime – begintime)
    The only cases where the delta would be 0 is
    - if the begintime equals the endtime
    - if the endtime is less than begintime (so delta < 0). This could be an internal clock issue… In my code, I’m setting negative delta’s to 0. Perhaps I should leave them as a negative value, but it would look bad, wouldn’t it
    - if the delta value returned by the function could not be converted to an integer. (it’s just a safety precaution in my code – it should never happen)

    Anyways – the code should return any values, including values below 16ms… unless the internal clock cannot handle it or unless it really is 0ms (starttime = endtime)… So I guess it’s not a code limitation, but it may be a system limitation

  • brownj00 brownj00 says:

    Right, thanks.

    I doubted it was a limitation in your code itself, but maybe there is an underlying limitation with the .Net stuff – how often it can get the cpu time or execution. I will be the first to tell you I don’t know enough to do more than ask silly questions so I will defer to you as the guru.

    I’ve tried it on several systems (PC’s and servers, XP, 2003, 32 & 64bit etc.) and get the same thing- never a result between 1-15 ms. Even when on the same Gb segment, 0 or 17+ and over the router where I expect 5-10 ms is the exact same results.

    Just curious, because what I really need to do immediately is quantify the latency through the firewall on 1433 is between 1-15ms. I can’t find anything that will do it. I like the tool and will keep it for use in other situations however!!!

    Cheers!

  • there’s got to be a different reason for the behaviour you are seeing

    Results of a tcpping to my webserver, also on gigabit network :

    ———————————
    PVE TCP Ping Utility
    Written by Peter Van Eeckhoutte
    http://www.corelan.be:8800
    Version 1.0
    ———————————

    [+] Connecting to tcp port 8800 on host http://www.corelan.be...
    [+] Number of pings : Unlimited
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 114ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 2ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 1ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 1ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 2ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 1ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 1ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 2ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 1ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 1ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 1ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 1ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 4ms.
    [+] Probing host https://www.corelan.be:8866 on port tcp/8800 – Connect OK – 1ms.

    TCP Ping statistics for https://www.corelan.be:8866 port tcp/8800
    Connects : 14, Success : 14, Failed : 0 (0% loss)
    Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 114ms, Average = 9ms

    As you can see, the tcpping does report latency of less than 16 ms…

Leave a comment

You must be logged in to post a comment.

Peter says:
« All of the info and all tools on this blog are free. Keeping this blog in the air is quite expensive. So if you like what I do and want to show your respect for my work, please consider donating (use the Donate link above)

»     ...     « If you have enjoyed a certain post or like one of my tools, don't forget to vote/rate it !

»     ...     « If you have questions about certain posts, content or tools published on this website, then please use the forums to post questions. Don't write your questions in the Comments section.

»     ...     « If you want to be the first to know about new posts/tools/tutorials on this blog, then subscribe to the mailinglist. Use the 'Subscribe to updates via email' link below (in the Stay posted section)

»
Categories