tcping的安装与使用

转载自:https://blog.csdn.net/gd007he/article/details/52474494

起因:
很多时候要测试端口,ping命令虽好但不能测试端口 ping 基于ICMP协议是属于ip层协议,通信不需要端口所以无法测试 tcp udp 运输层的端口,幸好 有tcping 命令,可是tcping命令用法网上讲十分简略,一个如此实用的工具百度上竟然找不到一份详细的说明,不经让我感叹颇多, 所以本人决定翻译 tcping的参数文档,希望对大家有点帮助。本人水平很有限,必有错误与不当,极力欢迎大家批评指正。

前言:

  • 1.tcping 非自带命令,我会先介绍如何安装tcping命令。
  • 2.提供tcping文档原文图片供大家参考。
  • 3.一行一行的翻译,不容易理解的地方我会举一个例子,并提供运行图片,例子和翻译用冒号隔开。

正文 :
1.安装tcping命令 ,从官网http://www.elifulkerson.com/projects/tcping.php 下载对应32位或64位的exe文件,然后将文件放到 c:\windows\system32\ 目录下面(注意:如果下载的是64位的要把名称改为tcping.exe不然运行的时候要输入tcping64 )然后在命令下输入tcping 如果出现帮助文档说明安装命令成功。

2.帮助文档的原文如下图:

C:\Users\XXX>tcping --help
Usage: tcping [-flags] server-address [server-port]

Usage (full): tcping [-t] [-d] [-i interval] [-n times] [-w ms] [-b n] [-r times] [-s] [-v] [-j] [-js size] [-4] [-6] [-c] [-g count] [-S source_address] [--file] [--tee filename] [-h] [-u] [--post] [--head] [--proxy-port port] [--proxy-server server] [--proxy-credentials username:password] [-f] server-address [server-port]

-t : ping continuously until stopped via control-c
-n 5 : for instance, send 5 pings
-i 5 : for instance, ping every 5 seconds
-w 0.5 : for instance, wait 0.5 seconds for a response
-d : include date and time on each line
-b 1 : enable beeps (1 for on-down, 2 for on-up,
3 for on-change, 4 for always)
-r 5 : for instance, relookup the hostname every 5 pings
-s : automatically exit on a successful ping
-v : print version and exit
-j : include jitter, using default rolling average
-js 5 : include jitter, with a rolling average size of (for instance) 5.
--tee : mirror output to a filename specified after '--tee'
--append : Append to the --tee filename rather than overwriting it
-4 : prefer ipv4
-6 : prefer ipv6
-c : only show an output line on changed state
--file : treat the "server-address" as a filename instead, loop through file line by line
Note: --file is incompatible with options such as -j and -c as it is looping through different targets
Optionally accepts server-port. For example, "example.org 443" is valid.
Alternately, use -p to force a port at command line for everything in the file.
-g 5 : for instance, give up if we fail 5 times in a row
-S X : Specify source address X. Source must be a valid IP for the client computer.
-p X : Alternate method to specify port
--fqdn : Print domain name on each line if available
--ansi : Use ANSI color sequences (cygwin)
--color: Use Windows color sequences
HTTP Options:
-h : HTTP mode (use url without http:// for server-address)
-u : include target URL on each line
--post : use POST rather than GET (may avoid caching)
--head : use HEAD rather than GET
--proxy-server : specify a proxy server
--proxy-port : specify a proxy port
--proxy-credentials : specify 'Proxy-Authorization: Basic' header in format username:password
Debug Options:
-f : force tcping to send at least one byte
--header : include a header with original args and date. Implied if using --tee.
--block : use a 'blocking' socket to connect. This prevents -w from working and uses the
default timeout (as long as 20 seconds in my case). However it can detect an actively
refused connection vs a timeout.
If you don't pass server-port, it defaults to 80.

3.翻译和实例:

-t 不停的发送数据包直到 按ctrl+c 停止,可以用此命令做小破坏。

-n 5 一次发送 5 个数据包,默认一次发送4个 : tecping -n 5 www.baidu.com 会tcping 百度5次,也可以跟其他数字。

-i 5 5秒发送一个数据包 : tcping -i 5 www.baidu.com 每间隔5秒tcping一次百度,也可以跟其他数字,也可以跟小数 :tcping -i 0.5 www.baidu.com 每隔 0.5秒tcping 一次百度。

-w 0.5 tcping不通的等待时间 tcping通则忽略次参数 : tcping -w 0.5 www.baidu.com 如果ping不同会等待0.5秒,默认tcping不通等2s,tcping 通则忽略此参数。

-d 在每行前面显示详细日期时间。

-b 1-4 ping的时候会响铃,参数4会一直响铃 : tcping -b 4 www.baidu.com
每显示一行内容就会响铃一次,默认会响铃4次

-r 5 每发送5个数据包重新查找主机一次(通过DNS或路由查找)

-s ping通就立即退出

-v 显示版本信息

-j 使用默认的方法求ping的均值减小波动,网络有一定的不稳定性用此参数可以减小波动。

-js 5 用5个实例求平均值减小波动,使用这个参数系统会tcping 5次然后求出平均值作为一次结果显示,减小波动。

–tee 将结果输出到指定位置 :tcping –tee d:\test.txt192.168.0.100 会将ping的结果保存在d盘下的test文件中。具体如下图:

-c 只显示转变的信息(ping时间很短一般不会转变)。

-g 5 失败5次就放弃(注意默认是80端口,端口没开也算失败)

-h 以http 的模式工作,可以测试主机是否提供http服务。具体如下图

–post 为了保证自己计算机的安全有些电脑禁止了别人ping 使用 post /head 参数
–head 加大ping通的机率

–proxy-server 指定代理服务 : 没有代理无法测试
–proxy-port 指定代理服务端口 : 没有代理无法测试
–proxy-credentials 使用代理的安全验证,需要输入 用户名和密码 : 没有代理无法测试

–f 强制ping命令至少发送一个比特(byte)

–file 从文件中获得ping的来源 : tcping –file d:\test.txt 我在d盘下新建一个test文件,并输入 我要tcping的所有ip或域名一行一个,然后执行命令,就会依次tcping文件中指定的地址。具体如下图:

–header 在头部显示时间和日期和–tee显示的格式差不多

–block tcping不通的等待时间,默认是20秒(很长),可以将 -w参数冲突掉 :tcping –block www.baiu.com 网址不正确显然tcpping 不通 默认会等待2s 但是加了 –block参数后每tcping一次会等 20s 的时间
: tcping -w 0.5 –block www.baiu.com 还是会等20s 而不是 0.5s因为–block会把 -w 会被冲突掉

posted @ 2023-03-31 15:17  七侠镇缁衣铺头  阅读(108)  评论(0编辑  收藏  举报