Files
Linux/Docs/测试Linux网络延迟.md
offends 9bd08c819e
All checks were successful
continuous-integration/drone Build is passing
first commit
2025-12-20 21:15:25 +08:00

46 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

> 本文作者:丁辉
# 测试Linux网络延迟
## 方法一
> Linux系统下测试网络延迟一般使用Ping命令,是最常见的方法。Ping命令以ICMP(Internet Control Message Protocol)报文形式将封包发送,然后等待对端的回复。通过Ping命令可以测试当前网络的基本状况,也可以了解当前的网络延迟。
使用的主要的命令格式如下
```bash
ping -c -t
```
\* -c: 指定发送封包的次数
\* -t: 指定发送封包的 TTL(Time To Live)值
以百度Baidu.com为例,指定发送50次, TTL设置为5
```bash
ping -c 50 -t 5 www.baidu.com
```
## 方法二
> 除了常规的Ping命令外,还可以通过MTR(My Trace Route)来检测网络中任意多跳节点间的延迟及包传输情况。MTR将Ping和Traceroute技术进行了结合,可以向任意指定的网站发送数据,并实时显示传输路径上各跳节点的延迟,这样可以很容易发现网络中每一跳节点的状况,从而更快的定位网络问题的存在位置。
MTR的主要命令格式如下
```
mtr -r -c
```
\* -r: 以报表形式输出结果
\* -c: 指定发送封包的次数
以百度Baidu.com为例,指定发送5次
```
mtr -r -c 5 www.baidu.com
```
MTR会根据发送的封包数显示报表,可以从中得到各个节点的延迟、丢包率等信息,便于及时的定位网络问题。