猿创征文|【实用工具tcping】ping & tcping的区别,使用命令,超全超详细使用手册(建议收藏)



ping

简介

ping (Packet Internet Groper)是一种英特网包探索器,用于测试网络连接量的程序 。Ping是工作在TCP/IP网络体系结构中应用层的一个服务命令, 主要是向特定的目的主机发送ICMP(Internet Control Message Protocol 因特网报文控制协议)Echo请求报文,测试目的站是否可达及了解其有关状态。ping用于确定本地主机是否能与另一台主机成功交换(发送与接收)数据包,再根据返回的信息,就可以推断TCP/IP参数是否设置正确,以及运行是否正常、网络是否通畅等。

Ping命令可以进行以下操作

  • 通过将ICMP并侦听回显回复数据包来验证与一台或多台远程计算机的连接
  • 每个发送的数据包最多等待一秒
  • 打印已传输和接收的数据包数

需要注意的是,Ping成功并不一定就代表TCP/IP配置正确,有可能还要执行大量的本地主机与远程主机的数据包交换,才能确信TCP/IP配置的正确性。如果执行ping成功而网络仍无法使用,那么问题很可能出在网络系统的软件配置方面,ping成功只保证当前主机与目的主机间存在一条连通的物理路径。


使用

用法

ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
	[-r count] [-s count] [[-j host-list] | [-k host-list]]
	[-w timeout] [-R] [-S srcaddr] [-c compartment] [-p]
	[-4] [-6] target_name

选项

选项描述
-tPing 指定的主机,直到停止。若要查看统计信息并继续操作,请键入 Ctrl+Break;若要停止,请键入 Ctrl+C。
-a将地址解析为主机名。
-n count要发送的回显请求数。
-l size发送缓冲区大小。
-f在数据包中设置“不分段”标记(仅适用于 IPv4)。
-i TTL生存时间。
-v TOS服务类型(仅适用于 IPv4。该设置已被弃用,对 IP 标头中的服务类型字段没有任何影响)。
-r count记录计数跃点的路由(仅适用于 IPv4)。
-s count计数跃点的时间戳(仅适用于 IPv4)。
-j host-list与主机列表一起使用的松散源路由(仅适用于 IPv4)。
-k host-list与主机列表一起使用的严格源路由(仅适用于 IPv4)。
-w timeout等待每次回复的超时时间(毫秒)。
-R同样使用路由标头测试反向路由(仅适用于 IPv6)。根据 RFC 5095,已弃用此路由标头。如果使用此标头,某些系统可能丢弃回显请求。
-S srcaddr要使用的源地址。
-c compartment路由隔离舱标识符。
-pPing Hyper-V 网络虚拟化提供程序地址。
-4强制使用 IPv4。
-6强制使用 IPv6。

示例

  • ping ip 端口(ICMP协议是属于ip层协议,通信不需要端口所以无法测试 tcp udp 运输层的端口)
ping www.baidu.com 80

结果:

错误的参数 80
  • ping ip
ping www.baidu.com

结果:

正在 Ping www.a.shifen.com [14.215.177.39] 具有 32 字节的数据:
来自 14.215.177.39 的回复: 字节=32 时间=92ms TTL=52
来自 14.215.177.39 的回复: 字节=32 时间=89ms TTL=52
来自 14.215.177.39 的回复: 字节=32 时间=92ms TTL=52
来自 14.215.177.39 的回复: 字节=32 时间=94ms TTL=52

14.215.177.39 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 89ms,最长 = 94ms,平均 = 91ms

-选项 后的字段都是需要填入值的

  • ping -n count(要发送的回显请求数)
ping -n 7 www.baidu.com

结果:

正在 Ping www.a.shifen.com [14.215.177.38] 具有 32 字节的数据:
来自 14.215.177.38 的回复: 字节=32 时间=107ms TTL=52
来自 14.215.177.38 的回复: 字节=32 时间=76ms TTL=52
来自 14.215.177.38 的回复: 字节=32 时间=121ms TTL=52
来自 14.215.177.38 的回复: 字节=32 时间=122ms TTL=52
来自 14.215.177.38 的回复: 字节=32 时间=179ms TTL=52
来自 14.215.177.38 的回复: 字节=32 时间=78ms TTL=52
来自 14.215.177.38 的回复: 字节=32 时间=83ms TTL=52

14.215.177.38 的 Ping 统计信息:
    数据包: 已发送 = 7,已接收 = 7,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 76ms,最长 = 179ms,平均 = 109ms
  • ping -l size(发送缓冲区大小)
ping -l 666 www.baidu.com

结果:

正在 Ping www.a.shifen.com [14.215.177.38] 具有 666 字节的数据:
来自 14.215.177.38 的回复: 字节=666 时间=95ms TTL=52
来自 14.215.177.38 的回复: 字节=666 时间=124ms TTL=52
来自 14.215.177.38 的回复: 字节=666 时间=99ms TTL=52
来自 14.215.177.38 的回复: 字节=666 时间=90ms TTL=52

14.215.177.38 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 90ms,最长 = 124ms,平均 = 102ms

tcping

简介

tcping(Transmission Control Packet Internet Groper)命令使用TCP传输层协议,可以检测IP端口状态和查看ping值,即使服务器禁 ping 也可以通过 tcping 来监控服务器网络状态。如果没有通过服务器端口,则默认为80。

tcping命令可操作

  • 可以在对方阻止ping的情况下探测指定端口的连通性
  • 可以检测IP端口状态和查看ping 值
  • 使用TCP协议进行数据连通性检测的程序

下载

tcping下载
在这里插入图片描述
下载后放到目录:C:\Windows\System32,这样就可以在任意路径下运行tcping命令了,ping也是在这个目录下,两者不影响。之后按下win+r输入cmd,打开控制台,输入tcping,如果输出帮助文档,则表示成功
在这里插入图片描述


使用

用法

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]

选项

选项
-tping continuously until stopped via control-c(持续Ping直到通过Ctrl-c停止)
-n 5for instance, send 5 pings(例如,发送5个tcping)
-i 5for instance, ping every 5 seconds(例如,每5秒tcping一次)
-w 0.5for instance, wait 0.5 seconds for a response(例如,等待响应0.5秒)
-dinclude date and time on each line(每行包括日期和时间)
-b 1enable beeps (1 for on-down, 2 for on-up, 3 for on-change, 4 for always)(启用哔哔声(1为关机,2为开机,3为重启,4为始终))
-r 5for instance, relookup the hostname every 5 pings(例如,每5次tcping就重新查找主机名)
-sautomatically exit on a successful ping(在tcping成功时自动退出)
-vprint version and exit(打印版本并退出)
-jinclude jitter, using default rolling average(包括抖动,使用默认滚动平均)
-js 5include jitter, with a rolling average size of (for instance) 5.(包括抖动,滚动平均大小为(例如)5。)
–teemirror output to a filename specified after ‘–tee’(镜像输出到’——tee’之后指定的文件名)
–appendAppend to the --tee filename rather than overwriting it(追加到——tee文件名,而不是覆盖它)
-4prefer ipv4(优先ipv4)
-6prefer ipv6(优先ipv6)
-conly show an output line on changed state(只显示已更改状态的输出行)
–filetreat 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.(注意:——file与选项如-j和-c不兼容,因为它是循环通过不同的目标可选地接受服务器端口。例如,“example.org 443”有效。另外,使用-p强制在命令行为文件中的所有内容设置端口。)
-g 5for instance, give up if we fail 5 times in a row(例如,如果我们连续失败5次,就放弃)
-S _X_Specify source address X. Source must be a valid IP for the client computer.(指定源地址_X_。源必须是客户端计算机的有效IP。)
-p _X_Alternate method to specify port(另一种指定端口的方法)
–fqdnPrint domain name on each line if available(如果可以,在每一行打印域名)
–ansiUse ANSI color sequences (cygwin)(使用ANSI颜色序列(cygwin))
–colorUse Windows color sequences(使用Windows颜色序列)

HTTP选项

HTTP选项描述
-hHTTP mode (use url without http:// for server-address)(HTTP模式(使用url,不使用http://作为服务器地址))
-uinclude target URL on each line(每行包含目标URL)
–postuse POST rather than GET (may avoid caching)(使用POST而不是GET(可以避免缓存))
–headuse HEAD rather than GET(使用HEAD而不是GET)
–proxy-serverspecify a proxy server(指定代理服务器)
–proxy-portspecify a proxy port(指定代理端口)
–proxy-credentialsspecify ‘Proxy-Authorization: Basic’ header in format username:password(指定“代理授权:基本”头,格式为用户名:密码)

调试选项

调试选项描述
-fforce tcping to send at least one byte(强制tcp至少发送一个字节)
–headerinclude a header with original args and date. Implied if using --tee.(包含一个带有原始参数和日期的标题。如果使用——tee则暗示)
–block使用“阻塞”套接字进行连接。这将阻止-w工作并使用默认超时(在我的例子中长达20秒)。然而,它可以主动检测拒绝连接与超时。

示例

  • tcping ip 端口
tcping www.baidu.com 80

结果:

Probing 14.215.177.38:80/tcp - Port is open - time=104.043ms
Probing 14.215.177.38:80/tcp - Port is open - time=95.994ms
Probing 14.215.177.38:80/tcp - Port is open - time=99.670ms
Probing 14.215.177.38:80/tcp - Port is open - time=105.977ms

Ping statistics for 14.215.177.38:80
     4 probes sent.
     4 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 95.994ms, Maximum = 105.977ms, Average = 101.421ms
  • tcping -t ip(一直检测,Ctrll+C停止)
tcping -t www.baidu.com 80

结果:

** Pinging continuously.  Press control-c to stop **

Probing 14.215.177.38:80/tcp - Port is open - time=85.118ms
Probing 14.215.177.38:80/tcp - Port is open - time=84.338ms
Probing 14.215.177.38:80/tcp - Port is open - time=82.035ms
Probing 14.215.177.38:80/tcp - Port is open - time=86.691ms
Probing 14.215.177.38:80/tcp - Port is open - time=104.070ms
Probing 14.215.177.38:80/tcp - Port is open - time=122.593ms
Probing 14.215.177.38:80/tcp - Port is open - time=163.882ms
Probing 14.215.177.38:80/tcp - Port is open - time=106.062ms
Probing 14.215.177.38:80/tcp - Port is open - time=242.789ms
Probing 14.215.177.38:80/tcp - Port is open - time=91.095ms
Probing 14.215.177.38:80/tcp - Port is open - time=118.070ms
Probing 14.215.177.38:80/tcp - Port is open - time=131.803ms
Probing 14.215.177.38:80/tcp - Port is open - time=171.199ms
Probing 14.215.177.38:80/tcp - Port is open - time=94.432ms
Probing 14.215.177.38:80/tcp - Port is open - time=170.511ms
Control-C

Ping statistics for 14.215.177.38:80
     15 probes sent.
     15 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 82.035ms, Maximum = 242.789ms, Average = 123.646ms
  • tcping --fqdn www.baidu.com 80(每一行打印域名)
tcping --fqdn www.baidu.com 80

结果:

Probing www.baidu.com:80/tcp - Port is open - time=89.863ms
Probing www.baidu.com:80/tcp - Port is open - time=97.284ms
Probing www.baidu.com:80/tcp - Port is open - time=222.348ms
Probing www.baidu.com:80/tcp - Port is open - time=86.891ms

Ping statistics for 14.215.177.38:80
     4 probes sent.
     4 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 86.891ms, Maximum = 222.348ms, Average = 124.096ms
  • tcping -n 5 www.baidu.com 80(发送5个tcping)
tcping -n 5 www.baidu.com 80

结果:

Probing 14.215.177.38:80/tcp - Port is open - time=88.883ms
Probing 14.215.177.38:80/tcp - Port is open - time=88.871ms
Probing 14.215.177.38:80/tcp - Port is open - time=85.013ms
Probing 14.215.177.38:80/tcp - Port is open - time=81.591ms
Probing 14.215.177.38:80/tcp - Port is open - time=90.829ms

Ping statistics for 14.215.177.38:80
     5 probes sent.
     5 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 81.591ms, Maximum = 90.829ms, Average = 87.037ms
  • tcping -w 3 www.baidu.com 80(等待响应3秒)
tcping -w 3 www.baidu.com 80

结果:

Probing 14.215.177.39:80/tcp - Port is open - time=89.445ms
Probing 14.215.177.39:80/tcp - Port is open - time=91.247ms
Probing 14.215.177.39:80/tcp - Port is open - time=94.874ms
Probing 14.215.177.39:80/tcp - Port is open - time=81.502ms

Ping statistics for 14.215.177.39:80
     4 probes sent.
     4 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 81.502ms, Maximum = 94.874ms, Average = 89.267ms
  • tcping -h www.baidu.com 80(使用HTTP模式url)
tcping -h www.baidu.com 80

结果:

Probing 14.215.177.39:80/tcp - HTTP is open - time=99.764ms rcv_time=96.177 status=200 bytes=8102 kbit/s=~673.926
Probing 14.215.177.39:80/tcp - HTTP is open - time=86.338ms rcv_time=98.719 status=200 bytes=8102 kbit/s=~656.569
Probing 14.215.177.39:80/tcp - HTTP is open - time=77.414ms rcv_time=92.856 status=200 bytes=8102 kbit/s=~698.024
Probing 14.215.177.39:80/tcp - HTTP is open - time=80.852ms rcv_time=93.861 status=200 bytes=8102 kbit/s=~690.555

Ping statistics for 14.215.177.39:80
     4 probes sent.
     4 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 77.414ms, Maximum = 99.764ms, Average = 86.092ms
Approximate download times in milli-seconds:
     Minimum = 92.856ms, Maximum = 98.719ms, Average = 95.403ms
  • tcping --block www.baidu.com 80(检测连接与超时)
tcping --block www.baidu.com 80

结果:

Probing 14.215.177.39:80/tcp - Port is open - time=82.162ms
Probing 14.215.177.39:80/tcp - Port is open - time=138.086ms
Probing 14.215.177.39:80/tcp - Port is open - time=110.414ms
Probing 14.215.177.39:80/tcp - Port is open - time=105.083ms

Ping statistics for 14.215.177.39:80
     4 probes sent.
     4 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 82.162ms, Maximum = 138.086ms, Average = 108.936ms

总结

以上就是关于ping和tcping的相关知识了,其实平时项目部署过程中用的比较多的还是端口监测,可以用来检测项目是否运行。
有问题可以评论区留言,看到第一时间回复,感谢支持!


  • 6
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小呆瓜耶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值