怎样使用Ping工具测试网络路由

2019年6月11日 | 分类: 【技术】

【缘起】

ping 命令基于 ICMP 协议,在严谨的网路环境中会拒绝 ICMP 回应,使得无法测得时延。

方案A:虽然 ping 不通,但得到 IP 。尝试 ping 此 IP 同一 IP 段的 IP 。直到出现一个可 ping 通的 IP 。

方案B:通过 ping 的替代工具。

【工具:Tcpping(Linux,基于TCP)】

Tcpping 通过 TCP/UDP 协议来测试时延,可以直接绕过多数 L3 防火墙。

运作方式:
Client: send TCP SYN (default 80)
Server: response TCP ACK (success)
Server: response TCP RST (fail)

依赖:

Tcpping 使用的是『半开连接技术』,依赖已经拥有此技术的 tcptraceroute 工具:

Ubuntu系统:

sudo apt install tcptraceroute -y

CentOS系统:

yum install tcptraceroute -y 

安装:

wget http://www.vdberg.org/~richard/tcpping && chmod +x tcpping

使用:

侦测主机:

./tcpping www.google.com

指定端口:

./tcpping www.google.com 25

参数 -c 可以配合 gnuplot script 制成图表:

./tcpping -c www.google.com

参考:https://blog.csdn.net/chinagrowing/article/details/81217527
参考:https://www.laozuo.org/9602.html
参考:https://blog.csdn.net/sifeimeng/article/details/84738157
参考:https://stackoverflow.com/questions/14796806/check-latency-if-server-denies-ping-requests

【工具:psping(Windows,基于TCP)】

参考:https://learn.microsoft.com/zh-cn/sysinternals/downloads/psping
下载:https://download.sysinternals.com/files/PSTools.zip

Use a ping based on TCP.
If you have access to a Windows box, use http://technet.microsoft.com/en-us/sysinternals/jj729731.aspx
Download the zip, unpack. From CMD prompt cd to unpacked folder, then run with -t flag like this:

下载压缩包,解压到文件夹:C:\psping

启动 PowerShell:

cd C:\psping
.\psping.exe -t nic.ar:80

返回:

TCP connect to 200.108.146.10:80:
Infinite iterations (warmup 1) ping test:
Connecting to 200.108.146.10:80 (warmup): from 149.104.76.185:50155: 1.34ms
Connecting to 200.108.146.10:80: from 149.104.76.185:50156: 2.13ms
...

  Sent = 11, Received = 11, Lost = 0 (0% loss),
  Minimum = 1.71ms, Maximum = 4.30ms, Average = 2.37ms

从而可知 LightNode 的布宜诺斯艾利斯机房到 NIC.AR 的延迟是 2.5 ms 。

注意:psing.exe 前必须有 .\ ,否则报错:psping.exe : The term ‘psping.exe’ is not recognized as the name of a cmdlet, function, script file, or operable
program.

psping to remote host with open TCP port
Please note: this assumes you have a web site running on remote host (port 80 in example above)

【工具:hping(Linux,基于TCP)】

Some people recommend hping which can use other protocols like TCP (for when ICMP is denied).

参考:https://amon.org/hping

【工具:MTR(My TraceRoute)】

参考:https://www.php.cn/linux-410987.html
参考:https://www.jb51.net/LINUXjishu/341687.html

【工具:BestTrace】

参考:https://www.vpsmm.com/best-trace.shtml

下载:http://cdn.ipip.net/17mon/besttrace.exe

【工具:WinMTR】

参考:https://www.itbulu.com/mtr.html
参考:http://www.downxia.com/downinfo/38565.html