官网

tcping.exe - 通过 TCP 连接执行 ping 操作

tcping.exe - 通过 TCP 连接执行 ping 操作

tcping.exe是一个控制台应用程序,其操作类似于“ping”,但它通过TCP端口工作。有许多不同的实现,由不同的人独立编写。有很多类似的,但这个是我的。
使用tcp协议尝试与某一个端口建立连接,然后获取与对方主机建立一次连接的回复。(延迟)
(原文:tcping.exe is a console application that operates similarly to 'ping', however it works over a tcp port. There are many different implementions of this floating around, written independently by different people. There are many like it, but this one is mine.)

下载:

http://pan.sfwww.cn/#s/9ivKon1w 密码:tcping

用法:

将tcping.exe放到C:\Windows\System32\里,打开CMD终端即可使用

NAME
    tcping - simulate "ping" over tcp by establishing a connection to network hosts.
    Measures the time for your system to [SYN], receive the target's [SYN][ACK] and send [ACK].  Note that the travel time for
    the last ACK is not included - only the time it takes to be put on the wire a tthe sending end.

SYNOPSIS
    tcping [-tdsvf46] [-i interval] [-n times] [-w interval] [-b n] [-r times][-j depth] [--tee filename] [-f] destination [port]

DESCRIPTION
    tcping measures the time it takes to perform a TCP 3-way handshake (SYN, SYN/ACK, ACK) between itself and a remote host.
    The travel time of the outgoing final ACK is not included, only the (minimal) amount of time it has taken to drop it on
    the wire at the near end.  This allows the travel time of the (SYN, SYN/ACK) to approximate the travel time of the
    ICMP (request, response) equivalent.
  
OPTIONS
    -4      Prefer using IPv4

    -6      Prefer using IPv6

    -t      ping continuously until stopped via control-c

    -n count
            send _count_ pings and then stop.  Default 4.
  
    -i interval
            Wait _interval_ seconds between pings.  Default 1.  Decimals permitted.
  
    -w interval
            Wait _interval_ seconds for a response.  Default 2.  Decimals permitted.

    -d      include date and time on every output line
  
    -f      Force sending at least one byte in addition to making the connection.

    -g count
            Give up after _count_ failed pings.
  
    -b type
            Enable audible beeps.
            '-b 1' will beep "on down".  If a host was up, but now its not, beep.
            '-b 2' will beep "on up".  If a host was down, but now its up, beep.
            '-b 3' will beep "on change".  If a host was one way, but now its the other, beep.
            '-b 4' will beep "always".

    -c      only show output on a changed state
  
    -r count
            Every _count_ pings, we will perform a new DNS lookup for the host in case it changed.

    -s      Exit immediately upon a success.      

    -v      Print version and exit.

    -j      Calculate jitter.  Jitter is defined as the difference between the last response time and the historical average.

    -js depth
            Calculate jitter, as with -j but with an optional _depth_ argument specified. If _depth_ is specified tcping will
            use the prior _depth_ values to calculate a rolling average.

    --tee _filename_
            Duplicate output to the _filename_ specified.  Windows can still not be depended upon to have a useful command line 
            environment. Don't tease me, *nix guys.

    --append
            When using --tee, append to rather than overwrite the output file.
          
    --file
            Treat the "destination" option as a filename.  That file becomes a source of destinations, looped through on a
            line by line basis.  Some options don't work in this mode and statistics will not be kept.


    destination
            A DNS name, an IP address, or (in "http" mode) a URL.
            Do not specify the protocol ("http://") in "http" mode.  Also do not specify server port via ":port" syntax.
            For instance:   "tcping http://www.elifulkerson.com:8080/index.html" would fail
            Use the style:  "tcping www.elifulkerson.com/index.html 8080" instead.
                              
    port
            A numeric TCP port, 1-65535.  If not specified, defaults to 80.

    --header
            include a header with the command line arguments and timestamp.  Header is implied if using --tee.
          
HTTP MODE OPTIONS   
    -h      Use "http" mode.  In http mode we will attempt to GET the specified document and return additional values including
            the document's size, http response code, kbit/s.
    -u      In "http" mode, include the target URL on each output line.
  
    --post  Use POST instead of GET in http mode.
    --head  Use HEAD instead of GET in http mode.
    --get   Shorthand to invoke "http" mode for consistency's sake.

    --proxy-server _proxyserver_
            Connect to _proxyserver_ to request the url rather than the server indicated in the url itself.
    --proxy-port _port_
            Specify the numeric TCP port of the proxy server.  Defaults to 3128.
    --proxy-credentials username:password
            Specify a username:password pair which is sent as a 'Proxy-Authorization: Basic' header.


RETURN VALUE
    tcping returns 0 if all pings are successful, 1 if zero pings are successful and 2 for mixed outcome.

BUGS/REQUESTS
    Please report bugs and feature requests to the author via contact information on http://www.elifulkerson.com
  
AVAILABILITY
    tcping is available at http://www.elifulkerson.com/projects/tcping.php

机翻

在本地主机和远程主机之间,tcping可以测试出执行TCP三次握手所需的时间(SYN,SYN / ACK,ACK)。最终ACK传送时间不包括在内,只有最少的时间才能将其丢弃在近端。

由于tcping的Linux源代码年久失修,tcping目前仅在Windows模式下提供强大的功能支持,Linux模式下仅提供基本功能支持。

# Windows下使用
tcping [参数选项] [目标主机地址] [端口]
 
# Linux下使用(参数较少)
tcping [目标主机地址] -p [端口]
下面以Windows下的tcping为例,详解相关选项和参数:

选项
-4,优先使用IPv4
 
-6,优先使用IPv6
 
-h,使用http模式
 
-t,让命令持续运行,直到使用ctrl + c指令退出
 
-n 数字,发送命令的次数,默认4次
 
-i 数字,发送ping命令的时间间隔,默认1s,可以为小数
 
-w 数字,等待响应的时间间隔,默认2s,可以为小数
 
-d,使输出的每一行显示时间和日期
 
-f,强制ping命令至少发送一个比特(byte)
 
-g 数字,失败指定次就放弃(注意默认是80端口,若其他端口没开也算失败)
 
-b 数字,开启蜂鸣器,参数4会一直响铃
 
-c,只显示改变的信息(ping时间很短一般不会改变)
 
-r 数字,每发送指定个数据包,就重新查找主机一次(通过DNS或路由查找)
 
-s,ping通就立即退出
 
-u,与-h命令连用,每一行输出目标的url
 
-v,显示版本信息
 
-j,使用默认的方法,求ping的均值减小波动,网络有一定的不稳定性时,用此参数可以减小波动
 
-js 数字,用指定个实例求平均值减小波动,使用这个参数,系统会tcping 指定次,然后求出平均值作为一次结果显示,减小波动
 
–tee file_path,将结果输出到指定位置,tcping –tee /data/test.txt192.168.0.100,会把ping的结果保存在/data下的test文件中
 
–file,从文件中获得ping的来源;在/data下新建一个test.txt文件,并输入要tcping的所有ip或域名,一行一个,然后执行命令tcping –file /data/test.txt,就会依次tcping文件中指定的地址
 
destination,可以是DNS地址、IP地址、URL(需要使用-h,http模式)。使用http模式时,不要加https//或:port,例如:tcping http://www.elifulkerson.com:8080/index.html就会失败,使用tcping www.elifulkerson.com/index.html 8080就会成功
 
port 数字,指定tcp端口(1-65535),如果不指定,默认是80
 
–header,在头部显示时间和日期,与–tee显示的格式差不多
 
–block,tcping不通的等待时间,默认是20秒(很长)。–block可以把-w参数冲突掉 ,例如tcping --block www.baiu.com网址不正确,显然tcpping不通,默认会等待20s 。 tcping -w 0.5 –block www.baiu.com还是会等20s,而不是0.5s,因为–block选项会把-w选项冲突掉。
 
HTTP模式选项
–post,在http模式中,使用post方法
 
–head,在http模式中,使用head方法
 
–get Shorthand to invoke “http” mode for consistency’s sake.
 
–proxy-server,指定代理服务
 
–proxy-port,指定代理服务端口
 
–proxy-credentials username:password,使用代理的安全验证,需要输入用户名和密码
 
返回值
如果所有的pings是成功的,返回0;如果所有ping都失败,返回1;混合结果,返回2
tcping在Windows下使用的实例

tcping -d -h -u -n 10 -i 0.1 -w 0.1 andyx.net 80
 
# 以上命令参数解释为:
#使用http模式(-h)
#在返回数据中显示目标源url地址(-u)
#向主机名为andyx.net的80端口发送10次数据包(-n 10)
#在返回数据行中显示发送数据包的日期(-d)
#指定每次发送数据包的时间间隔为0.1秒(-i 0.1)
#等待数据包相应的时间间隔为0.1秒(-w 0.1)

tcping在Linux下使用的实例

tcping -t 20 -c 7 andyx.net -p 80
 
# 以上命令参数解释为:
-p : 指定端口80
-t : 限定超时时间,以秒为单位 20秒
-c : 探测多少次后结束 7次

许可证:

  • 该程序的代码在GPL下可用。
  • 此实用程序包括 来自Winsock程序员常见问题解答 的公共域代码,您可能也对此感兴趣。
  • v0.28 及更高版本包括 base64.cpp (版权所有 (C) 2004-2008 René Nyffenegger)。许可证在源代码中,tl;dr - 用于任何用途;按原样无担保;请勿移除归因。

更新历史:

2007 年 2 月 28 日。根据请求添加了“-t”和“-n<计数>”命令行选项。
六月 22 2009.根据请求添加了“-i”、“-d”、“-b”命令行选项。
八月 16 2009.现在使用 QueryPerformanceCounter 而不是 ftime 进行计时。
十月 14 2009.返回 0 表示成功,返回 1 表示失败,返回 2 表示成功和失败混合。
八月 10 2010.添加了 -w 选项,用于在连接超时之前等待的最长时间。
八月 18 2010.增加了控制-c通过请求终止后的统计输出。
三月 10 2011.修复了失败的连接未关闭的问题。
三月 15 2011.添加了“-r x”以每x次尝试导致新的DNS查找。
三月 17 2011.删除了“cerr”与“cout”的区别,ctrl-c 现在响应速度更快。
四月 29 2011.-s 选项由 Michael Bray 提供。信用移动到 -v 输出以减少混乱。
七月 7 2011.“-b 3”现在应该在一开始就关闭的情况下工作。哎呀。感谢乔·胡贝尔。
十二月 13 2011.添加了“-o”、“-f”。从httping合并到'-d','-h'和'u'中。添加了“-p”。
七月 20 2012.更改了“-i”以允许浮点数(例如,在ping之间延迟0.1秒)。使用 http 模式时,在摘要统计信息中添加了最小/最大/平均下载时间。
四月 14 2013.删除了不准确的计时功能和“-o”,让您选择它。删除了“-p”,以支持“--head”和“--post”以指定HTTP命令。添加了“--tee 文件名”以输出到控制台之外的文件。添加了“-j”以显示抖动(当前计算为上次ping与历史平均值之间的差异)。修复了指定不正确的命令行参数时的崩溃错误。
四月 15 2013.将平均行为更改为仅计算成功的连接。'-j' 现在有一个可选参数,用于指定抖动计算的滚动平均值的深度。例如,“-j 10”将使用最多 10 个先前的 ping 结果,不包括当前结果。如果未指定深度,则禁用滚动平均值 - 在这种情况下,它将使用整个 sesion 的总平均值。更正了 0.15 中引入的输出缓冲区刷新错误。
四月 20 2013.IPv6 和 http 代理支持。添加了“-4”、“-6”、“--代理服务器”、“--代理端口”。“-w”现在以秒而不是毫秒为单位指定,以便与其他参数保持一致。
五月 29 2013.速度优化
2013 年 7 月 10 日。修复了某些 --proxy 参数的命令行处理中断的问题。
八月 26 2013.CPU 使用修复 - 在需要很长时间才能获得响应的情况下,为了精度,我们会退缩并停止研磨 CPU。
一月 20 2014.修复了一些资源泄漏。
三月 17 2014.添加了 -c 以仅在状态更改时输出行。
四月 2 2014.改写“无错误”以减少混淆。
一月 1 2015.将带和不带可选参数的 -j 分隔为 -j 和 -js,以避免命令行参数解析错误。
三月 18 2015.添加了“--文件”选项。将目标参数视为每行包含一个目标的文件名。禁用一些没有意义或困难的选项(当您击中不同的目标时,抖动,统计等没有任何意义,并且通过循环设置方式保留N个可能目标的所有数据并非易事)
Apr 7 2015.0.25 有一个崩溃错误 w使用 HTTP 代理的母鸡,现在应该修复。谢谢 андрей.
八月 1 2015.修复了 -w 的浮点值问题。添加了 -g X 以在 X 失败后放弃。谢谢滕。另外,现在在Win10 / VS2015下编译。
八月 8 2015.添加了 --proxy-credentials 以指定“代理授权:基本”标头。谢谢大妈。使用包括base64.cpp(版权所有(C)2004-2008 René Nyffenegger)对用户名:密码对进行编码。
九月 2 2015.0.28 还剩下一些调试行,哎呀。已删除,谢谢 Андрей.
十一月 13 2015.版本 0.30。添加了 --header 选项并修复了 http 代理模式问题 - 在应该发送主机时没有发送主机。
十二月 14 2015.如果 DNS 在第一次尝试时未解析,-r 选项现在应该可以正常工作。感谢迈克·韦斯特曼。
三月 15 2016.--file 选项现在可以选择包括每行的端口号。例如,行“127.0.0.1”和“127.0.0.1 443”应按预期工作。
四月 25 2016.添加了 -S 选项以指定源端口。
六月 6 2016.添加了 --block 选项以使用阻塞套接字。这会中断超时代码,但它可以更精细地检测端口阻塞的实际原因。特别是,现在您可以在测试防火墙规则时看到主动拒绝与超时。
五月 11 2017.版本 0.35。添加了 -p 选项来指定端口(即使在使用 --file 时也是如此,因为使用 --file 时不会发生正常的解析)。如果您使用的是cmd,还添加了--color.exe(如果您使用cygwin等,则为enredden故障添加--ssi)。还添加了 --fqdn,它将输出域名而不是 ip(如果可用,它不会强制反向 DNS 查找)。对于艾坦。
五月 12 2017.0.36. -p 中的错误破坏了原来的端口语法,已修复。在错误消息上添加了更多红色 --颜色。
十一月 7 2017.0.37. 添加了 --append 选项,当与 “--tee filename_” 结合使用时,将导致 _filename 被追加而不是覆盖。
十二月 28 2017.0.38. 添加了最小/平均/最大抖动和 http 抖动的摘要。使用抖动的绝对值。
十二月 30 2017.0.39. 修复了 0.38 中引入的 % 损失显示问题。
(原文:Update History:
Feb 28 2007. Have added '-t' and '-n ' command line options by request.
Jun 22 2009. Have added '-i', '-d', '-b' command line options by request.
Aug 16 2009. Now using QueryPerformanceCounter instead of ftime for timing.
Oct 14 2009. Returning 0 for success, 1 for failure, and 2 for mixed success and failure.
Aug 10 2010. Added -w option, for maximum time to wait before timing out a connection.
Aug 18 2010. Added statistics output after control-c termination by request.
Mar 10 2011. Fix for failed connections not being closed.
Mar 15 2011. Have added '-r x' to cause a new DNS lookup every x attempts.
Mar 17 2011. Removed the "cerr" vs "cout" distinction, ctrl-c is now more responsive.
Apr 29 2011. -s option contributed by Michael Bray. Credits moved to the -v output to be less cluttered.
Jul 7 2011. '-b 3' should work now in situations where it was down to start with. Oops. Thanks to Joe Hubele.
Dec 13 2011. Added '-o', '-f'. Merged in '-d', '-h' and 'u' from httping. Added '-p'.
Jul 20 2012. Changed '-i' to allow floats (for instance, delay 0.1 seconds between pings). Added min/max/avg download time to summary statistics when using http mode.
Apr 14 2013. Removed inaccurate timing function and '-o' which let you choose it.. Removed '-p' in favor of '--head' and '--post' to specify HTTP commands. Added '--tee filename' to output to a file in addition to the console. Added '-j' to display jitter (currently calculated as difference between last ping and historical average). Fixed a crash bug if incorrect command line arguments were specified.
Apr 15 2013. Changed average behavior to only count successful connections. '-j' now has an optional argument to specify the depth of a rolling average for jitter calculations. For instance, '-j 10' will use up to the 10 previous ping results, non-inclusive with the current result. Rolling average is disabled if no depth is specified - in that case it will use the total average of the entire sesion. Corrected output buffer flushing error introduced in 0.15.
Apr 20 2013. IPv6 and http proxy support. Added '-4', '-6', '--proxy-server', '--proxy-port'. '-w' is now specified in seconds rather than milliseconds for consistency with other arguments.
May 29 2013. Speed optimizations
Jul 10 2013. Fixed broken command line handling for certain --proxy arguments.
Aug 26 2013. CPU use fix - in cases where it takes a long time to get a response, we back off and stop grinding the cpu in the interest of precision.
Jan 20 2014. Fixed some resource leaks.
Mar 17 2014. Added -c to only output lines if there is a state change.
Apr 2 2014. Rephrased 'no error' to be less confusing.
Jan 1 2015. Separated -j with and without optional argument into -j and -js to avoid command line argument parsing bug.
Mar 18 2015. Added "--file" option. Treat the destination argument as a filename containing one destination per line. Disables some options that don't make sense or are difficult (jitter, statistics and the like don't make any sense when you are hitting different targets and it is non-trivial to retain all that data for N possible destinations with the way the loop is set up)
Apr 7 2015. 0.25 had a crash bug when using http proxy, should be fixed now. Thanks Андрей.
Aug 1 2015. Fixed an issue with float values for -w. Added -g X to give up after X failures. Thanks jk teng. Also, compiling under Win10/VS2015 now.
Aug 8 2015. Added --proxy-credentials to specify a 'Proxy-Authorization: Basic' header. Thanks Dam. Using includes base64.cpp (Copyright (C) 2004-2008 René Nyffenegger) to encode the username:password pair.
Sep 2 2015. 0.28 had some debugging lines left in, oops. Removed, thanks Андрей.
Nov 13 2015. Version 0.30. Added --header option and fixed a http proxy mode issue - wasn't sending the host when it should have.
Dec 14 2015. -r option should now work properly if DNS doesn't resolve on the first attempt. Thanks to Mike Westman.
Mar 15 2016. --file option now optionally includes port numbers for each line. For example, the lines "127.0.0.1" and "127.0.0.1 443" should work as expected.
Apr 25 2016. Added -S option to specify the source port.
Jun 6 2016. Added --block option to use a blocking socket. This breaks the timeout code, but it allows finer detection of the actual cause of a blocked port. In particular, now you can see actively refused vs timeout when testing firewall rules.
May 11 2017. Version 0.35. Added -p option to specify port (even when using --file, since the normal parsing doesn't happen when using --file). Also added --color to enredden failures if you're using cmd.exe (--ansi if you are using cygwin etc). Also added --fqdn which will output the domain name rather than the ip (if its available, it doesn't force a reverse DNS lookup). For Eitan.
May 12 2017. 0.36. Error in -p broke the original port syntax, fixed. Added a few more red --colors on error messages.
Nov 7 2017. 0.37. Added --append option, when used in conjuntion with "--tee filename_" will cause _filename to be appended to rather than overwritten.
Dec 28 2017. 0.38. Added summaries for min/avg/max for jitter and http jitter. Using absolute value for jitter.
Dec 30 2017. 0.39. Fixed display issue for % loss introduced in 0.38.)

例子

tcping01.png

最后修改:2023 年 12 月 21 日
如果我的文章对你有用,请帮助小站能够存活下去( •̀ ω •́ )✧