Files
Linux/Docs/测试Linux网络延迟.md
offends cee91802b3
Some checks failed
continuous-integration/drone Build is failing
synchronization
2025-08-25 15:57:40 +08:00

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