目 录CONTENT

文章目录

TCP怎么测呢?-nc.md

phyger
2025-09-24 / 0 评论 / 0 点赞 / 17 阅读 / 390 字 / 正在检测是否收录...

Server listening on UDP port 8899
Receiving 1470 byte datagrams
UDP buffer size: 208 KByte (default)

-s 以server模式启动

-u 使用UDP协议

-p 指定侦听端口


### 启动客户端

[root@agent-1 ~]# iperf -c 30.30.30.201 -u -p 8899

Client connecting to 30.30.30.201, UDP port 8899
Sending 1470 byte datagrams, IPG target: 11215.21 us (kalman adjust)
UDP buffer size: 208 KByte (default)

[ 3] local 30.30.30.147 port 52522 connected with 30.30.30.201 port 8899
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec
[ 3] Sent 892 datagrams
[ 3] Server Report:
[ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec 0.042 ms 0/ 892 (0%)

-c 指定client的身份

-u 使用UDP协议

-p 指定服务端端口


### 测试结果

如上,我们除了在客户端能够看到测试结果,服务端也有详细的测试结果。

![服务端打印](https://phyger.oss-cn-chengdu.aliyuncs.com/picture/2021-8-13/1628842079169-image.png "服务端打印")

> 根据 `iperf` 的测试结果,我们不但能够知道当前的 `UDP` 服务正常,而且带宽为: `1.05 Mbits/sec`。

关于 `UDP` 的测试我们今天先介绍到这里,后续更精彩。

# nc的更多用法

## 测试TCP链接

启动服务端

```bash
nc -nvl 192.168.0.4 6901

客户端

nc -v 192.168.0.4 6901

链接成功后,还可以直接在控制台进行输入聊天。

验证端口连通性

命令:nc -zv 172.1.2.3 8899

验证UDP端口

命令:nc -uvz 192.168.0.125 111

端口扫描

命令:nc -v -w 1 172.16.7.78 -z 22-81

0

评论区